Low level interface to the ticker of a target.
Low level interface to the ticker of a target.
Defined behavior
- The function ticker_init is safe to call repeatedly - Verified by test ticker_init_test
- The function ticker_init allows the ticker to keep counting and disables the ticker interrupt - Verified by test ticker_init_test
- Ticker frequency is non-zero and counter is at least 8 bits - Verified by ticker_info_test
- The ticker rolls over at (1 << bits) and continues counting starting from 0 - Verified by ticker_overflow_test
- The ticker counts at the specified frequency +- 10% - Verified by ticker_frequency_test
- The ticker increments by 1 each tick - Verified by ticker_increment_test
- The ticker interrupt fires only when the ticker times increments to or past the value set by ticker_set_interrupt. Verified by ticker_interrupt_test and ticker_past_test
- It is safe to call ticker_set_interrupt repeatedly before the handler is called - Verified by ticker_repeat_reschedule_test
- The function ticker_fire_interrupt causes ticker_irq_handler to be called immediately from interrupt context - Verified by ticker_fire_now_test
- The ticker operations ticker_read, ticker_clear_interrupt, ticker_set_interrupt and ticker_fire_interrupt take less than 20us to complete - Verified by ticker_speed_test
- The ticker operations ticker_init and ticker_read are atomic.
Undefined behavior
- Calling any function other than ticker_init before the initialization of the ticker
- Whether ticker_irq_handler is called a second time if the time wraps and matches the value set by ticker_set_interrupt again
- Calling ticker_set_interrupt with a value that has more than the supported number of bits
- Calling any function other than us_ticker_init after calling us_ticker_free
Potential bugs
- Drift due to reschedule - Verified by ticker_repeat_reschedule_test
- Incorrect overflow handling of timers - Verified by ticker_overflow_test
- Interrupting at a time of 0 - Verified by ticker_overflow_test
- Interrupt triggered more than once - Verified by ticker_interrupt_test