Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Ticker HAL functions

Ticker HAL functions
[Hal]

Functions

void ticker_set_handler (const ticker_data_t *const ticker, ticker_event_handler handler)
 Initialize a ticker and set the event handler.
void ticker_irq_handler (const ticker_data_t *const ticker)
 IRQ handler that goes through the events to trigger overdue events.
void ticker_remove_event (const ticker_data_t *const ticker, ticker_event_t *obj)
 Remove an event from the queue.
void ticker_insert_event (const ticker_data_t *const ticker, ticker_event_t *obj, timestamp_t timestamp, uint32_t id)
 Insert an event to the queue.
void ticker_insert_event_us (const ticker_data_t *const ticker, ticker_event_t *obj, us_timestamp_t timestamp, uint32_t id)
 Insert an event to the queue.
timestamp_t ticker_read (const ticker_data_t *const ticker)
 Read the current (relative) ticker's timestamp.
us_timestamp_t ticker_read_us (const ticker_data_t *const ticker)
 Read the current (absolute) ticker's timestamp.
int ticker_get_next_timestamp (const ticker_data_t *const ticker, timestamp_t *timestamp)
 Read the next event's timestamp.

Function Documentation

int ticker_get_next_timestamp ( const ticker_data_t *const   ticker,
timestamp_t timestamp 
)

Read the next event's timestamp.

Parameters:
tickerThe ticker object.
timestampThe timestamp object.
Returns:
1 if timestamp is pending event, 0 if there's no event pending

Definition at line 384 of file mbed_ticker_api.c.

void ticker_insert_event ( const ticker_data_t *const   ticker,
ticker_event_t obj,
timestamp_t  timestamp,
uint32_t  id 
)

Insert an event to the queue.

The event will be executed in timestamp - ticker_read().

Warning:
This function does not consider timestamp in the past. If an event is inserted with a timestamp less than the current timestamp then the event will be executed in timestamp - ticker_read() us. The internal counter wrap very quickly it is hard to decide weither an event is in the past or in 1 hour.
Note:
prefer the use of ticker_insert_event_us which allows registration of absolute timestamp.
Parameters:
tickerThe ticker object.
objThe event object to be inserted to the queue
timestampThe event's timestamp
idThe event object

Definition at line 289 of file mbed_ticker_api.c.

void ticker_insert_event_us ( const ticker_data_t *const   ticker,
ticker_event_t obj,
us_timestamp_t  timestamp,
uint32_t  id 
)

Insert an event to the queue.

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

Note:
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.
Parameters:
tickerThe ticker object.
objThe event object to be inserted to the queue
timestampThe event's timestamp
idThe event object

Definition at line 308 of file mbed_ticker_api.c.

void ticker_irq_handler ( const ticker_data_t *const   ticker )

IRQ handler that goes through the events to trigger overdue events.

Parameters:
tickerThe ticker object.

Definition at line 258 of file mbed_ticker_api.c.

timestamp_t ticker_read ( const ticker_data_t *const   ticker )

Read the current (relative) ticker's timestamp.

Warning:
Return a relative timestamp because the counter wrap every 4294 seconds.
Parameters:
tickerThe ticker object.
Returns:
The current timestamp

Definition at line 372 of file mbed_ticker_api.c.

us_timestamp_t ticker_read_us ( const ticker_data_t *const   ticker )

Read the current (absolute) ticker's timestamp.

Warning:
Return an absolute timestamp counting from the initialization of the ticker.
Parameters:
tickerThe ticker object.
Returns:
The current timestamp

Definition at line 377 of file mbed_ticker_api.c.

void ticker_remove_event ( const ticker_data_t *const   ticker,
ticker_event_t obj 
)

Remove an event from the queue.

Parameters:
tickerThe ticker object.
objThe event object to be removed from the queue

Definition at line 348 of file mbed_ticker_api.c.

void ticker_set_handler ( const ticker_data_t *const   ticker,
ticker_event_handler  handler 
)

Initialize a ticker and set the event handler.

Parameters:
tickerThe ticker object.
handlerA handler to be set

Definition at line 252 of file mbed_ticker_api.c.