mbed library sources

Fork of mbed-src by mbed official

Revision:
304:89b9c3a9a045
Parent:
36:ab3ee77451e7
--- a/api/Ticker.h	Fri Aug 29 11:45:07 2014 +0100
+++ b/api/Ticker.h	Fri Aug 29 17:15:07 2014 +0100
@@ -83,7 +83,7 @@
      *  @param fptr pointer to the function to be called
      *  @param t the time between calls in micro-seconds
      */
-    void attach_us(void (*fptr)(void), unsigned int t) {
+    void attach_us(void (*fptr)(void), timestamp_t t) {
         _function.attach(fptr);
         setup(t);
     }
@@ -95,21 +95,26 @@
      *  @param t the time between calls in micro-seconds
      */
     template<typename T>
-    void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
+    void attach_us(T* tptr, void (T::*mptr)(void), timestamp_t t) {
         _function.attach(tptr, mptr);
         setup(t);
     }
 
+    virtual ~Ticker() {
+        detach();
+    }
+
     /** Detach the function
      */
     void detach();
 
 protected:
-    void setup(unsigned int t);
+    void setup(timestamp_t t);
     virtual void handler();
 
-    unsigned int _delay;
-    FunctionPointer _function;
+protected:
+    timestamp_t     _delay;     /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
+    FunctionPointer _function;  /**< Callback. */
 };
 
 } // namespace mbed