From 609540d07cbf85cb94923ad3979f4ba7bc34ec84 Mon Sep 17 00:00:00 2001 From: Erik Henriksson Date: Fri, 12 Nov 2021 23:47:14 +0100 Subject: [PATCH] Upgrade to radio-hal 0.10 --- Cargo.toml | 12 +--- src/lib.rs | 121 +++++++++++++++++++++++++------ src/register.rs | 184 ++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 252 insertions(+), 65 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c1cfd6b..00efcb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,17 +11,12 @@ edition = "2018" util = [ "structopt", "linux-embedded-hal", "simplelog", "humantime", "bitbang-hal", "shared-bus", "nb", "void" ] default = ["log"] -defmt-default = ["defmt"] -defmt-trace = ["defmt"] -defmt-debug = ["defmt"] -defmt-info = ["defmt"] -defmt-warn = ["defmt"] -defmt-error = ["defmt"] - [dependencies] libc = { version = "0.2", optional = true } -radio = "0.9" +radio = "0.10" embedded-hal = { version = "0.2.4", features = ["unproven"] } +modular-bitfield = "0.11.0" + serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } structopt = { version = "0.3", optional = true } @@ -30,7 +25,6 @@ simplelog = { version = "0.10", optional = true } humantime = { version = "2.0", optional = true } shared-bus = { version = "0.2.0", features = ["std"], optional = true } bitbang-hal = { version = "0.3.2", optional = true } -modular-bitfield = "0.11.0" nb = {version = "1", optional = true} void = {version = "1", optional = true} diff --git a/src/lib.rs b/src/lib.rs index 70cc2ad..b4a01c9 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,9 +23,6 @@ use log::{debug, trace, warn}; #[cfg(feature = "defmt")] use defmt::{debug, trace, warn}; -extern crate modular_bitfield; -use modular_bitfield::prelude::*; - #[cfg(feature = "serde")] extern crate serde; @@ -37,7 +34,9 @@ use hal::blocking::spi::{Transfer, Write}; use hal::digital::v2::OutputPin; extern crate radio; -use radio::{Channel as _, Interrupts as _, Power as _, Rssi as _, State as _}; +use radio::{ + Channel as _, Interrupts as _, Power as _, Register as _, Registers as _, Rssi as _, State as _, +}; pub mod prelude; use prelude::*; @@ -91,12 +90,16 @@ pub enum Error { InvalidDevice(u8), /// Packet size disagrees with FIFO interrupt (first is packet len, second is buffer size) InvalidPacketSize(usize, usize), + // #[error("Unexpected register value (address: 0x{0:02x})")] + UnexpectedValue(u8), } impl Sx1231 where Spi: Transfer + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { /// Create a new radio instance with the provided SPI implementation and pins pub fn new(spi: Spi, cs: CsPin) -> Self { @@ -121,6 +124,8 @@ impl Sx1231 where Spi: Transfer + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { /// (re)apply device configuration pub fn configure(&mut self, config: &Config) -> Result<(), Error> { @@ -270,7 +275,7 @@ where /// Fetch device silicon version pub fn silicon_version(&mut self) -> Result> { - self.read_reg(Version::ADDRESS) + self.read_register::().map(|r| r.into()) } // Calculate a channel number from a given frequency @@ -303,15 +308,6 @@ where Ok(incoming[0]) } - pub fn read_register(&mut self) -> Result> - where - R: Reg + Specifier, - { - let data = self.read_reg(R::ADDRESS)?; - let reg = R::from_bytes(data).unwrap(); - Ok(reg) - } - /// Write a u8 value to the specified register pub fn write_reg(&mut self, reg: R, value: u8) -> Result<(), Error> where @@ -429,6 +425,8 @@ impl Sx1231 where Spi: Transfer + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { pub fn set_state_checked(&mut self, state: ModemMode) -> Result<(), Error> { // Send set state command @@ -460,6 +458,8 @@ impl radio::State for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type State = ModemMode; type Error = Error; @@ -483,6 +483,8 @@ impl radio::Power for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Error = Error; @@ -515,6 +517,8 @@ impl radio::Interrupts for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Irq = IrqFlags; type Error = Error; @@ -541,6 +545,8 @@ impl radio::Channel for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Channel = Channel; type Error = Error; @@ -589,6 +595,8 @@ impl radio::Transmit for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Error = Error; @@ -656,6 +664,8 @@ impl radio::Receive for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Info = PacketInfo; type Error = Error; @@ -741,11 +751,8 @@ where /// /// This copies data into the provided slice, updates the provided information object, /// and returns the number of bytes received on success - fn get_received( - &mut self, - info: &mut Self::Info, - data: &mut [u8], - ) -> Result { + fn get_received(&mut self, data: &mut [u8]) -> Result<(usize, Self::Info), Self::Error> { + let mut info = PacketInfo::default(); // Read the RSSI info.rssi = self.poll_rssi()?; // First byte is length and should not be returned. @@ -758,7 +765,7 @@ where #[cfg(feature = "defmt")] debug!("Received data: {} info: {:?}", packet_data, &info); - Ok(packet_data.len()) + Ok((packet_data.len(), info)) } } @@ -766,6 +773,8 @@ impl radio::Rssi for Sx1231 + Write, CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, { type Error = Error; @@ -778,6 +787,78 @@ where } } +pub trait RegisterWord { + type Bytes: Default + core::convert::AsMut<[u8]>; + fn to_bytes(self) -> Self::Bytes; + fn from_bytes(bytes: Self::Bytes) -> Self; +} + +impl RegisterWord for u8 { + type Bytes = [u8; 1]; + + fn to_bytes(self) -> [u8; 1] { + self.to_be_bytes() + } + + fn from_bytes(bytes: [u8; 1]) -> Self { + Self::from_be_bytes(bytes) + } +} + +impl RegisterWord for u16 { + type Bytes = [u8; 2]; + + fn to_bytes(self) -> [u8; 2] { + self.to_be_bytes() + } + + fn from_bytes(bytes: [u8; 2]) -> Self { + Self::from_be_bytes(bytes) + } +} + +impl radio::Registers + for Sx1231 +where + Spi: Transfer + Write, + CsPin: OutputPin, + SpiError: Debug, + PinError: Debug, + Word: RegisterWord, + Bytes: Default + core::convert::AsMut<[u8]>, +{ + type Error = Error; + + fn read_register>( + &mut self, + ) -> Result> { + let mut bytes = Bytes::default(); + + self.cs.set_low().map_err(|e| Error::Pin(e))?; + self.spi.write(&[R::ADDRESS]).map_err(|e| Error::Spi(e))?; + self.spi + .transfer(bytes.as_mut()) + .map_err(|e| Error::Spi(e))?; + self.cs.set_high().map_err(|e| Error::Pin(e))?; + + let d = R::Word::from_bytes(bytes); + R::try_from(d).map_err(|_| Error::UnexpectedValue(R::ADDRESS)) + } + + fn write_register>( + &mut self, + r: R, + ) -> Result<(), Error> { + self.cs.set_low().map_err(|e| Error::Pin(e))?; + self.spi.write(&[R::ADDRESS]).map_err(|e| Error::Spi(e))?; + self.spi + .write(r.into().to_bytes().as_mut()) + .map_err(|e| Error::Spi(e))?; + self.cs.set_high().map_err(|e| Error::Pin(e))?; + Ok(()) + } +} + #[cfg(test)] mod tests { #[test] diff --git a/src/register.rs b/src/register.rs index cd81b7b..9385fe7 100755 --- a/src/register.rs +++ b/src/register.rs @@ -10,19 +10,16 @@ // This warning is generated by some modular bitfield macro. #![allow(clippy::unnecessary_cast)] +use core::convert::Infallible; use modular_bitfield::prelude::*; -pub trait Reg { - const ADDRESS: u8; -} - #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct Fifo {} -impl Reg for Fifo { - const ADDRESS: u8 = 0x00; +impl Fifo { + pub const ADDRESS: u8 = 0x00; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -37,10 +34,21 @@ pub enum ModemMode { Receiver = 4, } +impl radio::RadioState for ModemMode { + fn idle() -> Self { + ModemMode::Standby + } + + fn sleep() -> Self { + ModemMode::Sleep + } +} + #[bitfield] #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct OpMode { #[skip] _reserved: B2, @@ -50,8 +58,10 @@ pub struct OpMode { pub sequencer_off: bool, } -impl Reg for OpMode { +impl radio::Register for OpMode { const ADDRESS: u8 = 0x01; + type Word = u8; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -85,6 +95,7 @@ pub enum DataMode { #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct DataModulation { pub mod_type: ModulationType, pub mode: DataMode, @@ -92,44 +103,55 @@ pub struct DataModulation { __: B1, } -impl Reg for DataModulation { +impl radio::Register for DataModulation { const ADDRESS: u8 = 0x02; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u16)] pub struct Bitrate { pub bitrate: u16, } -impl Reg for Bitrate { +impl radio::Register for Bitrate { const ADDRESS: u8 = 0x03; + type Word = u16; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u16)] pub struct Fdev { pub freq_dev: u16, } -impl Reg for Fdev { +impl radio::Register for Fdev { const ADDRESS: u8 = 0x05; + type Word = u16; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u16)] pub struct FreqDev { pub freq_dev: u16, } -impl Reg for FreqDev { +impl radio::Register for FreqDev { const ADDRESS: u8 = 0x05; + type Word = u16; + type Error = Infallible; } #[bitfield] @@ -140,14 +162,29 @@ pub struct CarrierFreq { pub freq: B24, } -impl Reg for CarrierFreq { +impl radio::Register for CarrierFreq { const ADDRESS: u8 = 0x07; + type Word = [u8; 3]; + type Error = Infallible; +} + +impl From<[u8; 3]> for CarrierFreq { + fn from(bytes: [u8; 3]) -> Self { + CarrierFreq::from_bytes(bytes) + } +} + +impl From for [u8; 3] { + fn from(reg: CarrierFreq) -> Self { + reg.into_bytes() + } } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct Oscillator { #[skip] __: B6, @@ -155,14 +192,17 @@ pub struct Oscillator { pub rc_cal_start: bool, } -impl Reg for Oscillator { +impl radio::Register for Oscillator { const ADDRESS: u8 = 0x0A; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct AfcControl { #[skip] __: B5, @@ -171,8 +211,10 @@ pub struct AfcControl { __2: B2, } -impl Reg for AfcControl { +impl radio::Register for AfcControl { const ADDRESS: u8 = 0x0B; + type Word = u8; + type Error = Infallible; } /// Action taken after acceptance of a packet in Listen mode @@ -223,14 +265,29 @@ pub struct Listen { pub coeff_rx: u8, } -impl Reg for Listen { +impl radio::Register for Listen { const ADDRESS: u8 = 0x0D; + type Word = [u8; 3]; + type Error = Infallible; +} + +impl From<[u8; 3]> for Listen { + fn from(bytes: [u8; 3]) -> Self { + Listen::from_bytes(bytes) + } +} + +impl From for [u8; 3] { + fn from(listen: Listen) -> Self { + listen.into_bytes() + } } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct AfcFei { #[skip] __: B5, @@ -239,26 +296,32 @@ pub struct AfcFei { pub afc_start: bool, } -impl Reg for AfcFei { +impl radio::Register for AfcFei { const ADDRESS: u8 = 0x0E; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct Version { pub version: u8, } -impl Reg for Version { +impl radio::Register for Version { const ADDRESS: u8 = 0x10; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct PaLevel { pub level: B5, pub pa2_on: bool, @@ -266,8 +329,10 @@ pub struct PaLevel { pub pa0_on: bool, } -impl Reg for PaLevel { +impl radio::Register for PaLevel { const ADDRESS: u8 = 0x11; + type Word = u8; + type Error = Infallible; } // Rise/Fall time of ramp up/down in FSK @@ -298,20 +363,24 @@ pub enum RampTime { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct PaRamp { pub time: RampTime, #[skip] __: B4, } -impl Reg for PaRamp { +impl radio::Register for PaRamp { const ADDRESS: u8 = 0x12; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct Ocp { pub trim: B4, pub ocp_on: bool, @@ -319,8 +388,10 @@ pub struct Ocp { __: B3, } -impl Reg for Ocp { +impl radio::Register for Ocp { const ADDRESS: u8 = 0x13; + type Word = u8; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -350,6 +421,7 @@ pub enum LnaZin { #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct Lna { pub gain_select: LnaGainSelect, pub current_gain: B3, @@ -358,8 +430,10 @@ pub struct Lna { pub zin: LnaZin, } -impl Reg for Lna { +impl radio::Register for Lna { const ADDRESS: u8 = 0x18; + type Word = u8; + type Error = Infallible; } // FSK bandwidth register values @@ -410,31 +484,38 @@ pub enum DccFreq { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct RxBw { pub bw: Bandwidth, pub dcc: DccFreq, } -impl Reg for RxBw { +impl radio::Register for RxBw { const ADDRESS: u8 = 0x19; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct AfcBw { pub bw: Bandwidth, pub dcc: DccFreq, } -impl Reg for AfcBw { +impl radio::Register for AfcBw { const ADDRESS: u8 = 0x20; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[repr(u8)] pub struct RssiConfig { pub start: bool, pub done: bool, @@ -442,26 +523,32 @@ pub struct RssiConfig { __: B6, } -impl Reg for RssiConfig { +impl radio::Register for RssiConfig { const ADDRESS: u8 = 0x23; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct RssiValue { pub value: u8, } -impl Reg for RssiValue { +impl radio::Register for RssiValue { const ADDRESS: u8 = 0x24; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u16)] pub struct IrqFlags { pub sync_address_match: bool, pub auto_mode: bool, @@ -482,8 +569,10 @@ pub struct IrqFlags { pub fifo_full: bool, } -impl Reg for IrqFlags { +impl radio::Register for IrqFlags { const ADDRESS: u8 = 0x27; + type Word = u16; + type Error = Infallible; } // #[cfg(feature = "std")] @@ -542,24 +631,30 @@ impl core::fmt::Debug for IrqFlags { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct RssiThreshold { pub value: u8, } -impl Reg for RssiThreshold { +impl radio::Register for RssiThreshold { const ADDRESS: u8 = 0x29; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u16)] pub struct Preamble { pub size: u16, } -impl Reg for Preamble { +impl radio::Register for Preamble { const ADDRESS: u8 = 0x2c; + type Word = u16; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -575,6 +670,7 @@ pub enum FifoFillCondition { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct SyncConfig { pub tolerated_bit_errors: B3, pub size_minus_one: B3, @@ -582,21 +678,25 @@ pub struct SyncConfig { pub sync_on: bool, } -impl Reg for SyncConfig { +impl radio::Register for SyncConfig { const ADDRESS: u8 = 0x2e; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct SyncValue { - #[skip] - __: B8, + pub value: B8, } -impl Reg for SyncValue { +impl radio::Register for SyncValue { const ADDRESS: u8 = 0x2f; + type Word = u8; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -650,6 +750,7 @@ pub enum PacketFormat { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct PacketConfig1 { #[skip] __: B1, @@ -660,20 +761,25 @@ pub struct PacketConfig1 { pub packet_format: PacketFormat, } -impl Reg for PacketConfig1 { +impl radio::Register for PacketConfig1 { const ADDRESS: u8 = 0x37; + type Word = u8; + type Error = Infallible; } #[bitfield] #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct PayloadLength { pub value: u8, } -impl Reg for PayloadLength { +impl radio::Register for PayloadLength { const ADDRESS: u8 = 0x38; + type Word = u8; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -691,13 +797,16 @@ pub enum TxStartCondition { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct FifoThreshold { pub threshold: B7, pub start_condition: TxStartCondition, } -impl Reg for FifoThreshold { +impl radio::Register for FifoThreshold { const ADDRESS: u8 = 0x3C; + type Word = u8; + type Error = Infallible; } #[derive(BitfieldSpecifier, Copy, Clone, PartialEq, Debug)] @@ -722,6 +831,7 @@ pub enum AutoRxRestart { #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[repr(u8)] pub struct PacketConfig2 { pub aes: Aes, pub auto_rx_restart: AutoRxRestart, @@ -729,6 +839,8 @@ pub struct PacketConfig2 { pub inter_packet_rx_delay: B5, } -impl Reg for PacketConfig2 { +impl radio::Register for PacketConfig2 { const ADDRESS: u8 = 0x3D; + type Word = u8; + type Error = Infallible; }