AnsweredAssumed Answered

STM32F0 Callback function

Question asked by Blas Cabrera on Mar 23, 2018
Latest reply on Mar 23, 2018 by Clive One

I am new to embedded world. I am activating the CANBUS peripheral of a STM32F0. I started from the example code of the device given by ST. In the example code there is a callback function that it is executed when the CAN peripheral receive a message (The device is interrupt mode, setup by CubeMX).:


void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *hcan)
// Read CANBUS Messages

npress = can_receive;

/* Receive */
if (HAL_CAN_Receive_IT(hcan, CAN_FIFO0) != HAL_OK)
/* Reception Error */
_Error_Handler(__FILE__, __LINE__);



The interrupt handler function is specified in the smt32f0xx_it.c file. I am getting confused between the role of the peripheral interrupt handler and the call complete function. My understanding is that the HAL_CAN_Recieive_IT has been already invoked. According to the code generated by CubeMX, which are the functions called during a CANBUS interrupt?


 CEC_CAN_IRQHandler(void) ->  HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *hcan)


If I want to load the data of the CANBUS is a global variable of the main loop, where is the right place to load the data in the IRQ or Callback function? (as I am doing, shown by the code given above)