/* tab:4 * Copyright (c) 2002 the University of Southern California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF SOUTHERN CALIFORNIA BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE * UNIVERSITY OF SOUTHERN CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * THE UNIVERSITY OF SOUTHERN CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF SOUTHERN CALIFORNIA HAS NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * * Authors: Wei Ye * * UART debugging: this component is for sending debugging bytes thru UART * Note: can't be used with any application that uses the UART, e.g. motenic * */ #ifndef UART_DEBUG #define UART_DEBUG //#define UART_DEBUG_ENABLE #ifdef UART_DEBUG_ENABLE #define DBG_BUF_LEN 40 #define ADVANCE(x) x = (((x+1) >= DBG_BUF_LEN) ? 0 : x+1) // from TXMAN.c #define UART_IDLE 0 #define UART_BUSY 1 // variables for UART debugging char UARTState; char dbgBuf[DBG_BUF_LEN]; uint8_t dbgHead; uint8_t dbgTail; uint8_t dbgBufCount; void uartDebug_init() { UARTState = UART_IDLE; dbgBufCount = 0; dbgHead = 0; dbgTail = 0; // initialize UART /* outp(12, UBRR); inp(UDR); outp(0xd8,UCR); TOSH_SET_UART_RXD0_PIN(); */ // Set 57.6 KBps outp(0,UBRR0H); outp(15, UBRR0L); // Set UART double speed outp((1< 0) { byte = dbgBuf[dbgHead]; ADVANCE(dbgHead); dbgBufCount--; if(prev) sei(); // send next byte to UART /* sbi(USR, TXC); outp(byte, UDR); */ outp(byte, UDR0); sbi(UCSR0A, TXC); } else { UARTState = UART_IDLE; if(prev) sei(); } } TOSH_SIGNAL(SIG_UART0_RECV) { return; } #else // UART_DEBUG_ENABLE is not defined static inline void uartDebug_init() { } static inline void uartDebug_txByte(char byte) { } #endif // UART_DEBUG_ENABLE #endif // UART_DEBUG