Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Common SW Timer

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,
 
)    ((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 SUB_TIME (   a,
 
)    ((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

Timeout type.

typedef void(* timer_expiry_cb_t)(void *)
typedef struct timer_info_tag timer_info_t

Timeout type.

Enumerator
SW_TIMEOUT_RELATIVE 

The timeout is relative to the current time.

SW_TIMEOUT_ABSOLUTE 

The timeout is an absolute value.

status_code_t sw_timer_get_id ( uint8_t *  timer_id)

Returns a timer id to be used before starting a timer.

Parameters
timer_idValue 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)
uint32_t sw_timer_get_time ( void  )

Gets current time.

This function returns the current time.

Parameters
[out]current_timeReturns current system time

References gettime().

Referenced by pal_get_current_time(), and pal_trx_read_timestamp().

bool sw_timer_is_running ( uint8_t  timer_id)

Checks whether a given timer is running or not.

Parameters
[out]Trueif the timer is running else False

Referenced by pal_is_timer_running().

uint32_t sw_timer_next_timer_expiry_duration ( void  )
void sw_timer_service ( void  )
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.

Parameters
timer_idTimer identifier
timer_countTimeout in microseconds
timeout_typeTIMEOUT_RELATIVE or TIMEOUT_ABSOLUTE
timer_cbCallback handler invoked upon timer expiry
param_cbArgument 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 bc_data_cb(), bcn_payload_update_cb(), gts_data_cb(), indirect_data_cb(), pal_timer_start(), sw_timer_run_residual_time(), usr_mlme_comm_status_ind(), usr_mlme_gts_ind(), and usr_mlme_start_conf().

uint32_t timer_info_tag::abs_exp_timer
uint8_t timer_info_tag::next_timer_in_queue
void* timer_info_tag::param_cb