From e99ce0cf1f015f0bce8ae0ac6177a4dfcc4a8814 Mon Sep 17 00:00:00 2001 From: Joseph Newman Date: Tue, 30 Oct 2018 19:22:06 +0000 Subject: [PATCH] [efr32] implement otPlatTime* APIs (#3212) --- examples/platforms/efr32/alarm.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/platforms/efr32/alarm.c b/examples/platforms/efr32/alarm.c index de0f838bb..0a647aeba 100644 --- a/examples/platforms/efr32/alarm.c +++ b/examples/platforms/efr32/alarm.c @@ -44,6 +44,9 @@ #include "em_core.h" #include "rail.h" +#define XTAL_ACCURACY 200 +#define US_IN_MS 1000 + static uint32_t sTimerHi = 0; static uint32_t sTimerLo = 0; static uint32_t sAlarmT0 = 0; @@ -54,10 +57,10 @@ void efr32AlarmInit(void) { } -uint32_t otPlatAlarmMilliGetNow(void) +uint64_t otPlatTimeGet(void) { uint32_t timer_lo; - uint32_t timer_ms; + uint64_t timer_us; CORE_DECLARE_IRQ_STATE; CORE_ENTER_CRITICAL(); @@ -71,11 +74,21 @@ uint32_t otPlatAlarmMilliGetNow(void) sTimerLo = timer_lo; - timer_ms = (((uint64_t)sTimerHi << 32) | sTimerLo) / 1000; + timer_us = (((uint64_t)sTimerHi << 32) | sTimerLo); CORE_EXIT_CRITICAL(); - return timer_ms; + return timer_us; +} + +uint32_t otPlatAlarmMilliGetNow(void) +{ + return otPlatTimeGet() / US_IN_MS; +} + +uint32_t otPlatTimeGetXtalAccuracy(void) +{ + return XTAL_ACCURACY; } void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)