Appiko
Macros | Enumerations | Functions
Microsecond timer

Driver to use micro-second timers using the TIMER peripheral. More...

Macros

#define US_TIMER_USED   TIMER_USED_US_TIMER
 
#define US_TIMER_CC_COUNT   CONCAT_3(TIMER, US_TIMER_USED, _CC_NUM)
 The number of CC registers in the TIMER peripheral used for us timer.
 

Enumerations

enum  us_timer_num {
  US_TIMER0, US_TIMER1, US_TIMER2, US_TIMER3,
  US_TIMER_MAX
}
 Enumeration used for specifying the timers that can be used with this TIMER peripheral. More...
 
enum  us_timer_mode { US_SINGLE_CALL, US_REPEATED_CALL }
 Enumeration to specify the mode of operation of the timer. More...
 

Functions

void us_timer_init (uint32_t irq_priority)
 Initialize the TIMER peripheral to use as a micro-second timer. More...
 
void us_timer_start (us_timer_num id, us_timer_mode mode, uint32_t time_us, void(*handler)(void))
 
void us_timer_stop (us_timer_num id)
 
bool us_timer_get_on_status (us_timer_num id)
 

Detailed Description

Note
This module utilizes the PCLK1M clock for its functioning

Macro Definition Documentation

◆ US_TIMER_USED

#define US_TIMER_USED   TIMER_USED_US_TIMER

Specify which TIMER peripheral would be used for the us timer module

Definition at line 48 of file us_timer.h.

Enumeration Type Documentation

◆ us_timer_mode

Enumerator
US_SINGLE_CALL 

One shot call of the timer.

US_REPEATED_CALL 

Repeated call of the timer.

Definition at line 71 of file us_timer.h.

◆ us_timer_num

Enumerator
US_TIMER0 

Microsecond Timer 0.

US_TIMER1 

Microsecond Timer 1.

US_TIMER2 

Microsecond Timer 2.

US_TIMER3 

Microsecond Timer 3.

US_TIMER_MAX 

Not a timer, just used to find the number of timers.

Definition at line 56 of file us_timer.h.

Function Documentation

◆ us_timer_get_on_status()

bool us_timer_get_on_status ( us_timer_num  id)

Returns if a timer is on

Parameters
idID of timer being enquired
Returns
Boolean value indicating if a timer is ON

Definition at line 111 of file us_timer.c.

◆ us_timer_init()

void us_timer_init ( uint32_t  irq_priority)
Parameters
irq_priorityThe priority of the interrupt level at which the callback function is called

Definition at line 56 of file us_timer.c.

References US_SINGLE_CALL, US_TIMER0, and US_TIMER_MAX.

◆ us_timer_start()

void us_timer_start ( us_timer_num  id,
us_timer_mode  mode,
uint32_t  time_us,
void(*)(void)  handler 
)

Start a micro-second timer

Parameters
idID of the timer to be used from us_timer_num
modeMode of the timer as specified in us_timer_mode
time_usThe number microseconds after which the timer expires
handlerPointer to a function which needs to be called when the timer expires
Note
Starting an already started will restart the timer with the current number of ticks passed. us_timer_get_on_status can be used to check if a timer is already running.

Definition at line 74 of file us_timer.c.

References US_SINGLE_CALL.

◆ us_timer_stop()

void us_timer_stop ( us_timer_num  id)

Stop a micro-second timer

Parameters
idID of the timer to be stopped
Note
Stopping an already stopped timer will not be an issue

Definition at line 97 of file us_timer.c.

References US_SINGLE_CALL.