29 lines
562 B
C++
29 lines
562 B
C++
/**
|
|||
|
|
* @file systick.cpp
|
||
|
|
* @brief SysTick 时基模块实现。
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include "main.h"
|
||
|
|
#include "sys/systick.h"
|
||
|
|
|
||
|
|
volatile uint32_t SysTickTimer::s_ms = 0U;
|
||
|
|
|
||
|
|
void SysTickTimer::onInterrupt()
|
||
|
|
{
|
||
|
|
s_ms++;
|
||
|
|
}
|
||
|
|
|
||
|
|
void SysTickTimer::delayMs(uint32_t ms)
|
||
|
|
{
|
||
|
|
uint32_t start = s_ms;
|
||
|
|
while((s_ms - start) < ms) { }
|
||
|
|
}
|
||
|
|
|
||
|
|
void SysTickTimer::initMs()
|
||
|
|
{
|
||
|
|
SystemCoreClockUpdate();
|
||
|
|
SysTick_Config(SystemCoreClock / 1000U);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ----- 中断入口 C 包装 ---------------------------------------------- */
|
||
|
|
void SysTick_Handler(void) { SysTickTimer::onInterrupt(); }
|