diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-11-22 10:32:09 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-11-22 10:32:09 +0000 |
commit | 087e521ea9d282d4b94f22d9bb85eb16c5d1a685 (patch) | |
tree | dafecfa8fe4a1ae8b2eeaec46faf57e5f089c8f6 /os/hal/ports | |
parent | 570949e7f457fb453839920d4884bf6370b5d401 (diff) | |
download | ChibiOS-087e521ea9d282d4b94f22d9bb85eb16c5d1a685.tar.gz ChibiOS-087e521ea9d282d4b94f22d9bb85eb16c5d1a685.tar.bz2 ChibiOS-087e521ea9d282d4b94f22d9bb85eb16c5d1a685.zip |
Fixed bug #442.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6506 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports')
-rw-r--r-- | os/hal/ports/STM32/USARTv1/serial_lld.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/os/hal/ports/STM32/USARTv1/serial_lld.c b/os/hal/ports/STM32/USARTv1/serial_lld.c index ae6042a8d..89ac1187b 100644 --- a/os/hal/ports/STM32/USARTv1/serial_lld.c +++ b/os/hal/ports/STM32/USARTv1/serial_lld.c @@ -142,9 +142,7 @@ static void set_error(SerialDriver *sdp, uint16_t sr) { sts |= SD_FRAMING_ERROR;
if (sr & USART_SR_NE)
sts |= SD_NOISE_ERROR;
- osalSysLockFromISR();
chnAddFlagsI(sdp, sts);
- osalSysUnlockFromISR();
}
/**
@@ -155,12 +153,8 @@ static void set_error(SerialDriver *sdp, uint16_t sr) { static void serve_interrupt(SerialDriver *sdp) {
USART_TypeDef *u = sdp->usart;
uint16_t cr1 = u->CR1;
- uint16_t sr = u->SR; /* SR reset step 1.*/
- uint16_t dr = u->DR; /* SR reset step 2.*/
+ uint16_t sr = u->SR;
- /* Error condition detection.*/
- if (sr & (USART_SR_ORE | USART_SR_NE | USART_SR_FE | USART_SR_PE))
- set_error(sdp, sr);
/* Special case, LIN break detection.*/
if (sr & USART_SR_LBD) {
osalSysLockFromISR();
@@ -168,12 +162,18 @@ static void serve_interrupt(SerialDriver *sdp) { osalSysUnlockFromISR();
u->SR &= ~USART_SR_LBD;
}
+
/* Data available.*/
- if (sr & USART_SR_RXNE) {
- osalSysLockFromISR();
- sdIncomingDataI(sdp, (uint8_t)dr);
- osalSysUnlockFromISR();
+ osalSysLockFromISR();
+ while (sr & USART_SR_RXNE) {
+ /* Error condition detection.*/
+ if (sr & (USART_SR_ORE | USART_SR_NE | USART_SR_FE | USART_SR_PE))
+ set_error(sdp, sr);
+ sdIncomingDataI(sdp, u->DR);
+ sr = u->SR;
}
+ osalSysUnlockFromISR();
+
/* Transmission buffer empty.*/
if ((cr1 & USART_CR1_TXEIE) && (sr & USART_SR_TXE)) {
msg_t b;
@@ -187,6 +187,7 @@ static void serve_interrupt(SerialDriver *sdp) { u->DR = b;
osalSysUnlockFromISR();
}
+
/* Physical transmission end.*/
if (sr & USART_SR_TC) {
osalSysLockFromISR();
|