Timer driver API definitions.
This module provides functions to configure and control Timer input/output and interrupt behavior.
Usage & Initialization.
This is an example show how to instantiate TIMER with timer_instance_t.
This implementation depends on PLIC Controller Driver for interrupt configuration.
#define TIMER_0 ((timer_hwreg_t *)SYSTEM_USER_TIMER_0_CTRL)
#define PRESCALER_VALUE 127
#define TIMER_LIMIT_VALUE 4095
.hwreg = TIMER_0,
.prescaler_value = PRESCALER_VALUE,
.prescaler_enable = 0x1U,
.self_restart = 0x1U,
.timer_limit = TIMER_LIMIT_VALUE,
};
.gateway = SYSTEM_USER_TIMER_0_INTERRUPTS_0,
.priority = 0x1U,
.enable = 0x1U,
.threshold = 0x0U,
};
void isrInit(){
}
#define BSP_PLIC_CPU_0
Primary PLIC CPU 0 External Interrupt base address.
void trap_entry(void)
The Main Trap Entry Point (Naked).
void irq_enable(void)
Enable Global Interrupts (MIE bit).
void irq_setType(cpu_irq_t enable)
Enable specific CPU interrupt sources.
void irq_setTrapVector(void(*trap_vector)(void))
Set the Machine Trap Vector (mtvec).
void plic_applyConfig(plic_instance_t *inst)
Apply stored PLIC configuration to hardware.
void timer_applyConfig(timer_instance_t *inst)
Apply the software configuration to the hardware.
RISC-V Core Interrupt Handling and Vector Table.
int irq_m_userTimer0_handler(void)
PLIC instance. Holds the software registers and hardware pointer.
UserTimer instance. Holds the software registers and hardware pointer.
User Timer driver API definitions.
- See also
- Example User Timer Demo - Learn how to use the driver for timer operations