cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F09xx USART LIN break interrupt management using HAL drivers

CptHuk
Associate

Hi everyone,

I tried to manage the USAR LIN break detection interrupt using only HAL driver functions but I did not find a way to do that. I had to modify the file stm32f0xx_hal_uasrt.c adding some code to manage the LIN break interrupt.

Is there a way to detect the LIN break in my application without modifying the driver code?

This is the code I added to the aforementioned HAL driver file:

// At the beginning of the file, where other prototypes are placed
 
#if defined (USART_CR2_LINEN) 
extern void HAL_UART_LINBreakCallback(UART_HandleTypeDef *);
#endif
 
//...
 
// Inside function HAL_UART_IRQHandler
 
#if defined (USART_CR2_LINEN)
  /* UART LIN break has been detected ----------------------------------------*/
  if(isrflags & USART_ISR_LBDF)
  {
    __HAL_UART_CLEAR_IT(huart, UART_CLEAR_LBDF);
    
    /* Call the callback function to signal LIN break detection */
    HAL_UART_LINBreakCallback(huart);
  }
#endif /* USART_CR2_LINEN */

If the function is currently unavailable, is there a way to tell STM to add it to the official driver so I can use the CUbeMX without needing to patch it every time?

Thank you so much,

Diego

1 REPLY 1
CptHuk
Associate

Ping...