Skip to content

Optionally implement defmt::Format #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `.uninit` section to the linker file. Due to its similarities with `.bss`, the
linker will place this new section in `REGION_BSS`.
- Additional feature `no-xie-xip` to work on chips without the XIE and XIP CSRs (e.g. ESP32-C2, ESP32-C3)
- Additional feature `defmt` which will implement `defmt::Format` on certain types

### Changed

Expand Down
3 changes: 3 additions & 0 deletions riscv-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ riscv = { path = "../riscv", version = "0.14.0" }
riscv-pac = { path = "../riscv-pac", version = "0.2.0" }
riscv-rt-macros = { path = "macros", version = "0.5.0" }

defmt = { version = "1.0.1", optional = true }

[dev-dependencies]
panic-halt = "1.0.0"

Expand All @@ -43,3 +45,4 @@ no-exceptions = []
no-xie-xip = []
device = []
memory = []
defmt = ["dep:defmt"]
1 change: 1 addition & 0 deletions riscv-rt/src/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// In vectored mode, we also must provide a vector table
#[riscv::pac_enum(unsafe CoreInterruptNumber)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
enum Interrupt {
SupervisorSoft = 1,
MachineSoft = 3,
Expand Down
1 change: 1 addition & 0 deletions riscv-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ pub unsafe extern "Rust" fn setup_interrupts() {
/// Registers saved in trap handler
#[repr(C)]
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TrapFrame {
/// `x1`: return address, stores the address to return to after a function call or interrupt.
pub ra: usize,
Expand Down
Loading