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
SoftSerial_Ticker.h@11:7fdc1c46de79, 2015-06-27 (annotated)
- Committer:
- marcpl
- Date:
- Sat Jun 27 09:25:12 2015 +0000
- Revision:
- 11:7fdc1c46de79
- Parent:
- 6:517082212c00
Add an #include in order to make SoftSerial to compile with the current mbed version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 6:517082212c00 | 1 | //A modified version of the regular ticker/timeout libraries to allow us to do timeout without losing accuracy |
Sissors | 6:517082212c00 | 2 | |
Sissors | 6:517082212c00 | 3 | #ifndef FLEXTICKER_H |
Sissors | 6:517082212c00 | 4 | #define FLEXTICKER_H |
Sissors | 6:517082212c00 | 5 | |
Sissors | 6:517082212c00 | 6 | #include "mbed.h" |
marcpl | 11:7fdc1c46de79 | 7 | #include "us_ticker_api.h" |
Sissors | 6:517082212c00 | 8 | |
Sissors | 6:517082212c00 | 9 | class FlexTicker: public TimerEvent { |
Sissors | 6:517082212c00 | 10 | public: |
Sissors | 6:517082212c00 | 11 | template<typename T> |
Sissors | 6:517082212c00 | 12 | void attach(T* tptr, void (T::*mptr)(void)) { |
Sissors | 6:517082212c00 | 13 | _function.attach(tptr, mptr); |
Sissors | 6:517082212c00 | 14 | } |
Sissors | 6:517082212c00 | 15 | |
Sissors | 6:517082212c00 | 16 | /** Detach the function |
Sissors | 6:517082212c00 | 17 | */ |
Sissors | 6:517082212c00 | 18 | void detach() { |
Sissors | 6:517082212c00 | 19 | remove(); |
Sissors | 6:517082212c00 | 20 | } |
Sissors | 6:517082212c00 | 21 | |
Sissors | 6:517082212c00 | 22 | void setNext(int delay) { |
Sissors | 6:517082212c00 | 23 | insert(event.timestamp + delay); |
Sissors | 6:517082212c00 | 24 | } |
Sissors | 6:517082212c00 | 25 | |
Sissors | 6:517082212c00 | 26 | void prime(void) { |
Sissors | 6:517082212c00 | 27 | event.timestamp = us_ticker_read(); |
Sissors | 6:517082212c00 | 28 | } |
Sissors | 6:517082212c00 | 29 | |
Sissors | 6:517082212c00 | 30 | protected: |
Sissors | 6:517082212c00 | 31 | virtual void handler() { |
Sissors | 6:517082212c00 | 32 | _function.call(); |
Sissors | 6:517082212c00 | 33 | } |
Sissors | 6:517082212c00 | 34 | |
Sissors | 6:517082212c00 | 35 | unsigned int _delay; |
Sissors | 6:517082212c00 | 36 | FunctionPointer _function; |
Sissors | 6:517082212c00 | 37 | }; |
Sissors | 6:517082212c00 | 38 | |
Sissors | 6:517082212c00 | 39 | #endif |