Test RTC

Dependencies:   DS1338 mbed

Files at this revision

API Documentation at this revision

Comitter:
gr66
Date:
Tue Dec 13 15:13:52 2016 +0000
Commit message:
Test RTC

Changed in this revision

DS1338.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/DS1338.lib	Tue Dec 13 15:13:52 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/IUT-DE-CACHAN-GE1/code/DS1338/#c62527bddf0f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 13 15:13:52 2016 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "ds1338.h"
+
+
+char date [50];
+int main()
+{
+    struct tm time; //creation d’une structure pour initialiser les paramétres de l’horloge
+    Serial pc(USBTX, USBRX); // initialisation de l’affichage (UART) sur un terminal
+    pc.baud(9600); // réglage de la vitesse de transmission
+    pc.printf("DS1338 Demo\r\n");
+    DS1338 ds1338(PB_7,PB_6); // l’initialisation des ports SDA et SCL
+//#ifdef INIT_TIME
+    time.tm_sec=0;
+    time.tm_min=46;
+    time.tm_hour=13;
+    time.tm_mday=12;
+    time.tm_mon=9;
+    time.tm_year=116;
+    time.tm_wday=3;
+    time.tm_yday=0;
+    time.tm_isdst=0;
+    
+    ds1338.writeTime(&time); // initialiser les paramétres de l’horloge
+//#endif
+    while (true) {
+        
+        
+        wait(0.5);
+        ds1338.readTime(&time); //lecture de l’horloge
+        pc.printf("time at %s\r\n",asctime(&time)); // affichage de l’heure sur terminal
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 13 15:13:52 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file