Files
player/Project/Src/rt-thread/core_delay.h
2025-06-27 00:32:57 +08:00

43 lines
1.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __CORE_DELAY_H
#define __CORE_DELAY_H
//#include "device_drv_config.h"
/* 获取内核时钟频率 */
#define GET_CPU_ClkFreq() GetSysClocksFreq()
#define SysClockFreq (180000000)
//获取系统主频
uint32_t GetSysClocksFreq (void);
/* 为方便使用在延时函数内部调用CPU_TS_TmrInit 函数初始化时间戳寄存器,
这样每次调用函数都会初始化一遍。
把本宏值设置为0然后在main 函数刚运行时调用CPU_TS_TmrInit 可避免每次都初始化 */
#define CPU_TS_INIT_IN_DELAY_FUNCTION 0
/*****************************************************************
* 函数声明
**************************************************************/
uint32_t CPU_TS_TmrRd(void);
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
//使用以下函数前必须先调用CPU_TS_TmrInit 函数使能计数器或使能宏CPU_TS_INIT_IN_DELAY_FUNCTION
//最大延时值为8 秒
void CPU_TS_Tmr_Delay_US(uint32_t us);
#define HAL_Delay(ms) CPU_TS_Tmr_Delay_US(ms*1000) (3)
#define CPU_TS_Tmr_Delay_S(s) CPU_TS_Tmr_Delay_MS(s*1000)
#endif /* __CORE_DELAY_H */