aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/obldc/usart_irq/usart_irq.c
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2011-02-17 18:32:07 -0800
committerPiotr Esden-Tempski2011-02-17 18:32:07 -0800
commit310561ac50be016fca2375d8d003e54d7478599d (patch)
tree14ed15bc529c555c3b3cf9b02642119a2bac34c3 /examples/stm32/obldc/usart_irq/usart_irq.c
parent7d3608f74637162a8d7da9983095c61cbb63852d (diff)
Made usart_irq example more robust. It should not duplicate bytes anymore.
Diffstat (limited to 'examples/stm32/obldc/usart_irq/usart_irq.c')
-rw-r--r--examples/stm32/obldc/usart_irq/usart_irq.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/stm32/obldc/usart_irq/usart_irq.c b/examples/stm32/obldc/usart_irq/usart_irq.c
index 2d4dd06..7e5f971 100644
--- a/examples/stm32/obldc/usart_irq/usart_irq.c
+++ b/examples/stm32/obldc/usart_irq/usart_irq.c
@@ -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);