9
0
Fork 0

Fix AVR uart bugs

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3700 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-06-13 01:42:21 +00:00
parent b8a9921f64
commit d471ef2e48
2 changed files with 32 additions and 29 deletions

View File

@ -198,32 +198,33 @@ void usart1_configure(void)
/* Select parity */
#if CONFIG_USART1_PARITY == 1
ucsr1c |= (UPM11 | UPM10); /* Odd parity */
ucsr1c |= ((1 << UPM11) | (1 << UPM10)); /* Odd parity */
#else
ucsr1c |= UPM11; /* Even parity */
ucsr1c |= (1 << UPM11); /* Even parity */
#endif
/* 1 or 2 stop bits */
#if defined(CONFIG_USART1_2STOP) && CONFIG_USART1_2STOP > 0
ucsr1c |= USBS1; /* Two stop bits */
ucsr1c |= (1 << USBS1); /* Two stop bits */
#endif
/* Word size */
#if CONFIG_USART1_BITS == 5
#elif CONFIG_USART1_BITS == 6
ucsr1c |= UCSZ10;
ucsr1c |= (1 << UCSZ10);
#elif CONFIG_USART1_BITS == 7
ucsr1c |= UCSZ11;
ucsr1c |= (1 << UCSZ11);
#elif CONFIG_USART1_BITS == 8
ucsr1c |= (UCSZ10 | UCSZ11);
ucsr1c |= ((1 << UCSZ10) | (1 << UCSZ11));
#elif CONFIG_USART1_BITS == 9
ucsr1c |= (UCSZ10 | UCSZ11);
ucsr1b |= UCSZ12;
ucsr1c |= ((1 << UCSZ10) | (1 << UCSZ11));
ucsr1b |= (1 << UCSZ12);
#else
# error "Unsupported word size"
#endif
UCSR1B = ucsr1b;
UCSR1C = ucsr1c;
@ -239,7 +240,7 @@ void usart1_configure(void)
* an output regardless of the value of DDD3.
*/
DDRD |= (1 << 3); /* Force Port D pin 3 to be an output */
DDRD |= (1 << 3); /* Force Port D pin 3 to be an output -- Shouldn't be necessary */
PORTD |= (1 << 2); /* Set pull-up on port D pin 2 */
/* Set the baud rate divisor */

View File

@ -279,32 +279,33 @@ void usart0_configure(void)
/* Select parity */
#if CONFIG_USART0_PARITY == 1
ucsr0c |= (UPM01 | UPM00); /* Odd parity */
ucsr0c |= ((1 << UPM01) | (1 << UPM00)); /* Odd parity */
#else
ucsr0c |= UPM00; /* Even parity */
ucsr0c |= (1 << UPM00); /* Even parity */
#endif
/* 1 or 2 stop bits */
#if defined(CONFIG_USART0_2STOP) && CONFIG_USART0_2STOP > 0
ucsr0c |= USBS0; /* Two stop bits */
ucsr0c |= (1 << USBS0); /* Two stop bits */
#endif
/* Word size */
#if CONFIG_USART0_BITS == 5
#elif CONFIG_USART0_BITS == 6
ucsr0c |= UCSZ00;
ucsr0c |= (1 << UCSZ00);
#elif CONFIG_USART0_BITS == 7
ucsr0c |= UCSZ01;
ucsr0c |= (1 << UCSZ01);
#elif CONFIG_USART0_BITS == 8
ucsr0c |= (UCSZ00 | UCSZ01);
ucsr0c |= ((1 << UCSZ00) | (1 << UCSZ01));
#elif CONFIG_USART0_BITS == 9
ucsr0c |= (UCSZ00 | UCSZ01);
ucsr0b |= UCSZ02;
ucsr0c |= ((1 << UCSZ0) | (1 << UCSZ01));
ucsr0b |= (1 << UCSZ02);
#else
# error "Unsupported word size"
#endif
UCSR0B = ucsr0b;
UCSR0C = ucsr0c;
@ -323,13 +324,13 @@ void usart0_configure(void)
* However, this is not explicitly stated in the text.
*/
DDRE |= (1 << 1); /* Force Port E pin 1 to be an input */
DDRE |= (1 << 1); /* Force Port E pin 1 to be an input -- might not be necessary */
PORTE |= (1 << 0); /* Set pull-up on Port E pin 0 */
/* Set the baud rate divisor */
UBRR0H = AVR_UBRR1 >> 8;
UBRR0L = AVR_UBRR1 & 0xff;
UBRR0H = AVR_UBRR0 >> 8;
UBRR0L = AVR_UBRR0 & 0xff;
}
#endif
@ -355,32 +356,33 @@ void usart1_configure(void)
/* Select parity */
#if CONFIG_USART1_PARITY == 1
ucsr1c |= (UPM11 | UPM10); /* Odd parity */
ucsr1c |= ((1 << UPM11) | (1 << UPM10)); /* Odd parity */
#else
ucsr1c |= UPM11; /* Even parity */
ucsr1c |= (1 << UPM11); /* Even parity */
#endif
/* 1 or 2 stop bits */
#if defined(CONFIG_USART1_2STOP) && CONFIG_USART1_2STOP > 0
ucsr1c |= USBS1; /* Two stop bits */
ucsr1c |= (1 << USBS1); /* Two stop bits */
#endif
/* Word size */
#if CONFIG_USART1_BITS == 5
#elif CONFIG_USART1_BITS == 6
ucsr1c |= UCSZ10;
ucsr1c |= (1 << UCSZ10);
#elif CONFIG_USART1_BITS == 7
ucsr1c |= UCSZ11;
ucsr1c |= (1 << UCSZ11);
#elif CONFIG_USART1_BITS == 8
ucsr1c |= (UCSZ10 | UCSZ11);
ucsr1c |= ((1 << UCSZ10) | (1 << UCSZ11));
#elif CONFIG_USART1_BITS == 9
ucsr1c |= (UCSZ10 | UCSZ11);
ucsr1b |= UCSZ12;
ucsr1c |= (U(1 << CSZ10) | (1 << UCSZ11));
ucsr1b |= (1 << UCSZ12);
#else
# error "Unsupported word size"
#endif
UCSR1B = ucsr1b;
UCSR1C = ucsr1c;
@ -396,7 +398,7 @@ void usart1_configure(void)
* an output regardless of the value of DDD3.
*/
DDRD |= (1 << 3); /* Force Port D pin 3 to be an output */
DDRD |= (1 << 3); /* Force Port D pin 3 to be an output -- should not be necessary */
PORTD |= (1 << 2); /* Set pull-up on port D pin 2 */
/* Set the baud rate divisor */