libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::CH32Timebase Class Reference
Inheritance diagram for LibXR::CH32Timebase:
[legend]
Collaboration diagram for LibXR::CH32Timebase:
[legend]

Public Member Functions

TimestampUS _get_microseconds () override
 纯虚函数,获取当前时间的微秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in microseconds (implemented by derived classes).
 
TimestampMS _get_milliseconds () override
 纯虚函数,获取当前时间的毫秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in milliseconds (implemented by derived classes).
 
- Public Member Functions inherited from LibXR::Timebase
 Timebase (uint64_t max_valid_us=UINT64_MAX, uint32_t max_valid_ms=UINT32_MAX)
 默认构造函数,初始化全局时间基指针。 Default constructor, initializing the global timebase pointer.
 

Static Public Attributes

static uint32_t cnt_per_microsec_
 
- Static Public Attributes inherited from LibXR::Timebase
static Timebasetimebase = nullptr
 静态指针,用于存储全局时间基对象。 Static pointer storing the global timebase instance.
 

Additional Inherited Members

- Static Public Member Functions inherited from LibXR::Timebase
static TimestampUS GetMicroseconds ()
 获取当前时间的微秒级时间戳。 Gets the current timestamp in microseconds.
 
static TimestampMS GetMilliseconds ()
 获取当前时间的毫秒级时间戳。 Gets the current timestamp in milliseconds.
 

Detailed Description

Definition at line 10 of file ch32_timebase.hpp.

Constructor & Destructor Documentation

◆ CH32Timebase()

LibXR::CH32Timebase::CH32Timebase ( )
inline

Definition at line 13 of file ch32_timebase.hpp.

13 : Timebase(UINT64_MAX, UINT32_MAX)
14 {
15 cnt_per_microsec_ = SystemCoreClock / 1000000;
16 }
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

Member Function Documentation

◆ _get_microseconds()

TimestampUS LibXR::CH32Timebase::_get_microseconds ( )
inlineoverridevirtual

纯虚函数,获取当前时间的微秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in microseconds (implemented by derived classes).

该函数需要在派生类中实现,以提供具体的时间获取机制。 This function must be implemented in derived classes to provide the actual time retrieval mechanism.

Returns
返回当前的时间戳(单位:微秒)。 Returns the current timestamp (in microseconds).

Implements LibXR::Timebase.

Definition at line 18 of file ch32_timebase.hpp.

19 {
20 uint64_t cnt = SysTick->CNT;
21 return TimestampUS(cnt / cnt_per_microsec_);
22 }

◆ _get_milliseconds()

TimestampMS LibXR::CH32Timebase::_get_milliseconds ( )
inlineoverridevirtual

纯虚函数,获取当前时间的毫秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in milliseconds (implemented by derived classes).

该函数需要在派生类中实现,以提供具体的时间获取机制。 This function must be implemented in derived classes to provide the actual time retrieval mechanism.

Returns
返回当前的时间戳(单位:毫秒)。 Returns the current timestamp (in milliseconds).

Implements LibXR::Timebase.

Definition at line 24 of file ch32_timebase.hpp.

24{ return cnt_per_microsec_ / 1000; }

Field Documentation

◆ cnt_per_microsec_

uint32_t LibXR::CH32Timebase::cnt_per_microsec_
inlinestatic

Definition at line 26 of file ch32_timebase.hpp.


The documentation for this class was generated from the following file: