Skip to content

Commit a39f0cf

Browse files
authored
Merge pull request #5977 from prplz/bitbang-i2c
Bitbang i2c: switch scl to input for reading
2 parents 87d97ae + 5472f41 commit a39f0cf

File tree

1 file changed

+2
-0
lines changed
  • shared-module/bitbangio

1 file changed

+2
-0
lines changed

shared-module/bitbangio/I2C.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ STATIC void scl_release(bitbangio_i2c_obj_t *self) {
4949
uint32_t count = self->us_timeout;
5050
delay(self);
5151
// For clock stretching, wait for the SCL pin to be released, with timeout.
52+
common_hal_digitalio_digitalinout_switch_to_input(&self->scl, PULL_UP);
5253
for (; !common_hal_digitalio_digitalinout_get_value(&self->scl) && count; --count) {
5354
common_hal_mcu_delay_us(1);
5455
}
56+
common_hal_digitalio_digitalinout_switch_to_output(&self->scl, true, DRIVE_MODE_OPEN_DRAIN);
5557
// raise exception on timeout
5658
if (count == 0) {
5759
mp_raise_msg(&mp_type_TimeoutError, translate("Clock stretch too long"));

0 commit comments

Comments
 (0)