overrun error in meterbus uart handled

This commit is contained in:
2020-11-22 21:23:52 +01:00
parent 3fd30aaa36
commit bd435dd5d6
8 changed files with 63 additions and 29 deletions

View File

@ -2014,6 +2014,10 @@ HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
return HAL_OK;
}
inline void dts(uint8_t v) {
for (uint8_t xx = 0; xx < v; xx++) HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_10);
}
/**
* @brief This function handles UART interrupt request.
* @param huart Pointer to a UART_HandleTypeDef structure that contains
@ -2022,6 +2026,8 @@ HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
*/
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
{
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_12);
uint32_t isrflags = READ_REG(huart->Instance->SR);
uint32_t cr1its = READ_REG(huart->Instance->CR1);
uint32_t cr3its = READ_REG(huart->Instance->CR3);
@ -2032,9 +2038,10 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
errorflags = (isrflags & (uint32_t)(USART_SR_PE | USART_SR_FE | USART_SR_ORE | USART_SR_NE));
if (errorflags == RESET)
{
/* UART in mode Receiver -------------------------------------------------*/
/* UART in mode Receiver -------------------------------------------------*/
if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
{
dts(1);
UART_Receive_IT(huart);
return;
}
@ -2043,6 +2050,7 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
/* If some errors occur */
if ((errorflags != RESET) && (((cr3its & USART_CR3_EIE) != RESET) || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != RESET)))
{
dts(2);
/* UART parity error interrupt occurred ----------------------------------*/
if (((isrflags & USART_SR_PE) != RESET) && ((cr1its & USART_CR1_PEIE) != RESET))
{
@ -2070,6 +2078,7 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
/* Call UART Error Call back function if need be --------------------------*/
if (huart->ErrorCode != HAL_UART_ERROR_NONE)
{
dts(3);
/* UART in mode Receiver -----------------------------------------------*/
if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
{
@ -2089,11 +2098,13 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
/* Disable the UART DMA Rx request if enabled */
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
{
dts(4);
CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
/* Abort the UART DMA Rx channel */
if (huart->hdmarx != NULL)
{
dts(5);
/* Set the UART DMA Abort callback :
will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;