Demo program for the RTC library.

Dependencies:   KL25Z_RTC mbed

Files at this revision

API Documentation at this revision

Comitter:
clemente
Date:
Sun Aug 25 22:14:04 2013 +0000
Commit message:
First release.

Changed in this revision

KL25Z_RTC.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
diff -r 000000000000 -r 92bedc4e1536 KL25Z_RTC.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KL25Z_RTC.lib	Sun Aug 25 22:14:04 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/clemente/code/KL25Z_RTC/#3bd0dc0c2b2e
diff -r 000000000000 -r 92bedc4e1536 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Aug 25 22:14:04 2013 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "KL25Z_RTC.h"
+
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+
+// Init the RTC module with an alarm value of 15 sec.
+KL25Z_RTC rtc( 15);
+
+// Callback user function
+void alm ( void);
+void sec ( void);
+
+// Function to put in sleep or deepsleep the ARM Core.
+#define SCB_SCR_SLEEPDEEP_MASK                   0x4u
+void sleep( void);
+void deepsleep (void);
+
+unsigned int count;
+
+int main() {
+    
+    pc.baud( 230400);
+    pc.printf("RTC Management.\r\n");
+
+    // rtc.RTC_Start( &sec, &alm);
+    rtc.RTC_Start( NULL, &alm);
+    pc.printf("Alarm configured [15sec], ");
+    
+    count=0;
+    while(1) 
+    {
+        //
+        pc.printf("enter sleep...\r\n");
+        deepsleep();
+        
+        pc.printf("exit sleep: %d\r\n", ++count);
+    }
+}
+
+void sec ( void)
+{
+    pc.printf("sec\r\n");
+}
+
+void alm ( void)
+{
+    pc.printf("alrm\r\n");
+}    
+
+void sleep( void)
+{
+    SCB->SCR &= ~SCB_SCR_SLEEPDEEP_MASK;
+    __wfi();
+}
+
+void deepsleep (void)
+{
+  /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
+  SCB->SCR |= SCB_SCR_SLEEPDEEP_MASK;
+
+  __wfi();
+}
\ No newline at end of file
diff -r 000000000000 -r 92bedc4e1536 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Aug 25 22:14:04 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file