use timestamp_t for Ticker::_delay

pull/467/merge
Rohit Grover 2014-08-27 09:25:24 +01:00
parent ab17cc71dc
commit fedb7f02c0
2 changed files with 8 additions and 6 deletions

View File

@ -83,7 +83,7 @@ public:
* @param fptr pointer to the function to be called * @param fptr pointer to the function to be called
* @param t the time between calls in micro-seconds * @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); _function.attach(fptr);
setup(t); setup(t);
} }
@ -95,7 +95,7 @@ public:
* @param t the time between calls in micro-seconds * @param t the time between calls in micro-seconds
*/ */
template<typename T> 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); _function.attach(tptr, mptr);
setup(t); setup(t);
} }
@ -105,11 +105,13 @@ public:
void detach(); void detach();
protected: protected:
void setup(unsigned int t); void setup(timestamp_t t);
virtual void handler(); virtual void handler();
unsigned int _delay; protected:
FunctionPointer _function; timestamp_t _delay; /* Time delay (in microseconds) for re-setting the multi-shot callback.
* Initialized at the point where callback is attached. */
FunctionPointer _function; /* Callback. */
}; };
} // namespace mbed } // namespace mbed

View File

@ -25,7 +25,7 @@ void Ticker::detach() {
_function.attach(0); _function.attach(0);
} }
void Ticker::setup(unsigned int t) { void Ticker::setup(timestamp_t t) {
remove(); remove();
_delay = t; _delay = t;
insert(_delay + us_ticker_read()); insert(_delay + us_ticker_read());