1.32.3.23 CANx_TxBuffersCallbackRegister Function

C

void CANx_TxBuffersCallbackRegister(CAN_TXRX_BUFFERS_CALLBACK callback, uintptr_t contextHandle) // x - Instance of the CAN peripheral

Summary

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

Precondition

CANx_Initialize must have been called for the associated CAN instance.

Parameters

Param Description
callback A pointer to callback function which function prototype definedby the CAN_TXRX_BUFFERS_CALLBACK data type.
contextHandle A value passed into the callback function as callback parameter.

Returns

None.

Example

void APP_CAN_TxBufferCallback(uint8_t bufferNumber, uintptr_t context)
{
}

uint8_t loop_count = 0;
uint8_t txFiFo[CAN0_TX_FIFO_BUFFER_SIZE];
CAN_TX_BUFFER *txBuffer = (CAN_TX_BUFFER *)txFiFo;
memset(txFiFo, 0x00, CAN0_TX_FIFO_BUFFER_ELEMENT_SIZE);
txBuffer->id = 0x100000A5;
txBuffer->dlc = 8;
txBuffer->xtd = 1;
txBuffer->fdf = 1;
txBuffer->brs = 1;
for (loop_count = 0; loop_count < 8; loop_count++){
    txBuffer->data[loop_count] = loop_count;
}
CAN0_TxBuffersCallbackRegister(APP_CAN_TxBufferCallback, NULL);
// Transmit message from Tx buffer 0
CAN0_MessageTransmit(0, txBuffer);

Remarks

None.