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§
- Trap
Frame - Registers saved during a trap.
Functions§
- Default
Exception Handler - Default exception handler - loops forever.
- Default
Interrupt Handler - 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.