You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.8 KiB

#if 0
#include "systick.h"
extern uint32_t g_sys_sick;
/*********************************************************
函数名: void User_SysTickInit(void)
描 述: 系统滴答初始化:100us
输入值: 无
输出值: 无
返回值: 无
如果配置1ms(重装载值48000)
**********************************************************/
void User_SysTickInit(void)
{
SYSTICK_InitStruType x;
// x.SysTick_Value = SystemCoreClock / 10000;//重装载值4800(SystemCoreClock=48M)
// x.SysTick_ClkSource = SysTick_ClkS_Cpu;//时钟48M
// x.SysTick_ITEnable = Enable;
// SysTick_Init(&x);//现在滴答定时器时钟用的48M,重装载值4800 t=1s/f(f=48M/4800)
x.SysTick_Value = SystemCoreClock / 1000;
x.SysTick_ClkSource = SysTick_ClkS_Cpu;//时钟48M
x.SysTick_ITEnable = Enable;
SysTick_Init(&x);//现在滴答定时器时钟用的48M,重装载值4800 t=1s/f(f=48M/48000)
SysTick_Disable();
}
//采用滴答定时器的时钟源,滴答定时器配置的是100us
// extern uint32_t g_sys_sick;
/**
* @brief ticket辅助方法
*/
uint32_t get_sys_ticket(void) { return g_sys_sick; }
uint32_t port_haspassedms(uint32_t ticket) {
uint32_t nowticket = get_sys_ticket();
if (nowticket >= ticket) {
return nowticket - ticket;
}
return UINT32_MAX - ticket + nowticket;
}
void port_do_debug_light_state(void) {
static uint32_t lastprocess = 0;
static uint8_t debug_led_state = 1;
if (port_haspassedms(lastprocess) > 1000) {
lastprocess = get_sys_ticket();
debug_led_state = !debug_led_state;
port_debug_set(debug_led_state);
}
}
void Delayms(__IO uint32_t nTime)
{
uint32_t TimingDelay = 0;
TimingDelay = get_sys_ticket();
// printf("nTime%d\r\n",nTime);
while (port_haspassedms(TimingDelay) <= nTime);
}
#endif