mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 11:37:45 +08:00
更新了大量文档
This commit is contained in:
@@ -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);
|
||||
```
|
||||
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
# bsp_dwt
|
||||
|
||||
DWT是stm32内部的一个"隐藏资源",他的用途是给下载器提供准确的定时,从而为调试信息加上时间戳.并在固定的时间间隔将调试数据发送到你的xxlink上.
|
||||
DWT是stm32内部的一个"隐藏资源",他的用途是给下载器提供准确的定时,从而为调试信息加上时间戳.并在固定的时间间隔将调试数据发送到你的xxlink上.
|
||||
|
||||
|
||||
|
||||
## 常用功能
|
||||
|
||||
### 计算两次进入同一个函数的时间间隔
|
||||
|
||||
```c
|
||||
static uint32_t cnt;
|
||||
float deltaT;
|
||||
|
||||
deltaT=DWT_GetDeltaT(&cnt);
|
||||
```
|
||||
|
||||
### 计算执行某部分代码的耗时
|
||||
|
||||
```c
|
||||
float start,end;
|
||||
start=DWT_DetTimeline_ms();
|
||||
|
||||
// some proc to go...
|
||||
for(uint8_t i=0;i<10;i++)
|
||||
foo();
|
||||
|
||||
end = DWT_DetTimeline_ms()-start;
|
||||
```
|
||||
|
||||
|
||||
@@ -11,6 +11,28 @@
|
||||
|
||||
bsp_log是基于segger RTT实现的日志打印模块。
|
||||
|
||||
推荐使用`bsp_log.h`中提供了三级日志:
|
||||
|
||||
```c
|
||||
#define LOGINFO(format,...)
|
||||
#define LOGWARNING(format,...)
|
||||
#define LOGERROR(format,...)
|
||||
```
|
||||
|
||||
分别用于输出不同等级的日志。
|
||||
|
||||
**若想启用RTT,必须通过`launch.json`的`debug-jlink`启动调试(不论使用什么调试器)。**
|
||||
|
||||
注意,若你使用的是cmsis-dap和daplink,**请在调试任务启动之后再打开`log`任务。**(均在项目文件夹下的.vsocde/task.json中,有注释自行查看)。
|
||||
|
||||
在ozone中查看log输出,直接打开console调试任务台和terminal调试中断便可看到调试输出。
|
||||
|
||||
> 由于ozone版本的原因,可能出现日志不换行或没有颜色。
|
||||
|
||||
## 自定义输出
|
||||
|
||||
你也可以自定义输出格式,详见Segger RTT的文档。
|
||||
|
||||
```c
|
||||
int printf_log(const char *fmt, ...);
|
||||
void Float2Str(char *str, float va);
|
||||
@@ -33,3 +55,6 @@ printf_log("Motor %d met some problem, error code %d!\n",3,1);
|
||||
```
|
||||
|
||||
或直接通过`%f`格式符直接使用`printf_log()`发送日志,可以设置小数点位数以降低带宽开销。
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# bsp usb
|
||||
|
||||
简单写点,有待优化.
|
||||
简单写点,有待优化. 目前仅支持虚拟串口通信,暂未开发其他内容.
|
||||
|
||||
注意,为了增加发送完成和接收完成回调,对Inc/usbd_xxxx.h四个文件做了修改,对Src/usbxxx.c也进行了修改。
|
||||
|
||||
Reference in New Issue
Block a user