Microchip® Advanced Software Framework

common_sw_timer.c File Reference

Copyright (c) 2013-2018 Microchip Technology Inc.

and its subsidiaries.

#include "compiler.h"
#include "conf_common_sw_timer.h"
#include "common_hw_timer.h"
#include "common_sw_timer.h"
#include "system.h"
#include "board.h"

Functions

static bool compare_time (uint32_t t1, uint32_t t2)
 
static uint32_t gettime (void)
 
void hw_expiry_cb (void)
 
void hw_overflow_cb (void)
 
static void internal_timer_handler (void)
 
static void load_hw_timer (uint8_t timer_id)
 
static void prog_ocr (void)
 
static void start_absolute_timer (uint8_t timer_id, uint32_t point_in_time, FUNC_PTR handler_cb, void *parameter)
 
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...
 
void wakeup_cb (void *parameter)
 

Variables

static uint8_t alloc_timer_id = 0
 
static uint_fast8_t expired_timer_queue_head
 
static uint_fast8_t expired_timer_queue_tail
 
static uint_fast8_t running_timer_queue_head
 
static uint8_t running_timers
 
bool sys_sleep
 
volatile uint16_t sys_time
 This is the most significant part of the system time. More...
 
timer_info_t timer_array [TOTAL_NUMBER_OF_SW_TIMERS]
 
volatile bool timer_trigger
 

static bool compare_time ( uint32_t  t1,
uint32_t  t2 
)
inlinestatic
static uint32_t gettime ( void  )
inlinestatic
void wakeup_cb ( void *  parameter)

uint8_t alloc_timer_id = 0
static

Referenced by sw_timer_get_id(), and sw_timer_init().

uint_fast8_t expired_timer_queue_head
static
uint_fast8_t expired_timer_queue_tail
static
bool sys_sleep
volatile uint16_t sys_time

This is the most significant part of the system time.

The least one is timer1 itself. Exported since input capture units might want to know about this value as well.

Referenced by gettime(), hw_overflow_cb(), prog_ocr(), and sw_timer_init().

volatile bool timer_trigger