esp32: Use always machine_pin_get_id for getting a Pin id.
This applies to all machine modules which have pins as arguments. Since
machine_pin_get_id() calls pin_find(), these pin arguments may be at the
moment either integer objects or Pin objects. That allows for instance to
write
uart = UART(1, tx=Pin(4), rx=Pin(5))
instead of
uart = UART(1, tx=4, rx=5)
which is consistent with other ports. Since this handling is done at a
single place in the code, extending that scheme to accept strings for named
pins is easy.
Signed-off-by: robert-hh <robert@hammelrath.com>
This commit is contained in:
@@ -185,10 +185,10 @@ mp_obj_t machine_hw_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
||||
|
||||
// Set SCL/SDA pins if given
|
||||
if (args[ARG_scl].u_obj != MP_OBJ_NULL) {
|
||||
self->scl = mp_hal_get_pin_obj(args[ARG_scl].u_obj);
|
||||
self->scl = machine_pin_get_id(args[ARG_scl].u_obj);
|
||||
}
|
||||
if (args[ARG_sda].u_obj != MP_OBJ_NULL) {
|
||||
self->sda = mp_hal_get_pin_obj(args[ARG_sda].u_obj);
|
||||
self->sda = machine_pin_get_id(args[ARG_sda].u_obj);
|
||||
}
|
||||
|
||||
// Initialise the I2C peripheral
|
||||
|
||||
Reference in New Issue
Block a user