first pass at demo rtc code for the kl25z

Dependencies:   KL25Z_RTC mbed

Fork of FRDM_RTC by clemente di caprio

Revision:
0:92bedc4e1536
Child:
1:48b423c65bcb
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