From c28e94b534aa5a3297a839b0e6cbed60df05be79 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Thu, 1 Jun 2017 00:32:53 +0200 Subject: [PATCH] nrf5/modules/machine: Reserving timer0 instance for bluetooth if compiled in. Leaving timer1 and timer2 for application. Note that music module soft-pwm will also occupy timer1 if enabled. --- nrf5/modules/machine/timer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nrf5/modules/machine/timer.c b/nrf5/modules/machine/timer.c index b1f9ad297a..1866dfa18e 100644 --- a/nrf5/modules/machine/timer.c +++ b/nrf5/modules/machine/timer.c @@ -113,6 +113,13 @@ STATIC mp_obj_t machine_timer_make_new(const mp_obj_type_t *type, size_t n_args, // get static peripheral object int timer_id = timer_find(args[0].u_obj); +#if BLUETOOTH_SD + if (timer_id == 0) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Timer(%d) reserved by Bluetooth LE stack.", timer_id)); + } +#endif + #if MICROPY_PY_MACHINE_SOFT_PWM if (timer_id == 1) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,