1.10.3.16 CANx_CallbackRegister Function

C

The prototype of CANx_CallbackRegister() varies based on device family. Refer to the generated header file for the actual prototype to be used.

void CANx_CallbackRegister(CAN_CALLBACK callback, uintptr_t contextHandle, uint8_t fifoNum) // x - Instance of the CAN peripheral

void CANx_CallbackRegister(CANFD_CALLBACK callback, uintptr_t contextHandle, uint8_t fifoQueueNum) // x - Instance of the CAN peripheral

Summary

Sets the pointer to the function (and it's context) to be called when the given CAN's transfer events occur.

Description

This routine sets the pointer to the function (and it's context) to be called when the given CAN's transfer events occur.

Precondition

CANx_Initialize must have been called for the associated CAN instance.

Parameters

Param Description
callback A pointer to a function with a calling signature definedby the callback data type.
contextHandle A value (usually a pointer) passed (unused) into the functionidentified by the callback parameter.
fifoNum Tx/Rx FIFO number
fifoQueueNum Tx Queue or Tx/Rx FIFO number

Returns

None.

Example

void APP_CAN_Callback (uintptr_t context)
{
}
CAN1_CallbackRegister( APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_TRANSMIT, 0 );
CAN1_MessageTransmit(messageID, messageLength, message, 0, CAN_MSG_TX_DATA_FRAME);

CAN1_CallbackRegister( APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_RECEIVE, 1 );
CAN1_MessageReceive(&rx_messageID, &rx_messageLength, rx_message, &timestamp, 1);
void APP_CAN_Callback (uintptr_t context)
{
}
CAN1_CallbackRegister( APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_TRANSMIT, 1 );
CAN1_MessageTransmit(messageID, messageLength, message, 1, CANFD_MODE_FD_WITH_BRS, CANFD_MSG_TX_DATA_FRAME);

CAN1_CallbackRegister( APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_RECEIVE, 2 );
CAN1_MessageReceive(&rx_messageID, &rx_messageLength, rx_message, &timestamp, 2, &msgAttr);

Remarks

None.