FreeRTOS port on GAP8/RISC-V
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timer

Data Structures

union  timer_cfg_u
 

Macros

#define fc_timer(id)
 
#define cl_timer(id)
 

Typedefs

typedef timer_unit_cfg_lo_t timer_cfg_u
 

Enumerations

enum  timer_e
 
enum  timer_e
 

Functions

void pi_timer_init (timer_e timer, timer_cfg_u cfg, uint32_t cmp_val)
 Initialize a timer. More...
 
void pi_timer_reset (timer_e timer)
 Reset a timer counter. More...
 
void pi_timer_start (timer_e timer)
 Start a timer. More...
 
void pi_timer_stop (timer_e timer)
 Stop a timer. More...
 
uint32_t pi_timer_value_read (timer_e timer)
 Get a timer's counter value. More...
 
void pi_timer_irq_set (timer_e timer, uint32_t time_us, uint8_t one_shot)
 Set timer to trigger IRQ. More...
 
void pi_timer_conf_init (timer_cfg_u *cfg)
 Initialize timer config structure. More...
 

Description

Macro Definition Documentation

#define cl_timer (   id)
#define fc_timer (   id)

Typedef Documentation

typedef timer_unit_cfg_lo_t timer_cfg_u

Enumeration Type Documentation

enum timer_e
Enumerator
SYS_TIMER 

FC_TIMER_0 used as SysTick timer by preemptive RTOS.

FC_TIMER_0 

FC Timer_Low.

FC_TIMER_1 

FC Timer_High.

CL_TIMER_0 

Cluster Timer_Low.

CL_TIMER_1 

Cluster Timer_High.

SYS_TIMER 

FC TIMER_0 used as SysTick timer by preemptive RTOS.

FC_TIMER_0 

FC Timer_0_Low. FC_TIMER_0 and FC_TIMER_1 can be used together for 64 bits timer.

FC_TIMER_1 

FC Timer_0_High.

FC_TIMER_2 

FC Timer_1_Low. FC_TIMER_2 and FC_TIMER_3 can be used together for 64 bits timer.

FC_TIMER_3 

FC Timer_1_High.

CL_TIMER_0 

Cluster Timer_0_Low.

CL_TIMER_1 

Cluster Timer_0_High.

enum timer_e
Enumerator
SYS_TIMER 

FC_TIMER_0 used as SysTick timer by preemptive RTOS.

FC_TIMER_0 

FC Timer_Low.

FC_TIMER_1 

FC Timer_High.

CL_TIMER_0 

Cluster Timer_Low.

CL_TIMER_1 

Cluster Timer_High.

SYS_TIMER 

FC TIMER_0 used as SysTick timer by preemptive RTOS.

FC_TIMER_0 

FC Timer_0_Low. FC_TIMER_0 and FC_TIMER_1 can be used together for 64 bits timer.

FC_TIMER_1 

FC Timer_0_High.

FC_TIMER_2 

FC Timer_1_Low. FC_TIMER_2 and FC_TIMER_3 can be used together for 64 bits timer.

FC_TIMER_3 

FC Timer_1_High.

CL_TIMER_0 

Cluster Timer_0_Low.

CL_TIMER_1 

Cluster Timer_0_High.

Function Documentation

void pi_timer_conf_init ( timer_cfg_u cfg)

This function sets defaults values to timer.

Parameters
cfgPointer to conf structure.

References timer_cfg_u::enable, timer_cfg_u::mode, and timer_cfg_u::reset.

Referenced by __pi_perf_enable_timer(), pi_timer_irq_set(), system_core_clock_update(), and system_setup_systick().

void pi_timer_init ( timer_e  timer,
timer_cfg_u  cfg,
uint32_t  cmp_val 
)

This function initializes a timer(on FC or Cluster) with given configuration.

Parameters
timerTimer to configure.
cfgConfiguration structure to set up the timer.
cmp_valCompare value.
Note
For preemptive RTOS using time slicing, the FC_Timer_0 should be used as SysTick timer. Thus a 64 bit timer can not be used.

References __g_timer_state, cl_timer, CL_TIMER_0, CL_TIMER_1, fc_timer, FC_TIMER_0, FC_TIMER_1, FC_TIMER_2, FC_TIMER_3, g_timer_state, hal_write32(), TIMER_INIT, timer_unit_cfg_hi_set(), timer_unit_cfg_lo_set(), timer_unit_cmp_hi_set(), timer_unit_cmp_lo_set(), timer_unit_cnt_hi_set(), timer_unit_cnt_lo_set(), and timer_cfg_u::word.

Referenced by __pi_perf_enable_timer(), pi_timer_irq_set(), system_core_clock_update(), and system_setup_systick().

void pi_timer_irq_set ( timer_e  timer,
uint32_t  time_us,
uint8_t  one_shot 
)

This function is used to set a timer to trigger an IRQ when the given value is reached.

Parameters
timerTimer to set.
time_usTimer value in us.
one_shotTimer mode : one-shot or continuous.
Note
one_shot = 1, one shot timer. one_shot = 0, continuous mode.
This function disables a timer if one is already enabled, and reconfigure it.

References __g_timer_state, timer_cfg_u::enable, timer_cfg_u::field, g_timer_state, timer_cfg_u::irq_en, timer_cfg_u::mode, timer_cfg_u::one_shot, pi_freq_get(), pi_timer_conf_init(), pi_timer_init(), pi_timer_start(), pi_timer_stop(), system_core_clock_get(), and TIMER_ENA.

void pi_timer_reset ( timer_e  timer)

This function resets a timer's counter register.

Parameters
timerTimer to reset.
Note
This function does not reset a timer's configration. To fully reset a timer, stop first the timer, then reinitialize the timer using pi_timer_init() function.

References cl_timer, CL_TIMER_0, CL_TIMER_1, fc_timer, FC_TIMER_0, FC_TIMER_1, FC_TIMER_2, FC_TIMER_3, timer_cfg_u::field, hal_or32(), timer_cfg_u::reset, timer_unit_reset_hi_set(), timer_unit_reset_lo_set(), and timer_cfg_u::word.

Referenced by __pi_perf_fc_reset().

uint32_t pi_timer_value_read ( timer_e  timer)

This function returns current counter value of a timer.

Parameters
timerTimer to stop.
Returns
Current counter value of the timer.

References cl_timer, CL_TIMER_0, CL_TIMER_1, fc_timer, FC_TIMER_0, FC_TIMER_1, FC_TIMER_2, FC_TIMER_3, hal_read32(), timer_unit_cnt_hi_get(), and timer_unit_cnt_lo_get().

Referenced by __pi_perf_save().