1#include "mspm0_timebase.hpp"
15 uint32_t tick_old = sys_tick_ms;
16 uint32_t val_old = DL_SYSTICK_getValue();
17 uint32_t tick_new = sys_tick_ms;
18 uint32_t val_new = DL_SYSTICK_getValue();
20 auto tick_diff = tick_new - tick_old;
22 uint32_t cycles_per_ms = DL_SYSTICK_getPeriod();
28 static_cast<uint64_t
>(tick_new) * 1000 +
29 static_cast<uint64_t
>(DL_SYSTICK_getPeriod() - val_old) * 1000 /
34 static_cast<uint64_t
>(tick_new) * 1000 +
35 static_cast<uint64_t
>(DL_SYSTICK_getPeriod() - val_new) * 1000 /
49extern "C" void SysTick_Handler(
void)
static volatile uint32_t sys_tick_ms
SysTick 毫秒计数器。 SysTick millisecond counter.
MSPM0Timebase()
构造函数 / Constructor
static void OnSysTickInterrupt()
SysTick 中断入口辅助函数。 Helper called from the SysTick interrupt path.
static void Sync(uint32_t ticks)
同步毫秒计数器。 Synchronize the millisecond counter.
微秒时间戳 / Microsecond timestamp
毫秒时间戳 / Millisecond timestamp
static void ConfigureWrapRange(uint64_t max_valid_us, uint32_t max_valid_ms) noexcept
配置时间戳回绕上界。 Configure the timestamp wraparound limits.
static void SetReady(bool ready=true) noexcept
设置时间基就绪状态。 Set the timebase ready flag.
static MicrosecondTimestamp GetMicroseconds()
获取当前时间的微秒级时间戳。 Gets the current timestamp in microseconds.
static MillisecondTimestamp GetMilliseconds()
获取当前时间的毫秒级时间戳。 Gets the current timestamp in milliseconds.