Wake-up timer library to wake from deepsleep/power-down

Dependencies:   LPC1114_WakeInterruptIn

Fork of WakeUp by Erik -

Revision:
20:68f2ee917691
Parent:
17:49d9e3a3e904
--- a/Device/WakeUp_STM_RTC.cpp	Wed Jul 01 19:33:12 2015 +0000
+++ b/Device/WakeUp_STM_RTC.cpp	Fri Oct 30 21:29:40 2015 +0000
@@ -4,7 +4,6 @@
 #include "rtc_api.h"
 
 #define BYTE2BCD(byte)      ((byte % 10) | ((byte / 10) << 4))
-#define EXTI_RTC_LINE       (1 << 17)
 
 //Most things are pretty similar between the different STM targets.
 //Only the IRQ number the alarm is connected to differs. Any errors
@@ -15,6 +14,15 @@
 #define RTC_IRQ     RTC_IRQn
 #endif
 
+// Some things to handle Disco L476VG (and similar ones)
+#if defined(TARGET_STM32L4)
+#define IMR     IMR1
+#define EMR     EMR1
+#define RTSR    RTSR1
+#define FTSR    FTSR2
+#define PR      PR1
+#endif
+
 //Disabling the Backup Powerdomain does not seem to work nicely anymore if you want to use other RTC functions afterwards.
 //For now I have disabled it in code, if you find WakeUp increases your powerconsumption, try enabling it again (code is still there, just commented)
 
@@ -67,10 +75,10 @@
     struct tm *timeinfo = localtime(&secs);
     
     //Enable rising edge EXTI interrupt of the RTC
-    EXTI->IMR |= EXTI_RTC_LINE;
-    EXTI->EMR &= ~EXTI_RTC_LINE;
-    EXTI->RTSR |= EXTI_RTC_LINE;
-    EXTI->FTSR &= ~EXTI_RTC_LINE;
+    EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT;
+    EXTI->EMR &= ~RTC_EXTI_LINE_ALARM_EVENT;
+    EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT;
+    EXTI->FTSR &= ~RTC_EXTI_LINE_ALARM_EVENT;
     
     //Calculate alarm register values
     uint32_t alarmreg = 0;
@@ -104,7 +112,7 @@
     RTC->WPR = 0x53;
     RTC->CR &= ~RTC_CR_ALRAE;
     RTC->WPR = 0xFF;        //Enable RTC write protection
-    EXTI->PR = EXTI_RTC_LINE;
+    EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT;
     //PWR->CR &= ~PWR_CR_DBP;     //Disable power domain 
     callback.call();
 }