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.

This commit is contained in:
Glenn Ruben Bakke 2017-06-01 00:32:53 +02:00 committed by glennrub
parent 6ddaba532a
commit c28e94b534
1 changed files with 7 additions and 0 deletions

View File

@ -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 // get static peripheral object
int timer_id = timer_find(args[0].u_obj); 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 MICROPY_PY_MACHINE_SOFT_PWM
if (timer_id == 1) { if (timer_id == 1) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,