25 #ifndef ACE_WIRE_SIMPLE_WIRE_INTERFACE_H
26 #define ACE_WIRE_SIMPLE_WIRE_INTERFACE_H
72 uint8_t dataPin, uint8_t clockPin, uint8_t delayMicros
76 mDelayMicros(delayMicros)
88 digitalWrite(mClockPin, LOW);
89 digitalWrite(mDataPin, LOW);
114 uint8_t effectiveAddr = (addr << 1) | 0x00;
115 write(effectiveAddr);
129 for (uint8_t i = 0; i < 8; ++i) {
152 uint8_t
requestFrom(uint8_t addr, uint8_t quantity,
bool stop =
true) {
153 mQuantity = quantity;
163 uint8_t effectiveAddr = (addr << 1) | 0x01;
164 write(effectiveAddr);
179 for (uint8_t i = 0; i < 8; ++i) {
182 uint8_t bit = digitalRead(mDataPin);
214 uint8_t readAck()
const {
217 uint8_t ack = digitalRead(mDataPin);
226 void sendAck()
const {
233 void sendNack()
const {
239 void bitDelay()
const { delayMicroseconds(mDelayMicros); }
241 void clockHigh()
const { pinMode(mClockPin, INPUT); bitDelay(); }
243 void clockLow()
const { pinMode(mClockPin, OUTPUT); bitDelay(); }
245 void dataHigh()
const { pinMode(mDataPin, INPUT); bitDelay(); }
247 void dataLow()
const { pinMode(mDataPin, OUTPUT); bitDelay(); }
250 uint8_t
const mDataPin;
251 uint8_t
const mClockPin;
252 uint8_t
const mDelayMicros;