Merge #811
811: Sync subghz peripheral support with stm32wlxx-hal r=lulf a=lulf * A few more registers exposed * Fix for "sleeping" * Updating comments Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
This commit is contained in:
commit
03c20604c3
24 changed files with 371 additions and 967 deletions
|
@ -33,7 +33,7 @@ impl BitSync {
|
|||
/// Enable simple bit synchronization.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// const BIT_SYNC: BitSync = BitSync::RESET.set_simple_bit_sync_en(true);
|
||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x40u8);
|
||||
|
@ -53,7 +53,7 @@ impl BitSync {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// let bs: BitSync = BitSync::RESET;
|
||||
/// assert_eq!(bs.simple_bit_sync_en(), false);
|
||||
|
@ -73,7 +73,7 @@ impl BitSync {
|
|||
/// Invert receive data.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// const BIT_SYNC: BitSync = BitSync::RESET.set_rx_data_inv(true);
|
||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x20u8);
|
||||
|
@ -93,7 +93,7 @@ impl BitSync {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// let bs: BitSync = BitSync::RESET;
|
||||
/// assert_eq!(bs.rx_data_inv(), false);
|
||||
|
@ -113,7 +113,7 @@ impl BitSync {
|
|||
/// Enable normal bit synchronization.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// const BIT_SYNC: BitSync = BitSync::RESET.set_norm_bit_sync_en(true);
|
||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x10u8);
|
||||
|
@ -133,7 +133,7 @@ impl BitSync {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BitSync;
|
||||
/// use stm32wlxx_hal::subghz::BitSync;
|
||||
///
|
||||
/// let bs: BitSync = BitSync::RESET;
|
||||
/// assert_eq!(bs.norm_bit_sync_en(), false);
|
||||
|
|
|
@ -75,7 +75,7 @@ impl CadParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CadParams;
|
||||
/// use stm32wlxx_hal::subghz::CadParams;
|
||||
///
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new();
|
||||
/// assert_eq!(CAD_PARAMS, CadParams::default());
|
||||
|
@ -97,7 +97,7 @@ impl CadParams {
|
|||
/// Set the number of symbols to 4.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CadParams, NbCadSymbol};
|
||||
/// use stm32wlxx_hal::subghz::{CadParams, NbCadSymbol};
|
||||
///
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new().set_num_symbol(NbCadSymbol::S4);
|
||||
/// # assert_eq!(CAD_PARAMS.as_slice()[1], 0x2);
|
||||
|
@ -117,7 +117,7 @@ impl CadParams {
|
|||
/// Setting the recommended value for a spreading factor of 7.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CadParams;
|
||||
/// use stm32wlxx_hal::subghz::CadParams;
|
||||
///
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x20).set_det_min(0x10);
|
||||
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x20);
|
||||
|
@ -140,7 +140,7 @@ impl CadParams {
|
|||
/// Setting the recommended value for a spreading factor of 6.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CadParams;
|
||||
/// use stm32wlxx_hal::subghz::CadParams;
|
||||
///
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x18).set_det_min(0x10);
|
||||
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x18);
|
||||
|
@ -159,7 +159,7 @@ impl CadParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CadParams, ExitMode};
|
||||
/// use stm32wlxx_hal::subghz::{CadParams, ExitMode};
|
||||
///
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new().set_exit_mode(ExitMode::Standby);
|
||||
/// # assert_eq!(CAD_PARAMS.as_slice()[4], 0x00);
|
||||
|
@ -178,7 +178,7 @@ impl CadParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CadParams, ExitMode, Timeout};
|
||||
/// use stm32wlxx_hal::subghz::{CadParams, ExitMode, Timeout};
|
||||
///
|
||||
/// const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new()
|
||||
|
@ -203,7 +203,7 @@ impl CadParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CadParams, ExitMode, NbCadSymbol, Timeout};
|
||||
/// use stm32wlxx_hal::subghz::{CadParams, ExitMode, NbCadSymbol, Timeout};
|
||||
///
|
||||
/// const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
|
||||
/// const CAD_PARAMS: CadParams = CadParams::new()
|
||||
|
|
|
@ -28,7 +28,7 @@ impl CalibrateImage {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CalibrateImage;
|
||||
/// use stm32wlxx_hal::subghz::CalibrateImage;
|
||||
///
|
||||
/// const CAL: CalibrateImage = CalibrateImage::new(0xE1, 0xE9);
|
||||
/// assert_eq!(CAL, CalibrateImage::ISM_902_928);
|
||||
|
@ -54,7 +54,7 @@ impl CalibrateImage {
|
|||
/// Create an image calibration for the 430 - 440 MHz ISM band.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CalibrateImage;
|
||||
/// use stm32wlxx_hal::subghz::CalibrateImage;
|
||||
///
|
||||
/// let cal: CalibrateImage = CalibrateImage::from_freq(428, 444);
|
||||
/// assert_eq!(cal, CalibrateImage::ISM_430_440);
|
||||
|
@ -106,7 +106,7 @@ impl Calibrate {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Calibrate;
|
||||
/// use stm32wlxx_hal::subghz::Calibrate;
|
||||
///
|
||||
/// assert_eq!(Calibrate::Image.mask(), 0b0100_0000);
|
||||
/// assert_eq!(Calibrate::AdcBulkP.mask(), 0b0010_0000);
|
||||
|
|
|
@ -27,7 +27,7 @@ impl Default for FallbackMode {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FallbackMode;
|
||||
/// use stm32wlxx_hal::subghz::FallbackMode;
|
||||
///
|
||||
/// assert_eq!(FallbackMode::default(), FallbackMode::Standby);
|
||||
/// ```
|
||||
|
|
|
@ -26,7 +26,7 @@ impl HseTrim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::HseTrim;
|
||||
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||
///
|
||||
/// assert_eq!(HseTrim::POR, HseTrim::default());
|
||||
/// ```
|
||||
|
@ -39,7 +39,7 @@ impl HseTrim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::HseTrim;
|
||||
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||
///
|
||||
/// assert_eq!(HseTrim::from_raw(0xFF), HseTrim::MAX);
|
||||
/// assert_eq!(HseTrim::from_raw(0x2F), HseTrim::MAX);
|
||||
|
@ -61,7 +61,7 @@ impl HseTrim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::HseTrim;
|
||||
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||
///
|
||||
/// assert!(HseTrim::from_farads(1.0).is_err());
|
||||
/// assert!(HseTrim::from_farads(1e-12).is_err());
|
||||
|
@ -84,7 +84,7 @@ impl HseTrim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::HseTrim;
|
||||
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||
///
|
||||
/// assert_eq!((HseTrim::MAX.as_farads() * 10e11) as u8, 33);
|
||||
/// assert_eq!((HseTrim::MIN.as_farads() * 10e11) as u8, 11);
|
||||
|
|
|
@ -99,7 +99,7 @@ impl Irq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Irq;
|
||||
/// use stm32wlxx_hal::subghz::Irq;
|
||||
///
|
||||
/// assert_eq!(Irq::TxDone.mask(), 0x0001);
|
||||
/// assert_eq!(Irq::Timeout.mask(), 0x0200);
|
||||
|
@ -128,7 +128,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CfgIrq;
|
||||
/// use stm32wlxx_hal::subghz::CfgIrq;
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new();
|
||||
/// ```
|
||||
|
@ -153,7 +153,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
||||
|
@ -179,7 +179,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
||||
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||
/// .irq_enable_all(Irq::TxDone)
|
||||
|
@ -214,7 +214,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
||||
|
@ -239,7 +239,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
||||
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||
/// .irq_enable_all(Irq::TxDone)
|
||||
|
@ -269,7 +269,7 @@ impl CfgIrq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
||||
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||
///
|
||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||
/// .irq_enable_all(Irq::TxDone)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -52,7 +52,7 @@ impl FskBandwidth {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskBandwidth;
|
||||
/// use stm32wlxx_hal::subghz::FskBandwidth;
|
||||
///
|
||||
/// assert_eq!(FskBandwidth::Bw4.hertz(), 4_800);
|
||||
/// assert_eq!(FskBandwidth::Bw5.hertz(), 5_800);
|
||||
|
@ -109,7 +109,7 @@ impl FskBandwidth {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskBandwidth;
|
||||
/// use stm32wlxx_hal::subghz::FskBandwidth;
|
||||
///
|
||||
/// assert_eq!(FskBandwidth::from_bits(0x1F), Ok(FskBandwidth::Bw4));
|
||||
/// assert_eq!(FskBandwidth::from_bits(0x17), Ok(FskBandwidth::Bw5));
|
||||
|
@ -206,7 +206,7 @@ impl FskBitrate {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskBitrate;
|
||||
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(9600);
|
||||
/// assert_eq!(BITRATE.as_bps(), 9600);
|
||||
|
@ -235,7 +235,7 @@ impl FskBitrate {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskBitrate;
|
||||
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_raw(0x7D00);
|
||||
/// assert_eq!(BITRATE.as_bps(), 32_000);
|
||||
|
@ -251,7 +251,7 @@ impl FskBitrate {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskBitrate;
|
||||
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||
///
|
||||
/// const BITS_PER_SEC: u32 = 9600;
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(BITS_PER_SEC);
|
||||
|
@ -296,7 +296,7 @@ impl FskFdev {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskFdev;
|
||||
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||
///
|
||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
||||
|
@ -317,7 +317,7 @@ impl FskFdev {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskFdev;
|
||||
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||
///
|
||||
/// const FDEV: FskFdev = FskFdev::from_raw(0x8000);
|
||||
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
||||
|
@ -333,7 +333,7 @@ impl FskFdev {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskFdev;
|
||||
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||
///
|
||||
/// const HERTZ: u32 = 31_250;
|
||||
/// const FDEV: FskFdev = FskFdev::from_hertz(HERTZ);
|
||||
|
@ -348,7 +348,7 @@ impl FskFdev {
|
|||
}
|
||||
}
|
||||
|
||||
/// (G)FSK modulation paramters.
|
||||
/// (G)FSK modulation parameters.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct FskModParams {
|
||||
|
@ -363,7 +363,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::FskModParams;
|
||||
/// use stm32wlxx_hal::subghz::FskModParams;
|
||||
///
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new();
|
||||
/// ```
|
||||
|
@ -394,7 +394,7 @@ impl FskModParams {
|
|||
/// Setting the bitrate to 32,000 bits per second.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskBitrate, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskBitrate, FskModParams};
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(32_000);
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
||||
|
@ -412,7 +412,7 @@ impl FskModParams {
|
|||
/// Setting the bitrate to 32,000 bits per second.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskBitrate, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskBitrate, FskModParams};
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(32_000);
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
||||
|
@ -434,7 +434,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskModParams, FskPulseShape};
|
||||
/// use stm32wlxx_hal::subghz::{FskModParams, FskPulseShape};
|
||||
///
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_pulse_shape(FskPulseShape::Bt03);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice()[4], 0x08);
|
||||
|
@ -453,7 +453,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskModParams};
|
||||
///
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
||||
/// assert_eq!(MOD_PARAMS.bandwidth(), Ok(FskBandwidth::Bw9));
|
||||
|
@ -467,7 +467,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskModParams};
|
||||
///
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice()[5], 0x1E);
|
||||
|
@ -483,7 +483,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskFdev, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskFdev, FskModParams};
|
||||
///
|
||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
||||
|
@ -499,7 +499,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskFdev, FskModParams};
|
||||
/// use stm32wlxx_hal::subghz::{FskFdev, FskModParams};
|
||||
///
|
||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
||||
|
@ -536,7 +536,7 @@ impl FskModParams {
|
|||
///
|
||||
/// ```
|
||||
/// extern crate static_assertions as sa;
|
||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskBitrate, FskFdev, FskModParams, FskPulseShape};
|
||||
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskBitrate, FskFdev, FskModParams, FskPulseShape};
|
||||
///
|
||||
/// const MOD_PARAMS: FskModParams = FskModParams::new()
|
||||
/// .set_bitrate(FskBitrate::from_bps(20_000))
|
||||
|
@ -576,7 +576,7 @@ impl FskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskBitrate, FskFdev, FskModParams, FskPulseShape};
|
||||
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskBitrate, FskFdev, FskModParams, FskPulseShape};
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(20_000);
|
||||
/// const PULSE_SHAPE: FskPulseShape = FskPulseShape::Bt03;
|
||||
|
@ -608,6 +608,9 @@ impl Default for FskModParams {
|
|||
/// LoRa spreading factor.
|
||||
///
|
||||
/// Argument of [`LoRaModParams::set_sf`].
|
||||
///
|
||||
/// Higher spreading factors improve receiver sensitivity, but reduce bit rate
|
||||
/// and increase power consumption.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
#[repr(u8)]
|
||||
|
@ -671,7 +674,7 @@ impl LoRaBandwidth {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaBandwidth;
|
||||
/// use stm32wlxx_hal::subghz::LoRaBandwidth;
|
||||
///
|
||||
/// assert_eq!(LoRaBandwidth::Bw7.hertz(), 7_810);
|
||||
/// assert_eq!(LoRaBandwidth::Bw10.hertz(), 10_420);
|
||||
|
@ -715,23 +718,38 @@ impl PartialOrd for LoRaBandwidth {
|
|||
/// LoRa forward error correction coding rate.
|
||||
///
|
||||
/// Argument of [`LoRaModParams::set_cr`].
|
||||
///
|
||||
/// A higher coding rate provides better immunity to interference at the expense
|
||||
/// of longer transmission time.
|
||||
/// In normal conditions [`CodingRate::Cr45`] provides the best trade off.
|
||||
/// In case of strong interference, a higher coding rate may be used.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
#[repr(u8)]
|
||||
pub enum CodingRate {
|
||||
/// No forward error correction coding rate 4/4
|
||||
///
|
||||
/// Overhead ratio of 1
|
||||
Cr44 = 0x00,
|
||||
/// Forward error correction coding rate 4/5
|
||||
///
|
||||
/// Overhead ratio of 1.25
|
||||
Cr45 = 0x1,
|
||||
/// Forward error correction coding rate 4/6
|
||||
///
|
||||
/// Overhead ratio of 1.5
|
||||
Cr46 = 0x2,
|
||||
/// Forward error correction coding rate 4/7
|
||||
///
|
||||
/// Overhead ratio of 1.75
|
||||
Cr47 = 0x3,
|
||||
/// Forward error correction coding rate 4/8
|
||||
///
|
||||
/// Overhead ratio of 2
|
||||
Cr48 = 0x4,
|
||||
}
|
||||
|
||||
/// LoRa modulation paramters.
|
||||
/// LoRa modulation parameters.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
|
||||
|
@ -747,7 +765,7 @@ impl LoRaModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaModParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaModParams;
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new();
|
||||
/// assert_eq!(MOD_PARAMS, LoRaModParams::default());
|
||||
|
@ -769,7 +787,7 @@ impl LoRaModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{LoRaModParams, SpreadingFactor};
|
||||
/// use stm32wlxx_hal::subghz::{LoRaModParams, SpreadingFactor};
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_sf(SpreadingFactor::Sf7);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x07, 0x00, 0x00, 0x00]);
|
||||
|
@ -785,7 +803,7 @@ impl LoRaModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{LoRaBandwidth, LoRaModParams};
|
||||
/// use stm32wlxx_hal::subghz::{LoRaBandwidth, LoRaModParams};
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_bw(LoRaBandwidth::Bw125);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x04, 0x00, 0x00]);
|
||||
|
@ -798,10 +816,12 @@ impl LoRaModParams {
|
|||
|
||||
/// Set the forward error correction coding rate.
|
||||
///
|
||||
/// See [`CodingRate`] for more information.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CodingRate, LoRaModParams};
|
||||
/// use stm32wlxx_hal::subghz::{CodingRate, LoRaModParams};
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_cr(CodingRate::Cr45);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x01, 0x00]);
|
||||
|
@ -814,10 +834,29 @@ impl LoRaModParams {
|
|||
|
||||
/// Set low data rate optimization enable.
|
||||
///
|
||||
/// For low data rates (typically high SF or low BW) and very long payloads
|
||||
/// (may last several seconds), the low data rate optimization (LDRO) can be
|
||||
/// enabled.
|
||||
/// This reduces the number of bits per symbol to the given SF minus 2,
|
||||
/// to allow the receiver to have a better tracking of the LoRa receive
|
||||
/// signal.
|
||||
/// Depending on the payload length, the low data rate optimization is
|
||||
/// usually recommended when the LoRa symbol time is equal or above
|
||||
/// 16.38 ms.
|
||||
/// When using LoRa modulation, the total frequency drift over the packet
|
||||
/// time must be kept lower than Freq_drift_max:
|
||||
///
|
||||
/// Freq_drift_max = BW / (3 × 2SF)
|
||||
///
|
||||
/// When possible, enabling the low data rate optimization, relaxes the
|
||||
/// total frequency drift over the packet time by 16:
|
||||
///
|
||||
/// Freq_drift_optimise_max = 16 × Freq_drift_max
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaModParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaModParams;
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_ldro_en(true);
|
||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x00, 0x01]);
|
||||
|
@ -833,7 +872,7 @@ impl LoRaModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CodingRate, LoRaBandwidth, LoRaModParams, SpreadingFactor};
|
||||
/// use stm32wlxx_hal::subghz::{CodingRate, LoRaBandwidth, LoRaModParams, SpreadingFactor};
|
||||
///
|
||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new()
|
||||
/// .set_sf(SpreadingFactor::Sf7)
|
||||
|
@ -854,7 +893,7 @@ impl Default for LoRaModParams {
|
|||
}
|
||||
}
|
||||
|
||||
/// BPSK modulation paramters.
|
||||
/// BPSK modulation parameters.
|
||||
///
|
||||
/// **Note:** There is no method to set the pulse shape because there is only
|
||||
/// one valid pulse shape (Gaussian BT 0.5).
|
||||
|
@ -872,7 +911,7 @@ impl BpskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BpskModParams;
|
||||
/// use stm32wlxx_hal::subghz::BpskModParams;
|
||||
///
|
||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new();
|
||||
/// assert_eq!(MOD_PARAMS, BpskModParams::default());
|
||||
|
@ -891,7 +930,7 @@ impl BpskModParams {
|
|||
/// Setting the bitrate to 600 bits per second.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{BpskModParams, FskBitrate};
|
||||
/// use stm32wlxx_hal::subghz::{BpskModParams, FskBitrate};
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(600);
|
||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
||||
|
@ -913,7 +952,7 @@ impl BpskModParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{BpskModParams, FskBitrate};
|
||||
/// use stm32wlxx_hal::subghz::{BpskModParams, FskBitrate};
|
||||
///
|
||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(100);
|
||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
||||
|
|
|
@ -31,7 +31,7 @@ impl OpError {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::OpError;
|
||||
/// use stm32wlxx_hal::subghz::OpError;
|
||||
///
|
||||
/// assert_eq!(OpError::PaRampError.mask(), 0b1_0000_0000);
|
||||
/// assert_eq!(OpError::PllLockError.mask(), 0b0_0100_0000);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// Power amplifier configuration paramters.
|
||||
/// Power amplifier configuration parameters.
|
||||
///
|
||||
/// Argument of [`set_pa_config`].
|
||||
///
|
||||
|
@ -52,7 +52,7 @@ impl PaConfig {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PaConfig;
|
||||
/// use stm32wlxx_hal::subghz::PaConfig;
|
||||
///
|
||||
/// const PA_CONFIG: PaConfig = PaConfig::new();
|
||||
/// ```
|
||||
|
@ -71,14 +71,14 @@ impl PaConfig {
|
|||
/// # Caution
|
||||
///
|
||||
/// The following restrictions must be observed to avoid over-stress on the PA:
|
||||
/// * LP PA mode with synthesis frequency > 400 MHz, PaDutyCycle must be < 0x7.
|
||||
/// * LP PA mode with synthesis frequency < 400 MHz, PaDutyCycle must be < 0x4.
|
||||
/// * HP PA mode, PaDutyCycle must be < 0x4
|
||||
/// * LP PA mode with synthesis frequency > 400 MHz, `pa_duty_cycle` must be < 0x7.
|
||||
/// * LP PA mode with synthesis frequency < 400 MHz, `pa_duty_cycle` must be < 0x4.
|
||||
/// * HP PA mode, `pa_duty_cycle` must be < 0x4
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{PaConfig, PaSel};
|
||||
/// use stm32wlxx_hal::subghz::{PaConfig, PaSel};
|
||||
///
|
||||
/// const PA_CONFIG: PaConfig = PaConfig::new().set_pa(PaSel::Lp).set_pa_duty_cycle(0x4);
|
||||
/// # assert_eq!(PA_CONFIG.as_slice()[1], 0x04);
|
||||
|
@ -96,7 +96,7 @@ impl PaConfig {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{PaConfig, PaSel};
|
||||
/// use stm32wlxx_hal::subghz::{PaConfig, PaSel};
|
||||
///
|
||||
/// const PA_CONFIG: PaConfig = PaConfig::new().set_pa(PaSel::Hp).set_hp_max(0x2);
|
||||
/// # assert_eq!(PA_CONFIG.as_slice()[2], 0x02);
|
||||
|
@ -112,7 +112,7 @@ impl PaConfig {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{PaConfig, PaSel};
|
||||
/// use stm32wlxx_hal::subghz::{PaConfig, PaSel};
|
||||
///
|
||||
/// const PA_CONFIG_HP: PaConfig = PaConfig::new().set_pa(PaSel::Hp);
|
||||
/// const PA_CONFIG_LP: PaConfig = PaConfig::new().set_pa(PaSel::Lp);
|
||||
|
@ -130,7 +130,7 @@ impl PaConfig {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{PaConfig, PaSel};
|
||||
/// use stm32wlxx_hal::subghz::{PaConfig, PaSel};
|
||||
///
|
||||
/// const PA_CONFIG: PaConfig = PaConfig::new()
|
||||
/// .set_pa(PaSel::Hp)
|
||||
|
|
|
@ -91,7 +91,7 @@ impl GenericPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new();
|
||||
/// assert_eq!(PKT_PARAMS, GenericPacketParams::default());
|
||||
|
@ -119,7 +119,7 @@ impl GenericPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_preamble_len(0x1234);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
||||
|
@ -135,12 +135,12 @@ impl GenericPacketParams {
|
|||
self
|
||||
}
|
||||
|
||||
/// Preabmle detection length in number of bit symbols.
|
||||
/// Preamble detection length in number of bit symbols.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{GenericPacketParams, PreambleDetection};
|
||||
/// use stm32wlxx_hal::subghz::{GenericPacketParams, PreambleDetection};
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams =
|
||||
/// GenericPacketParams::new().set_preamble_detection(PreambleDetection::Bit8);
|
||||
|
@ -162,7 +162,7 @@ impl GenericPacketParams {
|
|||
/// Set the sync word length to 4 bytes (16 bits).
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_sync_word_len(16);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 0x10);
|
||||
|
@ -185,7 +185,7 @@ impl GenericPacketParams {
|
|||
/// Enable address on the node address.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{AddrComp, GenericPacketParams};
|
||||
/// use stm32wlxx_hal::subghz::{AddrComp, GenericPacketParams};
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams =
|
||||
/// GenericPacketParams::new().set_addr_comp(AddrComp::Node);
|
||||
|
@ -208,7 +208,7 @@ impl GenericPacketParams {
|
|||
/// Set the header type to a variable length.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{GenericPacketParams, HeaderType};
|
||||
/// use stm32wlxx_hal::subghz::{GenericPacketParams, HeaderType};
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams =
|
||||
/// GenericPacketParams::new().set_header_type(HeaderType::Variable);
|
||||
|
@ -225,7 +225,7 @@ impl GenericPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_payload_len(12);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[7], 12);
|
||||
|
@ -241,7 +241,7 @@ impl GenericPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CrcType, GenericPacketParams};
|
||||
/// use stm32wlxx_hal::subghz::{CrcType, GenericPacketParams};
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams =
|
||||
/// GenericPacketParams::new().set_crc_type(CrcType::Byte2Inverted);
|
||||
|
@ -260,7 +260,7 @@ impl GenericPacketParams {
|
|||
/// Enable whitening.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_whitening_enable(true);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[9], 1);
|
||||
|
@ -276,7 +276,7 @@ impl GenericPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{
|
||||
/// use stm32wlxx_hal::subghz::{
|
||||
/// AddrComp, CrcType, GenericPacketParams, HeaderType, PreambleDetection,
|
||||
/// };
|
||||
///
|
||||
|
@ -322,7 +322,7 @@ impl LoRaPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new();
|
||||
/// assert_eq!(PKT_PARAMS, LoRaPacketParams::default());
|
||||
|
@ -349,7 +349,7 @@ impl LoRaPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_preamble_len(0x1234);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
||||
|
@ -372,7 +372,7 @@ impl LoRaPacketParams {
|
|||
/// Set the payload type to a fixed length.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{HeaderType, LoRaPacketParams};
|
||||
/// use stm32wlxx_hal::subghz::{HeaderType, LoRaPacketParams};
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_header_type(HeaderType::Fixed);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x01);
|
||||
|
@ -388,7 +388,7 @@ impl LoRaPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_payload_len(12);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 12);
|
||||
|
@ -406,7 +406,7 @@ impl LoRaPacketParams {
|
|||
/// Enable CRC.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_crc_en(true);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[5], 0x1);
|
||||
|
@ -424,7 +424,7 @@ impl LoRaPacketParams {
|
|||
/// Use an inverted IQ setup.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_invert_iq(true);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[6], 0x1);
|
||||
|
@ -440,7 +440,7 @@ impl LoRaPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{HeaderType, LoRaPacketParams};
|
||||
/// use stm32wlxx_hal::subghz::{HeaderType, LoRaPacketParams};
|
||||
///
|
||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new()
|
||||
/// .set_preamble_len(5 * 8)
|
||||
|
@ -482,7 +482,7 @@ impl BpskPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BpskPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::BpskPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new();
|
||||
/// assert_eq!(PKT_PARAMS, BpskPacketParams::default());
|
||||
|
@ -500,7 +500,7 @@ impl BpskPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::BpskPacketParams;
|
||||
/// use stm32wlxx_hal::subghz::BpskPacketParams;
|
||||
///
|
||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(12);
|
||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 12);
|
||||
|
@ -516,7 +516,7 @@ impl BpskPacketParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{BpskPacketParams, HeaderType};
|
||||
/// use stm32wlxx_hal::subghz::{BpskPacketParams, HeaderType};
|
||||
///
|
||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(24);
|
||||
///
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::{Ratio, Status};
|
|||
/// Returned by [`fsk_packet_status`].
|
||||
///
|
||||
/// [`fsk_packet_status`]: super::SubGhz::fsk_packet_status
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct FskPacketStatus {
|
||||
buf: [u8; 4],
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ impl FskPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CmdStatus, FskPacketStatus, Status, StatusMode};
|
||||
/// use stm32wlxx_hal::subghz::{CmdStatus, FskPacketStatus, Status, StatusMode};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0x54, 0, 0, 0];
|
||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
||||
|
@ -34,32 +34,32 @@ impl FskPacketStatus {
|
|||
Status::from_raw(self.buf[0])
|
||||
}
|
||||
|
||||
/// Returns `true` if a preabmle error occured.
|
||||
/// Returns `true` if a preamble error occurred.
|
||||
pub const fn preamble_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 7)) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if a synchronization error occured.
|
||||
/// Returns `true` if a synchronization error occurred.
|
||||
pub const fn sync_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 6)) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if an address error occured.
|
||||
/// Returns `true` if an address error occurred.
|
||||
pub const fn addr_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 5)) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if an crc error occured.
|
||||
/// Returns `true` if an CRC error occurred.
|
||||
pub const fn crc_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 4)) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if a length error occured.
|
||||
/// Returns `true` if a length error occurred.
|
||||
pub const fn length_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 3)) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if an abort error occured.
|
||||
/// Returns `true` if an abort error occurred.
|
||||
pub const fn abort_err(&self) -> bool {
|
||||
(self.buf[1] & (1 << 2)) != 0
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl FskPacketStatus {
|
|||
(self.buf[1] & 1) != 0
|
||||
}
|
||||
|
||||
/// Returns `true` if any error occured.
|
||||
/// Returns `true` if any error occurred.
|
||||
pub const fn any_err(&self) -> bool {
|
||||
(self.buf[1] & 0xFC) != 0
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl FskPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::{subghz::FskPacketStatus, Ratio};
|
||||
/// use stm32wlxx_hal::{subghz::FskPacketStatus, Ratio};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0, 0, 80, 0];
|
||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
||||
|
@ -103,7 +103,7 @@ impl FskPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::{subghz::FskPacketStatus, Ratio};
|
||||
/// use stm32wlxx_hal::{subghz::FskPacketStatus, Ratio};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0, 0, 0, 100];
|
||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
||||
|
@ -147,7 +147,7 @@ impl defmt::Format for FskPacketStatus {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for FskPacketStatus {
|
||||
impl core::fmt::Debug for FskPacketStatus {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("FskPacketStatus")
|
||||
.field("status", &self.status())
|
||||
|
@ -170,7 +170,7 @@ impl core::fmt::Display for FskPacketStatus {
|
|||
/// Returned by [`lora_packet_status`].
|
||||
///
|
||||
/// [`lora_packet_status`]: super::SubGhz::lora_packet_status
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct LoRaPacketStatus {
|
||||
buf: [u8; 4],
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ impl LoRaPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CmdStatus, LoRaPacketStatus, Status, StatusMode};
|
||||
/// use stm32wlxx_hal::subghz::{CmdStatus, LoRaPacketStatus, Status, StatusMode};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0x54, 0, 0, 0];
|
||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||
|
@ -206,7 +206,7 @@ impl LoRaPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
/// use stm32wlxx_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0, 80, 0, 0];
|
||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||
|
@ -223,7 +223,7 @@ impl LoRaPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
/// use stm32wlxx_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0, 0, 40, 0];
|
||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||
|
@ -240,7 +240,7 @@ impl LoRaPacketStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
/// use stm32wlxx_hal::{subghz::LoRaPacketStatus, Ratio};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 4] = [0, 0, 0, 80];
|
||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||
|
@ -270,7 +270,7 @@ impl defmt::Format for LoRaPacketStatus {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for LoRaPacketStatus {
|
||||
impl core::fmt::Debug for LoRaPacketStatus {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("LoRaPacketStatus")
|
||||
.field("status", &self.status())
|
||||
|
|
|
@ -23,7 +23,7 @@ impl PacketType {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PacketType;
|
||||
/// use stm32wlxx_hal::subghz::PacketType;
|
||||
///
|
||||
/// assert_eq!(PacketType::from_raw(0), Ok(PacketType::Fsk));
|
||||
/// assert_eq!(PacketType::from_raw(1), Ok(PacketType::LoRa));
|
||||
|
|
|
@ -50,7 +50,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_sync_det_en(true);
|
||||
/// ```
|
||||
|
@ -70,7 +70,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||
/// assert_eq!(pc.sync_det_en(), true);
|
||||
|
@ -88,7 +88,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_cont_tx_en(true);
|
||||
/// ```
|
||||
|
@ -107,7 +107,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||
/// assert_eq!(pc.cont_tx_en(), false);
|
||||
|
@ -133,7 +133,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{InfSeqSel, PktCtrl};
|
||||
/// use stm32wlxx_hal::subghz::{InfSeqSel, PktCtrl};
|
||||
///
|
||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||
/// assert_eq!(pc.inf_seq_sel(), InfSeqSel::Five);
|
||||
|
@ -159,12 +159,12 @@ impl PktCtrl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Enable infinute sequence generation.
|
||||
/// Enable infinite sequence generation.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_inf_seq_en(true);
|
||||
/// ```
|
||||
|
@ -178,12 +178,12 @@ impl PktCtrl {
|
|||
self
|
||||
}
|
||||
|
||||
/// Returns `true` if infinute sequence generation is enabled.
|
||||
/// Returns `true` if infinite sequence generation is enabled.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||
/// assert_eq!(pc.inf_seq_en(), false);
|
||||
|
@ -201,7 +201,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_whitening_init(true);
|
||||
/// ```
|
||||
|
@ -220,7 +220,7 @@ impl PktCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PktCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||
///
|
||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||
/// assert_eq!(pc.whitening_init(), true);
|
||||
|
|
|
@ -21,7 +21,7 @@ impl CurrentLim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CurrentLim;
|
||||
/// use stm32wlxx_hal::subghz::CurrentLim;
|
||||
///
|
||||
/// assert_eq!(CurrentLim::Milli25.as_milliamps(), 25);
|
||||
/// assert_eq!(CurrentLim::Milli50.as_milliamps(), 50);
|
||||
|
@ -74,7 +74,7 @@ impl PwrCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PwrCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PwrCtrl;
|
||||
///
|
||||
/// const PWR_CTRL: PwrCtrl = PwrCtrl::RESET.set_current_lim_en(true);
|
||||
/// # assert_eq!(u8::from(PWR_CTRL), 0x50u8);
|
||||
|
@ -94,7 +94,7 @@ impl PwrCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::PwrCtrl;
|
||||
/// use stm32wlxx_hal::subghz::PwrCtrl;
|
||||
///
|
||||
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
||||
/// assert_eq!(pc.current_limit_en(), true);
|
||||
|
@ -120,7 +120,7 @@ impl PwrCtrl {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CurrentLim, PwrCtrl};
|
||||
/// use stm32wlxx_hal::subghz::{CurrentLim, PwrCtrl};
|
||||
///
|
||||
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
||||
/// assert_eq!(pc.current_lim(), CurrentLim::Milli50);
|
||||
|
|
|
@ -15,7 +15,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// assert_eq!(RfFreq::F915.freq(), 915_000_000);
|
||||
/// ```
|
||||
|
@ -26,7 +26,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// assert_eq!(RfFreq::F868.freq(), 868_000_000);
|
||||
/// ```
|
||||
|
@ -37,7 +37,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// assert_eq!(RfFreq::F433.freq(), 433_000_000);
|
||||
/// ```
|
||||
|
@ -52,7 +52,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// const FREQ: RfFreq = RfFreq::from_raw(0x39300000);
|
||||
/// assert_eq!(FREQ, RfFreq::F915);
|
||||
|
@ -78,7 +78,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// const FREQ: RfFreq = RfFreq::from_frequency(915_000_000);
|
||||
/// assert_eq!(FREQ, RfFreq::F915);
|
||||
|
@ -97,7 +97,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// assert_eq!(RfFreq::from_raw(0x39300000).freq(), 915_000_000);
|
||||
/// ```
|
||||
|
@ -110,7 +110,7 @@ impl RfFreq {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::RfFreq;
|
||||
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||
///
|
||||
/// assert_eq!(RfFreq::F915.as_slice(), &[0x86, 0x39, 0x30, 0x00, 0x00]);
|
||||
/// ```
|
||||
|
|
|
@ -42,7 +42,7 @@ impl SleepCfg {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::SleepCfg;
|
||||
/// use stm32wlxx_hal::subghz::SleepCfg;
|
||||
///
|
||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new();
|
||||
/// assert_eq!(SLEEP_CFG, SleepCfg::default());
|
||||
|
@ -57,7 +57,7 @@ impl SleepCfg {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{SleepCfg, Startup};
|
||||
/// use stm32wlxx_hal::subghz::{SleepCfg, Startup};
|
||||
///
|
||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_startup(Startup::Cold);
|
||||
/// # assert_eq!(u8::from(SLEEP_CFG), 0b001);
|
||||
|
@ -77,7 +77,7 @@ impl SleepCfg {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::SleepCfg;
|
||||
/// use stm32wlxx_hal::subghz::SleepCfg;
|
||||
///
|
||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_rtc_wakeup_en(false);
|
||||
/// # assert_eq!(u8::from(SLEEP_CFG), 0b100);
|
||||
|
|
|
@ -21,7 +21,7 @@ impl SmpsDrv {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::SmpsDrv;
|
||||
/// use stm32wlxx_hal::subghz::SmpsDrv;
|
||||
///
|
||||
/// assert_eq!(SmpsDrv::Milli20.as_milliamps(), 20);
|
||||
/// assert_eq!(SmpsDrv::Milli40.as_milliamps(), 40);
|
||||
|
|
|
@ -26,7 +26,7 @@ impl FskStats {
|
|||
///
|
||||
/// [`fsk_stats`]: super::SubGhz::fsk_stats
|
||||
/// [`lora_stats`]: super::SubGhz::lora_stats
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
||||
#[derive(Eq, PartialEq, Clone, Copy)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct Stats<ModType> {
|
||||
status: Status,
|
||||
|
@ -52,7 +52,7 @@ impl<ModType> Stats<ModType> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CmdStatus, FskStats, Stats, StatusMode};
|
||||
/// use stm32wlxx_hal::subghz::{CmdStatus, FskStats, Stats, StatusMode};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 0, 0, 0];
|
||||
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||
|
@ -68,7 +68,7 @@ impl<ModType> Stats<ModType> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{FskStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 3, 0, 0, 0, 0];
|
||||
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||
|
@ -83,7 +83,7 @@ impl<ModType> Stats<ModType> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{LoRaStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{LoRaStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 1, 0, 0];
|
||||
/// let stats: Stats<LoRaStats> = Stats::from_raw_lora(example_data_from_radio);
|
||||
|
@ -100,7 +100,7 @@ impl Stats<FskStats> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{FskStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 0, 0, 0];
|
||||
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||
|
@ -114,7 +114,7 @@ impl Stats<FskStats> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{FskStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{FskStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 0, 0, 1];
|
||||
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||
|
@ -131,7 +131,7 @@ impl Stats<LoRaStats> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{LoRaStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{LoRaStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 0, 0, 0];
|
||||
/// let stats: Stats<LoRaStats> = Stats::from_raw_lora(example_data_from_radio);
|
||||
|
@ -145,7 +145,7 @@ impl Stats<LoRaStats> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{LoRaStats, Stats};
|
||||
/// use stm32wlxx_hal::subghz::{LoRaStats, Stats};
|
||||
///
|
||||
/// let example_data_from_radio: [u8; 7] = [0x54, 0, 0, 0, 0, 0, 1];
|
||||
/// let stats: Stats<LoRaStats> = Stats::from_raw_lora(example_data_from_radio);
|
||||
|
@ -156,7 +156,7 @@ impl Stats<LoRaStats> {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Stats<FskStats> {
|
||||
impl core::fmt::Debug for Stats<FskStats> {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("Stats")
|
||||
.field("status", &self.status())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// sub-GHz radio operating mode.
|
||||
///
|
||||
/// See `Get_Status` under section 5.8.5 "Communcation status information commands"
|
||||
/// See `Get_Status` under section 5.8.5 "Communication status information commands"
|
||||
/// in the reference manual.
|
||||
///
|
||||
/// This is returned by [`Status::mode`].
|
||||
|
@ -26,7 +26,7 @@ impl StatusMode {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::StatusMode;
|
||||
/// use stm32wlxx_hal::subghz::StatusMode;
|
||||
///
|
||||
/// assert_eq!(StatusMode::from_raw(0x2), Ok(StatusMode::StandbyRc));
|
||||
/// assert_eq!(StatusMode::from_raw(0x3), Ok(StatusMode::StandbyHse));
|
||||
|
@ -50,7 +50,7 @@ impl StatusMode {
|
|||
|
||||
/// Command status.
|
||||
///
|
||||
/// See `Get_Status` under section 5.8.5 "Communcation status information commands"
|
||||
/// See `Get_Status` under section 5.8.5 "Communication status information commands"
|
||||
/// in the reference manual.
|
||||
///
|
||||
/// This is returned by [`Status::cmd`].
|
||||
|
@ -89,7 +89,7 @@ impl CmdStatus {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::CmdStatus;
|
||||
/// use stm32wlxx_hal::subghz::CmdStatus;
|
||||
///
|
||||
/// assert_eq!(CmdStatus::from_raw(0x2), Ok(CmdStatus::Avaliable));
|
||||
/// assert_eq!(CmdStatus::from_raw(0x3), Ok(CmdStatus::Timeout));
|
||||
|
@ -116,7 +116,7 @@ impl CmdStatus {
|
|||
/// This is returned by [`status`].
|
||||
///
|
||||
/// [`status`]: super::SubGhz::status
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
pub struct Status(u8);
|
||||
|
||||
impl From<u8> for Status {
|
||||
|
@ -138,7 +138,7 @@ impl Status {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CmdStatus, Status, StatusMode};
|
||||
/// use stm32wlxx_hal::subghz::{CmdStatus, Status, StatusMode};
|
||||
///
|
||||
/// const STATUS: Status = Status::from_raw(0x54_u8);
|
||||
/// assert_eq!(STATUS.mode(), Ok(StatusMode::Rx));
|
||||
|
@ -153,7 +153,7 @@ impl Status {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{Status, StatusMode};
|
||||
/// use stm32wlxx_hal::subghz::{Status, StatusMode};
|
||||
///
|
||||
/// let status: Status = 0xACu8.into();
|
||||
/// assert_eq!(status.mode(), Ok(StatusMode::StandbyRc));
|
||||
|
@ -164,13 +164,13 @@ impl Status {
|
|||
|
||||
/// Command status.
|
||||
///
|
||||
/// For some reason `Err(1)` is a pretty common return value for this,
|
||||
/// despite being a reserved value.
|
||||
/// This method frequently returns reserved values such as `Err(1)`.
|
||||
/// ST support has confirmed that this is normal and should be ignored.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{CmdStatus, Status};
|
||||
/// use stm32wlxx_hal::subghz::{CmdStatus, Status};
|
||||
///
|
||||
/// let status: Status = 0xACu8.into();
|
||||
/// assert_eq!(status.cmd(), Ok(CmdStatus::Complete));
|
||||
|
@ -180,7 +180,7 @@ impl Status {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Status {
|
||||
impl core::fmt::Debug for Status {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("Status")
|
||||
.field("mode", &self.mode())
|
||||
|
|
|
@ -49,7 +49,7 @@ impl TcxoTrim {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::TcxoTrim;
|
||||
/// use stm32wlxx_hal::subghz::TcxoTrim;
|
||||
///
|
||||
/// assert_eq!(TcxoTrim::Volts1pt6.as_millivolts(), 1600);
|
||||
/// assert_eq!(TcxoTrim::Volts1pt7.as_millivolts(), 1700);
|
||||
|
@ -93,7 +93,7 @@ impl TcxoMode {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::TcxoMode;
|
||||
/// use stm32wlxx_hal::subghz::TcxoMode;
|
||||
///
|
||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new();
|
||||
/// ```
|
||||
|
@ -111,7 +111,7 @@ impl TcxoMode {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{TcxoMode, TcxoTrim};
|
||||
/// use stm32wlxx_hal::subghz::{TcxoMode, TcxoTrim};
|
||||
///
|
||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new().set_txco_trim(TcxoTrim::Volts1pt6);
|
||||
/// # assert_eq!(TCXO_MODE.as_slice()[1], 0x00);
|
||||
|
@ -128,7 +128,7 @@ impl TcxoMode {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::{TcxoMode, Timeout};
|
||||
/// use stm32wlxx_hal::subghz::{TcxoMode, Timeout};
|
||||
///
|
||||
/// // 15.625 ms timeout
|
||||
/// const TIMEOUT: Timeout = Timeout::from_duration_sat(Duration::from_millis(15_625));
|
||||
|
@ -151,7 +151,7 @@ impl TcxoMode {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{TcxoMode, TcxoTrim, Timeout};
|
||||
/// use stm32wlxx_hal::subghz::{TcxoMode, TcxoTrim, Timeout};
|
||||
///
|
||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new()
|
||||
/// .set_txco_trim(TcxoTrim::Volts1pt7)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use core::time::Duration;
|
||||
|
||||
use crate::subghz::value_error::ValueError;
|
||||
use super::ValueError;
|
||||
|
||||
const fn abs_diff(a: u64, b: u64) -> u64 {
|
||||
if a > b {
|
||||
|
@ -20,9 +20,9 @@ const fn abs_diff(a: u64, b: u64) -> u64 {
|
|||
/// Each timeout has 3 bytes, with a resolution of 15.625µs per bit, giving a
|
||||
/// range of 0s to 262.143984375s.
|
||||
///
|
||||
/// [`set_rx`]: crate::subghz::SubGhz::set_rx
|
||||
/// [`set_tx`]: crate::subghz::SubGhz::set_tx
|
||||
/// [`TcxoMode`]: crate::subghz::TcxoMode
|
||||
/// [`set_rx`]: super::SubGhz::set_rx
|
||||
/// [`set_tx`]: super::SubGhz::set_tx
|
||||
/// [`TcxoMode`]: super::TcxoMode
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct Timeout {
|
||||
|
@ -39,7 +39,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// const TIMEOUT: Timeout = Timeout::DISABLED;
|
||||
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_secs(0));
|
||||
|
@ -52,7 +52,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// const TIMEOUT: Timeout = Timeout::MIN;
|
||||
/// assert_eq!(TIMEOUT.into_bits(), 1);
|
||||
|
@ -65,7 +65,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// const TIMEOUT: Timeout = Timeout::MAX;
|
||||
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_nanos(262_143_984_375));
|
||||
|
@ -80,7 +80,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// Timeout::RESOLUTION.as_nanos(),
|
||||
|
@ -97,7 +97,7 @@ impl Timeout {
|
|||
/// Use [`from_millis_sat`](Self::from_millis_sat) for runtime timeout
|
||||
/// construction.
|
||||
/// This is not _that_ useful right now, it is simply future proofing for a
|
||||
/// time when `Result::unwrap` is avaliable for `const fn`.
|
||||
/// time when `Result::unwrap` is available for `const fn`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -105,7 +105,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::{Timeout, ValueError};
|
||||
/// use stm32wlxx_hal::subghz::{Timeout, ValueError};
|
||||
///
|
||||
/// const MIN: Duration = Timeout::RESOLUTION;
|
||||
/// assert_eq!(Timeout::from_duration(MIN).unwrap(), Timeout::MIN);
|
||||
|
@ -115,7 +115,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::{Timeout, ValueError};
|
||||
/// use stm32wlxx_hal::subghz::{Timeout, ValueError};
|
||||
///
|
||||
/// const LOWER_LIMIT_NANOS: u128 = 7813;
|
||||
/// const TOO_LOW_NANOS: u128 = LOWER_LIMIT_NANOS - 1;
|
||||
|
@ -130,7 +130,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::{Timeout, ValueError};
|
||||
/// use stm32wlxx_hal::subghz::{Timeout, ValueError};
|
||||
///
|
||||
/// const UPPER_LIMIT_NANOS: u128 = Timeout::MAX.as_nanos() as u128 + 7812;
|
||||
/// const TOO_HIGH_NANOS: u128 = UPPER_LIMIT_NANOS + 1;
|
||||
|
@ -186,7 +186,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// const DURATION_MAX_NS: u64 = 262_143_984_376;
|
||||
///
|
||||
|
@ -245,7 +245,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::from_millis_sat(0), Timeout::MIN);
|
||||
/// assert_eq!(Timeout::from_millis_sat(262_144), Timeout::MAX);
|
||||
|
@ -270,7 +270,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::from_raw(u32::MAX), Timeout::MAX);
|
||||
/// assert_eq!(Timeout::from_raw(0x00_FF_FF_FF), Timeout::MAX);
|
||||
|
@ -288,7 +288,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::MAX.as_nanos(), 262_143_984_375);
|
||||
/// assert_eq!(Timeout::DISABLED.as_nanos(), 0);
|
||||
|
@ -304,7 +304,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::MAX.as_micros(), 262_143_984);
|
||||
/// assert_eq!(Timeout::DISABLED.as_micros(), 0);
|
||||
|
@ -320,7 +320,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::MAX.as_millis(), 262_143);
|
||||
/// assert_eq!(Timeout::DISABLED.as_millis(), 0);
|
||||
|
@ -336,7 +336,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::MAX.as_secs(), 262);
|
||||
/// assert_eq!(Timeout::DISABLED.as_secs(), 0);
|
||||
|
@ -353,7 +353,7 @@ impl Timeout {
|
|||
///
|
||||
/// ```
|
||||
/// use core::time::Duration;
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// Timeout::MAX.as_duration(),
|
||||
|
@ -371,7 +371,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::from_raw(u32::MAX).into_bits(), 0x00FF_FFFF);
|
||||
/// assert_eq!(Timeout::from_raw(1).into_bits(), 1);
|
||||
|
@ -385,7 +385,7 @@ impl Timeout {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::Timeout;
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(Timeout::from_raw(u32::MAX).as_bytes(), [0xFF, 0xFF, 0xFF]);
|
||||
/// assert_eq!(Timeout::from_raw(1).as_bytes(), [0, 0, 1]);
|
||||
|
@ -397,6 +397,34 @@ impl Timeout {
|
|||
(self.bits & 0xFF) as u8,
|
||||
]
|
||||
}
|
||||
|
||||
/// Saturating timeout addition. Computes `self + rhs`, saturating at the
|
||||
/// numeric bounds instead of overflowing.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wlxx_hal::subghz::Timeout;
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// Timeout::from_raw(0xFF_FF_F0).saturating_add(Timeout::from_raw(0xFF)),
|
||||
/// Timeout::from_raw(0xFF_FF_FF)
|
||||
/// );
|
||||
/// assert_eq!(
|
||||
/// Timeout::from_raw(100).saturating_add(Timeout::from_raw(23)),
|
||||
/// Timeout::from_raw(123)
|
||||
/// );
|
||||
/// ```
|
||||
#[must_use = "saturating_add returns a new Timeout"]
|
||||
pub const fn saturating_add(self, rhs: Self) -> Self {
|
||||
// TODO: use core::cmp::min when it is const
|
||||
let bits: u32 = self.bits.saturating_add(rhs.bits);
|
||||
if bits > Self::MAX.bits {
|
||||
Self::MAX
|
||||
} else {
|
||||
Self { bits }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Timeout> for Duration {
|
||||
|
|
|
@ -100,7 +100,7 @@ impl TxParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::TxParams;
|
||||
/// use stm32wlxx_hal::subghz::TxParams;
|
||||
///
|
||||
/// const TX_PARAMS: TxParams = TxParams::new();
|
||||
/// assert_eq!(TX_PARAMS, TxParams::default());
|
||||
|
@ -136,7 +136,7 @@ impl TxParams {
|
|||
/// Set the output power to 0 dB.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{RampTime, TxParams};
|
||||
/// use stm32wlxx_hal::subghz::{RampTime, TxParams};
|
||||
///
|
||||
/// const TX_PARAMS: TxParams = TxParams::new().set_power(0x00);
|
||||
/// # assert_eq!(TX_PARAMS.as_slice()[1], 0x00);
|
||||
|
@ -156,7 +156,7 @@ impl TxParams {
|
|||
/// Set the ramp time to 200 microseconds.
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{RampTime, TxParams};
|
||||
/// use stm32wlxx_hal::subghz::{RampTime, TxParams};
|
||||
///
|
||||
/// const TX_PARAMS: TxParams = TxParams::new().set_ramp_time(RampTime::Micros200);
|
||||
/// # assert_eq!(TX_PARAMS.as_slice()[2], 0x04);
|
||||
|
@ -172,7 +172,7 @@ impl TxParams {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::{RampTime, TxParams};
|
||||
/// use stm32wlxx_hal::subghz::{RampTime, TxParams};
|
||||
///
|
||||
/// const TX_PARAMS: TxParams = TxParams::new()
|
||||
/// .set_ramp_time(RampTime::Micros80)
|
||||
|
|
|
@ -14,13 +14,13 @@ pub struct ValueError<T> {
|
|||
impl<T> ValueError<T> {
|
||||
/// Create a new `ValueError` for a value that exceeded an upper bound.
|
||||
///
|
||||
/// Unfortunately panic is not avaliable in `const fn`, so there are no
|
||||
/// Unfortunately panic is not available in `const fn`, so there are no
|
||||
/// guarantees on the value being greater than the limit.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||
/// assert!(ERROR.over());
|
||||
|
@ -36,13 +36,13 @@ impl<T> ValueError<T> {
|
|||
|
||||
/// Create a new `ValueError` for a value that exceeded a lower bound.
|
||||
///
|
||||
/// Unfortunately panic is not avaliable in `const fn`, so there are no
|
||||
/// Unfortunately panic is not available in `const fn`, so there are no
|
||||
/// guarantees on the value being less than the limit.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
||||
/// assert!(ERROR.under());
|
||||
|
@ -61,7 +61,7 @@ impl<T> ValueError<T> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||
/// assert_eq!(ERROR.value(), &101u8);
|
||||
|
@ -75,7 +75,7 @@ impl<T> ValueError<T> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||
/// assert_eq!(ERROR.limit(), &100u8);
|
||||
|
@ -89,7 +89,7 @@ impl<T> ValueError<T> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||
/// assert!(ERROR.over());
|
||||
|
@ -104,7 +104,7 @@ impl<T> ValueError<T> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use stm32wl_hal::subghz::ValueError;
|
||||
/// use stm32wlxx_hal::subghz::ValueError;
|
||||
///
|
||||
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
||||
/// assert!(ERROR.under());
|
||||
|
|
Loading…
Reference in a new issue