Updated Adafruit Library
Fork of Adafruit_RTCLib by
DS1307.h@2:f372b273d88f, 2017-06-08 (annotated)
- Committer:
- arsenalist
- Date:
- Thu Jun 08 15:26:26 2017 +0000
- Revision:
- 2:f372b273d88f
- Parent:
- 1:2c4e81ecda67
Use SoftI2C
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nkhorman | 0:7f90c8e04249 | 1 | // Code by JeeLabs http://news.jeelabs.org/code/ |
nkhorman | 0:7f90c8e04249 | 2 | // Released to the public domain! Enjoy! |
nkhorman | 0:7f90c8e04249 | 3 | |
nkhorman | 0:7f90c8e04249 | 4 | /* |
nkhorman | 0:7f90c8e04249 | 5 | * Taken from https://github.com/adafruit/RTClib |
nkhorman | 0:7f90c8e04249 | 6 | * and modified for LPC1768 by Neal Horman July 2012 |
nkhorman | 0:7f90c8e04249 | 7 | * Also add support for access to the 56 bytes of |
nkhorman | 0:7f90c8e04249 | 8 | * user accessible battery backed ram. |
nkhorman | 0:7f90c8e04249 | 9 | */ |
nkhorman | 0:7f90c8e04249 | 10 | |
nkhorman | 0:7f90c8e04249 | 11 | #ifndef _DS1307_H_ |
nkhorman | 0:7f90c8e04249 | 12 | #define _DS1307_H_ |
nkhorman | 0:7f90c8e04249 | 13 | |
nkhorman | 0:7f90c8e04249 | 14 | #include "mbed.h" |
nkhorman | 0:7f90c8e04249 | 15 | #include "DateTime.h" |
arsenalist | 2:f372b273d88f | 16 | #include "SoftI2C.h" |
nkhorman | 0:7f90c8e04249 | 17 | |
nkhorman | 1:2c4e81ecda67 | 18 | // RTC based on the DS1307 chip connected via I2C |
nkhorman | 0:7f90c8e04249 | 19 | class RtcDs1307 |
nkhorman | 0:7f90c8e04249 | 20 | { |
nkhorman | 0:7f90c8e04249 | 21 | public: |
arsenalist | 2:f372b273d88f | 22 | RtcDs1307(SoftI2C &i2c); |
nkhorman | 0:7f90c8e04249 | 23 | bool adjust(const DateTime& dt); |
nkhorman | 0:7f90c8e04249 | 24 | bool isRunning(); |
nkhorman | 0:7f90c8e04249 | 25 | DateTime now(); |
nkhorman | 0:7f90c8e04249 | 26 | bool commit(); |
nkhorman | 0:7f90c8e04249 | 27 | uint8_t &operator[](uint8_t i) { return mRam[(i<sizeof(mRam)-1 ? i+1 : 0)]; }; |
nkhorman | 0:7f90c8e04249 | 28 | protected: |
arsenalist | 2:f372b273d88f | 29 | SoftI2C &mI2c; |
nkhorman | 0:7f90c8e04249 | 30 | uint8_t mRam[1+56]; // device register address + 56 bytes |
nkhorman | 0:7f90c8e04249 | 31 | }; |
nkhorman | 0:7f90c8e04249 | 32 | |
nkhorman | 0:7f90c8e04249 | 33 | #endif |