Skip to content

Commit ee75741

Browse files
committed
codal_app/microbithal: Use i2c.redirect method to reconfig pins.
Fixes issue #112. Signed-off-by: Damien George <damien@micropython.org>
1 parent 057b4e1 commit ee75741

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/codal_app/microbithal.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,13 @@ void microbit_hal_pin_write_ws2812(int pin, const uint8_t *buf, size_t len) {
215215
}
216216

217217
int microbit_hal_i2c_init(int scl, int sda, int freq) {
218-
// TODO set pins
219-
int ret = uBit.i2c.setFrequency(freq);
218+
int ret = uBit.i2c.redirect(*pin_obj[sda], *pin_obj[scl]);
220219
if (ret != DEVICE_OK) {
221-
return ret;;
220+
return ret;
221+
}
222+
ret = uBit.i2c.setFrequency(freq);
223+
if (ret != DEVICE_OK) {
224+
return ret;
222225
}
223226
return 0;
224227
}

0 commit comments

Comments
 (0)