Commit b65cfa8e authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Pekka Niemimaa
Browse files

stm32_serial: fix Rx DMA mode to handle and recover from USART errors



If USART peripheral detect error, Rx DMA stops operating until errors are cleared.
Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@haltian.com>
parent 5d539093
......@@ -2631,6 +2631,22 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
up_dma_reenable(priv);
}
#endif
}
/* Get the masked USART status word to check and clear error flags.
* If error flag is not cleared, Rx DMA will be stuck. Clearing errors
* will release Rx DMA. */
priv->sr = up_serialin(priv, STM32_USART_SR_OFFSET);
if ((priv->sr & (USART_SR_ORE | USART_SR_NE | USART_SR_FE)) != 0)
{
#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
up_serialout(priv, STM32_USART_ICR_OFFSET,
(USART_ICR_NCF | USART_ICR_ORECF | USART_ICR_FECF));
#else
(void)up_serialin(priv, STM32_USART_RDR_OFFSET);
#endif
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment