添加了大量调试log,新增了dwt计时宏,增加了USB软件复位防止主控复位后上位机无法连接usb

This commit is contained in:
NeoZng
2023-06-22 21:52:46 +08:00
parent ea6163a48d
commit 4a45331d31
31 changed files with 247 additions and 275 deletions

View File

@@ -2,7 +2,8 @@
******************************************************************************
* @file bsp_dwt.h
* @author Wang Hongxi
* @version V1.1.0
* @author modified by NeoZng
* @version V1.2.0
* @date 2022/3/8
* @brief
******************************************************************************
@@ -15,6 +16,7 @@
#include "main.h"
#include "stdint.h"
#include "bsp_log.h"
typedef struct
{
@@ -23,17 +25,30 @@ typedef struct
uint16_t us;
} DWT_Time_t;
/**
* @brief 该宏用于计算代码段执行时间,单位为秒/s,返回值为float类型
* 首先需要创建一个float类型的变量,用于存储时间间隔
* 计算得到的时间间隔同时还会通过RTT打印到日志终端,你也可以将你的dt变量添加到查看
*/
#define TIME_ELAPSE(dt, code) \
do \
{ \
float tstart = DWT_GetTimeline_s(); \
code; \
dt = DWT_GetTimeline_s() - tstart; \
LOGINFO("[DWT] " #dt " = %f s\r\n", dt); \
} while (0)
/**
* @brief 初始化DWT,传入参数为CPU频率,单位MHz
*
*
* @param CPU_Freq_mHz c板为168MHz,A板为180MHz
*/
void DWT_Init(uint32_t CPU_Freq_mHz);
/**
* @brief 获取两次调用之间的时间间隔,单位为秒/s
*
*
* @param cnt_last 上一次调用的时间戳
* @return float 时间间隔,单位为秒/s
*/
@@ -41,7 +56,7 @@ float DWT_GetDeltaT(uint32_t *cnt_last);
/**
* @brief 获取两次调用之间的时间间隔,单位为秒/s,高精度
*
*
* @param cnt_last 上一次调用的时间戳
* @return double 时间间隔,单位为秒/s
*/
@@ -49,22 +64,22 @@ double DWT_GetDeltaT64(uint32_t *cnt_last);
/**
* @brief 获取当前时间,单位为秒/s,即初始化后的时间
*
*
* @return float 时间轴
*/
float DWT_GetTimeline_s(void);
/**
* @brief 获取当前时间,单位为毫秒/ms,即初始化后的时间
*
* @return float
*
* @return float
*/
float DWT_GetTimeline_ms(void);
/**
* @brief 获取当前时间,单位为微秒/us,即初始化后的时间
*
* @return uint64_t
*
* @return uint64_t
*/
uint64_t DWT_GetTimeline_us(void);
@@ -72,7 +87,7 @@ uint64_t DWT_GetTimeline_us(void);
* @brief DWT延时函数,单位为秒/s
* @attention 该函数不受中断是否开启的影响,可以在临界区和关闭中断时使用
* @note 禁止在__disable_irq()和__enable_irq()之间使用HAL_Delay()函数,应使用本函数
*
*
* @param Delay 延时时间,单位为秒/s
*/
void DWT_Delay(float Delay);
@@ -83,6 +98,4 @@ void DWT_Delay(float Delay);
*/
void DWT_SysTimeUpdate(void);
#endif /* BSP_DWT_H_ */