Made usart_irq example more robust. It should not duplicate bytes anymore.
This commit is contained in:
parent
7d3608f746
commit
310561ac50
@ -80,7 +80,8 @@ void usart1_isr(void)
|
||||
static u8 data = 'A';
|
||||
|
||||
/* Check if we were called because of RXNE. */
|
||||
if ((USART_SR(USART1) & USART_SR_RXNE) != 0) {
|
||||
if (((USART_CR1(USART1) & USART_SR_RXNEIE) != 0) &&
|
||||
((USART_SR(USART1) & USART_SR_RXNE) != 0)) {
|
||||
/* Indicate that we got data. */
|
||||
gpio_toggle(GPIOA, GPIO6);
|
||||
|
||||
@ -92,7 +93,8 @@ void usart1_isr(void)
|
||||
}
|
||||
|
||||
/* Check if we were called because of TXE. */
|
||||
if ((USART_SR(USART1) & USART_SR_TXE) != 0) {
|
||||
if ((USART_CR1(USART1) & USART_SR_TXEIE) != 0) &&
|
||||
((USART_SR(USART1) & USART_SR_TXE) != 0)) {
|
||||
/* Indicate that we are sending out data. */
|
||||
gpio_toggle(GPIOA, GPIO7);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user