cancel
Showing results for 
Search instead for 
Did you mean: 

Where is the CompleteCallbacks are located in layered architecture?

IKARA.15
Associate II

I am using STM32F405xx and Cube IDE environment to evaluate my app. A layered CAN communication is requested. At this point, there are three layer to build this architecture. 1. 1.Layer is HAL library for CAN provided by ST and CubeMxcan.c and can.h

This layer offers me some Rx, Tx, LL init, de-init, start-stop-wakeup CAN comm. or enable-disable irq etc. Addition to these synchronous functions, It also provides asynchronous completecallback functions.

2.The second layer will be a CanIf (can interface) to abstract layer1 and offers fully abstracted CAN interface for my upper layer in CanIf.c and CanIf.h

3.This layer will be vehicle_dynamic_collector which will send or receive pre-defined IDs and also will do some other stuff in Vehicle_Dynamics.c and Vehicle_Dynamics.h

Now, How should I design this asynchronous commication without breaking dependencies.

This is my ex and poor design.

This code block is located in can.c and Get_SimCanMsgPackage()

 function is located in vehicle_dynamics.h and there is no CanIf.h interface in this design. As you see I putted high level functions into low layer. I want to change this.

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(hcan);
 
  /* NOTE : This function Should not be modified, when the callback is needed,
            the HAL_CAN_RxFifo0MsgPendingCallback could be implemented in the
            user file
   */
      if(HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &pRxHeader, &aCanRxMsgData[0])!=HAL_OK)
      {
          Error_Handler();
      }
 
      else
      {
          if(pRxHeader.StdId==SIM)
          {
              Get_SimCanMsgPackage(); /*This function will be in upper layer in normal.*/
          }
      }
}

0 REPLIES 0