Not work original Lib on F446RE & L432KC . Change usage prime() & setNext() for both TX and RX function due to unexpected behavior (maybe os TimerEvent function problem)

Dependents:   BufferedSoftSerial

Committer:
kenjiArai
Date:
Sun May 10 08:05:32 2020 +0000
Revision:
12:cd58d03b8559
Parent:
6:517082212c00
Child:
13:6399b30798a5
Change usage prime() & setNext() for both TX and RX function due to unexpected behavior (maybe os  TimerEvent function problem)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 12:cd58d03b8559 1 //A modified version of the regular ticker/timeout libraries
kenjiArai 12:cd58d03b8559 2 // to allow us to do timeout without losing accuracy
kenjiArai 12:cd58d03b8559 3
kenjiArai 12:cd58d03b8559 4 // Modified by K.Arai / JH1PJL May 9th, 2020
Sissors 6:517082212c00 5
Sissors 6:517082212c00 6 #ifndef FLEXTICKER_H
Sissors 6:517082212c00 7 #define FLEXTICKER_H
Sissors 6:517082212c00 8
Sissors 6:517082212c00 9 #include "mbed.h"
Sissors 6:517082212c00 10
kenjiArai 12:cd58d03b8559 11 class FlexTicker: public TimerEvent
kenjiArai 12:cd58d03b8559 12 {
kenjiArai 12:cd58d03b8559 13 public:
Sissors 6:517082212c00 14 template<typename T>
kenjiArai 12:cd58d03b8559 15 void attach(T* tptr, void (T::*mptr)(void))
kenjiArai 12:cd58d03b8559 16 {
kenjiArai 12:cd58d03b8559 17 //_function.attach(tptr, mptr);
kenjiArai 12:cd58d03b8559 18 _function = Callback<void()>(tptr, mptr);
Sissors 6:517082212c00 19 }
kenjiArai 12:cd58d03b8559 20
Sissors 6:517082212c00 21 /** Detach the function
Sissors 6:517082212c00 22 */
kenjiArai 12:cd58d03b8559 23 void detach()
kenjiArai 12:cd58d03b8559 24 {
Sissors 6:517082212c00 25 remove();
Sissors 6:517082212c00 26 }
kenjiArai 12:cd58d03b8559 27
kenjiArai 12:cd58d03b8559 28 void setNext(int delay)
kenjiArai 12:cd58d03b8559 29 {
Sissors 6:517082212c00 30 insert(event.timestamp + delay);
kenjiArai 12:cd58d03b8559 31 //insert_absolute(event.timestamp + delay);
Sissors 6:517082212c00 32 }
kenjiArai 12:cd58d03b8559 33
kenjiArai 12:cd58d03b8559 34 void prime(int adjust_time)
kenjiArai 12:cd58d03b8559 35 {
kenjiArai 12:cd58d03b8559 36 event.timestamp = us_ticker_read() - adjust_time;
Sissors 6:517082212c00 37 }
kenjiArai 12:cd58d03b8559 38
Sissors 6:517082212c00 39 protected:
kenjiArai 12:cd58d03b8559 40 virtual void handler()
kenjiArai 12:cd58d03b8559 41 {
Sissors 6:517082212c00 42 _function.call();
Sissors 6:517082212c00 43 }
kenjiArai 12:cd58d03b8559 44
Sissors 6:517082212c00 45 unsigned int _delay;
kenjiArai 12:cd58d03b8559 46 Callback<void()> _function;
Sissors 6:517082212c00 47 };
Sissors 6:517082212c00 48
Sissors 6:517082212c00 49 #endif