summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Howard <github@gadgetoid.com>2025-03-13 13:02:11 +0000
committerDamien George <damien@micropython.org>2025-03-25 23:52:49 +1100
commitf315a376b616fb195a18700a724715f0e7d250e3 (patch)
treed51334f5e55a61f1954d9a3cdf1688f89ccef993
parent39452dbeed27423fd207d3cc48c52b4e591deea5 (diff)
rp2/machine_i2c: Require an I2C bus ID when no default is available.
When PICO_DEFAULT_I2C is not set require an I2C bus ID instead of using -1 as a default, which would fail with a cryptic: "I2C(-1) doesn't exist" Signed-off-by: Phil Howard <github@gadgetoid.com>
-rw-r--r--ports/rp2/machine_i2c.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/rp2/machine_i2c.c b/ports/rp2/machine_i2c.c
index e97a852b2..94212fb48 100644
--- a/ports/rp2/machine_i2c.c
+++ b/ports/rp2/machine_i2c.c
@@ -100,7 +100,7 @@ mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
#ifdef PICO_DEFAULT_I2C
{ MP_QSTR_id, MP_ARG_INT, {.u_int = PICO_DEFAULT_I2C} },
#else
- { MP_QSTR_id, MP_ARG_INT, {.u_int = -1} },
+ { MP_QSTR_id, MP_ARG_INT | MP_ARG_REQUIRED },
#endif
{ MP_QSTR_freq, MP_ARG_INT, {.u_int = DEFAULT_I2C_FREQ} },
{ MP_QSTR_scl, MICROPY_I2C_PINS_ARG_OPTS | MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },