From 2b09d3162ab343cc79e2b6fd951020157eb273dd Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 30 Mar 2021 00:53:37 +0200 Subject: [PATCH 1/2] cpu/nrf52: Expose more timers --- .../common/nrf52/include/cfg_timer_default.h | 20 +++++++++++++++++++ cpu/nrf5x_common/periph/timer.c | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/boards/common/nrf52/include/cfg_timer_default.h b/boards/common/nrf52/include/cfg_timer_default.h index a7d6786577..cc4b2ba17f 100644 --- a/boards/common/nrf52/include/cfg_timer_default.h +++ b/boards/common/nrf52/include/cfg_timer_default.h @@ -42,11 +42,31 @@ static const timer_conf_t timer_config[] = { .channels = 3, .bitmode = TIMER_BITMODE_BITMODE_08Bit, .irqn = TIMER2_IRQn + }, + /* The later timers are only present on the larger NRF52 CPUs like NRF52840 + * or NRF52833, but not small ones like NRF52810 */ +#ifdef NRF_TIMER3 + { + .dev = NRF_TIMER3, + .channels = 3, + .bitmode = TIMER_BITMODE_BITMODE_08Bit, + .irqn = TIMER3_IRQn + }, +#endif +#ifdef NRF_TIMER4 + { + .dev = NRF_TIMER4, + .channels = 3, + .bitmode = TIMER_BITMODE_BITMODE_08Bit, + .irqn = TIMER4_IRQn } +#endif }; #define TIMER_0_ISR isr_timer1 #define TIMER_1_ISR isr_timer2 +#define TIMER_2_ISR isr_timer3 +#define TIMER_3_ISR isr_timer4 #define TIMER_NUMOF ARRAY_SIZE(timer_config) /** @} */ diff --git a/cpu/nrf5x_common/periph/timer.c b/cpu/nrf5x_common/periph/timer.c index b0ca580a0c..b37939891f 100644 --- a/cpu/nrf5x_common/periph/timer.c +++ b/cpu/nrf5x_common/periph/timer.c @@ -199,3 +199,10 @@ void TIMER_2_ISR(void) irq_handler(2); } #endif + +#ifdef TIMER_3_ISR +void TIMER_3_ISR(void) +{ + irq_handler(3); +} +#endif From 1da4693e5cd03ad4d80ddf6834377a6ce008e9a7 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 30 Mar 2021 00:56:53 +0200 Subject: [PATCH 2/2] b/c/microbit: Use timer 2 on microbit-v2 Timer 1 is already in use for NRF802154_TIMER --- boards/common/microbit/microbit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/common/microbit/microbit.c b/boards/common/microbit/microbit.c index d105f7dd70..df2bc9d92e 100644 --- a/boards/common/microbit/microbit.c +++ b/boards/common/microbit/microbit.c @@ -137,7 +137,7 @@ static const uint8_t pixmap[ROWS][COLS] = { /** * @brief Timer dev */ -#define TIMER_DEV_NUM (1) +#define TIMER_DEV_NUM (2) #else #error "Module only compatible with microbit and microbit-v2 boards." #endif