From 64180f0742a1926162b784c68bafa49b9b58596c Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 18 Nov 2020 14:50:43 +1100 Subject: extmod/machine_i2c: Add init protocol method for generic I2C bindings. Hardware I2C implementations must provide a .init() protocol method if they want to support reconfiguration. Otherwise the default is that i2c.init() raises an OSError (currently the case for all ports). mp_machine_soft_i2c_locals_dict is renamed to mp_machine_i2c_locals_dict to match the generic SPI bindings. Fixes issue #6623 (where calling .init() on a HW I2C would crash). Signed-off-by: Damien George --- ports/stm32/machine_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ports/stm32/machine_i2c.c') diff --git a/ports/stm32/machine_i2c.c b/ports/stm32/machine_i2c.c index e0c408c6d0..cfa00b86d8 100644 --- a/ports/stm32/machine_i2c.c +++ b/ports/stm32/machine_i2c.c @@ -273,7 +273,7 @@ const mp_obj_type_t machine_hard_i2c_type = { .print = machine_hard_i2c_print, .make_new = machine_hard_i2c_make_new, .protocol = &machine_hard_i2c_p, - .locals_dict = (mp_obj_dict_t *)&mp_machine_soft_i2c_locals_dict, + .locals_dict = (mp_obj_dict_t *)&mp_machine_i2c_locals_dict, }; #endif // MICROPY_HW_ENABLE_HW_I2C -- cgit v1.2.3