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

HPM MCHTMR 时间基准实现 / HPM MCHTMR based timebase implementation. More...

#include <hpm_timebase.hpp>

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

Public Member Functions

 HPMTimebase (MCHTMR_Type *timer=HPM_MCHTMR, clock_name_t clock=clock_mchtmr0)
 构造 HPM 时间基对象 / Construct an HPM timebase object.
 
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.
 

Private Attributes

MCHTMR_Type * timer_
 定时器外设实例 / Timer peripheral instance.
 
uint32_t clock_hz_
 定时器输入时钟频率(Hz) / Timer input clock frequency in Hz.
 

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

HPM MCHTMR 时间基准实现 / HPM MCHTMR based timebase implementation.

基于 MCHTMR 计数器提供微秒与毫秒时间戳。 Provides microsecond and millisecond timestamps using MCHTMR counter.

Definition at line 19 of file hpm_timebase.hpp.

Constructor & Destructor Documentation

◆ HPMTimebase()

HPMTimebase::HPMTimebase ( MCHTMR_Type * timer = HPM_MCHTMR,
clock_name_t clock = clock_mchtmr0 )

构造 HPM 时间基对象 / Construct an HPM timebase object.

Parameters
timerMCHTMR 外设基地址 / MCHTMR base address.
clock定时器时钟源 / Clock source used by the timer.

Definition at line 19 of file hpm_timebase.cpp.

20 : Timebase(static_cast<uint64_t>(UINT32_MAX) * 1000 + 999, UINT32_MAX),
21 timer_(timer),
22 clock_hz_(clock_get_frequency(clock))
23{
24}
MCHTMR_Type * timer_
定时器外设实例 / Timer peripheral instance.
uint32_t clock_hz_
定时器输入时钟频率(Hz) / Timer input clock frequency in Hz.
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 HPMTimebase::_get_microseconds ( )
overridevirtual

获取微秒时间戳 / Get current timestamp in microseconds.

Returns
当前微秒时间戳 / Current microsecond timestamp.

Implements LibXR::Timebase.

Definition at line 26 of file hpm_timebase.cpp.

27{
28 const uint64_t ticks = mchtmr_get_count(timer_);
29 return MicrosecondTimestamp(ConvertTicksToTime(ticks, clock_hz_, 1000000ULL));
30}
表示微秒级时间戳的类。Class representing a timestamp in microseconds.

◆ _get_milliseconds()

MillisecondTimestamp HPMTimebase::_get_milliseconds ( )
overridevirtual

获取毫秒时间戳 / Get current timestamp in milliseconds.

Returns
当前毫秒时间戳 / Current millisecond timestamp.

Implements LibXR::Timebase.

Definition at line 32 of file hpm_timebase.cpp.

33{
34 const uint64_t ticks = mchtmr_get_count(timer_);
35 return MillisecondTimestamp(ConvertTicksToTime(ticks, clock_hz_, 1000ULL));
36}
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.

Field Documentation

◆ clock_hz_

uint32_t LibXR::HPMTimebase::clock_hz_
private

定时器输入时钟频率(Hz) / Timer input clock frequency in Hz.

Definition at line 45 of file hpm_timebase.hpp.

◆ timer_

MCHTMR_Type* LibXR::HPMTimebase::timer_
private

定时器外设实例 / Timer peripheral instance.

Definition at line 43 of file hpm_timebase.hpp.


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