Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

changed reads and writes

  • Loading branch information...
commit 75dc4129c66410bb83eb42c62ae54e3b1001d093 1 parent 72fc1a4
zeven zevenwolf authored

Showing 1 changed file with 20 additions and 20 deletions. Show diff stats Hide diff stats

  1. +20 20 RTClib.cpp
40 RTClib.cpp
@@ -10,7 +10,7 @@
10 10 #define SECONDS_PER_DAY 86400L
11 11
12 12 #define SECONDS_FROM_1970_TO_2000 946684800
13   -
  13 +#define i 0
14 14 ////////////////////////////////////////////////////////////////////////////////
15 15 // utility code, some of this could be exposed in the DateTime API if needed
16 16
@@ -130,41 +130,41 @@ uint8_t RTC_DS1307::begin(void) {
130 130
131 131 uint8_t RTC_DS1307::isrunning(void) {
132 132 Wire.beginTransmission(DS1307_ADDRESS);
133   - Wire.send(0);
  133 + Wire.write(i);
134 134 Wire.endTransmission();
135 135
136 136 Wire.requestFrom(DS1307_ADDRESS, 1);
137   - uint8_t ss = Wire.receive();
  137 + uint8_t ss = Wire.read();
138 138 return !(ss>>7);
139 139 }
140 140
141 141 void RTC_DS1307::adjust(const DateTime& dt) {
142 142 Wire.beginTransmission(DS1307_ADDRESS);
143   - Wire.send(0);
144   - Wire.send(bin2bcd(dt.second()));
145   - Wire.send(bin2bcd(dt.minute()));
146   - Wire.send(bin2bcd(dt.hour()));
147   - Wire.send(bin2bcd(0));
148   - Wire.send(bin2bcd(dt.day()));
149   - Wire.send(bin2bcd(dt.month()));
150   - Wire.send(bin2bcd(dt.year() - 2000));
151   - Wire.send(0);
  143 + Wire.write(i);
  144 + Wire.write(bin2bcd(dt.second()));
  145 + Wire.write(bin2bcd(dt.minute()));
  146 + Wire.write(bin2bcd(dt.hour()));
  147 + Wire.write(bin2bcd(0));
  148 + Wire.write(bin2bcd(dt.day()));
  149 + Wire.write(bin2bcd(dt.month()));
  150 + Wire.write(bin2bcd(dt.year() - 2000));
  151 + Wire.write(i);
152 152 Wire.endTransmission();
153 153 }
154 154
155 155 DateTime RTC_DS1307::now() {
156 156 Wire.beginTransmission(DS1307_ADDRESS);
157   - Wire.send(0);
  157 + Wire.write(i);
158 158 Wire.endTransmission();
159 159
160 160 Wire.requestFrom(DS1307_ADDRESS, 7);
161   - uint8_t ss = bcd2bin(Wire.receive() & 0x7F);
162   - uint8_t mm = bcd2bin(Wire.receive());
163   - uint8_t hh = bcd2bin(Wire.receive());
164   - Wire.receive();
165   - uint8_t d = bcd2bin(Wire.receive());
166   - uint8_t m = bcd2bin(Wire.receive());
167   - uint16_t y = bcd2bin(Wire.receive()) + 2000;
  161 + uint8_t ss = bcd2bin(Wire.read() & 0x7F);
  162 + uint8_t mm = bcd2bin(Wire.read());
  163 + uint8_t hh = bcd2bin(Wire.read());
  164 + Wire.read();
  165 + uint8_t d = bcd2bin(Wire.read());
  166 + uint8_t m = bcd2bin(Wire.read());
  167 + uint16_t y = bcd2bin(Wire.read()) + 2000;
168 168
169 169 return DateTime (y, m, d, hh, mm, ss);
170 170 }

0 comments on commit 75dc412

Please sign in to comment.
Something went wrong with that request. Please try again.