新函数库的说明是:
*** Interrupt mode operation ***
================================
[..]
(#) Notifications are activated using HAL_CAN_ActivateNotification()
function. Then, the process can be controlled through the
available user callbacks: HAL_CAN_xxxCallback(), using same APIs
HAL_CAN_GetRxMessage() and HAL_CAN_AddTxMessage().
(#) Notifications can be deactivated using
HAL_CAN_DeactivateNotification() function.
(#) Special care should be taken for CAN_IT_RX_FIFO0_MSG_PENDING and
CAN_IT_RX_FIFO1_MSG_PENDING notifications. These notifications trig
the callbacks HAL_CAN_RxFIFO0MsgPendingCallback() and
HAL_CAN_RxFIFO1MsgPendingCallback(). User has two possible options
here.
(++) Directly get the Rx message in the callback, using
HAL_CAN_GetRxMessage().
(++) Or deactivate the notification in the callback without
getting the Rx message. The Rx message can then be got later
using HAL_CAN_GetRxMessage(). Once the Rx message have been
read, the notification can be activated again.
while( HAL_CAN_GetTxMailboxesFreeLevel( &hcan1 ) == 0 );
HAL_CAN_AddTxMessage(&hcan1, &TxHeader, pTxMsg->Data, &TxMailbox);
评分
查看全部评分
顺便请教下,CAN_AddTxMessage()这个函数的最后一个参数,在什么情况下才会用到?
有三个发送邮箱,&TxMailbox 标记了成功写入到那个发送邮箱
评分
查看全部评分
在新库函数中已经变成CAN_AddTxMessage()
评分
查看全部评分
新函数库的说明是:
*** Interrupt mode operation ***
================================
[..]
(#) Notifications are activated using HAL_CAN_ActivateNotification()
function. Then, the process can be controlled through the
available user callbacks: HAL_CAN_xxxCallback(), using same APIs
HAL_CAN_GetRxMessage() and HAL_CAN_AddTxMessage().
(#) Notifications can be deactivated using
HAL_CAN_DeactivateNotification() function.
(#) Special care should be taken for CAN_IT_RX_FIFO0_MSG_PENDING and
CAN_IT_RX_FIFO1_MSG_PENDING notifications. These notifications trig
the callbacks HAL_CAN_RxFIFO0MsgPendingCallback() and
HAL_CAN_RxFIFO1MsgPendingCallback(). User has two possible options
here.
(++) Directly get the Rx message in the callback, using
HAL_CAN_GetRxMessage().
(++) Or deactivate the notification in the callback without
getting the Rx message. The Rx message can then be got later
using HAL_CAN_GetRxMessage(). Once the Rx message have been
read, the notification can be activated again.
函数名称不像以前那样HAL_CAN_Transmit()变成HAL_CAN_Transmit_IT()
评分
查看全部评分
再变化,本质还是不会改变的。只不过我们的使用方式会修改一下。
而用while的话,会死等,灯到发送邮箱有空的。
楼主 请问你是怎么解决的,我是单独用CAN1没问题,但是加上CAN2 就全都不行了,死在了CAN2 的 HAL_CAN_GetTxMailboxesFreeLevel
查询邮箱编号