libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
TIMER peripheral API

Access functions for the Timer/Counter More...

Collaboration diagram for TIMER peripheral API:

Functions

uint32_t timer_get_ticks (uint32_t timer)
 Get timer ticks. More...
 
void timer_set_mode (uint32_t timer, enum timer_mode mode)
 Set timer mode (counter/timer) More...
 
void timer_set_bitmode (uint32_t timer, enum timer_bitmode bitmode)
 Set timer bit mode (width) More...
 
void timer_start (uint32_t timer)
 Start the timer. More...
 
void timer_stop (uint32_t timer)
 Stop the timer. More...
 
void timer_clear (uint32_t timer)
 Clear the timer. More...
 
void timer_set_prescaler (uint32_t timer, uint8_t presc)
 Set prescaler value. More...
 
void timer_set_compare (uint32_t timer, uint8_t compare_num, uint32_t compare_val)
 Set compare register. More...
 
uint32_t timer_get_freq (uint32_t timer)
 Get the timer tick frequency. More...
 
uint32_t timer_get_cc (uint32_t timer, uint8_t compare_num)
 Get compare register. More...
 

Detailed Description

Access functions for the Timer/Counter

LGPL License Terms libopencm3 License

Author
© 2016 Maxim Sloyko maxim.nosp@m.s@go.nosp@m.ogle..nosp@m.com

Function Documentation

◆ timer_clear()

void timer_clear ( uint32_t  timer)

Clear the timer.

Parameters
[in]timeruint32_t timer base

Definition at line 96 of file timer.c.

References PERIPH_TRIGGER_TASK, and TIMER_TASK_CLEAR.

◆ timer_get_cc()

uint32_t timer_get_cc ( uint32_t  timer,
uint8_t  compare_num 
)

Get compare register.

Parameters
[in]timeruint32_t timer base
[in]compare_numuint8_t compare number (0-3)
Returns
compare register value

Definition at line 142 of file timer.c.

References TIMER_CC.

◆ timer_get_freq()

uint32_t timer_get_freq ( uint32_t  timer)

Get the timer tick frequency.

Parameters
[in]timeruint32_t timer base
Returns
frequency of ticking

Definition at line 131 of file timer.c.

References CLOCK_PCLK, and TIMER_PRESCALER.

◆ timer_get_ticks()

uint32_t timer_get_ticks ( uint32_t  timer)

Get timer ticks.

Parameters
[in]timeruint32_t timer base
Returns
current ticks value

Definition at line 41 of file timer.c.

References TIMER_CC, and TIMER_TASK_CAPTURE.

◆ timer_set_bitmode()

void timer_set_bitmode ( uint32_t  timer,
enum timer_bitmode  bitmode 
)

Set timer bit mode (width)

Parameters
[in]timeruint32_t timer base
[in]bitmodeenum timer_bitmode

Definition at line 69 of file timer.c.

References TIMER_BITMODE.

◆ timer_set_compare()

void timer_set_compare ( uint32_t  timer,
uint8_t  compare_num,
uint32_t  compare_val 
)

Set compare register.

Parameters
[in]timeruint32_t timer base
[in]compare_numuint8_t compare number (0-3)
[in]compare_valuint32_t compare value

Definition at line 117 of file timer.c.

References TIMER_CC.

◆ timer_set_mode()

void timer_set_mode ( uint32_t  timer,
enum timer_mode  mode 
)

Set timer mode (counter/timer)

Parameters
[in]timeruint32_t timer base
[in]modeenum timer_mode

Definition at line 59 of file timer.c.

References TIMER_MODE.

◆ timer_set_prescaler()

void timer_set_prescaler ( uint32_t  timer,
uint8_t  presc 
)

Set prescaler value.

Parameters
[in]timeruint32_t timer base
[in]prescuint8_t prescaler value

Definition at line 106 of file timer.c.

References TIMER_PRESCALER, and TIMER_PRESCALER_MASK.

◆ timer_start()

void timer_start ( uint32_t  timer)

Start the timer.

Parameters
[in]timeruint32_t timer base

Definition at line 78 of file timer.c.

References PERIPH_TRIGGER_TASK, and TIMER_TASK_START.

◆ timer_stop()

void timer_stop ( uint32_t  timer)

Stop the timer.

Parameters
[in]timeruint32_t timer base

Definition at line 87 of file timer.c.

References PERIPH_TRIGGER_TASK, and TIMER_TASK_STOP.