Working Version of the Real Time Clock module DS1307.
Fork of RTC-DS1307 by
Rtc_Ds1307.h@0:3940f0ad2ca5, 2013-06-02 (annotated)
- Committer:
- leihen
- Date:
- Sun Jun 02 09:59:39 2013 +0000
- Revision:
- 0:3940f0ad2ca5
- Child:
- 1:64274190e842
Initial Revision - not working yet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leihen | 0:3940f0ad2ca5 | 1 | /* Rtc_Ds1307.h */ |
leihen | 0:3940f0ad2ca5 | 2 | /* |
leihen | 0:3940f0ad2ca5 | 3 | Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de) |
leihen | 0:3940f0ad2ca5 | 4 | |
leihen | 0:3940f0ad2ca5 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
leihen | 0:3940f0ad2ca5 | 6 | of this software and associated documentation files (the "Software"), to deal |
leihen | 0:3940f0ad2ca5 | 7 | in the Software without restriction, including without limitation the rights |
leihen | 0:3940f0ad2ca5 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
leihen | 0:3940f0ad2ca5 | 9 | copies of the Software, and to permit persons to whom the Software is |
leihen | 0:3940f0ad2ca5 | 10 | furnished to do so, subject to the following conditions: |
leihen | 0:3940f0ad2ca5 | 11 | |
leihen | 0:3940f0ad2ca5 | 12 | The above copyright notice and this permission notice shall be included in |
leihen | 0:3940f0ad2ca5 | 13 | all copies or substantial portions of the Software. |
leihen | 0:3940f0ad2ca5 | 14 | |
leihen | 0:3940f0ad2ca5 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
leihen | 0:3940f0ad2ca5 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
leihen | 0:3940f0ad2ca5 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
leihen | 0:3940f0ad2ca5 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
leihen | 0:3940f0ad2ca5 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
leihen | 0:3940f0ad2ca5 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
leihen | 0:3940f0ad2ca5 | 21 | THE SOFTWARE. |
leihen | 0:3940f0ad2ca5 | 22 | */ |
leihen | 0:3940f0ad2ca5 | 23 | #ifndef __RTC_DS1307_H__ |
leihen | 0:3940f0ad2ca5 | 24 | #define __RTC_DS1307_H__ |
leihen | 0:3940f0ad2ca5 | 25 | |
leihen | 0:3940f0ad2ca5 | 26 | #include "mbed.h" |
leihen | 0:3940f0ad2ca5 | 27 | |
leihen | 0:3940f0ad2ca5 | 28 | |
leihen | 0:3940f0ad2ca5 | 29 | /** Class Rtc_Ds1307 implements the real time clock module DS1307 |
leihen | 0:3940f0ad2ca5 | 30 | * |
leihen | 0:3940f0ad2ca5 | 31 | * You can read the clock and set a new time and date. |
leihen | 0:3940f0ad2ca5 | 32 | * It is also possible to start and stop the clock. |
leihen | 0:3940f0ad2ca5 | 33 | * Rtc_Ds1307 allows you to display the time in a 12h or 24h format |
leihen | 0:3940f0ad2ca5 | 34 | */ |
leihen | 0:3940f0ad2ca5 | 35 | class Rtc_Ds1307 |
leihen | 0:3940f0ad2ca5 | 36 | { |
leihen | 0:3940f0ad2ca5 | 37 | I2C* m_rtc; |
leihen | 0:3940f0ad2ca5 | 38 | |
leihen | 0:3940f0ad2ca5 | 39 | public: |
leihen | 0:3940f0ad2ca5 | 40 | /** public constructor which creates the real time clock object |
leihen | 0:3940f0ad2ca5 | 41 | * |
leihen | 0:3940f0ad2ca5 | 42 | * @param sda : specifies the pin for the SDA communication line. |
leihen | 0:3940f0ad2ca5 | 43 | * |
leihen | 0:3940f0ad2ca5 | 44 | * @param scl : the pin for the serial clock |
leihen | 0:3940f0ad2ca5 | 45 | * |
leihen | 0:3940f0ad2ca5 | 46 | */ |
leihen | 0:3940f0ad2ca5 | 47 | Rtc_Ds1307(PinName sda, PinName scl); |
leihen | 0:3940f0ad2ca5 | 48 | |
leihen | 0:3940f0ad2ca5 | 49 | ~Rtc_Ds1307(); |
leihen | 0:3940f0ad2ca5 | 50 | |
leihen | 0:3940f0ad2ca5 | 51 | bool getTime(tm& time); |
leihen | 0:3940f0ad2ca5 | 52 | |
leihen | 0:3940f0ad2ca5 | 53 | bool setTime(tm& time); |
leihen | 0:3940f0ad2ca5 | 54 | }; |
leihen | 0:3940f0ad2ca5 | 55 | |
leihen | 0:3940f0ad2ca5 | 56 | |
leihen | 0:3940f0ad2ca5 | 57 | #endif // __RTC_DS1307_H__ |