1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

PiOS/USART: Apply same fix as Spektrum to force read of DR whenever there is an

error flag set

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2760 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-02-08 16:34:52 +00:00 committed by peabody124
parent 7e78e8af04
commit 9ed0882df9

View File

@ -465,17 +465,19 @@ void PIOS_USART_IRQ_Handler(uint8_t usart)
usart_dev = find_usart_dev_by_id(usart);
PIOS_DEBUG_Assert(usart_dev);
/* Check if RXNE flag is set */
if (usart_dev->cfg->regs->SR & USART_SR_RXNE) {
uint8_t b = usart_dev->cfg->regs->DR;
/* Force read of dr after sr to make sure to clear error flags */
volatile uint16_t sr = usart_dev->cfg->regs->SR;
volatile uint8_t dr = usart_dev->cfg->regs->DR;
if (PIOS_USART_RxBufferPut(usart, b) < 0) {
/* Check if RXNE flag is set */
if (sr & USART_SR_RXNE) {
if (PIOS_USART_RxBufferPut(usart, dr) < 0) {
/* Here we could add some error handling */
}
}
/* Check if TXE flag is set */
if (usart_dev->cfg->regs->SR & USART_SR_TXE) {
if (sr & USART_SR_TXE) {
if (PIOS_USART_TxBufferUsed(usart) > 0) {
int32_t b = PIOS_USART_TxBufferGet(usart);