From d2358743d776c32f721dca668ec2e5841b287190 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 14 May 2014 08:21:58 +0000 Subject: Fixed bug #503. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6935 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/USARTv2/serial_lld.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'os/hal/ports/STM32/LLD/USARTv2') 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(); } } -- cgit v1.2.3