Dallas DS1307 real-time clock minimalistic driver
Dependents: testing_RTC_OneWire EMIRv2
Revision 3:c5018c71887f, committed 2014-04-28
- Comitter:
- alpov
- Date:
- Mon Apr 28 13:08:38 2014 +0000
- Parent:
- 2:6d8d35a5b3f2
- Commit message:
- fixed wrong 12/24-hour config
Changed in this revision
DS1307.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6d8d35a5b3f2 -r c5018c71887f DS1307.cpp --- a/DS1307.cpp Mon Apr 28 09:23:06 2014 +0000 +++ b/DS1307.cpp Mon Apr 28 13:08:38 2014 +0000 @@ -16,7 +16,7 @@ if (ds1307_i2c.read(DS1307_ADDR, buffer, 7) != 0) return 0; if (buffer[0] & 0x80) return 0; // clock stopped - if (!(buffer[2] & 0x40)) return 0; // 12-hour format not supported + if (buffer[2] & 0x40) return 0; // 12-hour format not supported now.tm_sec = bcdToDecimal(buffer[0] & 0x7F); now.tm_min = bcdToDecimal(buffer[1]); now.tm_hour = bcdToDecimal(buffer[2] & 0x3F); @@ -35,9 +35,9 @@ now = localtime(&t); buffer[0] = 0x00; // memory address - buffer[1] = decimalToBcd(now->tm_sec) & 0x7f; // CH = 0 + buffer[1] = decimalToBcd(now->tm_sec) & 0x7F; // CH = 0 buffer[2] = decimalToBcd(now->tm_min); - buffer[3] = 0x40 | (decimalToBcd(now->tm_hour) & 0x3F); // 24-hour format + buffer[3] = decimalToBcd(now->tm_hour) & 0x3F; // 24-hour format buffer[4] = now->tm_wday + 1; buffer[5] = decimalToBcd(now->tm_mday); buffer[6] = decimalToBcd(now->tm_mon+1);