diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2008-06-21 23:16:27 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2008-06-21 23:16:27 +0000 |
commit | 79904311bb35ca52b51650f834683606e31882c2 (patch) | |
tree | 06c39698c080a079a3967dadacb59467ee76133d /libraries/Wire/Wire.cpp | |
parent | 75d1f5053c3460484973d6de1d0d7ec9d9a6516d (diff) |
Wire library patch to provide better error handling.
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: |