Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: hal/ticker_api.h
- Revision:
- 180:96ed750bd169
- Parent:
- 176:447f873cad2f
- Child:
- 186:707f6e361f3e
--- a/hal/ticker_api.h Thu Dec 07 14:01:42 2017 +0000 +++ b/hal/ticker_api.h Wed Jan 17 15:23:54 2018 +0000 @@ -24,11 +24,6 @@ #include "device.h" /** - * Maximum delta (in us) between too interrupts. - */ -#define MBED_TICKER_INTERRUPT_TIMESTAMP_MAX_DELTA 0x70000000ULL - -/** * Legacy format representing a timestamp in us. * Given it is modeled as a 32 bit integer, this type can represent timestamp * up to 4294 seconds (71 minutes). @@ -52,6 +47,14 @@ typedef void (*ticker_event_handler)(uint32_t id); +/** Information about the ticker implementation + */ +typedef struct { + uint32_t frequency; /**< Frequency in Hz this ticker runs at */ + uint32_t bits; /**< Number of bits this ticker supports */ +} ticker_info_t; + + /** Ticker's interface structure - required API for a ticker */ typedef struct { @@ -61,6 +64,7 @@ void (*clear_interrupt)(void); /**< Clear interrupt function */ void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */ void (*fire_interrupt)(void); /**< Fire interrupt right-away */ + const ticker_info_t *(*get_info)(void); /**< Return info about this ticker's implementation */ } ticker_interface_t; /** Ticker's event queue structure @@ -68,6 +72,12 @@ typedef struct { ticker_event_handler event_handler; /**< Event handler */ ticker_event_t *head; /**< A pointer to head */ + uint32_t frequency; /**< Frequency of the timer in Hz */ + uint32_t bitmask; /**< Mask to be applied to time values read */ + uint32_t max_delta; /**< Largest delta in ticks that can be used when scheduling */ + uint64_t max_delta_us; /**< Largest delta in us that can be used when scheduling */ + uint32_t tick_last_read; /**< Last tick read */ + uint64_t tick_remainder; /**< Ticks that have not been added to base_time */ us_timestamp_t present_time; /**< Store the timestamp used for present time */ bool initialized; /**< Indicate if the instance is initialized */ } ticker_event_queue_t; @@ -171,6 +181,19 @@ */ int ticker_get_next_timestamp(const ticker_data_t *const ticker, timestamp_t *timestamp); +/* Private functions + * + * @cond PRIVATE + * + */ + +int _ticker_match_interval_passed(timestamp_t prev_tick, timestamp_t cur_tick, timestamp_t match_tick); + +/* + * @endcond PRIVATE + * + */ + /**@}*/ #ifdef __cplusplus