aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/USARTv2
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-05-14 08:21:58 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-05-14 08:21:58 +0000
commitd2358743d776c32f721dca668ec2e5841b287190 (patch)
tree9bac8cd271139c3a7aaffaa7592922ee96018941 /os/hal/ports/STM32/LLD/USARTv2
parenta0cfa6d0544b7c58f4831e8531cc66ed623574af (diff)
downloadChibiOS-d2358743d776c32f721dca668ec2e5841b287190.tar.gz
ChibiOS-d2358743d776c32f721dca668ec2e5841b287190.tar.bz2
ChibiOS-d2358743d776c32f721dca668ec2e5841b287190.zip
Fixed bug #503.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6935 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/USARTv2')
-rw-r--r--os/hal/ports/STM32/LLD/USARTv2/serial_lld.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/os/hal/ports/STM32/LLD/USARTv2/serial_lld.c b/os/hal/ports/STM32/LLD/USARTv2/serial_lld.c
index 38042003e..3ecf1fcbf 100644
--- a/os/hal/ports/STM32/LLD/USARTv2/serial_lld.c
+++ b/os/hal/ports/STM32/LLD/USARTv2/serial_lld.c
@@ -155,18 +155,21 @@ static void serve_interrupt(SerialDriver *sdp) {
/* Error condition detection.*/
if (isr & (USART_ISR_ORE | USART_ISR_NE | USART_ISR_FE | USART_ISR_PE))
set_error(sdp, isr);
+
/* Special case, LIN break detection.*/
if (isr & USART_ISR_LBD) {
osalSysLockFromISR();
chnAddFlagsI(sdp, SD_BREAK_DETECTED);
osalSysUnlockFromISR();
}
+
/* Data available.*/
if (isr & USART_ISR_RXNE) {
osalSysLockFromISR();
sdIncomingDataI(sdp, (uint8_t)u->RDR);
osalSysUnlockFromISR();
}
+
/* Transmission buffer empty.*/
if ((cr1 & USART_CR1_TXEIE) && (isr & USART_ISR_TXE)) {
msg_t b;
@@ -180,12 +183,14 @@ static void serve_interrupt(SerialDriver *sdp) {
u->TDR = b;
osalSysUnlockFromISR();
}
+
/* Physical transmission end.*/
if (isr & USART_ISR_TC) {
osalSysLockFromISR();
- chnAddFlagsI(sdp, CHN_TRANSMISSION_END);
- osalSysUnlockFromISR();
+ if (oqIsEmptyI(&sdp->oqueue))
+ chnAddFlagsI(sdp, CHN_TRANSMISSION_END);
u->CR1 = cr1 & ~USART_CR1_TCIE;
+ osalSysUnlockFromISR();
}
}