Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RTC-DS1307 by
Revision 8:d0e66fa78e79, committed 2013-06-23
- Comitter:
- leihen
- Date:
- Sun Jun 23 19:24:57 2013 +0000
- Parent:
- 7:dca20be3ef38
- Child:
- 9:5627b407e097
- Commit message:
- Totally working now. Will set the MBED RTC once the class has been created. Can use the Ds1307 clock to Keep the System time up to date.
Changed in this revision
| Rtc_Ds1307.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Rtc_Ds1307.cpp Sun Jun 23 18:48:59 2013 +0000
+++ b/Rtc_Ds1307.cpp Sun Jun 23 19:24:57 2013 +0000
@@ -2,7 +2,7 @@
#include "Rtc_Ds1307.h"
#ifndef DEBUG
-//#define DEBUG
+#define DEBUG
#endif
#include "debug.h"
@@ -213,8 +213,9 @@
setSquareWaveOutput(true, RS1Hz);
// query time
getTime(t);
- struct tm now = {t.sec, t.min, t.hour, t.date, t.mon, t.year};
+ struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900};
m_time = mktime(&now);
+ set_time(m_time);
// register callback from now on the time will be maintained by the square wave input
m_sqw.rise(this, &RtcCls::_callback);
}
@@ -222,13 +223,14 @@
void RtcCls::_callback(void)
{
+// INFO("Tick!");
// Simply increase the number of seconds
m_time++;
- if (m_bAlarmEnabled && (m_time == m_alarmTime)) {
- if (m_alarmfunc != NULL)
- m_alarmfunc();
- m_bAlarmEnabled = false;
- }
+// if (m_bAlarmEnabled && (m_time == m_alarmTime)) {
+// if (m_alarmfunc != NULL)
+// m_alarmfunc();
+// m_bAlarmEnabled = false;
+// }
}
time_t RtcCls::getTime()
@@ -237,8 +239,12 @@
if (!m_bUseSqw) {
Time_rtc t;
getTime(t);
- struct tm now = {t.sec, t.min, t.hour, t.date, t.mon, t.year};
+ struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900};
m_time = mktime(&now);
+ INFO("getting time %02d.%02d.%04d %02d:%02d:%02d Ticks=%08lx", t.date, t.mon, t.year, t.hour, t.min, t.sec, m_time);
+ }
+ else {
+ INFO("getting time Ticks=%08lx", m_time);
}
return m_time;
}
@@ -253,9 +259,10 @@
tim.min = now->tm_min;
tim.hour = now->tm_hour;
tim.date = now->tm_mday;
- tim.mon = now->tm_mon;
+ tim.mon = now->tm_mon+1;
tim.year = now->tm_year + 1900;
tim.wday = now->tm_wday +1;
setTime( tim, true, true);
+ set_time(t);
}
