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;
|
sts |= SD_FRAMING_ERROR;
|
||||||
if (sr & USART_SR_NE)
|
if (sr & USART_SR_NE)
|
||||||
sts |= SD_NOISE_ERROR;
|
sts |= SD_NOISE_ERROR;
|
||||||
chSysLockFromIsr();
|
|
||||||
chnAddFlagsI(sdp, sts);
|
chnAddFlagsI(sdp, sts);
|
||||||
chSysUnlockFromIsr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,12 +154,8 @@ static void set_error(SerialDriver *sdp, uint16_t sr) {
|
||||||
static void serve_interrupt(SerialDriver *sdp) {
|
static void serve_interrupt(SerialDriver *sdp) {
|
||||||
USART_TypeDef *u = sdp->usart;
|
USART_TypeDef *u = sdp->usart;
|
||||||
uint16_t cr1 = u->CR1;
|
uint16_t cr1 = u->CR1;
|
||||||
uint16_t sr = u->SR; /* SR reset step 1.*/
|
uint16_t sr = u->SR;
|
||||||
uint16_t dr = u->DR; /* SR reset step 2.*/
|
|
||||||
|
|
||||||
/* 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.*/
|
/* Special case, LIN break detection.*/
|
||||||
if (sr & USART_SR_LBD) {
|
if (sr & USART_SR_LBD) {
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
|
@ -169,12 +163,18 @@ static void serve_interrupt(SerialDriver *sdp) {
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
u->SR &= ~USART_SR_LBD;
|
u->SR &= ~USART_SR_LBD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data available.*/
|
/* Data available.*/
|
||||||
if (sr & USART_SR_RXNE) {
|
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
sdIncomingDataI(sdp, (uint8_t)dr);
|
while (sr & USART_SR_RXNE) {
|
||||||
chSysUnlockFromIsr();
|
/* 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.*/
|
/* Transmission buffer empty.*/
|
||||||
if ((cr1 & USART_CR1_TXEIE) && (sr & USART_SR_TXE)) {
|
if ((cr1 & USART_CR1_TXEIE) && (sr & USART_SR_TXE)) {
|
||||||
msg_t b;
|
msg_t b;
|
||||||
|
@ -188,6 +188,7 @@ static void serve_interrupt(SerialDriver *sdp) {
|
||||||
u->DR = b;
|
u->DR = b;
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Physical transmission end.*/
|
/* Physical transmission end.*/
|
||||||
if (sr & USART_SR_TC) {
|
if (sr & USART_SR_TC) {
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
|
|
|
@ -156,18 +156,21 @@ static void serve_interrupt(SerialDriver *sdp) {
|
||||||
/* Error condition detection.*/
|
/* Error condition detection.*/
|
||||||
if (isr & (USART_ISR_ORE | USART_ISR_NE | USART_ISR_FE | USART_ISR_PE))
|
if (isr & (USART_ISR_ORE | USART_ISR_NE | USART_ISR_FE | USART_ISR_PE))
|
||||||
set_error(sdp, isr);
|
set_error(sdp, isr);
|
||||||
|
|
||||||
/* Special case, LIN break detection.*/
|
/* Special case, LIN break detection.*/
|
||||||
if (isr & USART_ISR_LBD) {
|
if (isr & USART_ISR_LBD) {
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
chnAddFlagsI(sdp, SD_BREAK_DETECTED);
|
chnAddFlagsI(sdp, SD_BREAK_DETECTED);
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data available.*/
|
/* Data available.*/
|
||||||
if (isr & USART_ISR_RXNE) {
|
if (isr & USART_ISR_RXNE) {
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
sdIncomingDataI(sdp, (uint8_t)u->RDR);
|
sdIncomingDataI(sdp, (uint8_t)u->RDR);
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transmission buffer empty.*/
|
/* Transmission buffer empty.*/
|
||||||
if ((cr1 & USART_CR1_TXEIE) && (isr & USART_ISR_TXE)) {
|
if ((cr1 & USART_CR1_TXEIE) && (isr & USART_ISR_TXE)) {
|
||||||
msg_t b;
|
msg_t b;
|
||||||
|
@ -181,6 +184,7 @@ static void serve_interrupt(SerialDriver *sdp) {
|
||||||
u->TDR = b;
|
u->TDR = b;
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Physical transmission end.*/
|
/* Physical transmission end.*/
|
||||||
if (isr & USART_ISR_TC) {
|
if (isr & USART_ISR_TC) {
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
|
|
|
@ -89,6 +89,8 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** 2.7.0 ***
|
*** 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)
|
- FIX: Fixed UART4/5-related bugs in STM32 USARTv1 UART driver (bug #440)
|
||||||
(backported to 2.6.2).
|
(backported to 2.6.2).
|
||||||
- FIX: Fixed race condition in STM32 DMA interrupt (bug #439)(backported
|
- FIX: Fixed race condition in STM32 DMA interrupt (bug #439)(backported
|
||||||
|
|
Loading…
Reference in New Issue