diff --git a/examples/platforms/nrf528xx/src/alarm.c b/examples/platforms/nrf528xx/src/alarm.c index 6d94ee663..3d6085613 100644 --- a/examples/platforms/nrf528xx/src/alarm.c +++ b/examples/platforms/nrf528xx/src/alarm.c @@ -66,6 +66,8 @@ #define US_PER_S NRF_802154_US_PER_S #define US_PER_OVERFLOW (512UL * NRF_802154_US_PER_S) ///< Time that has passed between overflow events. On full RTC speed, it occurs every 512 s. +#define RTC_COUNTER_BITS 24 ///< Number of bits in RTC COUNTER register. + #define MS_PER_S 1000UL #define MIN_RTC_COMPARE_EVENT_TICKS 2 ///< Minimum number of RTC ticks delay that guarantees that RTC compare event will fire. @@ -523,6 +525,16 @@ inline uint64_t nrf5AlarmGetCurrentTime(void) return GetCurrentTime(kUsTimer); } +uint64_t nrf5AlarmGetRawCounter(void) +{ + uint32_t offset = 0; + uint32_t counter = 0; + + GetOffsetAndCounter(&offset, &counter); + + return (((uint64_t)offset) << RTC_COUNTER_BITS) | counter; +} + uint32_t otPlatAlarmMilliGetNow(void) { return (uint32_t)(nrf5AlarmGetCurrentTime() / US_PER_MS); diff --git a/examples/platforms/nrf528xx/src/platform-nrf5.h b/examples/platforms/nrf528xx/src/platform-nrf5.h index afc06791e..8de1d6611 100644 --- a/examples/platforms/nrf528xx/src/platform-nrf5.h +++ b/examples/platforms/nrf528xx/src/platform-nrf5.h @@ -89,6 +89,12 @@ void nrf5AlarmProcess(otInstance *aInstance); */ uint64_t nrf5AlarmGetCurrentTime(void); +/** + * Function for getting raw counter value in RTC ticks. + * + */ +uint64_t nrf5AlarmGetRawCounter(void); + /** * Initialization of Random Number Generator. *