Jump to main content

##

# 2.64.27 MCANx_TxEventFifoCallbackRegister Function

## C

    void MCANx_TxEventFifoCallbackRegister(MCAN_TX_EVENT_FIFO_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_TX_EVENT_FIFO_CALLBACK data type.
contextHandle | A value passed into the callback function as callback parameter.

## Returns

None.

## Example

    void APP_MCAN_TxEventFifoCallback(uint8_t numberOfTxEvent, uintptr_t contextHandle)
    {
    }
    void APP_MCAN_TxFifoCallback(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_TxEventFifoCallbackRegister( APP_MCAN_TxEventFifoCallback, NULL);
    MCAN0_TxFifoCallbackRegister( APP_MCAN_TxFifoCallback, NULL);
    // Transmit message from Tx FIFO
    MCAN0_MessageTransmitFifo(1, txBuffer);

## Remarks

None.