I'm using the callback which is passed the index of the transmitted mailbox when the status is kStatus_FLEXCAN_TxIdle. I could use this to keep track of which mailboxes are free when a new request comes in but is there an existing way to check if a TX mailbox is free?
Related to this: When the status is kStatus_FLEXCAN_ErrorStatus, the other parameter passed to the callback is the status bits not the mailbox index. If I attempt to transmit and it is NACK'd I expect to get an error. How do I recover the mailbox index that failed to transmit?
Thanks.
Hi Kenny:
I would suggest you refer to the two CAN APIs.
/*!
* @brief Get the first valid Message buffer ID of give FlexCAN instance.
*
* This function is a helper function for Errata 5641 workaround.
*
* @param base FlexCAN peripheral base address.
* @return The first valid Message Buffer Number.
*/
static uint32_t FLEXCAN_GetFirstValidMb(CAN_Type *base);
/*!
* @brief Check if Message Buffer is occupied by Rx FIFO.
*
* This function check if Message Buffer is occupied by Rx FIFO.
*
* @param base FlexCAN peripheral base address.
* @param mbIdx The FlexCAN Message Buffer index.
*/
static bool FLEXCAN_IsMbOccupied(CAN_Type *base, uint8_t mbIdx);
Regards
Daniel