Skip to content

Commit ae52d05

Browse files
committed
Fix I2C thanks to Mark!
1 parent d0401f0 commit ae52d05

File tree

1 file changed

+4
-1
lines changed
  • ports/esp32s2/common-hal/busio

1 file changed

+4
-1
lines changed

ports/esp32s2/common-hal/busio/I2C.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
218218
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
219219
i2c_master_start(cmd);
220220
i2c_master_write_byte(cmd, addr << 1 | 1, true); // | 1 to indicate read
221-
i2c_master_read(cmd, data, len, true);
221+
if (len > 1) {
222+
i2c_master_read(cmd, data, len - 1, 0);
223+
}
224+
i2c_master_read_byte(cmd, data + len - 1, 1);
222225
i2c_master_stop(cmd);
223226
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */);
224227
i2c_cmd_link_delete(cmd);

0 commit comments

Comments
 (0)