Expand description
Low level access to RISC-V processors
§Minimum Supported Rust Version (MSRV)
This crate is guaranteed to compile on stable Rust 1.60 and up. It might compile with older versions but that may change in any new patch release.
§Features
This crate provides:
- Access to core registers like
mstatus
ormcause
. - Interrupt manipulation mechanisms.
- Wrappers around assembly instructions like
WFI
.
§Optional features
§s-mode
This feature re-exports in interrupt
S-mode interrupt functions defined in interrupt::supervisor
.
By default, the crate assumes that the target is running in M-mode.
Thus, interrupt
re-exports the M-mode functions defined in interrupt::machine
.
§critical-section-single-hart
This feature enables a critical-section
implementation suitable for single-hart targets, based on disabling interrupts globally.
This feature uses S-mode interrupt handling if the s-mode
feature is enabled, and M-mode otherwise.
It is unsound to enable it on multi-hart targets, and may cause functional problems in systems where some interrupts must NOT be disabled or critical sections are managed as part of an RTOS. In these cases, you should use a target-specific implementation instead, typically provided by a HAL or RTOS crate.
Modules§
- Assembly instructions
- Delay devices and providers
- Interrupts
- RISC-V CSR’s
Macros§
- Convenience macro around the
csrrc
assembly instruction to clear the CSR register. - Convenience macro to define field clear functions for a CSR type.
RV32
: Convenience macro around thecsrrc
assembly instruction to clear the CSR register.- Helper macro to define a CSR type.
- Convenience macro to read a composite value from a CSR register.
- Convenience macro to wrap the
csrrs
assembly instruction for reading a CSR register. - Convenience macro to read a CSR register value as a
register
type. RV32
: Convenience macro to read a CSR register value as aregister
type.- Convenience macro to read a CSR register value as a
usize
. RV32
: Convenience macro to read a CSR register value as ausize
.RV32
: Convenience macro to wrap thecsrrs
assembly instruction for reading a CSR register.- Helper macro to create a read-only CSR type.
- Defines field accesor functions for a read-only CSR type.
- Helper macro to create a read-write CSR type.
- Defines field accesor functions for a read-write CSR type.
- Convenience macro around the
csrrs
assembly instruction to set the CSR register. - Convenience macro to define field setter and clear functions for a CSR type.
- Convenience macro to define field setter functions for a CSR type.
RV32
: Convenience macro around thecsrrs
assembly instruction to set the CSR register.- Macro to create a mutable reference to a statically allocated value
- Convenience macro to wrap the
csrrw
assembly instruction for writing to CSR registers. - Convenience macro to write a value with
bits
to a CSR - Convenience macro to write a value to a CSR register.
- Convenience macro to write a
usize
value to a CSR register. RV32
: Convenience macro to write ausize
value to a CSR register.RV32
: Convenience macro to wrap thecsrrw
assembly instruction for writing to CSR registers.- Helper macro to create a read-only CSR type.
- Defines field accesor functions for a write-only CSR type.
Traits§
- Marker trait for enums of target-specific core interrupt numbers.
- Trait for enums of target-specific exception numbers.
- Marker trait for enums of target-specific external interrupt numbers.
- Trait for enums of HART identifiers.
- Trait for enums of target-specific interrupt numbers.
- Trait for enums of priority levels.
Attribute Macros§
- Attribute-like macro that implements the traits of the
riscv-pac
crate for a given enum.