Browse files

changed reads and writes

  • Loading branch information...
1 parent 72fc1a4 commit 75dc4129c66410bb83eb42c62ae54e3b1001d093 @zevenrodriguez zevenrodriguez committed Oct 27, 2011
Showing with 20 additions and 20 deletions.
  1. +20 −20 RTClib.cpp
View
40 RTClib.cpp
@@ -10,7 +10,7 @@
#define SECONDS_PER_DAY 86400L
#define SECONDS_FROM_1970_TO_2000 946684800
-
+#define i 0
////////////////////////////////////////////////////////////////////////////////
// utility code, some of this could be exposed in the DateTime API if needed
@@ -130,41 +130,41 @@ uint8_t RTC_DS1307::begin(void) {
uint8_t RTC_DS1307::isrunning(void) {
Wire.beginTransmission(DS1307_ADDRESS);
- Wire.send(0);
+ Wire.write(i);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 1);
- uint8_t ss = Wire.receive();
+ uint8_t ss = Wire.read();
return !(ss>>7);
}
void RTC_DS1307::adjust(const DateTime& dt) {
Wire.beginTransmission(DS1307_ADDRESS);
- Wire.send(0);
- Wire.send(bin2bcd(dt.second()));
- Wire.send(bin2bcd(dt.minute()));
- Wire.send(bin2bcd(dt.hour()));
- Wire.send(bin2bcd(0));
- Wire.send(bin2bcd(dt.day()));
- Wire.send(bin2bcd(dt.month()));
- Wire.send(bin2bcd(dt.year() - 2000));
- Wire.send(0);
+ Wire.write(i);
+ Wire.write(bin2bcd(dt.second()));
+ Wire.write(bin2bcd(dt.minute()));
+ Wire.write(bin2bcd(dt.hour()));
+ Wire.write(bin2bcd(0));
+ Wire.write(bin2bcd(dt.day()));
+ Wire.write(bin2bcd(dt.month()));
+ Wire.write(bin2bcd(dt.year() - 2000));
+ Wire.write(i);
Wire.endTransmission();
}
DateTime RTC_DS1307::now() {
Wire.beginTransmission(DS1307_ADDRESS);
- Wire.send(0);
+ Wire.write(i);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
- uint8_t ss = bcd2bin(Wire.receive() & 0x7F);
- uint8_t mm = bcd2bin(Wire.receive());
- uint8_t hh = bcd2bin(Wire.receive());
- Wire.receive();
- uint8_t d = bcd2bin(Wire.receive());
- uint8_t m = bcd2bin(Wire.receive());
- uint16_t y = bcd2bin(Wire.receive()) + 2000;
+ uint8_t ss = bcd2bin(Wire.read() & 0x7F);
+ uint8_t mm = bcd2bin(Wire.read());
+ uint8_t hh = bcd2bin(Wire.read());
+ Wire.read();
+ uint8_t d = bcd2bin(Wire.read());
+ uint8_t m = bcd2bin(Wire.read());
+ uint16_t y = bcd2bin(Wire.read()) + 2000;
return DateTime (y, m, d, hh, mm, ss);
}

0 comments on commit 75dc412

Please sign in to comment.