diff options
author | Radomir Dopieralski <openstack@sheep.art.pl> | 2016-10-08 17:34:46 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-10-11 15:30:46 +1100 |
commit | eaef6b5324fa2ff425802d4abeea45aa945bfc14 (patch) | |
tree | c88efbe8c9e09b7fcab8d32a41424eefc30a2ab9 | |
parent | 9e1dec181806d7cd34b5dfec8cdce4c41b39ab53 (diff) | |
download | micropython-eaef6b5324fa2ff425802d4abeea45aa945bfc14.tar.gz micropython-eaef6b5324fa2ff425802d4abeea45aa945bfc14.zip |
extmod/machine_i2c: Use writes not reads in i2c.scan().
As per discussion in #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.
-rw-r--r-- | extmod/machine_i2c.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c index d76e5eedd1..e201b23990 100644 --- a/extmod/machine_i2c.c +++ b/extmod/machine_i2c.c @@ -272,7 +272,7 @@ STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) { // 7-bit addresses 0b0000xxx and 0b1111xxx are reserved for (int addr = 0x08; addr < 0x78; ++addr) { mp_hal_i2c_start(self); - int ack = mp_hal_i2c_write_byte(self, (addr << 1) | 1); + int ack = mp_hal_i2c_write_byte(self, (addr << 1)); if (ack) { mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr)); } |