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:
Sun Jun 02 18:57:52 2013 +0000
Child:
1:6dbe51fe0737
Commit message:
First complete Version. Untested.

Changed in this revision

RTC-DS1307.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC-DS1307.lib	Sun Jun 02 18:57:52 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/leihen/code/RTC-DS1307/#64274190e842
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 02 18:57:52 2013 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "Rtc_Ds1307.h"
+
+DigitalOut myled(LED1);
+
+Rtc_Ds1307 rtc(p28, p27);
+
+Serial pc(USBTX, USBRX, "pc");
+
+char buffer[128];
+int readptr = 0;
+int main() {
+    char c;
+    pc.printf("Good morning Henry\n");
+    Time tm = {};
+    
+    while(1) {
+        pc.printf("*************************************\n");
+        pc.printf("* Menu for RTC Test :               *\n");
+        pc.printf("* read  - reads the clock           *\n");
+        pc.printf("* start - start the clock           *\n");
+        pc.printf("* stop  - stop the clock            *\n");
+        pc.printf("  write - write the clock           *\n");
+        pc.printf("*************************************\n");
+        
+        while( (c = pc.getc()) != '\n') {
+            buffer[readptr++] = c;
+        }
+        buffer[readptr++] = 0;
+        if (strncmp(buffer, "read", 4) == 0) {
+            //  perform read
+            pc.printf("Performing read operation\n");
+            if (rtc.getTime(tm) ) {
+                pc.printf("The current time is : %02d:%02d:%02d\n", tm.hour, tm.min, tm.sec);
+            }
+            
+        }
+        else if (strncmp(buffer, "write", 5) == 0) {
+            //  perform write
+            pc.printf("Performing write operation\n");
+        }
+        else if (strncmp(buffer, "start", 5) == 0) {
+            //  start
+            pc.printf("Performing start operation\n");
+        }
+        else if (strncmp(buffer, "stop", 4) == 0) {
+            //  stop
+            pc.printf("Performing stop operation\n");
+        }
+        else {
+            pc.printf("syntax error\n");
+        }
+        readptr = 0;
+        pc.printf("\n\n\n");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jun 02 18:57:52 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file