diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index b53676635..7b47d2df4 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -972,7 +972,7 @@ public: * 6.9.1 (albeit both unrelated to OT). * * The time is relative to the local radio clock as defined by - * `otPlatRadioGetNow`. + * `Radio::GetNow()`. * * @returns The timestamp in microseconds. */ diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 9021a1dc0..96d6a4b19 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -388,7 +388,7 @@ void SubMac::StartCsmaBackoff(void) { static constexpr uint32_t kAheadTime = kCcaSampleInterval + kCslTransmitTimeAhead + kRadioHeaderShrDuration; Time txStartTime = Time(mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime); - Time radioNow = Time(static_cast(otPlatRadioGetNow(&GetInstance()))); + Time radioNow = Time(static_cast(Get().GetNow())); txStartTime += (mTransmitFrame.mInfo.mTxInfo.mTxDelay - kAheadTime); diff --git a/src/core/mac/sub_mac_csl_receiver.cpp b/src/core/mac/sub_mac_csl_receiver.cpp index 34ee12129..bef89c579 100644 --- a/src/core/mac/sub_mac_csl_receiver.cpp +++ b/src/core/mac/sub_mac_csl_receiver.cpp @@ -125,7 +125,7 @@ bool SubMac::UpdateCsl(uint16_t aPeriod, uint8_t aChannel, otShortAddress aShort mCslTimer.Stop(); if (mCslPeriod > 0) { - mCslSampleTime = TimeMicro(static_cast(otPlatRadioGetNow(&GetInstance()))); + mCslSampleTime = TimeMicro(static_cast(Get().GetNow())); mIsCslSampling = false; HandleCslTimer(); } @@ -248,7 +248,7 @@ uint32_t SubMac::GetLocalTime(void) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_LOCAL_TIME_SYNC now = TimerMicro::GetNow().GetValue(); #else - now = static_cast(otPlatRadioGetNow(&GetInstance())); + now = static_cast(Get().GetNow()); #endif return now; diff --git a/src/core/radio/radio.hpp b/src/core/radio/radio.hpp index 4f7353fd8..51c822fb2 100644 --- a/src/core/radio/radio.hpp +++ b/src/core/radio/radio.hpp @@ -519,6 +519,14 @@ public: #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE + /** + * Get the current radio time in microseconds referenced to a continuous monotonic local radio clock (64 bits + * width). + * + * @returns The current radio clock time. + */ + uint64_t GetNow(void); + /** * Get the current accuracy, in units of ± ppm, of the clock used for scheduling CSL operations. * @@ -921,10 +929,10 @@ inline Error Radio::ResetCsl(void) { return otPlatRadioResetCsl(GetInstancePtr() #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE +inline uint64_t Radio::GetNow(void) { return otPlatRadioGetNow(GetInstancePtr()); } + inline uint8_t Radio::GetCslAccuracy(void) { return otPlatRadioGetCslAccuracy(GetInstancePtr()); } -#endif -#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE inline uint8_t Radio::GetCslUncertainty(void) { return otPlatRadioGetCslUncertainty(GetInstancePtr()); } #endif @@ -1029,6 +1037,8 @@ inline Error Radio::ResetCsl(void) { return kErrorNotImplemented; } #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE +inline uint64_t Radio::GetNow(void) { return NumericLimits::kMax; } + inline uint8_t Radio::GetCslAccuracy(void) { return NumericLimits::kMax; } inline uint8_t Radio::GetCslUncertainty(void) { return NumericLimits::kMax; } diff --git a/src/core/thread/csl_tx_scheduler.cpp b/src/core/thread/csl_tx_scheduler.cpp index 0fcea4670..6f5497289 100644 --- a/src/core/thread/csl_tx_scheduler.cpp +++ b/src/core/thread/csl_tx_scheduler.cpp @@ -156,7 +156,7 @@ uint32_t CslTxScheduler::GetNextCslTransmissionDelay(const Child &aChild, uint32_t &aDelayFromLastRx, uint32_t aAheadUs) const { - uint64_t radioNow = otPlatRadioGetNow(&GetInstance()); + uint64_t radioNow = Get().GetNow(); uint32_t periodInUs = aChild.GetCslPeriod() * kUsPerTenSymbols; /* see CslTxScheduler::ChildInfo::mCslPhase */