[−][src]Macro r3_port_riscv::use_timer
Attach the implementation of PortTimer
that is based on the RISC-V timer
(mtime
/mtimecfg
) to a given system type. This macro also implements
Timer
on the system type.
Requires TimerOptions
.
You should do the following:
- Implement
TimerOptions
on the system type$ty
. - Call
$ty::configure_timer()
in your configuration function. See the following example.
ⓘThis example is not tested
r3_port_riscv::use_timer!(unsafe impl PortTimer for System); impl r3_port_riscv::TimerOptions for System { const MTIME_PTR: usize = 0x1001_1000; const MTIMECMP_PTR: usize = 0x1001_1000; const FREQUENCY: u64 = 1_000_000; } const fn configure_app(b: &mut CfgBuilder<System>) -> Objects { System::configure_timer(b); /* ... */ }
Safety
TimerOptions
must be configured correctly.