From f4a3af4c442a844aa231f2cfcefe9bd015becb03 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 1 Sep 2021 09:15:24 +0200 Subject: [PATCH] pkg/mynewt-core/contrib: use same initializaion as Nimble for timers --- pkg/mynewt-core/contrib/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/mynewt-core/contrib/core.c b/pkg/mynewt-core/contrib/core.c index 9dc9e11ada..a780e0636f 100644 --- a/pkg/mynewt-core/contrib/core.c +++ b/pkg/mynewt-core/contrib/core.c @@ -25,10 +25,17 @@ void mynewt_core_init(void) { #if (MYNEWT_VAL_OS_CPUTIME_TIMER_NUM >= 0) && (defined(CPU_NRF51) || defined(CPU_NRF52)) - int rc = hal_timer_init(5, NULL); + /* in mynewt-nimble and uwb-core OS_CPUTIMER_TIMER_NUM == 5 is NRF_RTC0, + for nimble this must be used for the BLE stack and must go through + mynewt timer initialization for it to work properly. The RTC frequency + should be set to the highest possible value, so 32768Hz */ + assert(MYNEWT_VAL_OS_CPUTIME_TIMER_NUM == 5); + assert(MYNEWT_VAL_OS_CPUTIME_FREQ == 32768); + int rc = hal_timer_init(MYNEWT_VAL_OS_CPUTIME_TIMER_NUM, NULL); assert(rc == 0); - rc = os_cputime_init(MYNEWT_VAL_OS_CPUTIME_FREQ); + rc = hal_timer_config(MYNEWT_VAL_OS_CPUTIME_TIMER_NUM, + MYNEWT_VAL_OS_CPUTIME_FREQ); assert(rc == 0); - (void) rc; + (void)rc; #endif }