Mark Gottscho / HardwareTimersLib

Fork of HardwareTimersLib by Mark Gottscho

Files at this revision

API Documentation at this revision

Comitter:
mgottscho
Date:
Sun Mar 16 01:08:20 2014 +0000
Parent:
13:3564122e9c10
Commit message:
Bug fix.

Changed in this revision

HardwareTimer.cpp Show annotated file Show diff for this revision Revisions of this file
HardwareTimer.h Show annotated file Show diff for this revision Revisions of this file
--- a/HardwareTimer.cpp	Tue Mar 11 05:49:26 2014 +0000
+++ b/HardwareTimer.cpp	Sun Mar 16 01:08:20 2014 +0000
@@ -84,7 +84,12 @@
         
     if (__enabled)
         disable();
-    __user_fptr = new FunctionPointer(tptr, mptr);
+        
+    //set user function pointer
+    if (__user_fptr != NULL)
+        delete __user_fptr;
+    if (tptr != NULL && mptr != NULL)
+        __user_fptr = new FunctionPointer(tptr, mptr);
 
     __init_timer(); //Do hardware-specific initialization
     
--- a/HardwareTimer.h	Tue Mar 11 05:49:26 2014 +0000
+++ b/HardwareTimer.h	Sun Mar 16 01:08:20 2014 +0000
@@ -76,7 +76,7 @@
          * @param tptr the object 
          * @param mptr method to call on the object
          */
-        template <typename T> void enable(T *tptr, void (T::*mptr)(void));
+        template<typename T> void enable(T *tptr, void (T::*mptr)(void));
         
         /**
          * Stops and disables the timer. No user function callbacks will be made, and the tick value stops increasing.