Rtc
Fork of RTC-DS1307 by
Rtc_Ds1307.cpp@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.cpp */ |
leihen | 0:3940f0ad2ca5 | 2 | |
leihen | 0:3940f0ad2ca5 | 3 | #include "Rtc_Ds1307.h" |
leihen | 0:3940f0ad2ca5 | 4 | |
leihen | 0:3940f0ad2ca5 | 5 | #define _DEBUG 0 |
leihen | 0:3940f0ad2ca5 | 6 | |
leihen | 0:3940f0ad2ca5 | 7 | |
leihen | 0:3940f0ad2ca5 | 8 | #if (_DEBUG && !defined(TARGET_LPC11U24)) |
leihen | 0:3940f0ad2ca5 | 9 | #define INFO(x, ...) std::printf("[Rtc_Ds1307 : INFO]"x"\r\n", ##__VA_ARGS__); |
leihen | 0:3940f0ad2ca5 | 10 | #define WARN(x, ...) std::printf("[Rtc_Ds1307 : WARN]"x"\r\n", ##__VA_ARGS__); |
leihen | 0:3940f0ad2ca5 | 11 | #define ERR(x, ...) std::printf("[Rtc_Ds1307 : ERR]"x"\r\n", ##__VA_ARGS__); |
leihen | 0:3940f0ad2ca5 | 12 | #else |
leihen | 0:3940f0ad2ca5 | 13 | #define INFO(x, ...) |
leihen | 0:3940f0ad2ca5 | 14 | #define WARN(x, ...) |
leihen | 0:3940f0ad2ca5 | 15 | #define ERR(x, ...) |
leihen | 0:3940f0ad2ca5 | 16 | #endif |
leihen | 0:3940f0ad2ca5 | 17 | |
leihen | 0:3940f0ad2ca5 | 18 | |
leihen | 0:3940f0ad2ca5 | 19 | |
leihen | 0:3940f0ad2ca5 | 20 | |
leihen | 0:3940f0ad2ca5 | 21 | Rtc_Ds1307::Rtc_Ds1307(PinName sda, PinName scl) |
leihen | 0:3940f0ad2ca5 | 22 | { |
leihen | 0:3940f0ad2ca5 | 23 | // Create a new I2C object |
leihen | 0:3940f0ad2ca5 | 24 | m_rtc = new I2C(sda, scl); |
leihen | 0:3940f0ad2ca5 | 25 | if (m_rtc == NULL) |
leihen | 0:3940f0ad2ca5 | 26 | error("Rtc_Ds1307"); |
leihen | 0:3940f0ad2ca5 | 27 | } |
leihen | 0:3940f0ad2ca5 | 28 | |
leihen | 0:3940f0ad2ca5 | 29 | Rtc_Ds1307::~Rtc_Ds1307() |
leihen | 0:3940f0ad2ca5 | 30 | { |
leihen | 0:3940f0ad2ca5 | 31 | if (m_rtc != NULL) |
leihen | 0:3940f0ad2ca5 | 32 | delete m_rtc; |
leihen | 0:3940f0ad2ca5 | 33 | } |
leihen | 0:3940f0ad2ca5 | 34 | |
leihen | 0:3940f0ad2ca5 | 35 | bool Rtc_Ds1307::setTime(tm& time) |
leihen | 0:3940f0ad2ca5 | 36 | { |
leihen | 0:3940f0ad2ca5 | 37 | INFO("Setting new time : %d:%d:%d\n", time.tm_hour, time.tm_min, time.tm_sec); |
leihen | 0:3940f0ad2ca5 | 38 | |
leihen | 0:3940f0ad2ca5 | 39 | return true; |
leihen | 0:3940f0ad2ca5 | 40 | } |
leihen | 0:3940f0ad2ca5 | 41 | |
leihen | 0:3940f0ad2ca5 | 42 | bool Rtc_Ds1307::getTime(tm& time) |
leihen | 0:3940f0ad2ca5 | 43 | { |
leihen | 0:3940f0ad2ca5 | 44 | return false; |
leihen | 0:3940f0ad2ca5 | 45 | } |