Skip to content

Commit fcde9ff

Browse files
Merge pull request #335 from bjoernQ/optionally-impl-defmt-format
Optionally implement `defmt::Format`
2 parents 55578c3 + f207110 commit fcde9ff

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- Added `.uninit` section to the linker file. Due to its similarities with `.bss`, the
1515
linker will place this new section in `REGION_BSS`.
1616
- Additional feature `no-xie-xip` to work on chips without the XIE and XIP CSRs (e.g. ESP32-C2, ESP32-C3)
17+
- Additional feature `defmt` which will implement `defmt::Format` on certain types
1718

1819
### Changed
1920

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)