1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #16623 from fjmolinas/pr_riot_initialize_timers

pkg/nimble: have RIOT always initialize nimble timers
This commit is contained in:
Francisco 2021-09-02 08:54:53 +02:00 committed by GitHub
commit 65d717f5a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View File

@ -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
}

View File

@ -110,6 +110,21 @@ void nimble_riot_init(void)
int res;
(void)res;
#if !IS_USED(MODULE_MYNEWT_CORE) && IS_ACTIVE(NIMBLE_CFG_CONTROLLER)
/* 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 = hal_timer_config(MYNEWT_VAL_OS_CPUTIME_TIMER_NUM,
MYNEWT_VAL_OS_CPUTIME_FREQ);
assert(rc == 0);
(void)rc;
#endif
/* and finally initialize and run the host */
thread_create(_stack_host, sizeof(_stack_host),
NIMBLE_HOST_PRIO,