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

SoftSerial_Ticker.h

Committer:
kenjiArai
Date:
2020-05-12
Revision:
13:6399b30798a5
Parent:
12:cd58d03b8559

File content as of revision 13:6399b30798a5:

//A modified version of the regular ticker/timeout libraries
//      to allow us to do timeout without losing accuracy

// Modified by K.Arai / JH1PJL     May 12th, 2020

#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 = Callback<void()>(tptr, mptr);
    }

    /** Detach the function
     */
    void detach()
    {
        remove();
    }

    void setNext(int delay)
    {
        insert(event.timestamp + delay);
    }

    void prime(int comp_time = 0)
    {
        event.timestamp = us_ticker_read() + comp_time;
    }

protected:
    virtual void handler()
    {
        _function.call();
    }

    unsigned int _delay;
    Callback<void()> _function;
};

#endif