timer.h File Reference

Go to the source code of this file.

Macros

#define sys_tick_per_us   16
 
#define CLOCK_SYS_CLOCK_1250US   (1250 * sys_tick_per_us)
 
#define ClockTime   clock_time
 
#define WaitUs   sleep_us
 
#define WaitMs(t)   sleep_us((t)*1000)
 
#define sleep_ms(t)   sleep_us((t)*1000)
 

Enumerations

enum  TIMER_TypeDef { TIMER0 =0, TIMER1 =1, TIMER2 =2 }
 Type of Timer. More...
 
enum  TIMER_ModeTypeDef { TIMER_MODE_SYSCLK =0, TIMER_MODE_GPIO_TRIGGER =1, TIMER_MODE_GPIO_WIDTH =2, TIMER_MODE_TICK =3 }
 Mode of Timer. More...
 
enum  { CLOCK_16M_SYS_TIMER_CLK_1S = 16*1000*1000, CLOCK_16M_SYS_TIMER_CLK_1MS = 16*1000, CLOCK_16M_SYS_TIMER_CLK_1US = 16 }
 system Timer : 16Mhz, Constant More...
 

Functions

static unsigned long clock_time (void)
 This function performs to gets system timer0 address. More...
 
void sleep_us (unsigned long us)
 This function performs to set sleep us. More...
 
static unsigned int clock_time_exceed (unsigned int ref, unsigned int us)
 This function performs to calculation exceed us of the timer. More...
 
void timer0_gpio_init (GPIO_PinTypeDef pin, GPIO_PolTypeDef pol)
 initiate GPIO for gpio trigger and gpio width mode of timer0. More...
 
void timer1_gpio_init (GPIO_PinTypeDef pin, GPIO_PolTypeDef pol)
 initiate GPIO for gpio trigger and gpio width mode of timer1. More...
 
void timer2_gpio_init (GPIO_PinTypeDef pin, GPIO_PolTypeDef pol)
 initiate GPIO for gpio trigger and gpio width mode of timer2. More...
 
void timer0_set_mode (TIMER_ModeTypeDef mode, unsigned int init_tick, unsigned int cap_tick)
 set mode, initial tick and capture of timer0. More...
 
void timer1_set_mode (TIMER_ModeTypeDef mode, unsigned int init_tick, unsigned int cap_tick)
 set mode, initial tick and capture of timer1. More...
 
void timer2_set_mode (TIMER_ModeTypeDef mode, unsigned int init_tick, unsigned int cap_tick)
 set mode, initial tick and capture of timer2. More...
 
void timer_start (TIMER_TypeDef type)
 the specifed timer start working. More...
 
void timer_stop (TIMER_TypeDef type)
 the specifed timer stop working. More...
 

Macro Definition Documentation

◆ sys_tick_per_us

#define sys_tick_per_us   16

◆ CLOCK_SYS_CLOCK_1250US

#define CLOCK_SYS_CLOCK_1250US   (1250 * sys_tick_per_us)

◆ ClockTime

#define ClockTime   clock_time

◆ WaitUs

#define WaitUs   sleep_us

◆ WaitMs

#define WaitMs (   t)    sleep_us((t)*1000)

◆ sleep_ms

#define sleep_ms (   t)    sleep_us((t)*1000)

Enumeration Type Documentation

◆ TIMER_TypeDef

Type of Timer.

Enumerator
TIMER0 
TIMER1 
TIMER2 

◆ TIMER_ModeTypeDef

Mode of Timer.

Enumerator
TIMER_MODE_SYSCLK 
TIMER_MODE_GPIO_TRIGGER 
TIMER_MODE_GPIO_WIDTH 
TIMER_MODE_TICK 

◆ anonymous enum

anonymous enum

system Timer : 16Mhz, Constant

Enumerator
CLOCK_16M_SYS_TIMER_CLK_1S 
CLOCK_16M_SYS_TIMER_CLK_1MS 
CLOCK_16M_SYS_TIMER_CLK_1US 

Function Documentation

◆ clock_time()

static unsigned long clock_time ( void  )
inlinestatic

This function performs to gets system timer0 address.

Parameters
[in]none.
Returns
timer0 address.

◆ sleep_us()

void sleep_us ( unsigned long  us)

This function performs to set sleep us.

Parameters
[in]us- microseconds need to delay.
Returns
none

◆ clock_time_exceed()

static unsigned int clock_time_exceed ( unsigned int  ref,
unsigned int  us 
)
inlinestatic

This function performs to calculation exceed us of the timer.

Parameters
[in]ref- Variable of reference timer address.
[in]span_us- Variable of span us.
Returns
the exceed.

◆ timer0_gpio_init()

void timer0_gpio_init ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  pol 
)

initiate GPIO for gpio trigger and gpio width mode of timer0.

Parameters
[in]pin- select pin for timer0.
[in]pol- select polarity for gpio trigger and gpio width
Returns
none

◆ timer1_gpio_init()

void timer1_gpio_init ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  pol 
)

initiate GPIO for gpio trigger and gpio width mode of timer1.

Parameters
[in]pin- select pin for timer1.
[in]pol- select polarity for gpio trigger and gpio width
Returns
none

◆ timer2_gpio_init()

void timer2_gpio_init ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  pol 
)

initiate GPIO for gpio trigger and gpio width mode of timer2.

Parameters
[in]pin- select pin for timer2.
[in]pol- select polarity for gpio trigger and gpio width
Returns
none

◆ timer0_set_mode()

void timer0_set_mode ( TIMER_ModeTypeDef  mode,
unsigned int  init_tick,
unsigned int  cap_tick 
)

set mode, initial tick and capture of timer0.

Parameters
[in]mode- select mode for timer0.
[in]init_tick- initial tick.
[in]cap_tick- tick of capture.
Returns
none

◆ timer1_set_mode()

void timer1_set_mode ( TIMER_ModeTypeDef  mode,
unsigned int  init_tick,
unsigned int  cap_tick 
)

set mode, initial tick and capture of timer1.

Parameters
[in]mode- select mode for timer1.
[in]init_tick- initial tick.
[in]cap_tick- tick of capture.
Returns
none

◆ timer2_set_mode()

void timer2_set_mode ( TIMER_ModeTypeDef  mode,
unsigned int  init_tick,
unsigned int  cap_tick 
)

set mode, initial tick and capture of timer2.

Parameters
[in]mode- select mode for timer2.
[in]init_tick- initial tick.
[in]cap_tick- tick of capture.
Returns
none

◆ timer_start()

void timer_start ( TIMER_TypeDef  type)

the specifed timer start working.

Parameters
[in]type- select the timer to start.
Returns
none

◆ timer_stop()

void timer_stop ( TIMER_TypeDef  type)

the specifed timer stop working.

Parameters
[in]type- select the timer to stop.
Returns
none