Skip to content

Commit 52b898e

Browse files
mattwlowefacchinm
authored andcommitted
Support for repeated starts added to SAM Wire library
Additional interface method ported to avr for compatibility Fix issue #2428.
1 parent 971de63 commit 52b898e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libraries/Wire/Wire.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ void TwoWire::setClock(uint32_t frequency) {
131131
TWI_SetClock(twi, twiClock, VARIANT_MCK);
132132
}
133133

134-
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
134+
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop) {
135135
if (quantity > BUFFER_LENGTH)
136136
quantity = BUFFER_LENGTH;
137137

138138
// perform blocking read into buffer
139139
int readed = 0;
140-
TWI_StartRead(twi, address, 0, 0);
140+
TWI_StartRead(twi, address, iaddress, isize);
141141
do {
142142
// Stop condition must be set during the reception of last byte
143143
if (readed + 1 == quantity)
@@ -157,6 +157,10 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop
157157
return readed;
158158
}
159159

160+
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
161+
return requestFrom((uint8_t) address, (uint8_t) quantity, (uint32_t) 0, (uint8_t) 0, (uint8_t) sendStop);
162+
}
163+
160164
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) {
161165
return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) true);
162166
}

libraries/Wire/Wire.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TwoWire : public Stream {
4242
uint8_t endTransmission(uint8_t);
4343
uint8_t requestFrom(uint8_t, uint8_t);
4444
uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
45+
uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t);
4546
uint8_t requestFrom(int, int);
4647
uint8_t requestFrom(int, int, int);
4748
virtual size_t write(uint8_t);

0 commit comments

Comments
 (0)