mimxrt: Support gaps in the SPI an I2C device numbers.
That allows also to use e.g. SPI1 and SPI2 instead SPI0 and SPI1.
This commit is contained in:
parent
e1a84a0c6f
commit
2dd3d88409
@ -109,7 +109,7 @@ mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
||||
|
||||
// Get I2C bus.
|
||||
int i2c_id = mp_obj_get_int(args[ARG_id].u_obj);
|
||||
if (i2c_id < 0 || i2c_id >= MICROPY_HW_I2C_NUM) {
|
||||
if (i2c_id < 0 || i2c_id >= MICROPY_HW_I2C_NUM || i2c_index_table[i2c_id] == 0) {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("I2C(%d) doesn't exist"), i2c_id);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
||||
|
||||
// Get the SPI bus id.
|
||||
int spi_id = mp_obj_get_int(args[ARG_id].u_obj);
|
||||
if (spi_id < 0 || spi_id >= MP_ARRAY_SIZE(spi_index_table)) {
|
||||
if (spi_id < 0 || spi_id >= MP_ARRAY_SIZE(spi_index_table) || spi_index_table[spi_id] == 0) {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("SPI(%d) doesn't exist"), spi_id);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user