Implements the software Algorithm for Timer Handling in the Stack.
Modules | |
Group_pal_common_hw_timer | |
Implements a common api interface for accessing timer drivers of all architectures. | |
Data Structures | |
struct | timer_info_tag |
Macros | |
#define | ADD_TIME(a, b) ((a) + (b)) |
Adds two time values. More... | |
#define | HW_TIME_MASK (0xFFFF) |
#define | MAX_NO_OF_TIMERS (25) |
#define | MAX_TIMEOUT (0x7FFFFFFF) |
#define | MIN_TIMEOUT (0x80) |
#define | NO_TIMER (0xFF) |
#define | SUB_TIME(a, b) ((a) - (b)) |
Subtracts two time values. More... | |
#define | SYS_TIME_SHIFT_MASK (16) |
#define | TOTAL_TIMERS TOTAL_NUMBER_OF_TIMERS |
Typedefs | |
typedef enum sw_timeout_type_tag | sw_timeout_type_t |
Timeout type. More... | |
typedef void(* | timer_expiry_cb_t )(void *) |
typedef struct timer_info_tag | timer_info_t |
Enumerations | |
enum | sw_timeout_type_tag { SW_TIMEOUT_RELATIVE, SW_TIMEOUT_ABSOLUTE } |
Timeout type. More... | |
Functions | |
status_code_t | sw_timer_get_id (uint8_t *timer_id) |
Returns a timer id to be used before starting a timer. More... | |
uint32_t | sw_timer_get_residual_time (uint8_t timer_id) |
uint32_t | sw_timer_get_time (void) |
Gets current time. More... | |
void | sw_timer_init (void) |
Initializes the Software Timer module. More... | |
bool | sw_timer_is_running (uint8_t timer_id) |
Checks whether a given timer is running or not. More... | |
uint32_t | sw_timer_next_timer_expiry_duration (void) |
void | sw_timer_run_residual_time (uint32_t offset) |
void | sw_timer_service (void) |
Handles Queues and Callbacks for Expired Timers. More... | |
status_code_t | sw_timer_start (uint8_t timer_id, uint32_t timer_count, sw_timeout_type_t timeout_type, FUNC_PTR timer_cb, void *param_cb) |
Starts a timer. More... | |
status_code_t | sw_timer_stop (uint8_t timer_id) |
Stops a running timer. More... | |
Variables | |
uint32_t | timer_info_tag::abs_exp_timer |
bool | timer_info_tag::loaded |
uint8_t | timer_info_tag::next_timer_in_queue |
void * | timer_info_tag::param_cb |
FUNC_PTR | timer_info_tag::timer_cb |
#define ADD_TIME | ( | a, | |
b | |||
) | ((a) + (b)) |
Adds two time values.
Referenced by pal_add_time_us(), and sw_timer_start().
#define HW_TIME_MASK (0xFFFF) |
Referenced by prog_ocr().
#define MAX_NO_OF_TIMERS (25) |
#define MAX_TIMEOUT (0x7FFFFFFF) |
Referenced by sw_timer_start().
#define MIN_TIMEOUT (0x80) |
#define NO_TIMER (0xFF) |
#define SUB_TIME | ( | a, | |
b | |||
) | ((a) - (b)) |
Subtracts two time values.
Referenced by pal_sub_time_us(), and sw_timer_start().
#define SYS_TIME_SHIFT_MASK (16) |
Referenced by prog_ocr().
#define TOTAL_TIMERS TOTAL_NUMBER_OF_TIMERS |
typedef enum sw_timeout_type_tag sw_timeout_type_t |
Timeout type.
typedef void(* timer_expiry_cb_t)(void *) |
typedef struct timer_info_tag timer_info_t |
enum sw_timeout_type_tag |
status_code_t sw_timer_get_id | ( | uint8_t * | timer_id | ) |
Returns a timer id to be used before starting a timer.
timer_id | Value of the id returned by the function |
References alloc_timer_id, ERR_NO_TIMER, STATUS_OK, and TOTAL_NUMBER_OF_SW_TIMERS.
Referenced by main(), and pal_timer_get_id().
uint32_t sw_timer_get_residual_time | ( | uint8_t | timer_id | ) |
References timer_info_tag::abs_exp_timer, and gettime().
Referenced by handle_gts_data_req(), mac_ready_to_sleep(), and sw_timer_next_timer_expiry_duration().
uint32_t sw_timer_get_time | ( | void | ) |
Gets current time.
This function returns the current time.
[out] | current_time | Returns current system time |
References gettime().
Referenced by pal_get_current_time(), and pal_trx_read_timestamp().
void sw_timer_init | ( | void | ) |
Initializes the Software Timer module.
References alloc_timer_id, common_tc_init(), expired_timer_queue_head, expired_timer_queue_tail, hw_expiry_cb(), hw_overflow_cb(), timer_info_tag::next_timer_in_queue, NO_TIMER, running_timer_queue_head, running_timers, set_common_tc_expiry_callback(), set_common_tc_overflow_callback(), sys_time, timer_info_tag::timer_cb, timer_trigger, and TOTAL_NUMBER_OF_SW_TIMERS.
Referenced by main().
bool sw_timer_is_running | ( | uint8_t | timer_id | ) |
Checks whether a given timer is running or not.
[out] | True | if the timer is running else False |
Referenced by pal_is_timer_running().
uint32_t sw_timer_next_timer_expiry_duration | ( | void | ) |
References NO_TIMER, running_timer_queue_head, and sw_timer_get_residual_time().
void sw_timer_run_residual_time | ( | uint32_t | offset | ) |
void sw_timer_service | ( | void | ) |
Handles Queues and Callbacks for Expired Timers.
References cpu_irq_restore(), cpu_irq_save(), expired_timer_queue_head, expired_timer_queue_tail, internal_timer_handler(), timer_info_tag::loaded, NO_TIMER, timer_info_tag::param_cb, and timer_info_tag::timer_cb.
Referenced by hw_expiry_cb(), and pal_task().
status_code_t sw_timer_start | ( | uint8_t | timer_id, |
uint32_t | timer_count, | ||
sw_timeout_type_t | timeout_type, | ||
FUNC_PTR | timer_cb, | ||
void * | param_cb | ||
) |
Starts a timer.
This function starts a regular timer and installs the corresponding callback function handle the timeout event.
timer_id | Timer identifier |
timer_count | Timeout in microseconds |
timeout_type | TIMEOUT_RELATIVE or TIMEOUT_ABSOLUTE |
timer_cb | Callback handler invoked upon timer expiry |
param_cb | Argument for the callback handler |
References ADD_TIME, ERR_INVALID_ARG, ERR_TIMER_ALREADY_RUNNING, gettime(), MAX_TIMEOUT, MIN_TIMEOUT, start_absolute_timer(), STATUS_OK, SUB_TIME, SW_TIMEOUT_ABSOLUTE, SW_TIMEOUT_RELATIVE, and TOTAL_NUMBER_OF_SW_TIMERS.
Referenced by pal_timer_start(), sw_timer_run_residual_time(), usr_mcps_data_ind(), and usr_mlme_get_conf().
status_code_t sw_timer_stop | ( | uint8_t | timer_id | ) |
Stops a running timer.
This function stops a running timer with specified timer_id
timer_id | Timer identifier |
References common_tc_compare_stop(), cpu_irq_restore(), cpu_irq_save(), ERR_INVALID_ARG, ERR_TIMER_NOT_RUNNING, expired_timer_queue_head, expired_timer_queue_tail, internal_timer_handler(), load_hw_timer(), timer_info_tag::loaded, timer_info_tag::next_timer_in_queue, NO_TIMER, timer_info_tag::param_cb, running_timer_queue_head, running_timers, STATUS_OK, timer_info_tag::timer_cb, and TOTAL_NUMBER_OF_SW_TIMERS.
Referenced by pal_timer_stop(), sw_timer_run_residual_time(), and usr_mlme_associate_conf().
uint32_t timer_info_tag::abs_exp_timer |
Referenced by load_hw_timer(), prog_ocr(), start_absolute_timer(), and sw_timer_get_residual_time().
bool timer_info_tag::loaded |
Referenced by load_hw_timer(), prog_ocr(), start_absolute_timer(), sw_timer_service(), and sw_timer_stop().
uint8_t timer_info_tag::next_timer_in_queue |
Referenced by start_absolute_timer(), sw_timer_init(), and sw_timer_stop().
void* timer_info_tag::param_cb |
Referenced by start_absolute_timer(), sw_timer_run_residual_time(), sw_timer_service(), and sw_timer_stop().
FUNC_PTR timer_info_tag::timer_cb |
Referenced by start_absolute_timer(), sw_timer_init(), sw_timer_run_residual_time(), sw_timer_service(), and sw_timer_stop().