Atmega: Eliminate some warnings

This commit is contained in:
Gregory Nutt 2016-01-06 09:50:15 -06:00
parent fe94318bb4
commit 951c40215a
2 changed files with 77 additions and 73 deletions

View File

@ -39,7 +39,7 @@ config AVR_USART1
endmenu # ATMega Peripheral Selections
menu "Low level UART driver options"
menu "Low level USART driver options"
depends on AVR_USART0 || AVR_USART1
config SERIAL_TERMIOS

View File

@ -77,41 +77,43 @@
* AVR_DBLSPEED_UBRR1 = 104 (rounded), actual baud = 9615
*/
#undef UART0_DOUBLE_SPEED
#if BOARD_CPU_CLOCK <= 4000000
# if CONFIG_USART0_BAUD <= 9600
# define AVR_UBRR0 AVR_NORMAL_UBRR0
#undef USART0_DOUBLE_SPEED
#ifdef CONFIG_AVR_USART0
# if BOARD_CPU_CLOCK <= 4000000
# if CONFIG_USART0_BAUD <= 9600
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define USART0_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 8000000
# if CONFIG_USART0_BAUD <= 19200
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define USART0_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 12000000
# if CONFIG_USART0_BAUD <= 28800
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define USART0_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 16000000
# if CONFIG_USART0_BAUD <= 38400
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define USART0_DOUBLE_SPEED 1
# endif
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define UART0_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 8000000
# if CONFIG_USART0_BAUD <= 19200
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define UART0_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 12000000
# if CONFIG_USART0_BAUD <= 28800
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define UART0_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 16000000
# if CONFIG_USART0_BAUD <= 38400
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define UART0_DOUBLE_SPEED 1
# endif
#else
# if CONFIG_USART0_BAUD <= 57600
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define UART0_DOUBLE_SPEED 1
# if CONFIG_USART0_BAUD <= 57600
# define AVR_UBRR0 AVR_NORMAL_UBRR0
# else
# define AVR_UBRR0 AVR_DBLSPEED_UBRR0
# define USART0_DOUBLE_SPEED 1
# endif
# endif
#endif
@ -137,41 +139,43 @@
* AVR_DBLSPEED_UBRR1 = 104 (rounded), actual baud = 9615
*/
#undef UART1_DOUBLE_SPEED
#if BOARD_CPU_CLOCK <= 4000000
# if CONFIG_USART1_BAUD <= 9600
# define AVR_UBRR1 AVR_NORMAL_UBRR1
#undef USART1_DOUBLE_SPEED
#ifdef CONFIG_AVR_USART1
# if BOARD_CPU_CLOCK <= 4000000
# if CONFIG_USART1_BAUD <= 9600
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define USART1_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 8000000
# if CONFIG_USART1_BAUD <= 19200
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define USART1_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 12000000
# if CONFIG_USART1_BAUD <= 28800
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define USART1_DOUBLE_SPEED 1
# endif
# elif BOARD_CPU_CLOCK <= 16000000
# if CONFIG_USART1_BAUD <= 38400
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define USART1_DOUBLE_SPEED 1
# endif
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define UART1_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 8000000
# if CONFIG_USART1_BAUD <= 19200
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define UART1_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 12000000
# if CONFIG_USART1_BAUD <= 28800
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define UART1_DOUBLE_SPEED 1
# endif
#elif BOARD_CPU_CLOCK <= 16000000
# if CONFIG_USART1_BAUD <= 38400
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define UART1_DOUBLE_SPEED 1
# endif
#else
# if CONFIG_USART1_BAUD <= 57600
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define UART1_DOUBLE_SPEED 1
# if CONFIG_USART1_BAUD <= 57600
# define AVR_UBRR1 AVR_NORMAL_UBRR1
# else
# define AVR_UBRR1 AVR_DBLSPEED_UBRR1
# define USART1_DOUBLE_SPEED 1
# endif
# endif
#endif
@ -270,7 +274,7 @@ void usart0_configure(void)
/* Select normal or double speed. */
#ifdef UART0_DOUBLE_SPEED
#ifdef USART0_DOUBLE_SPEED
UCSR0A = (1 << U2X0);
#else
UCSR0A = 0;
@ -324,7 +328,7 @@ void usart0_configure(void)
* USART0 forces this pin to be an input, a logical one in PORTD0 will
* turn on the internal pull-up.
*
* Port D, Bit 1: TXD0, UART0 Transmit pin.
* Port D, Bit 1: TXD0, USART0 Transmit pin.
*/
DDRD |= (1 << 1); /* Force Port D pin 1 to be an output -- should not be necessary */
@ -340,7 +344,7 @@ void usart0_configure(void)
* USART0 forces this pin to be an input, a logical one in PORTE0 will
* turn on the internal pull-up.
*
* Port E, Bit 1: TXD0, UART0 Transmit pin.
* Port E, Bit 1: TXD0, USART0 Transmit pin.
*
* REVISIT: According to table 41, TXD0 is also automatically configured.
* However, this is not explicitly stated in the text.
@ -365,7 +369,7 @@ void usart1_configure(void)
/* Select normal or double speed. */
#ifdef UART1_DOUBLE_SPEED
#ifdef USART1_DOUBLE_SPEED
UCSR1A = (1 << U2X1);
#else
UCSR1A = 0;