Skip to content

Commit eaef6b5

Browse files
deshipudpgeorge
authored andcommitted
extmod/machine_i2c: Use writes not reads in i2c.scan().
As per discussion in adafruit#2449, using write requests instead of read requests for I2C.scan() seems to support a larger number of devices, especially ones that are write-only. Even a read-only I2C device has to implement writes in order to be able to receive the address of the register to read.
1 parent 9e1dec1 commit eaef6b5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

extmod/machine_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
272272
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
273273
for (int addr = 0x08; addr < 0x78; ++addr) {
274274
mp_hal_i2c_start(self);
275-
int ack = mp_hal_i2c_write_byte(self, (addr << 1) | 1);
275+
int ack = mp_hal_i2c_write_byte(self, (addr << 1));
276276
if (ack) {
277277
mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr));
278278
}

0 commit comments

Comments
 (0)