diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-05-29 16:32:31 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-06-24 12:47:58 -0700 |
| commit | ae52d052cb6b4fb6cd89702dafe8448565b4aa5e (patch) | |
| tree | 79d26c02db7c0a695a5c67317f6ec910b7c6265d | |
| parent | d0401f02a947a468d3019e70b5b0f5f633429c5d (diff) | |
Fix I2C thanks to Mark!
| -rw-r--r-- | ports/esp32s2/common-hal/busio/I2C.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ports/esp32s2/common-hal/busio/I2C.c b/ports/esp32s2/common-hal/busio/I2C.c index 80743dc89..0a696bed6 100644 --- a/ports/esp32s2/common-hal/busio/I2C.c +++ b/ports/esp32s2/common-hal/busio/I2C.c @@ -218,7 +218,10 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, addr << 1 | 1, true); // | 1 to indicate read - i2c_master_read(cmd, data, len, true); + if (len > 1) { + i2c_master_read(cmd, data, len - 1, 0); + } + i2c_master_read_byte(cmd, data + len - 1, 1); i2c_master_stop(cmd); esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */); i2c_cmd_link_delete(cmd); |
