Skip to main content

Crate hpm_riscv_rt

Crate hpm_riscv_rt 

Source
Expand description

HPMicro RISC-V Runtime

This crate provides complete runtime support for HPMicro RISC-V MCUs, with HPMicro-specific customizations for PLIC vectored interrupt mode.

§Usage

Add this crate as a dependency:

[dependencies]
hpm-riscv-rt = "0.2"

Configure linker scripts in .cargo/config.toml:

rustflags = [
    "-C", "link-arg=-Tmemory.x",   # User-provided memory layout
    "-C", "link-arg=-Tdevice.x",   # From hpm-metapac (__INTERRUPTS)
    "-C", "link-arg=-Tlink.x",     # From hpm-riscv-rt
]

Use the provided macros:

use hpm_riscv_rt::{entry, pre_init, fast};

#[pre_init]
unsafe fn before_main() {
    // Called before RAM is initialized
}

#[entry]
fn main() -> ! {
    loop {}
}

#[fast]
fn critical_function() {
    // Runs from ILM for better performance
}

Modules§

trap
Trap handling for HPMicro RISC-V MCUs.

Structs§

TrapFrame
Registers saved during a trap.

Functions§

DefaultExceptionHandler
Default exception handler - loops forever.
DefaultInterruptHandler
Default interrupt handler - loops forever.
_hpm_start_rust
Rust startup function called from assembly after RAM is initialized.
setup_interrupts
Setup interrupts for HPMicro MCUs.

Attribute Macros§

entry
Attribute to declare the entry point of the program.
external_interrupt
Define an external interrupt handler for HPMicro PLIC.
fast
Place a function or static into fast memory (ILM/DLM).
pre_init
Attribute to declare a function that runs before RAM is initialized.