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

MicrosecondTimestamp _get_microseconds () override
 纯虚函数,获取当前时间的微秒级时间戳(由派生类实现)。 Pure virtual function for obtaining the current timestamp in microseconds (implemented by derived classes).
 
MillisecondTimestamp _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 MicrosecondTimestamp GetMicroseconds ()
 获取当前时间的微秒级时间戳。 Gets the current timestamp in microseconds.
 
static MillisecondTimestamp GetMilliseconds ()
 获取当前时间的毫秒级时间戳。 Gets the current timestamp in milliseconds.
 

Detailed Description

Definition at line 12 of file ch32_timebase.hpp.

Constructor & Destructor Documentation

◆ CH32Timebase()

CH32Timebase::CH32Timebase ( )

Definition at line 5 of file ch32_timebase.cpp.

5 : Timebase(UINT64_MAX, UINT32_MAX)
6{
7 cnt_per_microsec_ = SystemCoreClock / 1000000;
8}
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()

MicrosecondTimestamp CH32Timebase::_get_microseconds ( )
overridevirtual

纯虚函数,获取当前时间的微秒级时间戳(由派生类实现)。 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 10 of file ch32_timebase.cpp.

11{
12 uint64_t cnt = SysTick->CNT;
13 return MicrosecondTimestamp(cnt / cnt_per_microsec_);
14}
表示微秒级时间戳的类。Class representing a timestamp in microseconds.

◆ _get_milliseconds()

MillisecondTimestamp CH32Timebase::_get_milliseconds ( )
overridevirtual

纯虚函数,获取当前时间的毫秒级时间戳(由派生类实现)。 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 16 of file ch32_timebase.cpp.

17{
18 return cnt_per_microsec_ / 1000;
19}

Field Documentation

◆ cnt_per_microsec_

uint32_t LibXR::CH32Timebase::cnt_per_microsec_
inlinestatic

Definition at line 21 of file ch32_timebase.hpp.


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