Fixed bug #442.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6503 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
10fcc2b9f6
commit
9d19282875
|
@ -143,9 +143,7 @@ static void set_error(SerialDriver *sdp, uint16_t sr) {
|
|||
sts |= SD_FRAMING_ERROR;
|
||||
if (sr & USART_SR_NE)
|
||||
sts |= SD_NOISE_ERROR;
|
||||
chSysLockFromIsr();
|
||||
chnAddFlagsI(sdp, sts);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,12 +154,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) {
|
||||
chSysLockFromIsr();
|
||||
|
@ -169,12 +163,18 @@ static void serve_interrupt(SerialDriver *sdp) {
|
|||
chSysUnlockFromIsr();
|
||||
u->SR &= ~USART_SR_LBD;
|
||||
}
|
||||
|
||||
/* Data available.*/
|
||||
if (sr & USART_SR_RXNE) {
|
||||
chSysLockFromIsr();
|
||||
sdIncomingDataI(sdp, (uint8_t)dr);
|
||||
chSysUnlockFromIsr();
|
||||
chSysLockFromIsr();
|
||||
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;
|
||||
}
|
||||
chSysUnlockFromIsr();
|
||||
|
||||
/* Transmission buffer empty.*/
|
||||
if ((cr1 & USART_CR1_TXEIE) && (sr & USART_SR_TXE)) {
|
||||
msg_t b;
|
||||
|
@ -188,6 +188,7 @@ static void serve_interrupt(SerialDriver *sdp) {
|
|||
u->DR = b;
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/* Physical transmission end.*/
|
||||
if (sr & USART_SR_TC) {
|
||||
chSysLockFromIsr();
|
||||
|
|
|
@ -156,18 +156,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) {
|
||||
chSysLockFromIsr();
|
||||
chnAddFlagsI(sdp, SD_BREAK_DETECTED);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/* Data available.*/
|
||||
if (isr & USART_ISR_RXNE) {
|
||||
chSysLockFromIsr();
|
||||
sdIncomingDataI(sdp, (uint8_t)u->RDR);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/* Transmission buffer empty.*/
|
||||
if ((cr1 & USART_CR1_TXEIE) && (isr & USART_ISR_TXE)) {
|
||||
msg_t b;
|
||||
|
@ -181,6 +184,7 @@ static void serve_interrupt(SerialDriver *sdp) {
|
|||
u->TDR = b;
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/* Physical transmission end.*/
|
||||
if (isr & USART_ISR_TC) {
|
||||
chSysLockFromIsr();
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** 2.7.0 ***
|
||||
- FIX: Fixed lost incoming characters in STM32 USARTv1 driver (bug #442)
|
||||
(backported to 2.4.6 and 2.6.2).
|
||||
- FIX: Fixed UART4/5-related bugs in STM32 USARTv1 UART driver (bug #440)
|
||||
(backported to 2.6.2).
|
||||
- FIX: Fixed race condition in STM32 DMA interrupt (bug #439)(backported
|
||||
|
|
Loading…
Reference in New Issue