infantry_gimbal/bsp/dwt/bsp_dwt.h

102 lines
2.8 KiB
C
Raw Normal View History

2024-03-27 00:09:20 +08:00
/**
******************************************************************************
* @file bsp_dwt.h
* @author Wang Hongxi
* @author modified by NeoZng
* @version V1.2.0
* @date 2022/3/8
* @brief
******************************************************************************
* @attention
*
******************************************************************************
*/
#ifndef _BSP_DWT_H
#define _BSP_DWT_H
#include "main.h"
#include "stdint.h"
#include "bsp_log.h"
typedef struct
{
uint32_t s;
uint16_t ms;
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
*/
float DWT_GetDeltaT(uint32_t *cnt_last);
/**
* @brief ,/s,
*
* @param cnt_last
* @return double ,/s
*/
double DWT_GetDeltaT64(uint32_t *cnt_last);
/**
* @brief ,/s,
*
* @return float
*/
float DWT_GetTimeline_s(void);
/**
* @brief ,/ms,
*
* @return float
*/
float DWT_GetTimeline_ms(void);
/**
* @brief ,/us,
*
* @return uint64_t
*/
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);
/**
* @brief DWT更新时间轴函数,timeline函数调用
* @attention timeline函数,,CYCCNT溢出后定时和时间轴不准确
*/
void DWT_SysTimeUpdate(void);
#endif /* BSP_DWT_H_ */