diff options
author | Damien George <damien@micropython.org> | 2020-12-03 13:07:37 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-12-07 17:22:08 +1100 |
commit | 1e4e2644ecfd2cab5154a2ad95f3eb5aca545ba7 (patch) | |
tree | d4de3b10f7c0d8dd3be06e92e275fbe32e370530 /ports/stm32/timer.c | |
parent | 4ce6427bd71129b1ab3b9eeaf2c1182d623cd7b9 (diff) |
stm32: Add support for a board to reserve certain peripherals.
Allows reserving CAN, I2C, SPI, Timer and UART peripherals. If reserved
the peripheral cannot be accessed from Python.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/timer.c')
-rw-r--r-- | ports/stm32/timer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index 9b8c14c0d..a34d2984d 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -896,6 +896,11 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Timer(%d) doesn't exist"), tim_id); } + // check if the timer is reserved for system use or not + if (MICROPY_HW_TIM_IS_RESERVED(tim_id)) { + mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Timer(%d) is reserved"), tim_id); + } + pyb_timer_obj_t *tim; if (MP_STATE_PORT(pyb_timer_obj_all)[tim_id - 1] == NULL) { // create new Timer object |