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>
This commit is contained in:
Damien George
2020-12-03 13:07:37 +11:00
parent 4ce6427bd7
commit 1e4e2644ec
6 changed files with 65 additions and 12 deletions

View File

@@ -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