Open matthijskooijman opened 3 years ago
ACK. I recall having coded that specifically as to one of the cores (must have been ArduinoCore-samd at the time) had exactly those semantics.
Yup, seems they fixed it for SAMD here-ish (https://github.com/adafruit/ArduinoCore-samd/blob/master/libraries/Wire/Wire.cpp#diff-df1cdf716a3ab485d49151a55cbbd816f3689b57dc5999174d66f9d8f0241bac) and it now looks like this: https://github.com/adafruit/ArduinoCore-samd/blob/0b160161de695ba9e5b0ce223f9e1181224800d9/libraries/Wire/Wire.cpp#L65-L98
Previously, it would return the number of requested bytes, even if the slave returned a NAK on the address byte, preventing libraries to detect such a NAK. For example, the SparkFun HTU21D library would fail to read humidity, because the "I'm not ready measuring"-NAK would look like a successful read, but with dummy data.
This matches the return value with that of the official Arduino versions and the documentation at https://www.arduino.cc/en/Reference/WireRequestFrom