跳转到内容

bsp::CANDriver API

文档稀疏
符号
31
已记录
16
修订版本
0.1.0+855c407f828e

15 / 31 个公开 API 符号没有说明。

命名空间

1

结构体

2

anonymous_namespace{can_driver.cpp}::CAN_CallbackMap

CAN 回调函数表 由于 HAL 只允许将一个函数作为回调函数,如果想在一条总线上处理不同种类的 信息(有多个不同的回调函数),就必须要通过一个主回调函数进行分发 STM32 的 CAN mailbox 数量往往有限,但是在很短的时间内可能连续发送多条消息 自带的 mailbox 无法满足要求,故需要做一个软件缓冲区来临时储存溢出的消息

bsp/can_driver/can_driver.cpp:54

anonymous_namespace{can_driver.cpp}::CAN_MessageDef

储存于软件缓冲区的 CAN 消息类型 包括 TxHeader 和 至多 8 bytes 的数据

bsp/can_driver/can_driver.cpp:39

函数

12

CAN_Fifo0ReceiveCallback

                    void CAN_Fifo0ReceiveCallback (CAN_HandleTypeDef *hcan)
                  

取消注册 CAN Fifo 处理回调 本函数非线程安全,调用时请注意 hcan can handle filter_match_index 需要取消注册对应的过滤器对应的 id CAN Fifo0 接收处理函数 hcan can handle 本函数将会根据 hcan 和 rx_header 内部的 filter_id 来调用对应的回调函数

bsp/can_driver/can_driver.cpp:202

CAN_Fifo1ReceiveCallback

                    void CAN_Fifo1ReceiveCallback (CAN_HandleTypeDef *hcan)
                  

CAN Fifo1 接收处理函数 hcan can handle 本函数将会根据 hcan 和 rx_header 内部的 filter_id 来调用对应的回调函数

bsp/can_driver/can_driver.cpp:231

CAN_RegisterCallback

                    void CAN_RegisterCallback (CAN_HandleTypeDef *hcan, CAN_FifoReceiveCallback_t callback)
                  

注册 CAN Fifo 处理回调 本函数非线程安全,调用时请注意 hcan hcan callback 回调函数指针

bsp/can_driver/can_driver.hpp:72

CAN_RegisterCallback

                    void CAN_RegisterCallback (CAN_HandleTypeDef *hcan, const CAN_FifoReceiveCallback_t callback)
                  

注册 CAN Fifo 处理回调 本函数非线程安全,调用时请注意 hcan hcan callback 回调函数指针

bsp/can_driver/can_driver.cpp:155

CAN_SendMessage

                    uint32_t CAN_SendMessage (CAN_HandleTypeDef *hcan, const CAN_TxHeaderTypeDef *header, const uint8_t data[])
                  

发送一条 CAN 消息 hcan can handle header CAN_TxHeaderTypeDef data 数据 本函数是线程安全的 mailbox, 0xFFFF 表示发送失败

bsp/can_driver/can_driver.hpp:64

CAN_SendMessage

                    uint32_t CAN_SendMessage (CAN_HandleTypeDef *hcan, const CAN_TxHeaderTypeDef *header, const uint8_t data[])
                  

发送一条 CAN 消息 hcan can handle header CAN_TxHeaderTypeDef data 数据 本函数是线程安全的 mailbox, 0xFFFF 表示发送失败

bsp/can_driver/can_driver.cpp:88

CAN_Start

                    void CAN_Start (CAN_HandleTypeDef *hcan, const uint32_t ActiveITs)
                  

CAN 初始化 hcan can handle ActiveITs CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_RX_FIFO1_MSG_PENDING

bsp/can_driver/can_driver.cpp:132

CAN_Start

                    void CAN_Start (CAN_HandleTypeDef *hcan, uint32_t ActiveITs)
                  

CAN 初始化 hcan can handle ActiveITs CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_RX_FIFO1_MSG_PENDING

bsp/can_driver/can_driver.hpp:70

anonymous_namespace{can_driver.cpp}::get_map

                    CAN_CallbackMap * anonymous_namespace{can_driver.cpp}::get_map (const CAN_HandleTypeDef *hcan)
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:70

类型定义

1

CAN_FifoReceiveCallback_t

                    typedef void(* CAN_FifoReceiveCallback_t) (const CAN_HandleTypeDef *hcan, const CAN_RxHeaderTypeDef *header, const uint8_t *data) )(const CAN_HandleTypeDef *hcan, const CAN_RxHeaderTypeDef *header, const uint8_t *data)
                  

上游未提供说明。

bsp/can_driver/can_driver.hpp:58

变量

8

anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::buffer

                    libs::RingBuffer<CAN_MessageDef, CAN_TX_QUEUE_SIZE, true> anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::buffer
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:61

anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::callback_count

                    uint32_t anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::callback_count
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:58

anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::callbacks

                    CAN_FifoReceiveCallback_t anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::callbacks[CAN_MAX_CALLBACK_NUM] [CAN_MAX_CALLBACK_NUM]
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:57

anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::hcan

                    CAN_HandleTypeDef* anonymous_namespace{can_driver.cpp}::CAN_CallbackMap::hcan
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:56

anonymous_namespace{can_driver.cpp}::CAN_MessageDef::data

                    uint8_t anonymous_namespace{can_driver.cpp}::CAN_MessageDef::data[8] [8]
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:42

anonymous_namespace{can_driver.cpp}::CAN_MessageDef::header

                    CAN_TxHeaderTypeDef anonymous_namespace{can_driver.cpp}::CAN_MessageDef::header
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:41

anonymous_namespace{can_driver.cpp}::maps

                    CAN_CallbackMap anonymous_namespace{can_driver.cpp}::maps[CAN_NUM] [CAN_NUM]
                  

上游未提供说明。

bsp/can_driver/can_driver.cpp:66

宏定义

4

文件

3

bsp/can_driver/can_driver.cpp

syhanjin 2025-09-04This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository:

bsp/can_driver/can_driver.cpp

bsp/can_driver/can_driver.hpp

CAN wrapper based on HAL library. syhanjin 2025-09-04 本驱动是对 HAL 库的一层简要封装 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository:

bsp/can_driver/can_driver.hpp