mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-30 11:24:12 +01:00
Fixing bug in Wire library that caused it to read and discard one extra byte when do a requestFrom() a slave device. Thanks to Christopher K. Johnson.
This commit is contained in:
parent
15cff82214
commit
6ba23bafe2
@ -135,7 +135,12 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length)
|
|||||||
|
|
||||||
// initialize buffer iteration vars
|
// initialize buffer iteration vars
|
||||||
twi_masterBufferIndex = 0;
|
twi_masterBufferIndex = 0;
|
||||||
twi_masterBufferLength = length;
|
twi_masterBufferLength = length-1; // This is not intuitive, read on...
|
||||||
|
// On receive, the previously configured ACK/NACK setting is transmitted in
|
||||||
|
// response to the received byte before the interrupt is signalled.
|
||||||
|
// Therefor we must actually set NACK when the _next_ to last byte is
|
||||||
|
// received, causing that NACK to be sent in response to receiving the last
|
||||||
|
// expected byte of data.
|
||||||
|
|
||||||
// build sla+w, slave device address + w bit
|
// build sla+w, slave device address + w bit
|
||||||
twi_slarw = TW_READ;
|
twi_slarw = TW_READ;
|
||||||
|
Loading…
Reference in New Issue
Block a user