From d9813910dad9d95b8e53ef3c6916a24747070390 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Wed, 24 May 2017 23:33:28 +0200 Subject: [PATCH] nrf5/modules/machine/timer: If timer is used in combination with SOFT_PWM (implicitly use of ticker.c) guard the Timer1 instance from being instantiated trough python timer module. Also disable implementation of the HAL IRQ handler which is for now explicitly implemented in ticker.c for Timer1. --- nrf5/hal/hal_timer.c | 4 ++-- nrf5/modules/machine/timer.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nrf5/hal/hal_timer.c b/nrf5/hal/hal_timer.c index 42d4d24c21..715d540288 100644 --- a/nrf5/hal/hal_timer.c +++ b/nrf5/hal/hal_timer.c @@ -39,15 +39,15 @@ void hal_timer_start(uint8_t id) { void hal_timer_stop(uint8_t id) { } -#if (MICROPY_PY_MACHINE_SOFT_PWM != 1) void TIMER0_IRQHandler(void) { } -#endif +#if (MICROPY_PY_MACHINE_SOFT_PWM != 1) void TIMER1_IRQHandler(void) { } +#endif void TIMER2_IRQHandler(void) { diff --git a/nrf5/modules/machine/timer.c b/nrf5/modules/machine/timer.c index a8284cd741..e81379ae3e 100644 --- a/nrf5/modules/machine/timer.c +++ b/nrf5/modules/machine/timer.c @@ -99,7 +99,7 @@ STATIC mp_obj_t machine_timer_make_new(const mp_obj_type_t *type, size_t n_args, int timer_id = timer_find(args[ARG_NEW_id].u_obj); #if MICROPY_PY_MACHINE_SOFT_PWM - if (timer_id == 0) { + if (timer_id == 1) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Timer(%d) reserved by ticker driver.", timer_id)); }