forked SoftSerial
Fork of SoftSerial by
SoftSerial_Ticker.h@6:517082212c00, 2014-04-27 (annotated)
- Committer:
- Sissors
- Date:
- Sun Apr 27 08:33:17 2014 +0000
- Revision:
- 6:517082212c00
Added custom ticker lib to allow for baudrate up to 57600
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" |
| Sissors | 6:517082212c00 | 7 | |
| Sissors | 6:517082212c00 | 8 | class FlexTicker: public TimerEvent { |
| Sissors | 6:517082212c00 | 9 | public: |
| Sissors | 6:517082212c00 | 10 | template<typename T> |
| Sissors | 6:517082212c00 | 11 | void attach(T* tptr, void (T::*mptr)(void)) { |
| Sissors | 6:517082212c00 | 12 | _function.attach(tptr, mptr); |
| Sissors | 6:517082212c00 | 13 | } |
| Sissors | 6:517082212c00 | 14 | |
| Sissors | 6:517082212c00 | 15 | /** Detach the function |
| Sissors | 6:517082212c00 | 16 | */ |
| Sissors | 6:517082212c00 | 17 | void detach() { |
| Sissors | 6:517082212c00 | 18 | remove(); |
| Sissors | 6:517082212c00 | 19 | } |
| Sissors | 6:517082212c00 | 20 | |
| Sissors | 6:517082212c00 | 21 | void setNext(int delay) { |
| Sissors | 6:517082212c00 | 22 | insert(event.timestamp + delay); |
| Sissors | 6:517082212c00 | 23 | } |
| Sissors | 6:517082212c00 | 24 | |
| Sissors | 6:517082212c00 | 25 | void prime(void) { |
| Sissors | 6:517082212c00 | 26 | event.timestamp = us_ticker_read(); |
| Sissors | 6:517082212c00 | 27 | } |
| Sissors | 6:517082212c00 | 28 | |
| Sissors | 6:517082212c00 | 29 | protected: |
| Sissors | 6:517082212c00 | 30 | virtual void handler() { |
| Sissors | 6:517082212c00 | 31 | _function.call(); |
| Sissors | 6:517082212c00 | 32 | } |
| Sissors | 6:517082212c00 | 33 | |
| Sissors | 6:517082212c00 | 34 | unsigned int _delay; |
| Sissors | 6:517082212c00 | 35 | FunctionPointer _function; |
| Sissors | 6:517082212c00 | 36 | }; |
| Sissors | 6:517082212c00 | 37 | |
| Sissors | 6:517082212c00 | 38 | #endif |
