uart.c: save resources if UART1 isn't used

This commit is contained in:
Christian Kroll 2014-09-28 00:45:04 +02:00
parent 43f4fc9b2c
commit 877bebd41a
2 changed files with 5 additions and 10 deletions

View File

@ -245,7 +245,7 @@ static volatile unsigned char UART_RxHead;
static volatile unsigned char UART_RxTail;
static volatile unsigned char UART_LastRxError;
#if defined( ATMEGA_USART1 )
#if defined( ATMEGA_USART1 ) && defined (USE_UART1)
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
static volatile unsigned char UART1_TxHead;
@ -506,7 +506,7 @@ void uart_puts_p(const char *progmem_s )
/*
* these functions are only for ATmegas with two USART
*/
#if defined( ATMEGA_USART1 )
#if defined( ATMEGA_USART1 ) && defined (USE_UART1)
ISR(UART1_RECEIVE_INTERRUPT)
/*************************************************************************
@ -565,9 +565,6 @@ Purpose: called when the UART1 is ready to transmit the next byte
}
#if defined USE_UART1 || defined DOXYGEN
/*************************************************************************
Function: uart1_init()
Purpose: initialize UART1 and set baudrate
@ -688,6 +685,4 @@ void uart1_puts_p(const char *progmem_s )
}/* uart1_puts_p */
#endif // defined USE_UART1 || defined DOXYGEN
#endif

View File

@ -285,10 +285,10 @@ static bool uartcmd_read_until_enter(void) {
case 27: // ignore Esc
break;
default:
// We don't accept control characters (except for \r and \n) and
// we also limit the input to 7 bit ASCII.
// We don't accept control characters except for \b, \r and \n.
// We also limit the input to 7 bit ASCII.
if ((uart_result < 0x20) || (uart_result > 0x7f)) {
uart_putc('\007'); // complain via ASCII bell
uart_putc('\a'); // complain via ASCII bell
} else {
g_rx_buffer[g_rx_index++] = uart_result; // accept input
uart_putc(uart_result); // echo input back to terminal