Fork of the original SoftSerial library with just a little modification in order to compile it with the current mbed version.
Dependents: Adafruit_FONA_Library_FONAtest
Fork of SoftSerial by
Diff: SoftSerial_Ticker.h
- Revision:
- 6:517082212c00
- Child:
- 11:7fdc1c46de79
diff -r acfd0329f648 -r 517082212c00 SoftSerial_Ticker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SoftSerial_Ticker.h Sun Apr 27 08:33:17 2014 +0000 @@ -0,0 +1,38 @@ +//A modified version of the regular ticker/timeout libraries to allow us to do timeout without losing accuracy + +#ifndef FLEXTICKER_H +#define FLEXTICKER_H + +#include "mbed.h" + +class FlexTicker: public TimerEvent { + public: + template<typename T> + void attach(T* tptr, void (T::*mptr)(void)) { + _function.attach(tptr, mptr); + } + + /** Detach the function + */ + void detach() { + remove(); + } + + void setNext(int delay) { + insert(event.timestamp + delay); + } + + void prime(void) { + event.timestamp = us_ticker_read(); + } + +protected: + virtual void handler() { + _function.call(); + } + + unsigned int _delay; + FunctionPointer _function; +}; + +#endif \ No newline at end of file