Sample to demonstrate the functionality of my DS1307 real time clock library.

Dependencies:   RTC-DS1307 mbed

Files at this revision

API Documentation at this revision

Comitter:
leihen
Date:
Wed Jun 26 21:07:13 2013 +0000
Parent:
1:6dbe51fe0737
Commit message:
Updated library

Changed in this revision

RTC-DS1307.lib Show annotated file Show diff for this revision Revisions of this file
debug.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6dbe51fe0737 -r 3be003301107 RTC-DS1307.lib
--- a/RTC-DS1307.lib	Wed Jun 05 20:43:13 2013 +0000
+++ b/RTC-DS1307.lib	Wed Jun 26 21:07:13 2013 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/leihen/code/RTC-DS1307/#ee81f2c5a706
+https://mbed.org/users/leihen/code/RTC-DS1307/#5627b407e097
diff -r 6dbe51fe0737 -r 3be003301107 debug.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debug.h	Wed Jun 26 21:07:13 2013 +0000
@@ -0,0 +1,16 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+
+#ifdef DEBUG
+#define INFO(x, ...) std::printf("[INFO: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define WARN(x, ...) std::printf("[WARN: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define ERR(x, ...) std::printf("[ERR: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#else
+#define INFO(x, ...)
+#define WARN(x, ...)
+#define ERR(x, ...)
+#endif
+
+
+#endif
\ No newline at end of file
diff -r 6dbe51fe0737 -r 3be003301107 main.cpp
--- a/main.cpp	Wed Jun 05 20:43:13 2013 +0000
+++ b/main.cpp	Wed Jun 26 21:07:13 2013 +0000
@@ -1,7 +1,8 @@
 #include "mbed.h"
 #include "Rtc_Ds1307.h"
 
-Rtc_Ds1307 rtc(p9, p10);
+//RtcCls rtc(p28, p27, p29, true);
+Rtc_Ds1307 rtc(p28, p27);
 
 Serial pc(USBTX, USBRX, "pc");
 
@@ -10,7 +11,7 @@
 
 int main() {
     char c;
-    Time tm = {};
+    Rtc_Ds1307::Time_rtc tm = {};
     
     while(1) {
         pc.printf("*************************************\n");
@@ -71,11 +72,11 @@
             pc.printf("Please specify the frequency : [0 = 1Hz, 1 = 4.096kHz, 2 = 8.192kHz, 3 = 32.768kHz] ");
             scanf("%d", &rs);
             pc.printf("Enabling the output with %d option\n", rs);
-            rtc.setSquareWaveOutput(true, (RateSelect_t)rs);
+            rtc.setSquareWaveOutput(true, (Rtc_Ds1307::SqwRateSelect_t)rs);
         }
         else if (strncmp(buffer, "dis", 3) == 0) {
             pc.printf("Disableing square wave output\n");
-            rtc.setSquareWaveOutput(false, RS_1Hz);
+            rtc.setSquareWaveOutput(false, Rtc_Ds1307::RS1Hz);
         }
         else {
             pc.printf("syntax error\n");