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

ESP32 时间基准实现 / ESP32 timebase implementation. More...

#include <esp_timebase.hpp>

Inheritance diagram for LibXR::ESP32Timebase:
[legend]
Collaboration diagram for LibXR::ESP32Timebase:
[legend]

Public Member Functions

 ESP32Timebase ()
 构造函数 / Constructor
 
MicrosecondTimestamp _get_microseconds () override
 获取当前微秒计数 / Get current timestamp in microseconds
 
MillisecondTimestamp _get_milliseconds () override
 获取当前毫秒计数 / Get current timestamp in milliseconds
 
- 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 MicrosecondTimestamp GetMicroseconds ()
 获取当前时间的微秒级时间戳。 Gets the current timestamp in microseconds.
 
static MillisecondTimestamp GetMilliseconds ()
 获取当前时间的毫秒级时间戳。 Gets the current timestamp in milliseconds.
 
static void DelayMicroseconds (uint32_t us)
 微秒级延时 / Delay in microseconds
 
- Static Public Attributes inherited from LibXR::Timebase
static Timebasetimebase = nullptr
 静态指针,用于存储全局时间基对象。 Static pointer storing the global timebase instance.
 

Detailed Description

ESP32 时间基准实现 / ESP32 timebase implementation.

基于 esp_timer 提供微秒和毫秒时间戳。 在支持的平台上使用 systimer HAL 快速路径。 Provides microsecond and millisecond timestamps based on esp_timer. Uses optional systimer HAL fast path when available.

Definition at line 23 of file esp_timebase.hpp.

Constructor & Destructor Documentation

◆ ESP32Timebase()

LibXR::ESP32Timebase::ESP32Timebase ( )

构造函数 / Constructor

Definition at line 11 of file esp_timebase.cpp.

11 : Timebase(static_cast<uint64_t>(UINT64_MAX), UINT32_MAX)
12{
13#if SOC_SYSTIMER_SUPPORTED
14 systimer_hal_init(&systimer_hal_);
15
16 systimer_hal_tick_rate_ops_t tick_rate_ops = {
17 .ticks_to_us = systimer_ticks_to_us,
18 .us_to_ticks = systimer_us_to_ticks,
19 };
20 systimer_hal_set_tick_rate_ops(&systimer_hal_, &tick_rate_ops);
21 systimer_hal_enable_counter(&systimer_hal_, SYSTIMER_COUNTER_ESPTIMER);
22 systimer_ready_ = true;
23#endif
24}
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 IRAM_ATTR LibXR::ESP32Timebase::_get_microseconds ( )
overridevirtual

获取当前微秒计数 / Get current timestamp in microseconds

Returns
MicrosecondTimestamp 微秒时间戳 / Microsecond timestamp

Implements LibXR::Timebase.

Definition at line 26 of file esp_timebase.cpp.

27{
28#if SOC_SYSTIMER_SUPPORTED
29 if (systimer_ready_)
30 {
31 return systimer_hal_get_time(&systimer_hal_, SYSTIMER_COUNTER_ESPTIMER);
32 }
33#endif
34 return static_cast<MicrosecondTimestamp>(esp_timer_get_time());
35}

◆ _get_milliseconds()

MillisecondTimestamp IRAM_ATTR LibXR::ESP32Timebase::_get_milliseconds ( )
overridevirtual

获取当前毫秒计数 / Get current timestamp in milliseconds

Returns
MillisecondTimestamp 毫秒时间戳 / Millisecond timestamp

Implements LibXR::Timebase.

Definition at line 37 of file esp_timebase.cpp.

38{
39 return MillisecondTimestamp(static_cast<uint32_t>(_get_microseconds() / 1000ULL));
40}
MicrosecondTimestamp _get_microseconds() override
获取当前微秒计数 / Get current timestamp in microseconds

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