Skip to content

Commit f315a37

Browse files
Gadgetoiddpgeorge
authored andcommitted
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 <[email protected]>
1 parent 39452db commit f315a37

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ports/rp2/machine_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
100100
#ifdef PICO_DEFAULT_I2C
101101
{ MP_QSTR_id, MP_ARG_INT, {.u_int = PICO_DEFAULT_I2C} },
102102
#else
103-
{ MP_QSTR_id, MP_ARG_INT, {.u_int = -1} },
103+
{ MP_QSTR_id, MP_ARG_INT | MP_ARG_REQUIRED },
104104
#endif
105105
{ MP_QSTR_freq, MP_ARG_INT, {.u_int = DEFAULT_I2C_FREQ} },
106106
{ MP_QSTR_scl, MICROPY_I2C_PINS_ARG_OPTS | MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },

0 commit comments

Comments
 (0)