1.27.9.25 MCANx_TxBuffersCallbackRegister Function

C

void MCANx_TxBuffersCallbackRegister(MCAN_TXRX_BUFFERS_CALLBACK callback, uintptr_t contextHandle) // x - Instance of the MCAN peripheral

Summary

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

Precondition

MCANx_Initialize must have been called for the associated MCAN instance.

Parameters

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

Returns

None.

Example

void APP_MCAN_TxBufferCallback(uint8_t bufferNumber, uintptr_t context)
{
}

uint8_t loop_count = 0;
uint8_t txFiFo[MCAN0_TX_FIFO_BUFFER_SIZE];
MCAN_TX_BUFFER *txBuffer = (MCAN_TX_BUFFER *)txFiFo;
memset(txFiFo, 0x00, MCAN0_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;
}
MCAN0_TxBuffersCallbackRegister(APP_MCAN_TxBufferCallback, NULL);
// Transmit message from Tx buffer 0
MCAN0_MessageTransmit(0, txBuffer);

Remarks

None.