Skip to content

Commit 11c3a3b

Browse files
committed
Optionally implement defmt::Format
1 parent 55578c3 commit 11c3a3b

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

riscv-rt/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ riscv = { path = "../riscv", version = "0.14.0" }
2828
riscv-pac = { path = "../riscv-pac", version = "0.2.0" }
2929
riscv-rt-macros = { path = "macros", version = "0.5.0" }
3030

31+
defmt = { version = "1.0.1", optional = true }
32+
3133
[dev-dependencies]
3234
panic-halt = "1.0.0"
3335

@@ -43,3 +45,4 @@ no-exceptions = []
4345
no-xie-xip = []
4446
device = []
4547
memory = []
48+
defmt = ["dep:defmt"]

riscv-rt/src/interrupts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// In vectored mode, we also must provide a vector table
2121
#[riscv::pac_enum(unsafe CoreInterruptNumber)]
2222
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2324
enum Interrupt {
2425
SupervisorSoft = 1,
2526
MachineSoft = 3,

riscv-rt/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ pub unsafe extern "Rust" fn setup_interrupts() {
707707
/// Registers saved in trap handler
708708
#[repr(C)]
709709
#[derive(Debug)]
710+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
710711
pub struct TrapFrame {
711712
/// `x1`: return address, stores the address to return to after a function call or interrupt.
712713
pub ra: usize,

0 commit comments

Comments
 (0)