stm32l4xx-hal icon indicating copy to clipboard operation
stm32l4xx-hal copied to clipboard

I2C NACK polling

Open Crzyrndm opened this issue 3 years ago • 2 comments

current master branch asserts that the buffer length for I2C::read and I2C::write is at least 1 and less than 256 (1..=255)

write: https://github.com/stm32-rs/stm32l4xx-hal/blob/master/src/i2c.rs#L254 read: https://github.com/stm32-rs/stm32l4xx-hal/blob/master/src/i2c.rs#L308

A fairly common I2C operation is checking if an address is present/responding by just writing the address and checking for the device ACK. Note that this is a 0 length read/write and therefore the asserts linked above prevent this.

I see the motivation for preventing 0-sized reads/writes, but there isn't a solid alternative right now. There is some conversation in the embedded-hal crate about adding an explicit method for this but no real consensus or movement.

Crzyrndm avatar Jun 02 '21 03:06 Crzyrndm

Assert removed in #295 . Tested on r5.

gauteh avatar Mar 02 '22 09:03 gauteh

Fixed for write

gauteh avatar Mar 05 '22 14:03 gauteh