FlexCAN: How to test if a TX mailbox is available?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FlexCAN: How to test if a TX mailbox is available?

1,819 次查看
razed11
Contributor V

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.

标记 (2)
0 项奖励
1 回复

684 次查看
danielchen
NXP TechSupport
NXP TechSupport

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

0 项奖励