Skip to content

Commit e69c2f7

Browse files
robamuqwandor
authored andcommitted
add defmt support and basic IEEE802154 derives
1 parent 3c77a9e commit e69c2f7

File tree

11 files changed

+26
-1
lines changed

11 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
- Updated `embedded-io` to 0.7.1
1212
- Added `core::fmt::Error` implementation to `uarte::Error`.
1313

14+
### New features
15+
16+
- Optional `defmt` feature for all HALs
17+
- Basic derives for and defmt support for `ieee802154` module
18+
1419
## [0.18.0]
1520

1621
### Breaking changes

nrf-hal-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ embedded-storage = "0.3.1"
2929
fixed = "1.25.1"
3030
nb = "1.1.0"
3131
rand_core = "0.9.0"
32+
defmt = { version = "1", optional = true }
3233

3334
[dependencies.void]
3435
default-features = false

nrf-hal-common/src/ieee802154.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub const DEFAULT_SFD: u8 = 0xA7;
8181

8282
// TODO expose the other variants in `pac::CCAMODE_A`
8383
/// Clear Channel Assessment method
84+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
85+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8486
pub enum Cca {
8587
/// Carrier sense
8688
CarrierSense,
@@ -98,6 +100,8 @@ pub enum Cca {
98100
/// IEEE 802.15.4 channels
99101
///
100102
/// NOTE these are NOT the same as WiFi 2.4 GHz channels
103+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
104+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
101105
pub enum Channel {
102106
/// 2_405 MHz
103107
_11 = 5,
@@ -135,7 +139,8 @@ pub enum Channel {
135139

136140
/// Transmission power in dBm (decibel milliwatt)
137141
// TXPOWERA enum minus the deprecated Neg30dBm variant and with better docs
138-
#[derive(Clone, Copy, PartialEq)]
142+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
143+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
139144
pub enum TxPower {
140145
/// +8 dBm
141146
Pos8dBm,
@@ -732,6 +737,7 @@ impl<'c> Radio<'c> {
732737

733738
/// Error
734739
#[derive(Copy, Clone, Debug, PartialEq)]
740+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
735741
pub enum Error {
736742
/// Incorrect CRC
737743
Crc(u16),
@@ -744,22 +750,27 @@ pub enum Error {
744750
/// After, or at the start of, any method call the RADIO will be in one of these states
745751
// This is a subset of the STATE_A enum
746752
#[derive(Copy, Clone, PartialEq)]
753+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
747754
enum State {
748755
Disabled,
749756
RxIdle,
750757
TxIdle,
751758
}
752759

753760
/// NOTE must be followed by a volatile write operation
761+
#[inline]
754762
fn dma_start_fence() {
755763
atomic::compiler_fence(Ordering::Release);
756764
}
757765

758766
/// NOTE must be preceded by a volatile read operation
767+
#[inline]
759768
fn dma_end_fence() {
760769
atomic::compiler_fence(Ordering::Acquire);
761770
}
762771

772+
#[derive(Debug)]
773+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
763774
enum Event {
764775
PhyEnd,
765776
}

nrf51-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ version = "=0.19.0"
3030
[features]
3131
doc = []
3232
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
33+
defmt = ["nrf-hal-common/defmt"]
3334
rt = ["nrf51-pac/rt"]
3435
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]
3536
# Note: We use the xxAB package by default because it has the least amount of available resources.

nrf52805-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ version = "=0.19.0"
2828

2929
[features]
3030
doc = []
31+
defmt = ["nrf-hal-common/defmt"]
3132
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
3233
rt = ["nrf52805-pac/rt"]
3334
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]

nrf52810-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ version = "=0.19.0"
2828

2929
[features]
3030
doc = []
31+
defmt = ["nrf-hal-common/defmt"]
3132
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
3233
rt = ["nrf52810-pac/rt"]
3334
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]

nrf52811-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ version = "=0.19.0"
2828

2929
[features]
3030
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
31+
defmt = ["nrf-hal-common/defmt"]
3132
rt = ["nrf52811-pac/rt"]
3233
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]
3334
default = ["rt", "embedded-hal-02"]

nrf52832-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ version = "=0.19.0"
2626

2727
[features]
2828
doc = []
29+
defmt = ["nrf-hal-common/defmt"]
2930
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
3031
rt = ["nrf52832-pac/rt"]
3132
xxAA-package = []

nrf52833-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ version = "=0.19.0"
2929

3030
[features]
3131
doc = []
32+
defmt = ["nrf-hal-common/defmt"]
3233
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
3334
rt = ["nrf52833-pac/rt"]
3435
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]

nrf52840-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ version = "=0.19.0"
2828

2929
[features]
3030
doc = []
31+
defmt = ["nrf-hal-common/defmt"]
3132
embedded-hal-02 = ["nrf-hal-common/embedded-hal-02"]
3233
rt = ["nrf52840-pac/rt"]
3334
rtic-monotonic = ["nrf-hal-common/rtic-monotonic"]

0 commit comments

Comments
 (0)