Files
player/Project/Src/Drive/Source/delay.c.tmp
2025-06-28 22:15:49 +08:00

52 lines
1.1 KiB
Plaintext
Raw 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.

/***
***************************************************************************
* @file delay.c
* @version V1.0.0
* @brief delay接口相关函数
***************************************************************************
* @description
*
* SysTick定时器配置为1ms中断实现毫秒延时
*
***************************************************************************
***/
#include "delay.h"
static __IO u32 TimingDelay; //计数变量
// 函数:延时初始化
// 说明:配置 SysTick 为1ms中断并启动定时器
//
void Delay_Init(void)
{
SysTick_Config(SystemCoreClock / 1000); //配置SysTick时钟为1ms中断
}
// 函数:计时函数
// 说明:在 SysTick 中断服务函数里被调用
//
void OS_CPU_SysTickHandler(void)
{
if (TimingDelay != 0)
{
TimingDelay--;
}
}
// 函数:毫秒延时
// 参数nTime - 延时时间单位ms
// 说明每次调用都会重新给TimingDelay赋值实现 n 毫秒的延时,最大延时 4294967295 ms。
//
void Delay_ms(u32 nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}