Timeout service for XMEGA.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TIMEOUT_COMP TIMEOUT_CLOCK_SOURCE_HZ / TIMEOUT_TICK_HZ |
Typedefs | |
typedef uint8_t | timeout_id_t |
Timeout identifier. More... | |
Functions | |
void | timeout_init (void) |
Initialize timeout. More... | |
void | timeout_start_offset (timeout_id_t id, uint16_t period, uint16_t start_offset) |
Start periodic timeout with a specific start timeout. More... | |
void | timeout_start_periodic (timeout_id_t id, uint16_t period) |
Start periodic timeout. More... | |
void | timeout_start_singleshot (timeout_id_t id, uint16_t timeout) |
Start singleshot timeout. More... | |
void | timeout_stop (timeout_id_t id) |
Stop running timeout. More... | |
bool | timeout_test_and_clear_expired (timeout_id_t id) |
Test and clear expired flag for running timeout. More... | |
#define TIMEOUT_COMP TIMEOUT_CLOCK_SOURCE_HZ / TIMEOUT_TICK_HZ |
Referenced by tick_handler(), and timeout_init().
typedef uint8_t timeout_id_t |
Timeout identifier.
Index for timeout channel to use. Limited by max value configured with TIMEOUT_COUNT.
void timeout_init | ( | void | ) |
Initialize timeout.
Initializes timeout counter for desired tick rate and starts it. The device interrupt controller should be initialized prior to calling this function, and global interrupts must be enabled.
References rtc_init(), rtc_set_alarm(), rtc_set_callback(), rtc_set_time(), tick_handler(), and TIMEOUT_COMP.
Referenced by main().
void timeout_start_offset | ( | timeout_id_t | id, |
uint16_t | period, | ||
uint16_t | offset | ||
) |
Start periodic timeout with a specific start timeout.
id | timeout_id_t |
period | Time period in number of ticks |
offset | Time to first timeout in number of ticks |
References timeout_struct::count, cpu_irq_restore(), cpu_irq_save(), timeout_struct::period, timeout_active, timeout_array, and timeout_expired.
Referenced by timeout_start_periodic(), and timeout_start_singleshot().
void timeout_start_periodic | ( | timeout_id_t | id, |
uint16_t | period | ||
) |
Start periodic timeout.
id | timeout_id_t |
period | Time period in number of ticks |
References timeout_start_offset().
Referenced by main(), and test_periodic_timeout().
void timeout_start_singleshot | ( | timeout_id_t | id, |
uint16_t | timeout | ||
) |
Start singleshot timeout.
id | timeout_id_t |
timeout | Timeout in number of ticks |
References timeout_start_offset().
Referenced by main(), and test_singleshot_timeout().
void timeout_stop | ( | timeout_id_t | id | ) |
Stop running timeout.
id | timeout_id_t |
References cpu_irq_restore(), cpu_irq_save(), and timeout_active.
bool timeout_test_and_clear_expired | ( | timeout_id_t | id | ) |
Test and clear expired flag for running timeout.
id | timeout_id_t |
true | Timer have expired; clearing expired flag |
false | Timer still running |
References cpu_irq_restore(), cpu_irq_save(), and timeout_expired.
Referenced by main(), test_initialization(), test_periodic_timeout(), and test_singleshot_timeout().