delay_s()延时秒= delay_ms()毫秒*1000= delay_us()微秒*1000000
微秒定时器代码
void delay_us(uint32_t n)
{
SysTick->CTRL = 0; // Disable SysTick,关闭系统定时器
SysTick->LOAD = SystemCoreClock/1000000*n-1; // 就是nus
SysTick->LOAD = SystemCoreClock/1000*n-1; // 就是ms
SysTick->LOAD = SystemCoreClock/1*n-1; // 就是s
SysTick->VAL = 0; // Clear current value as well as count flag,清空当前计数值且清零count flag
SysTick->CTRL = 5; // Enable SysTick timer with processor clock,启动系统定时器,其时钟源为处理器时钟168MHz
while ((SysTick->CTRL & 0x10000)==0);// Wait until count flag is set
SysTick->CTRL = 0; // Disable SysTick,关闭系统定时器
}