mbed library sources
Dependents: Freedman_v2 Nucleo_i2c_OLED_BME280_copy
Fork of mbed-src by
Diff: api/Ticker.h
- Revision:
- 304:89b9c3a9a045
- Parent:
- 36:ab3ee77451e7
- Child:
- 525:c320967f86b9
diff -r 78e31413b129 -r 89b9c3a9a045 api/Ticker.h --- 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