libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
ch32_timebase.hpp
1#pragma once
2
3#include DEF2STR(LIBXR_CH32_CONFIG_FILE)
4
5extern uint32_t SystemCoreClock;
6
7namespace LibXR
8{
9
10class CH32Timebase : public Timebase
11{
12 public:
13 CH32Timebase() : Timebase(UINT64_MAX, UINT32_MAX)
14 {
15 cnt_per_microsec_ = SystemCoreClock / 1000000;
16 }
17
19 {
20 uint64_t cnt = SysTick->CNT;
21 return TimestampUS(cnt / cnt_per_microsec_);
22 }
23
24 TimestampMS _get_milliseconds() override { return cnt_per_microsec_ / 1000; }
25
26 static inline uint32_t cnt_per_microsec_;
27};
28
29} // namespace LibXR
TimestampMS _get_milliseconds() override
纯虚函数,获取当前时间的毫秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in milliseconds...
TimestampUS _get_microseconds() override
纯虚函数,获取当前时间的微秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in microseconds...
时间基类,用于提供高精度时间戳。 Timebase class for providing high-precision timestamps.
Definition timebase.hpp:18
Timebase(uint64_t max_valid_us=UINT64_MAX, uint32_t max_valid_ms=UINT32_MAX)
默认构造函数,初始化全局时间基指针。 Default constructor, initializing the global timebase pointer.
Definition timebase.hpp:30
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
表示微秒级时间戳的类。Class representing a timestamp in microseconds.
LibXR 命名空间
Definition ch32_gpio.hpp:9