earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 boards
GNU Lesser General Public License v2.1
1.92k stars 402 forks source link

zero-byte writes in arduino Wire must be handled by bitbanging #38

Closed ladyada closed 3 years ago

ladyada commented 3 years ago

a common thing done in arduino libraries is performing a zero-byte-write, like this https://github.com/arduino-libraries/ArduinoECCX08/blob/master/src/ECCX08.cpp#L440 or in address scanning/checking

the RP2040 I2C peripheral does not permit that, so for writes of 0 bytes, it must be bitbanged, we've done so in CircuitPython and MicroPython does the same

right now, because of this bug, a lot of libraries (including a lot of Adafruit ones) will not work, they will fail on the address detection step!

(cc @sandeepmistry in case Arduino's core needs it too)

ladyada commented 3 years ago

(besides that, this core works really well! good job :)

brandonplank commented 3 years ago

Thumbs up to this!

earlephilhower commented 3 years ago

Thanks, @ladyada and @brandonplank!

I don't really have many I2C devices to test on, but I've run it against the other I2C port on the Pico and patch #40 seems to work properly with special-cased 0-len I2C reads. (I ran this I2S scanner: https://gist.github.com/tfeldmann/5411375 and a few ad-hoc tests).

Would one of you be able to test on your own setup and report back, please?

brandonplank commented 3 years ago

Yep! Let me get everything hooked up on my end and i'll let you know!

ladyada commented 3 years ago

tested, the sensors i tried before are now working :)

earlephilhower commented 3 years ago

Thanks for the update @ladyada !