return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop); | return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop); | ||||
} | } | ||||
uint8_t TwoWire::requestFrom(uint8_t addr, uint8_t qty, uint32_t iaddr, uint8_t n, uint8_t stop) | |||||
{ | |||||
if (n > 0) { | |||||
union { uint32_t ul; uint8_t b[4]; } iaddress; | |||||
iaddress.ul = iaddr; | |||||
beginTransmission(addr); | |||||
if (n > 3) n = 3; | |||||
do { | |||||
n = n - 1; | |||||
write(iaddress.b[n]); | |||||
} while (n > 0); | |||||
endTransmission(false); | |||||
} | |||||
if (qty > BUFFER_LENGTH) qty = BUFFER_LENGTH; | |||||
return requestFrom(addr, qty, stop); | |||||
} | |||||
void TwoWire::beginTransmission(uint8_t address) | void TwoWire::beginTransmission(uint8_t address) | ||||
{ | { | ||||
// indicate that we are transmitting | // indicate that we are transmitting |
uint8_t requestFrom(uint8_t, uint8_t, uint8_t); | uint8_t requestFrom(uint8_t, uint8_t, uint8_t); | ||||
uint8_t requestFrom(int, int); | uint8_t requestFrom(int, int); | ||||
uint8_t requestFrom(int, int, int); | uint8_t requestFrom(int, int, int); | ||||
uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t); | |||||
virtual size_t write(uint8_t); | virtual size_t write(uint8_t); | ||||
virtual size_t write(const uint8_t *, size_t); | virtual size_t write(const uint8_t *, size_t); | ||||
virtual int available(void); | virtual int available(void); |
return rxBufferLength; | return rxBufferLength; | ||||
} | } | ||||
uint8_t TwoWire::requestFrom(uint8_t addr, uint8_t qty, uint32_t iaddr, uint8_t n, uint8_t stop) | |||||
{ | |||||
if (n > 0) { | |||||
union { uint32_t ul; uint8_t b[4]; } iaddress; | |||||
iaddress.ul = iaddr; | |||||
beginTransmission(addr); | |||||
if (n > 3) n = 3; | |||||
do { | |||||
n = n - 1; | |||||
write(iaddress.b[n]); | |||||
} while (n > 0); | |||||
endTransmission(false); | |||||
} | |||||
if (qty > BUFFER_LENGTH) qty = BUFFER_LENGTH; | |||||
return requestFrom(addr, qty, stop); | |||||
} | |||||
uint8_t requestFrom(int address, int quantity) { | uint8_t requestFrom(int address, int quantity) { | ||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)1); | return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)1); | ||||
} | } | ||||
uint8_t requestFrom(uint8_t addr, uint8_t qty, uint32_t iaddr, uint8_t n, uint8_t stop); | |||||
virtual size_t write(uint8_t data); | virtual size_t write(uint8_t data); | ||||
virtual size_t write(const uint8_t *data, size_t quantity); | virtual size_t write(const uint8_t *data, size_t quantity); | ||||
virtual int available(void) { | virtual int available(void) { |
return count; | return count; | ||||
} | } | ||||
uint8_t TwoWire::requestFrom(uint8_t addr, uint8_t qty, uint32_t iaddr, uint8_t n, uint8_t stop) | |||||
{ | |||||
if (n > 0) { | |||||
union { uint32_t ul; uint8_t b[4]; } iaddress; | |||||
iaddress.ul = iaddr; | |||||
beginTransmission(addr); | |||||
if (n > 3) n = 3; | |||||
do { | |||||
n = n - 1; | |||||
write(iaddress.b[n]); | |||||
} while (n > 0); | |||||
endTransmission(false); | |||||
} | |||||
if (qty > BUFFER_LENGTH) qty = BUFFER_LENGTH; | |||||
return requestFrom(addr, qty, stop); | |||||
} | |||||
// for compatibility with examples that directly call this AVR-specific function | // for compatibility with examples that directly call this AVR-specific function | ||||
// https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/wiring-and-test | // https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/wiring-and-test | ||||
// https://forum.pjrc.com/threads/44922-Undefined-reference-to-twi_writeTo | // https://forum.pjrc.com/threads/44922-Undefined-reference-to-twi_writeTo |
uint8_t requestFrom(int address, int quantity) { | uint8_t requestFrom(int address, int quantity) { | ||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)1); | return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)1); | ||||
} | } | ||||
uint8_t requestFrom(uint8_t addr, uint8_t qty, uint32_t iaddr, uint8_t n, uint8_t stop); | |||||
virtual size_t write(uint8_t data); | virtual size_t write(uint8_t data); | ||||
virtual size_t write(const uint8_t *data, size_t quantity); | virtual size_t write(const uint8_t *data, size_t quantity); | ||||
virtual int available(void) { | virtual int available(void) { |