Skip to content

Commit 67a442d

Browse files
committed
alif/machine_i2c: Allow changing I2C SCL/SDA pins.
Signed-off-by: Damien George <[email protected]>
1 parent 6e72cae commit 67a442d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ports/alif/machine_i2c.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
125125
self->freq = args[ARG_freq].u_int;
126126
self->timeout = args[ARG_timeout].u_int;
127127

128-
// here we would check the scl/sda pins and configure them, but it's not implemented
129-
if (args[ARG_scl].u_obj != mp_const_none || args[ARG_sda].u_obj != mp_const_none) {
130-
mp_raise_ValueError(MP_ERROR_TEXT("explicit choice of scl/sda is not implemented"));
128+
// Set SCL/SDA pins if given.
129+
if (args[ARG_scl].u_obj != mp_const_none) {
130+
self->scl = mp_hal_get_pin_obj(args[ARG_scl].u_obj);
131+
}
132+
if (args[ARG_sda].u_obj != mp_const_none) {
133+
self->sda = mp_hal_get_pin_obj(args[ARG_sda].u_obj);
131134
}
132135

133136
// Disable I2C controller.

0 commit comments

Comments
 (0)