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

pkg/mynewt-core: fix timer config for nrf51

This commit is contained in:
Hauke Petersen 2022-05-25 09:16:54 +02:00
parent 6cca6234b0
commit 39085c7182
2 changed files with 20 additions and 3 deletions

View File

@ -22,6 +22,12 @@
#include "os/os_cputime.h"
#include "hal/hal_timer.h"
#ifdef CPU_FAM_NRF51
#define TIMER_NUM 3
#else
#define TIMER_NUM 5
#endif
void mynewt_core_init(void)
{
#if (MYNEWT_VAL_OS_CPUTIME_TIMER_NUM >= 0) && (defined(CPU_NRF51) || defined(CPU_NRF52))
@ -29,7 +35,7 @@ void mynewt_core_init(void)
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_TIMER_NUM == TIMER_NUM);
assert(MYNEWT_VAL_OS_CPUTIME_FREQ == 32768);
int rc = hal_timer_init(MYNEWT_VAL_OS_CPUTIME_TIMER_NUM, NULL);
assert(rc == 0);

View File

@ -60,18 +60,29 @@
/** @} */
/**
* @brief TIMER 5 (RTC_DEV0) will be mynewt-core OS_CPUTIME timer
* @brief TIMER 3 or 5 (RTC_DEV0) will be mynewt-core OS_CPUTIME timer,
* depending on used CPU family
*/
#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM
#ifdef CPU_FAM_NRF51
#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (3)
#else
#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (5)
#endif
#endif
/**
* @brief Enable TIMER 5 (RTC_DEV0)
* @brief Enable TIMER 3 or TIMER 5 (RTC_DEV0) depending on used CPU family
*/
#ifdef CPU_FAM_NRF51
#ifndef MYNEWT_VAL_TIMER_3
#define MYNEWT_VAL_TIMER_3 (1)
#endif
#else
#ifndef MYNEWT_VAL_TIMER_5
#define MYNEWT_VAL_TIMER_5 (1)
#endif
#endif
#if IS_USED(MODULE_NIMBLE)
/*** @mynewt-nimble */