libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::ESP32Timebase Class Reference

基于 esp_timer 的时间基准实现(微秒与毫秒) Timebase implementation using esp_timer (microseconds and milliseconds) More...

#include <esp_timebase.hpp>

Inheritance diagram for LibXR::ESP32Timebase:
Collaboration diagram for LibXR::ESP32Timebase:

Public Member Functions

 ESP32Timebase ()
 构造函数
 
TimestampUS _get_microseconds () override
 获取当前时间(微秒)
 
TimestampMS _get_milliseconds () override
 获取当前时间(毫秒)
 
- 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.
 

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

Detailed Description

基于 esp_timer 的时间基准实现(微秒与毫秒) Timebase implementation using esp_timer (microseconds and milliseconds)

Definition at line 14 of file esp_timebase.hpp.

Constructor & Destructor Documentation

◆ ESP32Timebase()

LibXR::ESP32Timebase::ESP32Timebase ( )
inline

构造函数

Definition at line 20 of file esp_timebase.hpp.

21 : Timebase(static_cast<uint64_t>(UINT64_MAX), UINT32_MAX) // 最大值可根据需要修改
22 {
23 }
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
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ _get_microseconds()

TimestampUS LibXR::ESP32Timebase::_get_microseconds ( )
inlineoverridevirtual

获取当前时间(微秒)

Returns
TimestampUS 当前时间(微秒)

Implements LibXR::Timebase.

Definition at line 29 of file esp_timebase.hpp.

30 {
31 return esp_timer_get_time(); // 返回自启动以来的微秒数
32 }

◆ _get_milliseconds()

TimestampMS LibXR::ESP32Timebase::_get_milliseconds ( )
inlineoverridevirtual

获取当前时间(毫秒)

Returns
TimestampMS 当前时间(毫秒)

Implements LibXR::Timebase.

Definition at line 38 of file esp_timebase.hpp.

39 {
40 return static_cast<TimestampMS>(esp_timer_get_time() / 1000) % UINT32_MAX;
41 }

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