diff options
Diffstat (limited to 'libraries/Wire/Wire.cpp')
-rwxr-xr-x | libraries/Wire/Wire.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index 73369b3..0ee3012 100755 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -77,22 +77,24 @@ void TwoWire::begin(int address) begin((uint8_t)address); } -void TwoWire::requestFrom(uint8_t address, uint8_t quantity) +uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) { // clamp to buffer length if(quantity > BUFFER_LENGTH){ quantity = BUFFER_LENGTH; } // perform blocking read into buffer - twi_readFrom(address, rxBuffer, quantity); + uint8_t read = twi_readFrom(address, rxBuffer, quantity); // set rx buffer iterator vars rxBufferIndex = 0; - rxBufferLength = quantity; + rxBufferLength = read; + + return read; } -void TwoWire::requestFrom(int address, int quantity) +uint8_t TwoWire::requestFrom(int address, int quantity) { - requestFrom((uint8_t)address, (uint8_t)quantity); + return requestFrom((uint8_t)address, (uint8_t)quantity); } void TwoWire::beginTransmission(uint8_t address) @@ -111,15 +113,16 @@ void TwoWire::beginTransmission(int address) beginTransmission((uint8_t)address); } -void TwoWire::endTransmission(void) +uint8_t TwoWire::endTransmission(void) { // transmit buffer (blocking) - twi_writeTo(txAddress, txBuffer, txBufferLength, 1); + int8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1); // reset tx buffer iterator vars txBufferIndex = 0; txBufferLength = 0; // indicate that we are done transmitting transmitting = 0; + return ret; } // must be called in: |