Skip to content

Commit

Permalink
Improve UART IRQ management.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrella committed Jul 29, 2015
1 parent bb08369 commit 711dd02
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions platform/stm32nucleo-spirit1/stm32cube-hal/Src/stm32l1xx_it.c
Expand Up @@ -41,6 +41,7 @@
#include "radio_gpio.h"
#include "spirit1.h"


extern UART_HandleTypeDef UartHandle;
/** @addtogroup STM32L1xx_HAL_Examples
* @{
Expand Down Expand Up @@ -319,10 +320,28 @@ void EXTI15_10_IRQHandler(void)

void USART2_IRQHandler()
{
slip_input_byte(UartHandle.Instance->DR);
return;

//HAL_UART_IRQHandler(&UartHandle);
UART_HandleTypeDef *huart = &UartHandle;

if(__HAL_UART_GET_FLAG(huart, UART_FLAG_PE)){
__HAL_UART_CLEAR_PEFLAG(huart);
}

if(__HAL_UART_GET_FLAG(huart, UART_FLAG_FE)){
__HAL_UART_CLEAR_FEFLAG(huart);
}

if(__HAL_UART_GET_FLAG(huart, UART_FLAG_NE)){
__HAL_UART_CLEAR_NEFLAG(huart);
}

if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)){
__HAL_UART_CLEAR_OREFLAG(&UartHandle);
}

if(__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE)){
slip_input_byte(UartHandle.Instance->DR);
__HAL_UART_GET_IT_SOURCE(&UartHandle, UART_IT_RXNE);
}
}

/**
Expand Down

0 comments on commit 711dd02

Please sign in to comment.