Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
TickerDataClock Class Reference

A partial implementation of a C++11 Clock representing a HAL ticker. More...

#include <TickerDataClock.h>

Public Member Functions

constexpr TickerDataClock (const ticker_data_t *ticker)
 Construct a TickerDataClock referring to a ticker_data_t. More...
void set_handler (ticker_event_handler handler)
 Initialize a ticker and set the event handler. More...
void remove_event (ticker_event_t *obj)
 Remove an event from the queue. More...
void insert_event (ticker_event_t *obj, time_point timestamp, uint32_t id)
 Insert an event to the queue. More...
time_point now () const
 Read the current (absolute) ticker's timestamp. More...
int get_next_timestamp (time_point *timestamp) const
 Read the next event's timestamp. More...
void suspend ()
 Suspend this ticker. More...
void resume ()
 Resume this ticker. More...

Detailed Description

A partial implementation of a C++11 Clock representing a HAL ticker.

This class allows us to create chrono time_points for objects like Timer, with the limitation that the tickers are not singletons. This means:

This "pseudo-Clock" approach has been endorsed by Howard Hinnant (designer of Chrono) here: https://stackoverflow.com/questions/56400313/why-does-the-c-standard-require-the-clocknow-function-to-be-static

TickerDataClock::time_point values should only be used with mbed APIs specifically taking them, not passed to generic templated chrono algorithms, and it is up to the user to use them in conjunction with the correct TickerDataClock.

operators for -> and conversion to ticker_data_t * are provided allowing TickerDataClock to be easily substituted in place of a ticker_data_t *.

Definition at line 52 of file TickerDataClock.h.

Constructor & Destructor Documentation

constexpr TickerDataClock ( const ticker_data_t ticker)

Construct a TickerDataClock referring to a ticker_data_t.

Definition at line 55 of file TickerDataClock.h.

Member Function Documentation

int get_next_timestamp ( time_point *  timestamp) const

Read the next event's timestamp.

timestampThe timestamp object.
1 if timestamp is pending event, 0 if there's no event pending

Definition at line 118 of file TickerDataClock.h.

void insert_event ( ticker_event_t obj,
time_point  timestamp,
uint32_t  id 

Insert an event to the queue.

The event will be executed in timestamp - ticker_read_us() us.

If an event is inserted with a timestamp less than the current timestamp then the event will be scheduled immediately resulting in an instant call to event handler.
objThe event object to be inserted to the queue
timestampThe event's timestamp
idThe event object

Definition at line 96 of file TickerDataClock.h.

time_point now ( ) const

Read the current (absolute) ticker's timestamp.

Return an absolute timestamp counting from the initialization of the ticker.
The current timestamp

Definition at line 108 of file TickerDataClock.h.

void remove_event ( ticker_event_t obj)

Remove an event from the queue.

objThe event object to be removed from the queue

Definition at line 79 of file TickerDataClock.h.

void resume ( )

Resume this ticker.

When resumed the ticker will ignore any time that has passed and continue counting up where it left off.

Definition at line 144 of file TickerDataClock.h.

void set_handler ( ticker_event_handler  handler)

Initialize a ticker and set the event handler.

handlerA handler to be set

Definition at line 70 of file TickerDataClock.h.

void suspend ( )

Suspend this ticker.

When suspended reads will always return the same time and no events will be dispatched. When suspended the common layer will only ever call the interface function clear_interrupt() and that is only if ticker_irq_handler is called.

Definition at line 134 of file TickerDataClock.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.