更新了大量文档

This commit is contained in:
NeoZng
2023-06-03 21:58:21 +08:00
parent ff5028036a
commit 253f391cd5
17 changed files with 141 additions and 74 deletions

View File

@@ -2,7 +2,9 @@
<p align='right'>neozng1@hnu.edu.cn</p>
# 请注意使用CAN设备的时候务必保证总线只接入了2个终端电阻开发板一般都有一个6020电机和HT、LK电机也都有终端电阻注意把多于2个的全部断开通过拨码
# 请注意使用CAN设备的时候务必保证总线只接入了2个终端电阻开发板一般都有一个6020电机、c620/c610电调、LK电机也都有终端电阻注意把多于2个的全部断开通过拨码
## 使用说明
@@ -23,16 +25,18 @@
/* can instance typedef, every module registered to CAN should have this variable */
typedef struct _
{
CAN_HandleTypeDef* can_handle;
CAN_TxHeaderTypeDef txconf;
uint32_t tx_id;
uint32_t tx_mailbox;
uint8_t tx_buff[8];
uint8_t rx_buff[8];
uint32_t rx_id;
void (*can_module_callback)(struct _*);
void* id;
} can_instance;
CAN_HandleTypeDef *can_handle; // can句柄
CAN_TxHeaderTypeDef txconf; // CAN报文发送配置
uint32_t tx_id; // 发送id
uint32_t tx_mailbox; // CAN消息填入的邮箱号
uint8_t tx_buff[8]; // 发送缓存,发送消息长度可以通过CANSetDLC()设定,最大为8
uint8_t rx_buff[8]; // 接收缓存,最大消息长度为8
uint32_t rx_id; // 接收id
uint8_t rx_len; // 接收长度,可能为0-8
// 接收的回调函数,用于解析接收到的数据
void (*can_module_callback)(struct _ *); // callback needs an instance to tell among registered ones
void *id; // 使用can外设的模块指针(即id指向的模块拥有此can实例,是父子关系)
} CANInstance;
typedef struct
{
@@ -62,6 +66,7 @@ typedef void (*can_callback)(can_instance*);
```c
void CANRegister(can_instance* instance, can_instance_config config);
void CANSetDLC(CANInstance *_instance, uint8_t length); // 设置发送帧的数据长度
uint8_t CANTransmit(can_instance* _instance, uint8_t timeout);
```