Fork of original library to fix mbed 5 deprecation warnings

Dependencies:   LPC1114_WakeInterruptIn

Dependents:   low-power-sleep

Fork of WakeUp by Erik -

Files at this revision

API Documentation at this revision

Comitter:
RobMeades
Date:
Mon Apr 10 13:05:23 2017 +0000
Parent:
22:49ca85e8822f
Commit message:
Fix deprecation warnings.

Changed in this revision

Device/WakeUp_Freescale.cpp Show annotated file Show diff for this revision Revisions of this file
Device/WakeUp_LPC11XX.cpp Show annotated file Show diff for this revision Revisions of this file
Device/WakeUp_LPC11u24.cpp Show annotated file Show diff for this revision Revisions of this file
Device/WakeUp_LPC812.cpp Show annotated file Show diff for this revision Revisions of this file
Device/WakeUp_STM_RTC.cpp Show annotated file Show diff for this revision Revisions of this file
WakeUp.h Show annotated file Show diff for this revision Revisions of this file
--- a/Device/WakeUp_Freescale.cpp	Wed Nov 11 20:20:27 2015 +0000
+++ b/Device/WakeUp_Freescale.cpp	Mon Apr 10 13:05:23 2017 +0000
@@ -3,7 +3,7 @@
 #include "WakeUp.h"
 #include "us_ticker_api.h"
 
-FunctionPointer WakeUp::callback;
+Callback<void()> WakeUp::cbk;
 float WakeUp::cycles_per_ms = 1.0;
 
 static uint16_t remainder_count;
@@ -90,7 +90,9 @@
     // write 1 to TCF to clear the LPT timer compare flag
     LPTMR0->CSR |= LPTMR_CSR_TCF_MASK;
     restore();
-    callback.call();
+    if (cbk) {
+        cbk.call();
+    }
 }
 
 void WakeUp::calibrate(void)
--- a/Device/WakeUp_LPC11XX.cpp	Wed Nov 11 20:20:27 2015 +0000
+++ b/Device/WakeUp_LPC11XX.cpp	Mon Apr 10 13:05:23 2017 +0000
@@ -17,7 +17,7 @@
 WakeInterruptIn IRQ_in(WakeUpPin);
 PwmOut pulse_out(WakeUpPin);
 
-FunctionPointer WakeUp::callback;
+Callback<void()> WakeUp::cbk;
 float WakeUp::cycles_per_ms = 20.0;
 
 static uint32_t old_clk_sel = ~0;
@@ -103,7 +103,9 @@
 void WakeUp::irq_handler(void)
 {    
     restore();    
-    callback.call();
+    if (cbk) {
+        cbk.call();
+    }
 }
 
 void WakeUp::calibrate(void)
--- a/Device/WakeUp_LPC11u24.cpp	Wed Nov 11 20:20:27 2015 +0000
+++ b/Device/WakeUp_LPC11u24.cpp	Mon Apr 10 13:05:23 2017 +0000
@@ -9,7 +9,7 @@
 
 #include "WakeUp.h"
 
-FunctionPointer WakeUp::callback;
+Callback<void()> WakeUp::cbk;
 float WakeUp::cycles_per_ms = 5.0;
 
 void WakeUp::set_ms(uint32_t ms)
@@ -43,7 +43,9 @@
 void WakeUp::irq_handler(void)
 {
     LPC_WWDT->MOD = 1<<3;
-    callback.call();
+    if (cbk) {
+        cbk.call();
+    }
 }
 
 void WakeUp::calibrate(void)
--- a/Device/WakeUp_LPC812.cpp	Wed Nov 11 20:20:27 2015 +0000
+++ b/Device/WakeUp_LPC812.cpp	Mon Apr 10 13:05:23 2017 +0000
@@ -2,7 +2,7 @@
 
 #include "WakeUp.h"
 
-FunctionPointer WakeUp::callback;
+Callback<void()> WakeUp::cbk;
 float WakeUp::cycles_per_ms = 10.0;
 
 void WakeUp::set_ms(uint32_t ms)
@@ -49,7 +49,9 @@
     //Disable the 10kHz timer
     LPC_PMU->DPDCTRL &= ~((1<<2) | (1<<3));
 
-    callback.call();
+    if (cbk) {
+        cbk.call();
+    }
 }
 
 void WakeUp::calibrate(void)
--- a/Device/WakeUp_STM_RTC.cpp	Wed Nov 11 20:20:27 2015 +0000
+++ b/Device/WakeUp_STM_RTC.cpp	Mon Apr 10 13:05:23 2017 +0000
@@ -26,7 +26,7 @@
 //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)
 
-FunctionPointer WakeUp::callback;
+Callback<void()> WakeUp::cbk;
 
 void WakeUp::set_ms(uint32_t ms)
 {        
@@ -114,7 +114,9 @@
     RTC->WPR = 0xFF;        //Enable RTC write protection
     EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT;
     //PWR->CR &= ~PWR_CR_DBP;     //Disable power domain 
-    callback.call();
+    if (cbk) {
+        cbk.call();
+    }
 }
 
 void WakeUp::calibrate(void)
--- a/WakeUp.h	Wed Nov 11 20:20:27 2015 +0000
+++ b/WakeUp.h	Mon Apr 10 13:05:23 2017 +0000
@@ -72,12 +72,12 @@
     * @param *function function to call
     */
     static void attach(void (*function)(void)) {
-        callback.attach(function);
+        cbk = function;
     }
 
     template<typename T>
     static void attach(T *object, void (T::*member)(void)) {
-        callback.attach(object, member);
+        cbk.attach(object, member);
     }
     
     /**
@@ -92,7 +92,7 @@
 
 
 private:
-    static FunctionPointer callback;
+    static Callback<void()> cbk;
     static void irq_handler(void);
     static float cycles_per_ms;
 };
\ No newline at end of file