1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

Merge pull request #18136 from haukepetersen/fix_mynewtcore_timernrf51

pkg/mynewt-core: fix timer configuration for nrf51
This commit is contained in:
benpicco 2022-06-03 01:08:15 +02:00 committed by GitHub
commit d20d353633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 */