初级会员

- 积分
- 136
- 金钱
- 136
- 注册时间
- 2020-1-15
- 在线时间
- 39 小时
|
之前用UART ,SPI ,都是用的类似这样的接口
HAL_XXX_Transmit
HAL_XXX_Receive
到了CAN接口,发现库里面还有
HAL_CAN_Transmit,HAL_CAN_Receive,但是原子哥用的却是HAL_CAN_AddTxMessage这样的接口。百度了一下几乎没有HAL_CAN_Transmit的例子,都是用HAL_CAN_AddTxMessage。
觉得很疑惑。
而看HAL库代码来找两个API的区别,根本不可能,CAN都还不会用就想搞懂两个接口的区别是不可能的。
于是谷歌了一下,发现原来是升级了一次,,,,不用纠结两个接口有什么区别,直接用新接口即可。
- HAL_CAN_Init() is split into both HAL_CAN_Init() and HAL_CAN_Start()
- HAL_CAN_Transmit() is replaced by HAL_CAN_AddTxMessage() to place Tx request, then HAL_CAN_GetTxMailboxesFreeLevel() for polling until completion
- HAL_CAN_Transmit_IT() is replaced by HAL_CAN_ActivateNotification() to enable transmission with interrupt mode, then HAL_CAN_AddTxMessage() to place Tx request
- HAL_CAN_Receive() is replaced by HAL_CAN_GetRxFifoFillLevel() for polling until reception, then HAL_CAN_GetRxMessage() to get Rx message
- HAL_CAN_Receive_IT() is replaced by HAL_CAN_ActivateNotification() to enable reception with interrupt mode, then HAL_CAN_GetRxMessage() in the receive callback to get Rx message
- HAL_CAN_Sleep() is renamed to HAL_CAN_RequestSleep()
- HAL_CAN_TxCpltCallback() is split into HAL_CAN_TxMailbox0CompleteCallback(), HAL_CAN_TxMailbox1CompleteCallback() and HAL_CAN_TxMailbox2CompleteCallback()
- HAL_CAN_RxCpltCallback() is split into HAL_CAN_RxFifo0MsgPendingCallback() and HAL_CAN_RxFifo1MsgPendingCallback()
谷歌真的必不可少,百度或许能快速上手,常见问题也没问题,但是遇到难题都得靠谷歌。
|
|