RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
timer.c
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5
15
16#include "timer/timer.h"
17
18/*----------------------------------------------------------------------------*/
19/* Function implementations */
20/*----------------------------------------------------------------------------*/
21
26{
27 return inst->hwreg->TIMER_CONFIG;
28}
29
34{
35 inst->hwreg->TIMER_CONFIG = value;
36}
37
45
50{
51 inst->hwreg->PRESCALER = value;
52}
53
58{
59 return inst->hwreg->TIMER_LIMIT;
60}
61
66{
67 inst->hwreg->TIMER_LIMIT = value;
68}
69
74{
75 return inst->hwreg->TIMER_VALUE;
76}
77
82{
83 inst->hwreg->TIMER_VALUE=0;
84}
85
94{
95 slen mask = 0;
96 inst->hwreg->TIMER_LIMIT = inst->timer_limit;
97
98 if (inst->self_restart == 1) mask |= TIMER_CONFIG_SELF_RESTART;
99 if (inst->prescaler_enable == 1) {
101 inst->hwreg->PRESCALER = inst->prescaler_value;
102 }
103 else
105 inst->hwreg->TIMER_CONFIG=mask;
106}
u32 timer_getConfig(timer_instance_t *inst)
Get stored Timer Configuration.
Definition timer.c:25
u32 timer_setPrescalerValue(timer_instance_t *inst, u32 value)
Set Timer Prescaler Value.
Definition timer.c:49
u32 timer_getValue(timer_instance_t *inst)
Get stored Timer Value.
Definition timer.c:73
u32 timer_setConfig(timer_instance_t *inst, u32 value)
Set Timer Configuration.
Definition timer.c:33
void timer_applyConfig(timer_instance_t *inst)
Apply the software configuration to the hardware.
Definition timer.c:93
void timer_clearValue(timer_instance_t *inst)
Get stored Timer Configuration.
Definition timer.c:81
u32 timer_setLimit(timer_instance_t *inst, u32 value)
Set Timer Limit (Reload Value).
Definition timer.c:65
u32 timer_getLimit(timer_instance_t *inst)
Get stored Timer Limit (Reload Value).
Definition timer.c:57
u32 timer_getPrescalerValue(timer_instance_t *inst)
Get stored Timer Prescaler Value.
Definition timer.c:41
#define TIMER_CONFIG_WITHOUT_PRESCALER
No Prescaler *‍/.
Definition timer.h:91
#define TIMER_CONFIG_WITH_PRESCALER
Prescaler Enabled *‍/.
Definition timer.h:90
#define TIMER_CONFIG_SELF_RESTART
Self Restart *‍/.
Definition timer.h:92
u32 TIMER_CONFIG
Address Offset: 0x40 - Timer Configuration Register *‍/.
Definition timer.h:132
u32 PRESCALER
Address Offset: 0x00 - Prescaler Register *‍/.
Definition timer.h:130
u32 TIMER_VALUE
Address Offset: 0x48 - Timer Current Value Register *‍/.
Definition timer.h:134
u32 TIMER_LIMIT
Address Offset: 0x44 - Timer Limit Register *‍/.
Definition timer.h:133
UserTimer instance. Holds the software registers and hardware pointer.
Definition timer.h:149
u32 prescaler_value
Prescaler value *‍/.
Definition timer.h:151
u32 self_restart
Self restart enable flag *‍/.
Definition timer.h:153
timer_hwreg_t * hwreg
Pointer to Hardware Register Map *‍/.
Definition timer.h:150
u32 prescaler_enable
Prescaler enable flag *‍/.
Definition timer.h:152
u32 timer_limit
Timer limit value *‍/.
Definition timer.h:154
User Timer driver API definitions.
int32_t slen
Definition type.h:20
uint32_t u32
Definition type.h:26