Timeout service for XMEGA.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | timeout_struct |
Timeout timekeeping data. More... | |
Functions | |
static void | tick_handler (uint32_t time) |
Callback function for RTC compare interrupt handler. More... | |
void | timeout_init (void) |
Initialize timeout. More... | |
void | timeout_start_offset (timeout_id_t id, uint16_t period, uint16_t 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... | |
Variables | |
static uint8_t | timeout_active |
Bitmask of active timeouts. More... | |
static struct timeout_struct | timeout_array [TIMEOUT_COUNT] |
Array of configurable timeout timekeeping data. More... | |
static uint8_t | timeout_expired |
Bitmask of expired timeouts. More... | |
|
static |
Callback function for RTC compare interrupt handler.
The function executes when the RTC compare interrupt occurs and loop through all timeout channels. The timeout_array[channel_index] which contains the remaining ticks before timeout is decremented and the timeout active/expired masks are updated.
References timeout_struct::count, timeout_struct::period, rtc_set_alarm(), rtc_set_time(), timeout_active, timeout_array, TIMEOUT_COMP, and timeout_expired.
Referenced by timeout_init().
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().
|
static |
Bitmask of active timeouts.
Referenced by tick_handler(), timeout_start_offset(), and timeout_stop().
|
static |
Array of configurable timeout timekeeping data.
Referenced by tick_handler(), and timeout_start_offset().
|
static |
Bitmask of expired timeouts.
Referenced by tick_handler(), timeout_start_offset(), and timeout_test_and_clear_expired().