STM32 HAL timer interrupt callback function library with serial port interrupt callback function

void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef * htim) 
{ 
     // add the program logic behind the callback 
IF (htim-> == htim2.Instance Instance) // determines whether the timer 2 { } } void HAL_UART_RxCpltCallback (UART_HandleTypeDef * HUART) {
     // add callback after the program logic
iF (huart-> == Instance the USART1) // determines whether a serial { } }

  Interrupt callback function is called after the completion of an interrupt occurs, with Cubemx generated code, in fact, have a callback function generates an interrupt, but that we can not control, interrupt callback function and rewrite their own program in the project logic can be.

  

  We can see from the chart, automatically generated code, interrupt the callback function has a __weak keyword, added __weak function modifier, the user can redefine a function in the user file of the same name, the final compiler when will choose user-defined functions, if the user does not redefine this function, the compiler will perform the function __weak declaration, and the compiler will not complain . So we can define a function with the same name in other places, but do not have to try not to modify the function before.

 

 

Guess you like

Origin www.cnblogs.com/xingboy/p/10967174.html