macro_rules! use_mtime {
    (unsafe impl PortTimer for $Traits:ty) => { ... };
}
Expand description

Attach the implementation of PortTimer based on the RISC-V machine-mode timer (mtime/mtimecfg) to a given kernel trait type. This macro also implements Timer on the kernel trait type. Requires MtimeOptions.

You should do the following:

  • Implement MtimeOptions on the kernel trait type $Traits.
  • Call $Traits::configure_timer() in your configuration function. See the following example.
r3_port_riscv::use_mtime!(unsafe impl PortTimer for SystemTraits);

impl r3_port_riscv::MtimeOptions for SystemTraits {
    const MTIME_PTR: usize = 0x1001_1000;
    const MTIMECMP_PTR: usize = 0x1001_1000;
    const FREQUENCY: u64 = 1_000_000;
}

const fn configure_app(b: &mut r3_kernel::Cfg<SystemTraits>) -> Objects {
    SystemTraits::configure_timer(b);
    /* ... */
}

Safety

  • MtimeOptions must be configured correctly.