2013-02-18 15:32:11 +00:00
/* mbed Microcontroller Library
2019-07-11 15:23:39 +00:00
* Copyright ( c ) 2006 - 2019 ARM Limited
2018-11-09 11:22:52 +00:00
* SPDX - License - Identifier : Apache - 2.0
2013-02-18 15:32:11 +00:00
*
* Licensed under the Apache License , Version 2.0 ( the " License " ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an " AS IS " BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*/
# ifndef MBED_TIMEREVENT_H
# define MBED_TIMEREVENT_H
2016-10-01 07:11:36 +00:00
# include "hal/ticker_api.h"
2020-02-13 09:21:20 +00:00
# include "platform/mbed_toolchain.h"
drivers: Mark non identity types as non copyable with the NonCopyable traits.
Classes changed: CAN, Ethernet, FlashIAP, I2C, InterruptIn, LowPowerTicker, LowPowerTimeout, LowPowerTimer, RawSerial, Serial, SerialBase, SPI, SPISlave, Ticker, Timeout, Timer, TimerEvent and UARTSerial.
2017-06-20 13:26:29 +00:00
# include "platform/NonCopyable.h"
2020-02-13 09:21:20 +00:00
# include "drivers/TickerDataClock.h"
2013-02-18 15:32:11 +00:00
namespace mbed {
2020-02-13 09:21:20 +00:00
2019-07-11 15:23:39 +00:00
/**
2019-09-06 21:58:57 +00:00
* \ defgroup drivers_TimerEvent TimerEvent class
2019-07-24 15:59:40 +00:00
* \ ingroup drivers - public - api - ticker
2019-07-11 15:23:39 +00:00
* @ {
*/
2013-02-18 15:32:11 +00:00
/** Base abstraction for timer interrupts
2016-06-08 12:52:14 +00:00
*
2017-04-04 17:40:09 +00:00
* @ note Synchronization level : Interrupt safe
2016-06-08 12:52:14 +00:00
*/
drivers: Mark non identity types as non copyable with the NonCopyable traits.
Classes changed: CAN, Ethernet, FlashIAP, I2C, InterruptIn, LowPowerTicker, LowPowerTimeout, LowPowerTimer, RawSerial, Serial, SerialBase, SPI, SPISlave, Ticker, Timeout, Timer, TimerEvent and UARTSerial.
2017-06-20 13:26:29 +00:00
class TimerEvent : private NonCopyable < TimerEvent > {
2020-02-13 09:21:20 +00:00
# if !defined(DOXYGEN_ONLY)
protected :
2015-04-23 13:56:34 +00:00
TimerEvent ( const ticker_data_t * data ) ;
2013-02-18 15:32:11 +00:00
/** The handler registered with the underlying timer interrupt
2017-06-05 16:55:27 +00:00
*
* @ param id Timer Event ID
2013-02-18 15:32:11 +00:00
*/
static void irq ( uint32_t id ) ;
/** Destruction removes it...
*/
2020-02-13 09:21:20 +00:00
~ TimerEvent ( ) ;
2013-02-18 15:32:11 +00:00
// The handler called to service the timer event of the derived class
virtual void handler ( ) = 0 ;
2017-09-05 13:50:21 +00:00
/** Set relative timestamp of the internal event.
* @ param timestamp event ' s us timestamp
*
* @ warning
* Do not insert more than one timestamp .
* The same @ a event object is used for every @ a insert / insert_absolute call .
*
* @ warning
* Ticker ' s present timestamp is used for reference . For timestamps
* from the past the event is scheduled after ticker ' s overflow .
* For reference @ see convert_timestamp
2020-02-13 09:21:20 +00:00
*
* @ deprecated use ` insert ( std : : chrono : : microseconds timestamp ) `
2017-09-05 13:50:21 +00:00
*/
2020-02-13 09:21:20 +00:00
MBED_DEPRECATED_SINCE ( " mbed-os-6.0.0 " , " Pass a chrono duration, not an integer microsecond count. For example use `5ms` rather than `5000`. " )
2014-08-20 12:32:49 +00:00
void insert ( timestamp_t timestamp ) ;
2013-02-18 15:32:11 +00:00
2020-02-13 09:21:20 +00:00
/** Set relative timestamp of the internal event.
* @ param timestamp event ' s us timestamp
*
* @ warning
* Do not insert more than one timestamp .
* The same @ a event object is used for every @ a insert / insert_absolute call .
*
* @ warning
* Ticker ' s present timestamp is used for reference . For timestamps
* from the past the event is scheduled after ticker ' s overflow .
* For reference @ see convert_timestamp
*/
void insert ( std : : chrono : : microseconds timestamp ) ;
2017-09-05 13:50:21 +00:00
/** Set absolute timestamp of the internal event.
* @ param timestamp event ' s us timestamp
*
* @ warning
* Do not insert more than one timestamp .
* The same @ a event object is used for every @ a insert / insert_absolute call .
2020-02-13 09:21:20 +00:00
*
* @ deprecated use ` insert_absolute ( TickerDataClock : : time_point timestamp ) `
2017-09-05 13:50:21 +00:00
*/
2020-02-13 09:21:20 +00:00
MBED_DEPRECATED_SINCE ( " mbed-os-6.0.0 " , " Pass a chrono time_point, not an integer microsecond count. For example use `_ticker_data.now() + 5ms` rather than `ticker_read_us(_ticker_data) + 5000`. " )
2017-03-31 13:30:42 +00:00
void insert_absolute ( us_timestamp_t timestamp ) ;
2020-02-13 09:21:20 +00:00
/** Set absolute timestamp of the internal event.
* @ param timestamp event ' s us timestamp
*
* @ warning
* Do not insert more than one timestamp .
* The same @ a event object is used for every @ a insert / insert_absolute call .
*/
void insert_absolute ( TickerDataClock : : time_point timestamp ) ;
2017-09-05 13:50:21 +00:00
/** Remove timestamp.
*/
2013-02-18 15:32:11 +00:00
void remove ( ) ;
ticker_event_t event ;
2015-04-23 13:56:34 +00:00
2020-02-13 09:21:20 +00:00
TickerDataClock _ticker_data ;
2018-11-07 19:23:06 +00:00
# endif
2013-02-18 15:32:11 +00:00
} ;
2019-07-11 15:23:39 +00:00
/** @}*/
2013-02-18 15:32:11 +00:00
} // namespace mbed
# endif