20#ifndef MBED_TICKER_API_H
21#define MBED_TICKER_API_H
49typedef void (*ticker_event_handler)(uint32_t
id);
63 uint32_t (*read)(void);
64 void (*disable_interrupt)(void);
65 void (*clear_interrupt)(void);
67 void (*fire_interrupt)(void);
77#define MBED_TICKER_JUST_US (!MBED_CONF_TARGET_CUSTOM_TICKERS && DEVICE_USTICKER && !DEVICE_LPTICKER)
78#define MBED_TICKER_JUST_LP (!MBED_CONF_TARGET_CUSTOM_TICKERS && DEVICE_LPTICKER && !DEVICE_USTICKER)
80#if (MBED_TICKER_JUST_US && defined US_TICKER_PERIOD_NUM) || \
81 (!MBED_CONF_TARGET_CUSTOM_TICKERS && defined US_TICKER_PERIOD_NUM && defined LP_TICKER_PERIOD_NUM && \
82 US_TICKER_PERIOD_NUM == LP_TICKER_PERIOD_NUM)
83#define MBED_TICKER_CONSTANT_PERIOD_NUM US_TICKER_PERIOD_NUM
84#elif MBED_TICKER_JUST_LP && defined LP_TICKER_PERIOD_NUM
85#define MBED_TICKER_CONSTANT_PERIOD_NUM LP_TICKER_PERIOD_NUM
88#if (MBED_TICKER_JUST_US && defined US_TICKER_PERIOD_DEN) || \
89 (!MBED_CONF_TARGET_CUSTOM_TICKERS && defined US_TICKER_PERIOD_DEN && defined LP_TICKER_PERIOD_DEN && \
90 US_TICKER_PERIOD_DEN == LP_TICKER_PERIOD_DEN)
91#define MBED_TICKER_CONSTANT_PERIOD_DEN US_TICKER_PERIOD_DEN
92#elif MBED_TICKER_JUST_LP && defined LP_TICKER_PERIOD_DEN
93#define MBED_TICKER_CONSTANT_PERIOD_DEN LP_TICKER_PERIOD_DEN
96#if defined MBED_TICKER_CONSTANT_PERIOD_NUM && defined MBED_TICKER_CONSTANT_PERIOD_DEN
97#define MBED_TICKER_CONSTANT_PERIOD
100#if (MBED_TICKER_JUST_US && defined US_TICKER_MASK) || \
101 (!MBED_CONF_TARGET_CUSTOM_TICKERS && defined US_TICKER_MASK && defined LP_TICKER_MASK && \
102 US_TICKER_MASK == LP_TICKER_MASK)
103#define MBED_TICKER_CONSTANT_MASK US_TICKER_MASK
104#elif MBED_TICKER_JUST_LP && defined LP_TICKER_MASK
105#define MBED_TICKER_CONSTANT_MASK LP_TICKER_MASK
113#ifndef MBED_TICKER_CONSTANT_PERIOD_NUM
116#ifndef MBED_TICKER_CONSTANT_PERIOD_DEN
119#ifndef MBED_TICKER_CONSTANT_MASK
123#if !(defined MBED_TICKER_CONSTANT_PERIOD && defined MBED_TICKER_CONSTANT_MASK)
127#if MBED_TICKER_CONSTANT_PERIOD_DEN != 1
134#ifndef MBED_TICKER_CONSTANT_PERIOD_NUM
137#ifndef MBED_TICKER_CONSTANT_PERIOD_DEN
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.
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.
void ticker_set_handler(const ticker_data_t *const ticker, ticker_event_handler handler)
Initialize a ticker and set the event handler.
timestamp_t ticker_read(const ticker_data_t *const ticker)
Read the current (relative) ticker's timestamp.
int ticker_get_next_timestamp_us(const ticker_data_t *const ticker, us_timestamp_t *timestamp)
Read the next event's timestamp.
void ticker_irq_handler(const ticker_data_t *const ticker)
IRQ handler that goes through the events to trigger overdue events.
void ticker_resume(const ticker_data_t *const ticker)
Resume this ticker.
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_remove_event(const ticker_data_t *const ticker, ticker_event_t *obj)
Remove an event from the queue.
void ticker_suspend(const ticker_data_t *const ticker)
Suspend this ticker.
struct ticker_event_s ticker_event_t
Ticker's event structure.
uint32_t timestamp_t
Legacy format representing a timestamp in us.
uint64_t us_timestamp_t
A us timestamp stored in a 64 bit integer.
ticker_event_queue_t * queue
Ticker's event queue.
const ticker_interface_t * interface
Ticker's interface.
Ticker's event queue structure.
int8_t period_den_shifts
If denominator is a value of 2^n, this is n, otherwise -1.
uint32_t period_num
Ratio of period to 1us, numerator.
ticker_event_t * head
A pointer to head.
uint32_t tick_remainder
Ticks that have not been added to base_time.
int8_t period_num_shifts
If numerator is a value of 2^n, this is n, otherwise -1.
uint32_t period_den
Ratio of period to 1us, denominator.
uint64_t max_delta_us
Largest delta in us that can be used when scheduling.
uint32_t bitmask
Mask to be applied to time values read.
bool dispatching
The function ticker_irq_handler is dispatching.
us_timestamp_t present_time
Store the timestamp used for present time.
uint32_t max_delta
Largest delta in ticks that can be used when scheduling.
ticker_event_handler event_handler
Event handler.
uint32_t tick_last_read
Last tick read.
bool suspended
Indicate if the instance is suspended.
bool initialized
Indicate if the instance is initialized.
Ticker's event structure.
struct ticker_event_s * next
Next event in the queue.
us_timestamp_t timestamp
Event's timestamp.
uint32_t id
TimerEvent object.
Information about the ticker implementation.
uint32_t frequency
Frequency in Hz this ticker runs at.
uint32_t bits
Number of bits this ticker supports.
Ticker's interface structure - required API for a ticker.
bool runs_in_deep_sleep
Whether ticker operates in deep sleep.