Mark Gottscho / HardwareTimersLib

Fork of HardwareTimersLib by Mark Gottscho

Revision:
12:cb395e4be69e
Parent:
7:78f6ee57d324
Child:
14:960fbd85909f
--- a/HardwareTimer.h	Tue Mar 11 04:54:13 2014 +0000
+++ b/HardwareTimer.h	Tue Mar 11 05:38:56 2014 +0000
@@ -90,9 +90,10 @@
          * Note that the timer counts up. Note that some timers may not support the full 32-bit range. Use getMaxCallbackTickCount()
          * To check the maximum allowed value. If callback_tick_count is greater than that value, this method will have no effect.
          * @param periodic if true, the timer will call the user function every time the internal tick modulo callback_tick_count is reached.
-         * If false, the user callback function is only called the first time.
+         * If false, the user callback function is only called the first num_callbacks times.
+         * @param num_callbacks if periodic is set to false, this many callbacks will be made. Before the timer stops.
          */
-        void start(uint32_t callback_tick_count, bool periodic);
+        void start(uint32_t callback_tick_count, bool periodic, uint32_t num_callbacks);
         
         /**
          * @returns the maximum value of the user-settable callback tick count (via startTimer()).
@@ -139,10 +140,10 @@
         virtual void __stop_timer() = 0;
         
         bool __valid; //timer can be used
-        uint32_t __count; //number of rollovers
+        volatile uint32_t __count; //number of rollovers
         uint32_t __rolloverValue; //ticks per rollover
         bool __periodic; //periodic callbacks
-        bool __call_user_function; //flag
+        volatile uint32_t __num_callbacks;
         
         FunctionPointer *__user_fptr; //User callback function