Jump to main content

##

# 2.8.87 CANx_TxFifoCallbackRegister Function

## C

    void CANx_TxFifoCallbackRegister(CAN_TX_FIFO_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_TX_FIFO_CALLBACK data type.
contextHandle | A value passed into the callback function as callback parameter.

## Returns

None.

## Example

    void APP_CAN_TxFifoCallback(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_TxFifoCallbackRegister( APP_CAN_TxFifoCallback, NULL);
    // Transmit message from Tx FIFO
    CAN0_MessageTransmitFifo(1, txBuffer);

## Remarks

None.