Sync subghz peripheral support with stm32wlxx-hal
This commit is contained in:
parent
624e46ccfb
commit
3696226fe8
24 changed files with 418 additions and 979 deletions
|
@ -33,7 +33,7 @@ impl BitSync {
|
||||||
/// Enable simple bit synchronization.
|
/// 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);
|
/// const BIT_SYNC: BitSync = BitSync::RESET.set_simple_bit_sync_en(true);
|
||||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x40u8);
|
/// # assert_eq!(u8::from(BIT_SYNC), 0x40u8);
|
||||||
|
@ -53,7 +53,7 @@ impl BitSync {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BitSync;
|
/// use stm32wlxx_hal::subghz::BitSync;
|
||||||
///
|
///
|
||||||
/// let bs: BitSync = BitSync::RESET;
|
/// let bs: BitSync = BitSync::RESET;
|
||||||
/// assert_eq!(bs.simple_bit_sync_en(), false);
|
/// assert_eq!(bs.simple_bit_sync_en(), false);
|
||||||
|
@ -73,7 +73,7 @@ impl BitSync {
|
||||||
/// Invert receive data.
|
/// Invert receive data.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BitSync;
|
/// use stm32wlxx_hal::subghz::BitSync;
|
||||||
///
|
///
|
||||||
/// const BIT_SYNC: BitSync = BitSync::RESET.set_rx_data_inv(true);
|
/// const BIT_SYNC: BitSync = BitSync::RESET.set_rx_data_inv(true);
|
||||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x20u8);
|
/// # assert_eq!(u8::from(BIT_SYNC), 0x20u8);
|
||||||
|
@ -93,7 +93,7 @@ impl BitSync {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BitSync;
|
/// use stm32wlxx_hal::subghz::BitSync;
|
||||||
///
|
///
|
||||||
/// let bs: BitSync = BitSync::RESET;
|
/// let bs: BitSync = BitSync::RESET;
|
||||||
/// assert_eq!(bs.rx_data_inv(), false);
|
/// assert_eq!(bs.rx_data_inv(), false);
|
||||||
|
@ -113,7 +113,7 @@ impl BitSync {
|
||||||
/// Enable normal bit synchronization.
|
/// 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);
|
/// const BIT_SYNC: BitSync = BitSync::RESET.set_norm_bit_sync_en(true);
|
||||||
/// # assert_eq!(u8::from(BIT_SYNC), 0x10u8);
|
/// # assert_eq!(u8::from(BIT_SYNC), 0x10u8);
|
||||||
|
@ -133,7 +133,7 @@ impl BitSync {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BitSync;
|
/// use stm32wlxx_hal::subghz::BitSync;
|
||||||
///
|
///
|
||||||
/// let bs: BitSync = BitSync::RESET;
|
/// let bs: BitSync = BitSync::RESET;
|
||||||
/// assert_eq!(bs.norm_bit_sync_en(), false);
|
/// assert_eq!(bs.norm_bit_sync_en(), false);
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl CadParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::CadParams;
|
/// use stm32wlxx_hal::subghz::CadParams;
|
||||||
///
|
///
|
||||||
/// const CAD_PARAMS: CadParams = CadParams::new();
|
/// const CAD_PARAMS: CadParams = CadParams::new();
|
||||||
/// assert_eq!(CAD_PARAMS, CadParams::default());
|
/// assert_eq!(CAD_PARAMS, CadParams::default());
|
||||||
|
@ -97,7 +97,7 @@ impl CadParams {
|
||||||
/// Set the number of symbols to 4.
|
/// 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);
|
/// const CAD_PARAMS: CadParams = CadParams::new().set_num_symbol(NbCadSymbol::S4);
|
||||||
/// # assert_eq!(CAD_PARAMS.as_slice()[1], 0x2);
|
/// # assert_eq!(CAD_PARAMS.as_slice()[1], 0x2);
|
||||||
|
@ -117,7 +117,7 @@ impl CadParams {
|
||||||
/// Setting the recommended value for a spreading factor of 7.
|
/// 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);
|
/// const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x20).set_det_min(0x10);
|
||||||
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x20);
|
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x20);
|
||||||
|
@ -140,7 +140,7 @@ impl CadParams {
|
||||||
/// Setting the recommended value for a spreading factor of 6.
|
/// 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);
|
/// const CAD_PARAMS: CadParams = CadParams::new().set_det_peak(0x18).set_det_min(0x10);
|
||||||
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x18);
|
/// # assert_eq!(CAD_PARAMS.as_slice()[2], 0x18);
|
||||||
|
@ -159,7 +159,7 @@ impl CadParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CadParams, ExitMode};
|
/// use stm32wlxx_hal::subghz::{CadParams, ExitMode};
|
||||||
///
|
///
|
||||||
/// const CAD_PARAMS: CadParams = CadParams::new().set_exit_mode(ExitMode::Standby);
|
/// const CAD_PARAMS: CadParams = CadParams::new().set_exit_mode(ExitMode::Standby);
|
||||||
/// # assert_eq!(CAD_PARAMS.as_slice()[4], 0x00);
|
/// # assert_eq!(CAD_PARAMS.as_slice()[4], 0x00);
|
||||||
|
@ -178,7 +178,7 @@ impl CadParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CadParams, ExitMode, Timeout};
|
/// use stm32wlxx_hal::subghz::{CadParams, ExitMode, Timeout};
|
||||||
///
|
///
|
||||||
/// const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
|
/// const TIMEOUT: Timeout = Timeout::from_raw(0x123456);
|
||||||
/// const CAD_PARAMS: CadParams = CadParams::new()
|
/// const CAD_PARAMS: CadParams = CadParams::new()
|
||||||
|
@ -203,7 +203,7 @@ impl CadParams {
|
||||||
/// # Example
|
/// # 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 TIMEOUT: Timeout = Timeout::from_raw(0x123456);
|
||||||
/// const CAD_PARAMS: CadParams = CadParams::new()
|
/// const CAD_PARAMS: CadParams = CadParams::new()
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl CalibrateImage {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::CalibrateImage;
|
/// use stm32wlxx_hal::subghz::CalibrateImage;
|
||||||
///
|
///
|
||||||
/// const CAL: CalibrateImage = CalibrateImage::new(0xE1, 0xE9);
|
/// const CAL: CalibrateImage = CalibrateImage::new(0xE1, 0xE9);
|
||||||
/// assert_eq!(CAL, CalibrateImage::ISM_902_928);
|
/// assert_eq!(CAL, CalibrateImage::ISM_902_928);
|
||||||
|
@ -54,7 +54,7 @@ impl CalibrateImage {
|
||||||
/// Create an image calibration for the 430 - 440 MHz ISM band.
|
/// 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);
|
/// let cal: CalibrateImage = CalibrateImage::from_freq(428, 444);
|
||||||
/// assert_eq!(cal, CalibrateImage::ISM_430_440);
|
/// assert_eq!(cal, CalibrateImage::ISM_430_440);
|
||||||
|
@ -106,7 +106,7 @@ impl Calibrate {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Calibrate;
|
/// use stm32wlxx_hal::subghz::Calibrate;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Calibrate::Image.mask(), 0b0100_0000);
|
/// assert_eq!(Calibrate::Image.mask(), 0b0100_0000);
|
||||||
/// assert_eq!(Calibrate::AdcBulkP.mask(), 0b0010_0000);
|
/// assert_eq!(Calibrate::AdcBulkP.mask(), 0b0010_0000);
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl Default for FallbackMode {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FallbackMode;
|
/// use stm32wlxx_hal::subghz::FallbackMode;
|
||||||
///
|
///
|
||||||
/// assert_eq!(FallbackMode::default(), FallbackMode::Standby);
|
/// assert_eq!(FallbackMode::default(), FallbackMode::Standby);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl HseTrim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::HseTrim;
|
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||||
///
|
///
|
||||||
/// assert_eq!(HseTrim::POR, HseTrim::default());
|
/// assert_eq!(HseTrim::POR, HseTrim::default());
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -39,7 +39,7 @@ impl HseTrim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::HseTrim;
|
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||||
///
|
///
|
||||||
/// assert_eq!(HseTrim::from_raw(0xFF), HseTrim::MAX);
|
/// assert_eq!(HseTrim::from_raw(0xFF), HseTrim::MAX);
|
||||||
/// assert_eq!(HseTrim::from_raw(0x2F), HseTrim::MAX);
|
/// assert_eq!(HseTrim::from_raw(0x2F), HseTrim::MAX);
|
||||||
|
@ -61,7 +61,7 @@ impl HseTrim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::HseTrim;
|
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||||
///
|
///
|
||||||
/// assert!(HseTrim::from_farads(1.0).is_err());
|
/// assert!(HseTrim::from_farads(1.0).is_err());
|
||||||
/// assert!(HseTrim::from_farads(1e-12).is_err());
|
/// assert!(HseTrim::from_farads(1e-12).is_err());
|
||||||
|
@ -84,7 +84,7 @@ impl HseTrim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::HseTrim;
|
/// use stm32wlxx_hal::subghz::HseTrim;
|
||||||
///
|
///
|
||||||
/// assert_eq!((HseTrim::MAX.as_farads() * 10e11) as u8, 33);
|
/// assert_eq!((HseTrim::MAX.as_farads() * 10e11) as u8, 33);
|
||||||
/// assert_eq!((HseTrim::MIN.as_farads() * 10e11) as u8, 11);
|
/// assert_eq!((HseTrim::MIN.as_farads() * 10e11) as u8, 11);
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl Irq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Irq;
|
/// use stm32wlxx_hal::subghz::Irq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Irq::TxDone.mask(), 0x0001);
|
/// assert_eq!(Irq::TxDone.mask(), 0x0001);
|
||||||
/// assert_eq!(Irq::Timeout.mask(), 0x0200);
|
/// assert_eq!(Irq::Timeout.mask(), 0x0200);
|
||||||
|
@ -128,7 +128,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::CfgIrq;
|
/// use stm32wlxx_hal::subghz::CfgIrq;
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new();
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -153,7 +153,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq, IrqLine};
|
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||||
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
||||||
|
@ -179,7 +179,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||||
/// .irq_enable_all(Irq::TxDone)
|
/// .irq_enable_all(Irq::TxDone)
|
||||||
|
@ -214,7 +214,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq, IrqLine};
|
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq, IrqLine};
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||||
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
/// .irq_enable(IrqLine::Global, Irq::TxDone)
|
||||||
|
@ -239,7 +239,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||||
/// .irq_enable_all(Irq::TxDone)
|
/// .irq_enable_all(Irq::TxDone)
|
||||||
|
@ -269,7 +269,7 @@ impl CfgIrq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CfgIrq, Irq};
|
/// use stm32wlxx_hal::subghz::{CfgIrq, Irq};
|
||||||
///
|
///
|
||||||
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
/// const IRQ_CFG: CfgIrq = CfgIrq::new()
|
||||||
/// .irq_enable_all(Irq::TxDone)
|
/// .irq_enable_all(Irq::TxDone)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -52,7 +52,7 @@ impl FskBandwidth {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskBandwidth;
|
/// use stm32wlxx_hal::subghz::FskBandwidth;
|
||||||
///
|
///
|
||||||
/// assert_eq!(FskBandwidth::Bw4.hertz(), 4_800);
|
/// assert_eq!(FskBandwidth::Bw4.hertz(), 4_800);
|
||||||
/// assert_eq!(FskBandwidth::Bw5.hertz(), 5_800);
|
/// assert_eq!(FskBandwidth::Bw5.hertz(), 5_800);
|
||||||
|
@ -109,7 +109,7 @@ impl FskBandwidth {
|
||||||
/// # Example
|
/// # 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(0x1F), Ok(FskBandwidth::Bw4));
|
||||||
/// assert_eq!(FskBandwidth::from_bits(0x17), Ok(FskBandwidth::Bw5));
|
/// assert_eq!(FskBandwidth::from_bits(0x17), Ok(FskBandwidth::Bw5));
|
||||||
|
@ -206,7 +206,7 @@ impl FskBitrate {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskBitrate;
|
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||||
///
|
///
|
||||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(9600);
|
/// const BITRATE: FskBitrate = FskBitrate::from_bps(9600);
|
||||||
/// assert_eq!(BITRATE.as_bps(), 9600);
|
/// assert_eq!(BITRATE.as_bps(), 9600);
|
||||||
|
@ -235,7 +235,7 @@ impl FskBitrate {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskBitrate;
|
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||||
///
|
///
|
||||||
/// const BITRATE: FskBitrate = FskBitrate::from_raw(0x7D00);
|
/// const BITRATE: FskBitrate = FskBitrate::from_raw(0x7D00);
|
||||||
/// assert_eq!(BITRATE.as_bps(), 32_000);
|
/// assert_eq!(BITRATE.as_bps(), 32_000);
|
||||||
|
@ -251,7 +251,7 @@ impl FskBitrate {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskBitrate;
|
/// use stm32wlxx_hal::subghz::FskBitrate;
|
||||||
///
|
///
|
||||||
/// const BITS_PER_SEC: u32 = 9600;
|
/// const BITS_PER_SEC: u32 = 9600;
|
||||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(BITS_PER_SEC);
|
/// const BITRATE: FskBitrate = FskBitrate::from_bps(BITS_PER_SEC);
|
||||||
|
@ -296,7 +296,7 @@ impl FskFdev {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskFdev;
|
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||||
///
|
///
|
||||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||||
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
||||||
|
@ -317,7 +317,7 @@ impl FskFdev {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskFdev;
|
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||||
///
|
///
|
||||||
/// const FDEV: FskFdev = FskFdev::from_raw(0x8000);
|
/// const FDEV: FskFdev = FskFdev::from_raw(0x8000);
|
||||||
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
/// assert_eq!(FDEV.as_hertz(), 31_250);
|
||||||
|
@ -333,7 +333,7 @@ impl FskFdev {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskFdev;
|
/// use stm32wlxx_hal::subghz::FskFdev;
|
||||||
///
|
///
|
||||||
/// const HERTZ: u32 = 31_250;
|
/// const HERTZ: u32 = 31_250;
|
||||||
/// const FDEV: FskFdev = FskFdev::from_hertz(HERTZ);
|
/// 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)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub struct FskModParams {
|
pub struct FskModParams {
|
||||||
|
@ -363,7 +363,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::FskModParams;
|
/// use stm32wlxx_hal::subghz::FskModParams;
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new();
|
/// const MOD_PARAMS: FskModParams = FskModParams::new();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -394,7 +394,7 @@ impl FskModParams {
|
||||||
/// Setting the bitrate to 32,000 bits per second.
|
/// 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 BITRATE: FskBitrate = FskBitrate::from_bps(32_000);
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
||||||
|
@ -412,7 +412,7 @@ impl FskModParams {
|
||||||
/// Setting the bitrate to 32,000 bits per second.
|
/// 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 BITRATE: FskBitrate = FskBitrate::from_bps(32_000);
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bitrate(BITRATE);
|
||||||
|
@ -434,7 +434,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{FskModParams, FskPulseShape};
|
/// use stm32wlxx_hal::subghz::{FskModParams, FskPulseShape};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_pulse_shape(FskPulseShape::Bt03);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_pulse_shape(FskPulseShape::Bt03);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice()[4], 0x08);
|
/// # assert_eq!(MOD_PARAMS.as_slice()[4], 0x08);
|
||||||
|
@ -453,7 +453,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskModParams};
|
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskModParams};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
||||||
/// assert_eq!(MOD_PARAMS.bandwidth(), Ok(FskBandwidth::Bw9));
|
/// assert_eq!(MOD_PARAMS.bandwidth(), Ok(FskBandwidth::Bw9));
|
||||||
|
@ -467,7 +467,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{FskBandwidth, FskModParams};
|
/// use stm32wlxx_hal::subghz::{FskBandwidth, FskModParams};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_bandwidth(FskBandwidth::Bw9);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice()[5], 0x1E);
|
/// # assert_eq!(MOD_PARAMS.as_slice()[5], 0x1E);
|
||||||
|
@ -483,7 +483,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{FskFdev, FskModParams};
|
/// use stm32wlxx_hal::subghz::{FskFdev, FskModParams};
|
||||||
///
|
///
|
||||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
||||||
|
@ -499,7 +499,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{FskFdev, FskModParams};
|
/// use stm32wlxx_hal::subghz::{FskFdev, FskModParams};
|
||||||
///
|
///
|
||||||
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
/// const FDEV: FskFdev = FskFdev::from_hertz(31_250);
|
||||||
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
/// const MOD_PARAMS: FskModParams = FskModParams::new().set_fdev(FDEV);
|
||||||
|
@ -536,7 +536,7 @@ impl FskModParams {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// extern crate static_assertions as sa;
|
/// 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()
|
/// const MOD_PARAMS: FskModParams = FskModParams::new()
|
||||||
/// .set_bitrate(FskBitrate::from_bps(20_000))
|
/// .set_bitrate(FskBitrate::from_bps(20_000))
|
||||||
|
@ -576,7 +576,7 @@ impl FskModParams {
|
||||||
/// # Example
|
/// # 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 BITRATE: FskBitrate = FskBitrate::from_bps(20_000);
|
||||||
/// const PULSE_SHAPE: FskPulseShape = FskPulseShape::Bt03;
|
/// const PULSE_SHAPE: FskPulseShape = FskPulseShape::Bt03;
|
||||||
|
@ -608,6 +608,9 @@ impl Default for FskModParams {
|
||||||
/// LoRa spreading factor.
|
/// LoRa spreading factor.
|
||||||
///
|
///
|
||||||
/// Argument of [`LoRaModParams::set_sf`].
|
/// 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)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
@ -671,7 +674,7 @@ impl LoRaBandwidth {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaBandwidth;
|
/// use stm32wlxx_hal::subghz::LoRaBandwidth;
|
||||||
///
|
///
|
||||||
/// assert_eq!(LoRaBandwidth::Bw7.hertz(), 7_810);
|
/// assert_eq!(LoRaBandwidth::Bw7.hertz(), 7_810);
|
||||||
/// assert_eq!(LoRaBandwidth::Bw10.hertz(), 10_420);
|
/// assert_eq!(LoRaBandwidth::Bw10.hertz(), 10_420);
|
||||||
|
@ -715,23 +718,38 @@ impl PartialOrd for LoRaBandwidth {
|
||||||
/// LoRa forward error correction coding rate.
|
/// LoRa forward error correction coding rate.
|
||||||
///
|
///
|
||||||
/// Argument of [`LoRaModParams::set_cr`].
|
/// 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)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum CodingRate {
|
pub enum CodingRate {
|
||||||
/// No forward error correction coding rate 4/4
|
/// No forward error correction coding rate 4/4
|
||||||
|
///
|
||||||
|
/// Overhead ratio of 1
|
||||||
Cr44 = 0x00,
|
Cr44 = 0x00,
|
||||||
/// Forward error correction coding rate 4/5
|
/// Forward error correction coding rate 4/5
|
||||||
|
///
|
||||||
|
/// Overhead ratio of 1.25
|
||||||
Cr45 = 0x1,
|
Cr45 = 0x1,
|
||||||
/// Forward error correction coding rate 4/6
|
/// Forward error correction coding rate 4/6
|
||||||
|
///
|
||||||
|
/// Overhead ratio of 1.5
|
||||||
Cr46 = 0x2,
|
Cr46 = 0x2,
|
||||||
/// Forward error correction coding rate 4/7
|
/// Forward error correction coding rate 4/7
|
||||||
|
///
|
||||||
|
/// Overhead ratio of 1.75
|
||||||
Cr47 = 0x3,
|
Cr47 = 0x3,
|
||||||
/// Forward error correction coding rate 4/8
|
/// Forward error correction coding rate 4/8
|
||||||
|
///
|
||||||
|
/// Overhead ratio of 2
|
||||||
Cr48 = 0x4,
|
Cr48 = 0x4,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LoRa modulation paramters.
|
/// LoRa modulation parameters.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
|
|
||||||
|
@ -747,7 +765,7 @@ impl LoRaModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaModParams;
|
/// use stm32wlxx_hal::subghz::LoRaModParams;
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new();
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new();
|
||||||
/// assert_eq!(MOD_PARAMS, LoRaModParams::default());
|
/// assert_eq!(MOD_PARAMS, LoRaModParams::default());
|
||||||
|
@ -769,7 +787,7 @@ impl LoRaModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{LoRaModParams, SpreadingFactor};
|
/// use stm32wlxx_hal::subghz::{LoRaModParams, SpreadingFactor};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_sf(SpreadingFactor::Sf7);
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_sf(SpreadingFactor::Sf7);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x07, 0x00, 0x00, 0x00]);
|
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x07, 0x00, 0x00, 0x00]);
|
||||||
|
@ -785,7 +803,7 @@ impl LoRaModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{LoRaBandwidth, LoRaModParams};
|
/// use stm32wlxx_hal::subghz::{LoRaBandwidth, LoRaModParams};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_bw(LoRaBandwidth::Bw125);
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_bw(LoRaBandwidth::Bw125);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x04, 0x00, 0x00]);
|
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x04, 0x00, 0x00]);
|
||||||
|
@ -798,10 +816,12 @@ impl LoRaModParams {
|
||||||
|
|
||||||
/// Set the forward error correction coding rate.
|
/// Set the forward error correction coding rate.
|
||||||
///
|
///
|
||||||
|
/// See [`CodingRate`] for more information.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CodingRate, LoRaModParams};
|
/// use stm32wlxx_hal::subghz::{CodingRate, LoRaModParams};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_cr(CodingRate::Cr45);
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_cr(CodingRate::Cr45);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x01, 0x00]);
|
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x01, 0x00]);
|
||||||
|
@ -814,10 +834,29 @@ impl LoRaModParams {
|
||||||
|
|
||||||
/// Set low data rate optimization enable.
|
/// 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
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaModParams;
|
/// use stm32wlxx_hal::subghz::LoRaModParams;
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_ldro_en(true);
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new().set_ldro_en(true);
|
||||||
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x00, 0x01]);
|
/// # assert_eq!(MOD_PARAMS.as_slice(), &[0x8B, 0x05, 0x00, 0x00, 0x01]);
|
||||||
|
@ -833,7 +872,7 @@ impl LoRaModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CodingRate, LoRaBandwidth, LoRaModParams, SpreadingFactor};
|
/// use stm32wlxx_hal::subghz::{CodingRate, LoRaBandwidth, LoRaModParams, SpreadingFactor};
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new()
|
/// const MOD_PARAMS: LoRaModParams = LoRaModParams::new()
|
||||||
/// .set_sf(SpreadingFactor::Sf7)
|
/// .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
|
/// **Note:** There is no method to set the pulse shape because there is only
|
||||||
/// one valid pulse shape (Gaussian BT 0.5).
|
/// one valid pulse shape (Gaussian BT 0.5).
|
||||||
|
@ -872,7 +911,7 @@ impl BpskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BpskModParams;
|
/// use stm32wlxx_hal::subghz::BpskModParams;
|
||||||
///
|
///
|
||||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new();
|
/// const MOD_PARAMS: BpskModParams = BpskModParams::new();
|
||||||
/// assert_eq!(MOD_PARAMS, BpskModParams::default());
|
/// assert_eq!(MOD_PARAMS, BpskModParams::default());
|
||||||
|
@ -891,7 +930,7 @@ impl BpskModParams {
|
||||||
/// Setting the bitrate to 600 bits per second.
|
/// 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 BITRATE: FskBitrate = FskBitrate::from_bps(600);
|
||||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
||||||
|
@ -913,7 +952,7 @@ impl BpskModParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{BpskModParams, FskBitrate};
|
/// use stm32wlxx_hal::subghz::{BpskModParams, FskBitrate};
|
||||||
///
|
///
|
||||||
/// const BITRATE: FskBitrate = FskBitrate::from_bps(100);
|
/// const BITRATE: FskBitrate = FskBitrate::from_bps(100);
|
||||||
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
/// const MOD_PARAMS: BpskModParams = BpskModParams::new().set_bitrate(BITRATE);
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl OpError {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::OpError;
|
/// use stm32wlxx_hal::subghz::OpError;
|
||||||
///
|
///
|
||||||
/// assert_eq!(OpError::PaRampError.mask(), 0b1_0000_0000);
|
/// assert_eq!(OpError::PaRampError.mask(), 0b1_0000_0000);
|
||||||
/// assert_eq!(OpError::PllLockError.mask(), 0b0_0100_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`].
|
/// Argument of [`set_pa_config`].
|
||||||
///
|
///
|
||||||
|
@ -13,37 +13,58 @@ impl PaConfig {
|
||||||
/// Optimal settings for +15dBm output power with the low-power PA.
|
/// Optimal settings for +15dBm output power with the low-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::LP_15`](super::TxParams::LP_15).
|
/// This must be used with [`TxParams::LP_15`](super::TxParams::LP_15).
|
||||||
pub const LP_15: PaConfig = PaConfig::new().set_pa_duty_cycle(0x6).set_hp_max(0x0).set_pa(PaSel::Lp);
|
pub const LP_15: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x6)
|
||||||
|
.set_hp_max(0x0)
|
||||||
|
.set_pa(PaSel::Lp);
|
||||||
|
|
||||||
/// Optimal settings for +14dBm output power with the low-power PA.
|
/// Optimal settings for +14dBm output power with the low-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::LP_14`](super::TxParams::LP_14).
|
/// This must be used with [`TxParams::LP_14`](super::TxParams::LP_14).
|
||||||
pub const LP_14: PaConfig = PaConfig::new().set_pa_duty_cycle(0x4).set_hp_max(0x0).set_pa(PaSel::Lp);
|
pub const LP_14: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x4)
|
||||||
|
.set_hp_max(0x0)
|
||||||
|
.set_pa(PaSel::Lp);
|
||||||
|
|
||||||
/// Optimal settings for +10dBm output power with the low-power PA.
|
/// Optimal settings for +10dBm output power with the low-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::LP_10`](super::TxParams::LP_10).
|
/// This must be used with [`TxParams::LP_10`](super::TxParams::LP_10).
|
||||||
pub const LP_10: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp);
|
pub const LP_10: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x1)
|
||||||
|
.set_hp_max(0x0)
|
||||||
|
.set_pa(PaSel::Lp);
|
||||||
|
|
||||||
/// Optimal settings for +22dBm output power with the high-power PA.
|
/// Optimal settings for +22dBm output power with the high-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
||||||
pub const HP_22: PaConfig = PaConfig::new().set_pa_duty_cycle(0x4).set_hp_max(0x7).set_pa(PaSel::Hp);
|
pub const HP_22: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x4)
|
||||||
|
.set_hp_max(0x7)
|
||||||
|
.set_pa(PaSel::Hp);
|
||||||
|
|
||||||
/// Optimal settings for +20dBm output power with the high-power PA.
|
/// Optimal settings for +20dBm output power with the high-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
||||||
pub const HP_20: PaConfig = PaConfig::new().set_pa_duty_cycle(0x3).set_hp_max(0x5).set_pa(PaSel::Hp);
|
pub const HP_20: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x3)
|
||||||
|
.set_hp_max(0x5)
|
||||||
|
.set_pa(PaSel::Hp);
|
||||||
|
|
||||||
/// Optimal settings for +17dBm output power with the high-power PA.
|
/// Optimal settings for +17dBm output power with the high-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
||||||
pub const HP_17: PaConfig = PaConfig::new().set_pa_duty_cycle(0x2).set_hp_max(0x3).set_pa(PaSel::Hp);
|
pub const HP_17: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x2)
|
||||||
|
.set_hp_max(0x3)
|
||||||
|
.set_pa(PaSel::Hp);
|
||||||
|
|
||||||
/// Optimal settings for +14dBm output power with the high-power PA.
|
/// Optimal settings for +14dBm output power with the high-power PA.
|
||||||
///
|
///
|
||||||
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
/// This must be used with [`TxParams::HP`](super::TxParams::HP).
|
||||||
pub const HP_14: PaConfig = PaConfig::new().set_pa_duty_cycle(0x2).set_hp_max(0x2).set_pa(PaSel::Hp);
|
pub const HP_14: PaConfig = PaConfig::new()
|
||||||
|
.set_pa_duty_cycle(0x2)
|
||||||
|
.set_hp_max(0x2)
|
||||||
|
.set_pa(PaSel::Hp);
|
||||||
|
|
||||||
/// Create a new `PaConfig` struct.
|
/// Create a new `PaConfig` struct.
|
||||||
///
|
///
|
||||||
|
@ -52,7 +73,7 @@ impl PaConfig {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PaConfig;
|
/// use stm32wlxx_hal::subghz::PaConfig;
|
||||||
///
|
///
|
||||||
/// const PA_CONFIG: PaConfig = PaConfig::new();
|
/// const PA_CONFIG: PaConfig = PaConfig::new();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -71,14 +92,14 @@ impl PaConfig {
|
||||||
/// # Caution
|
/// # Caution
|
||||||
///
|
///
|
||||||
/// The following restrictions must be observed to avoid over-stress on the PA:
|
/// 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, `pa_duty_cycle` must be < 0x7.
|
||||||
/// * LP PA mode with synthesis frequency < 400 MHz, PaDutyCycle must be < 0x4.
|
/// * LP PA mode with synthesis frequency < 400 MHz, `pa_duty_cycle` must be < 0x4.
|
||||||
/// * HP PA mode, PaDutyCycle must be < 0x4
|
/// * HP PA mode, `pa_duty_cycle` must be < 0x4
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # 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);
|
/// const PA_CONFIG: PaConfig = PaConfig::new().set_pa(PaSel::Lp).set_pa_duty_cycle(0x4);
|
||||||
/// # assert_eq!(PA_CONFIG.as_slice()[1], 0x04);
|
/// # assert_eq!(PA_CONFIG.as_slice()[1], 0x04);
|
||||||
|
@ -96,7 +117,7 @@ impl PaConfig {
|
||||||
/// # Example
|
/// # 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);
|
/// const PA_CONFIG: PaConfig = PaConfig::new().set_pa(PaSel::Hp).set_hp_max(0x2);
|
||||||
/// # assert_eq!(PA_CONFIG.as_slice()[2], 0x02);
|
/// # assert_eq!(PA_CONFIG.as_slice()[2], 0x02);
|
||||||
|
@ -112,7 +133,7 @@ impl PaConfig {
|
||||||
/// # Example
|
/// # 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_HP: PaConfig = PaConfig::new().set_pa(PaSel::Hp);
|
||||||
/// const PA_CONFIG_LP: PaConfig = PaConfig::new().set_pa(PaSel::Lp);
|
/// const PA_CONFIG_LP: PaConfig = PaConfig::new().set_pa(PaSel::Lp);
|
||||||
|
@ -130,7 +151,7 @@ impl PaConfig {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{PaConfig, PaSel};
|
/// use stm32wlxx_hal::subghz::{PaConfig, PaSel};
|
||||||
///
|
///
|
||||||
/// const PA_CONFIG: PaConfig = PaConfig::new()
|
/// const PA_CONFIG: PaConfig = PaConfig::new()
|
||||||
/// .set_pa(PaSel::Hp)
|
/// .set_pa(PaSel::Hp)
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl GenericPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new();
|
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new();
|
||||||
/// assert_eq!(PKT_PARAMS, GenericPacketParams::default());
|
/// assert_eq!(PKT_PARAMS, GenericPacketParams::default());
|
||||||
|
@ -119,7 +119,7 @@ impl GenericPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_preamble_len(0x1234);
|
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_preamble_len(0x1234);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
||||||
|
@ -135,19 +135,22 @@ impl GenericPacketParams {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Preabmle detection length in number of bit symbols.
|
/// Preamble detection length in number of bit symbols.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{GenericPacketParams, PreambleDetection};
|
/// use stm32wlxx_hal::subghz::{GenericPacketParams, PreambleDetection};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams =
|
/// const PKT_PARAMS: GenericPacketParams =
|
||||||
/// GenericPacketParams::new().set_preamble_detection(PreambleDetection::Bit8);
|
/// GenericPacketParams::new().set_preamble_detection(PreambleDetection::Bit8);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x4);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x4);
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use = "set_preamble_detection returns a modified GenericPacketParams"]
|
#[must_use = "set_preamble_detection returns a modified GenericPacketParams"]
|
||||||
pub const fn set_preamble_detection(mut self, pb_det: PreambleDetection) -> GenericPacketParams {
|
pub const fn set_preamble_detection(
|
||||||
|
mut self,
|
||||||
|
pb_det: PreambleDetection,
|
||||||
|
) -> GenericPacketParams {
|
||||||
self.buf[3] = pb_det as u8;
|
self.buf[3] = pb_det as u8;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -162,7 +165,7 @@ impl GenericPacketParams {
|
||||||
/// Set the sync word length to 4 bytes (16 bits).
|
/// 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);
|
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_sync_word_len(16);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 0x10);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 0x10);
|
||||||
|
@ -185,7 +188,7 @@ impl GenericPacketParams {
|
||||||
/// Enable address on the node address.
|
/// Enable address on the node address.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{AddrComp, GenericPacketParams};
|
/// use stm32wlxx_hal::subghz::{AddrComp, GenericPacketParams};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams =
|
/// const PKT_PARAMS: GenericPacketParams =
|
||||||
/// GenericPacketParams::new().set_addr_comp(AddrComp::Node);
|
/// GenericPacketParams::new().set_addr_comp(AddrComp::Node);
|
||||||
|
@ -208,7 +211,7 @@ impl GenericPacketParams {
|
||||||
/// Set the header type to a variable length.
|
/// Set the header type to a variable length.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{GenericPacketParams, HeaderType};
|
/// use stm32wlxx_hal::subghz::{GenericPacketParams, HeaderType};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams =
|
/// const PKT_PARAMS: GenericPacketParams =
|
||||||
/// GenericPacketParams::new().set_header_type(HeaderType::Variable);
|
/// GenericPacketParams::new().set_header_type(HeaderType::Variable);
|
||||||
|
@ -225,7 +228,7 @@ impl GenericPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_payload_len(12);
|
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_payload_len(12);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[7], 12);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[7], 12);
|
||||||
|
@ -241,7 +244,7 @@ impl GenericPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CrcType, GenericPacketParams};
|
/// use stm32wlxx_hal::subghz::{CrcType, GenericPacketParams};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams =
|
/// const PKT_PARAMS: GenericPacketParams =
|
||||||
/// GenericPacketParams::new().set_crc_type(CrcType::Byte2Inverted);
|
/// GenericPacketParams::new().set_crc_type(CrcType::Byte2Inverted);
|
||||||
|
@ -260,7 +263,7 @@ impl GenericPacketParams {
|
||||||
/// Enable whitening.
|
/// Enable whitening.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::GenericPacketParams;
|
/// use stm32wlxx_hal::subghz::GenericPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_whitening_enable(true);
|
/// const PKT_PARAMS: GenericPacketParams = GenericPacketParams::new().set_whitening_enable(true);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[9], 1);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[9], 1);
|
||||||
|
@ -276,7 +279,7 @@ impl GenericPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{
|
/// use stm32wlxx_hal::subghz::{
|
||||||
/// AddrComp, CrcType, GenericPacketParams, HeaderType, PreambleDetection,
|
/// AddrComp, CrcType, GenericPacketParams, HeaderType, PreambleDetection,
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
|
@ -322,7 +325,7 @@ impl LoRaPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new();
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new();
|
||||||
/// assert_eq!(PKT_PARAMS, LoRaPacketParams::default());
|
/// assert_eq!(PKT_PARAMS, LoRaPacketParams::default());
|
||||||
|
@ -349,7 +352,7 @@ impl LoRaPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_preamble_len(0x1234);
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_preamble_len(0x1234);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 0x12);
|
||||||
|
@ -372,7 +375,7 @@ impl LoRaPacketParams {
|
||||||
/// Set the payload type to a fixed length.
|
/// 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);
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_header_type(HeaderType::Fixed);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x01);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x01);
|
||||||
|
@ -388,7 +391,7 @@ impl LoRaPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_payload_len(12);
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_payload_len(12);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 12);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[4], 12);
|
||||||
|
@ -406,7 +409,7 @@ impl LoRaPacketParams {
|
||||||
/// Enable CRC.
|
/// Enable CRC.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::LoRaPacketParams;
|
/// use stm32wlxx_hal::subghz::LoRaPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_crc_en(true);
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_crc_en(true);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[5], 0x1);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[5], 0x1);
|
||||||
|
@ -424,7 +427,7 @@ impl LoRaPacketParams {
|
||||||
/// Use an inverted IQ setup.
|
/// 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);
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new().set_invert_iq(true);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[6], 0x1);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[6], 0x1);
|
||||||
|
@ -440,7 +443,7 @@ impl LoRaPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{HeaderType, LoRaPacketParams};
|
/// use stm32wlxx_hal::subghz::{HeaderType, LoRaPacketParams};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new()
|
/// const PKT_PARAMS: LoRaPacketParams = LoRaPacketParams::new()
|
||||||
/// .set_preamble_len(5 * 8)
|
/// .set_preamble_len(5 * 8)
|
||||||
|
@ -482,7 +485,7 @@ impl BpskPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BpskPacketParams;
|
/// use stm32wlxx_hal::subghz::BpskPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new();
|
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new();
|
||||||
/// assert_eq!(PKT_PARAMS, BpskPacketParams::default());
|
/// assert_eq!(PKT_PARAMS, BpskPacketParams::default());
|
||||||
|
@ -500,7 +503,7 @@ impl BpskPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::BpskPacketParams;
|
/// use stm32wlxx_hal::subghz::BpskPacketParams;
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(12);
|
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(12);
|
||||||
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 12);
|
/// # assert_eq!(PKT_PARAMS.as_slice()[1], 12);
|
||||||
|
@ -516,7 +519,7 @@ impl BpskPacketParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{BpskPacketParams, HeaderType};
|
/// use stm32wlxx_hal::subghz::{BpskPacketParams, HeaderType};
|
||||||
///
|
///
|
||||||
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(24);
|
/// const PKT_PARAMS: BpskPacketParams = BpskPacketParams::new().set_payload_len(24);
|
||||||
///
|
///
|
||||||
|
|
|
@ -5,7 +5,7 @@ use super::{Ratio, Status};
|
||||||
/// Returned by [`fsk_packet_status`].
|
/// Returned by [`fsk_packet_status`].
|
||||||
///
|
///
|
||||||
/// [`fsk_packet_status`]: super::SubGhz::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 {
|
pub struct FskPacketStatus {
|
||||||
buf: [u8; 4],
|
buf: [u8; 4],
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ impl FskPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0x54, 0, 0, 0];
|
||||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
||||||
|
@ -34,32 +34,32 @@ impl FskPacketStatus {
|
||||||
Status::from_raw(self.buf[0])
|
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 {
|
pub const fn preamble_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 7)) != 0
|
(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 {
|
pub const fn sync_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 6)) != 0
|
(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 {
|
pub const fn addr_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 5)) != 0
|
(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 {
|
pub const fn crc_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 4)) != 0
|
(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 {
|
pub const fn length_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 3)) != 0
|
(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 {
|
pub const fn abort_err(&self) -> bool {
|
||||||
(self.buf[1] & (1 << 2)) != 0
|
(self.buf[1] & (1 << 2)) != 0
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ impl FskPacketStatus {
|
||||||
(self.buf[1] & 1) != 0
|
(self.buf[1] & 1) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if any error occured.
|
/// Returns `true` if any error occurred.
|
||||||
pub const fn any_err(&self) -> bool {
|
pub const fn any_err(&self) -> bool {
|
||||||
(self.buf[1] & 0xFC) != 0
|
(self.buf[1] & 0xFC) != 0
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ impl FskPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0, 0, 80, 0];
|
||||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
||||||
|
@ -103,7 +103,7 @@ impl FskPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0, 0, 0, 100];
|
||||||
/// let pkt_status: FskPacketStatus = FskPacketStatus::from(example_data_from_radio);
|
/// 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 {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("FskPacketStatus")
|
f.debug_struct("FskPacketStatus")
|
||||||
.field("status", &self.status())
|
.field("status", &self.status())
|
||||||
|
@ -170,7 +170,7 @@ impl core::fmt::Display for FskPacketStatus {
|
||||||
/// Returned by [`lora_packet_status`].
|
/// Returned by [`lora_packet_status`].
|
||||||
///
|
///
|
||||||
/// [`lora_packet_status`]: super::SubGhz::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 {
|
pub struct LoRaPacketStatus {
|
||||||
buf: [u8; 4],
|
buf: [u8; 4],
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ impl LoRaPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0x54, 0, 0, 0];
|
||||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||||
|
@ -206,7 +206,7 @@ impl LoRaPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0, 80, 0, 0];
|
||||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||||
|
@ -223,7 +223,7 @@ impl LoRaPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0, 0, 40, 0];
|
||||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
||||||
|
@ -240,7 +240,7 @@ impl LoRaPacketStatus {
|
||||||
/// # Example
|
/// # 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 example_data_from_radio: [u8; 4] = [0, 0, 0, 80];
|
||||||
/// let pkt_status: LoRaPacketStatus = LoRaPacketStatus::from(example_data_from_radio);
|
/// 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 {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("LoRaPacketStatus")
|
f.debug_struct("LoRaPacketStatus")
|
||||||
.field("status", &self.status())
|
.field("status", &self.status())
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl PacketType {
|
||||||
/// # Example
|
/// # 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(0), Ok(PacketType::Fsk));
|
||||||
/// assert_eq!(PacketType::from_raw(1), Ok(PacketType::LoRa));
|
/// assert_eq!(PacketType::from_raw(1), Ok(PacketType::LoRa));
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_sync_det_en(true);
|
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_sync_det_en(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -70,7 +70,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||||
/// assert_eq!(pc.sync_det_en(), true);
|
/// assert_eq!(pc.sync_det_en(), true);
|
||||||
|
@ -88,7 +88,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_cont_tx_en(true);
|
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_cont_tx_en(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -107,7 +107,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||||
/// assert_eq!(pc.cont_tx_en(), false);
|
/// assert_eq!(pc.cont_tx_en(), false);
|
||||||
|
@ -133,7 +133,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{InfSeqSel, PktCtrl};
|
/// use stm32wlxx_hal::subghz::{InfSeqSel, PktCtrl};
|
||||||
///
|
///
|
||||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||||
/// assert_eq!(pc.inf_seq_sel(), InfSeqSel::Five);
|
/// assert_eq!(pc.inf_seq_sel(), InfSeqSel::Five);
|
||||||
|
@ -159,12 +159,12 @@ impl PktCtrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable infinute sequence generation.
|
/// Enable infinite sequence generation.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_inf_seq_en(true);
|
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_inf_seq_en(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -178,12 +178,12 @@ impl PktCtrl {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if infinute sequence generation is enabled.
|
/// Returns `true` if infinite sequence generation is enabled.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||||
/// assert_eq!(pc.inf_seq_en(), false);
|
/// assert_eq!(pc.inf_seq_en(), false);
|
||||||
|
@ -201,7 +201,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_whitening_init(true);
|
/// const PKT_CTRL: PktCtrl = PktCtrl::RESET.set_whitening_init(true);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -220,7 +220,7 @@ impl PktCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PktCtrl;
|
/// use stm32wlxx_hal::subghz::PktCtrl;
|
||||||
///
|
///
|
||||||
/// let pc: PktCtrl = PktCtrl::RESET;
|
/// let pc: PktCtrl = PktCtrl::RESET;
|
||||||
/// assert_eq!(pc.whitening_init(), true);
|
/// assert_eq!(pc.whitening_init(), true);
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl CurrentLim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::CurrentLim;
|
/// use stm32wlxx_hal::subghz::CurrentLim;
|
||||||
///
|
///
|
||||||
/// assert_eq!(CurrentLim::Milli25.as_milliamps(), 25);
|
/// assert_eq!(CurrentLim::Milli25.as_milliamps(), 25);
|
||||||
/// assert_eq!(CurrentLim::Milli50.as_milliamps(), 50);
|
/// assert_eq!(CurrentLim::Milli50.as_milliamps(), 50);
|
||||||
|
@ -74,7 +74,7 @@ impl PwrCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PwrCtrl;
|
/// use stm32wlxx_hal::subghz::PwrCtrl;
|
||||||
///
|
///
|
||||||
/// const PWR_CTRL: PwrCtrl = PwrCtrl::RESET.set_current_lim_en(true);
|
/// const PWR_CTRL: PwrCtrl = PwrCtrl::RESET.set_current_lim_en(true);
|
||||||
/// # assert_eq!(u8::from(PWR_CTRL), 0x50u8);
|
/// # assert_eq!(u8::from(PWR_CTRL), 0x50u8);
|
||||||
|
@ -94,7 +94,7 @@ impl PwrCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::PwrCtrl;
|
/// use stm32wlxx_hal::subghz::PwrCtrl;
|
||||||
///
|
///
|
||||||
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
||||||
/// assert_eq!(pc.current_limit_en(), true);
|
/// assert_eq!(pc.current_limit_en(), true);
|
||||||
|
@ -120,7 +120,7 @@ impl PwrCtrl {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CurrentLim, PwrCtrl};
|
/// use stm32wlxx_hal::subghz::{CurrentLim, PwrCtrl};
|
||||||
///
|
///
|
||||||
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
/// let pc: PwrCtrl = PwrCtrl::RESET;
|
||||||
/// assert_eq!(pc.current_lim(), CurrentLim::Milli50);
|
/// assert_eq!(pc.current_lim(), CurrentLim::Milli50);
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(RfFreq::F915.freq(), 915_000_000);
|
/// assert_eq!(RfFreq::F915.freq(), 915_000_000);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -26,7 +26,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(RfFreq::F868.freq(), 868_000_000);
|
/// assert_eq!(RfFreq::F868.freq(), 868_000_000);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -37,7 +37,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(RfFreq::F433.freq(), 433_000_000);
|
/// assert_eq!(RfFreq::F433.freq(), 433_000_000);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -52,7 +52,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// const FREQ: RfFreq = RfFreq::from_raw(0x39300000);
|
/// const FREQ: RfFreq = RfFreq::from_raw(0x39300000);
|
||||||
/// assert_eq!(FREQ, RfFreq::F915);
|
/// assert_eq!(FREQ, RfFreq::F915);
|
||||||
|
@ -78,7 +78,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// const FREQ: RfFreq = RfFreq::from_frequency(915_000_000);
|
/// const FREQ: RfFreq = RfFreq::from_frequency(915_000_000);
|
||||||
/// assert_eq!(FREQ, RfFreq::F915);
|
/// assert_eq!(FREQ, RfFreq::F915);
|
||||||
|
@ -89,7 +89,10 @@ impl RfFreq {
|
||||||
|
|
||||||
// Get the frequency bit value.
|
// Get the frequency bit value.
|
||||||
const fn as_bits(&self) -> u32 {
|
const fn as_bits(&self) -> u32 {
|
||||||
((self.buf[1] as u32) << 24) | ((self.buf[2] as u32) << 16) | ((self.buf[3] as u32) << 8) | (self.buf[4] as u32)
|
((self.buf[1] as u32) << 24)
|
||||||
|
| ((self.buf[2] as u32) << 16)
|
||||||
|
| ((self.buf[3] as u32) << 8)
|
||||||
|
| (self.buf[4] as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the actual frequency.
|
/// Get the actual frequency.
|
||||||
|
@ -97,7 +100,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(RfFreq::from_raw(0x39300000).freq(), 915_000_000);
|
/// assert_eq!(RfFreq::from_raw(0x39300000).freq(), 915_000_000);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -110,7 +113,7 @@ impl RfFreq {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::RfFreq;
|
/// use stm32wlxx_hal::subghz::RfFreq;
|
||||||
///
|
///
|
||||||
/// assert_eq!(RfFreq::F915.as_slice(), &[0x86, 0x39, 0x30, 0x00, 0x00]);
|
/// assert_eq!(RfFreq::F915.as_slice(), &[0x86, 0x39, 0x30, 0x00, 0x00]);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -42,14 +42,16 @@ impl SleepCfg {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::SleepCfg;
|
/// use stm32wlxx_hal::subghz::SleepCfg;
|
||||||
///
|
///
|
||||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new();
|
/// const SLEEP_CFG: SleepCfg = SleepCfg::new();
|
||||||
/// assert_eq!(SLEEP_CFG, SleepCfg::default());
|
/// assert_eq!(SLEEP_CFG, SleepCfg::default());
|
||||||
/// # assert_eq!(u8::from(SLEEP_CFG), 0b101);
|
/// # assert_eq!(u8::from(SLEEP_CFG), 0b101);
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn new() -> SleepCfg {
|
pub const fn new() -> SleepCfg {
|
||||||
SleepCfg(0).set_startup(Startup::Warm).set_rtc_wakeup_en(true)
|
SleepCfg(0)
|
||||||
|
.set_startup(Startup::Warm)
|
||||||
|
.set_rtc_wakeup_en(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the startup mode.
|
/// Set the startup mode.
|
||||||
|
@ -57,7 +59,7 @@ impl SleepCfg {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{SleepCfg, Startup};
|
/// use stm32wlxx_hal::subghz::{SleepCfg, Startup};
|
||||||
///
|
///
|
||||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_startup(Startup::Cold);
|
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_startup(Startup::Cold);
|
||||||
/// # assert_eq!(u8::from(SLEEP_CFG), 0b001);
|
/// # assert_eq!(u8::from(SLEEP_CFG), 0b001);
|
||||||
|
@ -77,7 +79,7 @@ impl SleepCfg {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::SleepCfg;
|
/// use stm32wlxx_hal::subghz::SleepCfg;
|
||||||
///
|
///
|
||||||
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_rtc_wakeup_en(false);
|
/// const SLEEP_CFG: SleepCfg = SleepCfg::new().set_rtc_wakeup_en(false);
|
||||||
/// # assert_eq!(u8::from(SLEEP_CFG), 0b100);
|
/// # assert_eq!(u8::from(SLEEP_CFG), 0b100);
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl SmpsDrv {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::SmpsDrv;
|
/// use stm32wlxx_hal::subghz::SmpsDrv;
|
||||||
///
|
///
|
||||||
/// assert_eq!(SmpsDrv::Milli20.as_milliamps(), 20);
|
/// assert_eq!(SmpsDrv::Milli20.as_milliamps(), 20);
|
||||||
/// assert_eq!(SmpsDrv::Milli40.as_milliamps(), 40);
|
/// assert_eq!(SmpsDrv::Milli40.as_milliamps(), 40);
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl FskStats {
|
||||||
///
|
///
|
||||||
/// [`fsk_stats`]: super::SubGhz::fsk_stats
|
/// [`fsk_stats`]: super::SubGhz::fsk_stats
|
||||||
/// [`lora_stats`]: super::SubGhz::lora_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))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub struct Stats<ModType> {
|
pub struct Stats<ModType> {
|
||||||
status: Status,
|
status: Status,
|
||||||
|
@ -52,7 +52,7 @@ impl<ModType> Stats<ModType> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||||
|
@ -68,7 +68,7 @@ impl<ModType> Stats<ModType> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||||
|
@ -83,7 +83,7 @@ impl<ModType> Stats<ModType> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<LoRaStats> = Stats::from_raw_lora(example_data_from_radio);
|
||||||
|
@ -100,7 +100,7 @@ impl Stats<FskStats> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||||
|
@ -114,7 +114,7 @@ impl Stats<FskStats> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<FskStats> = Stats::from_raw_fsk(example_data_from_radio);
|
||||||
|
@ -131,7 +131,7 @@ impl Stats<LoRaStats> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// let stats: Stats<LoRaStats> = Stats::from_raw_lora(example_data_from_radio);
|
||||||
|
@ -145,7 +145,7 @@ impl Stats<LoRaStats> {
|
||||||
/// # Example
|
/// # 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 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);
|
/// 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 {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("Stats")
|
f.debug_struct("Stats")
|
||||||
.field("status", &self.status())
|
.field("status", &self.status())
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/// sub-GHz radio operating mode.
|
/// 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.
|
/// in the reference manual.
|
||||||
///
|
///
|
||||||
/// This is returned by [`Status::mode`].
|
/// This is returned by [`Status::mode`].
|
||||||
|
@ -26,7 +26,7 @@ impl StatusMode {
|
||||||
/// # Example
|
/// # 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(0x2), Ok(StatusMode::StandbyRc));
|
||||||
/// assert_eq!(StatusMode::from_raw(0x3), Ok(StatusMode::StandbyHse));
|
/// assert_eq!(StatusMode::from_raw(0x3), Ok(StatusMode::StandbyHse));
|
||||||
|
@ -50,7 +50,7 @@ impl StatusMode {
|
||||||
|
|
||||||
/// Command status.
|
/// 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.
|
/// in the reference manual.
|
||||||
///
|
///
|
||||||
/// This is returned by [`Status::cmd`].
|
/// This is returned by [`Status::cmd`].
|
||||||
|
@ -89,7 +89,7 @@ impl CmdStatus {
|
||||||
/// # Example
|
/// # 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(0x2), Ok(CmdStatus::Avaliable));
|
||||||
/// assert_eq!(CmdStatus::from_raw(0x3), Ok(CmdStatus::Timeout));
|
/// assert_eq!(CmdStatus::from_raw(0x3), Ok(CmdStatus::Timeout));
|
||||||
|
@ -116,7 +116,7 @@ impl CmdStatus {
|
||||||
/// This is returned by [`status`].
|
/// This is returned by [`status`].
|
||||||
///
|
///
|
||||||
/// [`status`]: super::SubGhz::status
|
/// [`status`]: super::SubGhz::status
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
pub struct Status(u8);
|
pub struct Status(u8);
|
||||||
|
|
||||||
impl From<u8> for Status {
|
impl From<u8> for Status {
|
||||||
|
@ -138,7 +138,7 @@ impl Status {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CmdStatus, Status, StatusMode};
|
/// use stm32wlxx_hal::subghz::{CmdStatus, Status, StatusMode};
|
||||||
///
|
///
|
||||||
/// const STATUS: Status = Status::from_raw(0x54_u8);
|
/// const STATUS: Status = Status::from_raw(0x54_u8);
|
||||||
/// assert_eq!(STATUS.mode(), Ok(StatusMode::Rx));
|
/// assert_eq!(STATUS.mode(), Ok(StatusMode::Rx));
|
||||||
|
@ -153,7 +153,7 @@ impl Status {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{Status, StatusMode};
|
/// use stm32wlxx_hal::subghz::{Status, StatusMode};
|
||||||
///
|
///
|
||||||
/// let status: Status = 0xACu8.into();
|
/// let status: Status = 0xACu8.into();
|
||||||
/// assert_eq!(status.mode(), Ok(StatusMode::StandbyRc));
|
/// assert_eq!(status.mode(), Ok(StatusMode::StandbyRc));
|
||||||
|
@ -164,13 +164,13 @@ impl Status {
|
||||||
|
|
||||||
/// Command status.
|
/// Command status.
|
||||||
///
|
///
|
||||||
/// For some reason `Err(1)` is a pretty common return value for this,
|
/// This method frequently returns reserved values such as `Err(1)`.
|
||||||
/// despite being a reserved value.
|
/// ST support has confirmed that this is normal and should be ignored.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{CmdStatus, Status};
|
/// use stm32wlxx_hal::subghz::{CmdStatus, Status};
|
||||||
///
|
///
|
||||||
/// let status: Status = 0xACu8.into();
|
/// let status: Status = 0xACu8.into();
|
||||||
/// assert_eq!(status.cmd(), Ok(CmdStatus::Complete));
|
/// 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 {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("Status")
|
f.debug_struct("Status")
|
||||||
.field("mode", &self.mode())
|
.field("mode", &self.mode())
|
||||||
|
@ -192,6 +192,11 @@ impl core::fmt::Display for Status {
|
||||||
#[cfg(feature = "defmt")]
|
#[cfg(feature = "defmt")]
|
||||||
impl defmt::Format for Status {
|
impl defmt::Format for Status {
|
||||||
fn format(&self, fmt: defmt::Formatter) {
|
fn format(&self, fmt: defmt::Formatter) {
|
||||||
defmt::write!(fmt, "Status {{ mode: {}, cmd: {} }}", self.mode(), self.cmd())
|
defmt::write!(
|
||||||
|
fmt,
|
||||||
|
"Status {{ mode: {}, cmd: {} }}",
|
||||||
|
self.mode(),
|
||||||
|
self.cmd()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl TcxoTrim {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::TcxoTrim;
|
/// use stm32wlxx_hal::subghz::TcxoTrim;
|
||||||
///
|
///
|
||||||
/// assert_eq!(TcxoTrim::Volts1pt6.as_millivolts(), 1600);
|
/// assert_eq!(TcxoTrim::Volts1pt6.as_millivolts(), 1600);
|
||||||
/// assert_eq!(TcxoTrim::Volts1pt7.as_millivolts(), 1700);
|
/// assert_eq!(TcxoTrim::Volts1pt7.as_millivolts(), 1700);
|
||||||
|
@ -93,7 +93,7 @@ impl TcxoMode {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::TcxoMode;
|
/// use stm32wlxx_hal::subghz::TcxoMode;
|
||||||
///
|
///
|
||||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new();
|
/// const TCXO_MODE: TcxoMode = TcxoMode::new();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -111,7 +111,7 @@ impl TcxoMode {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{TcxoMode, TcxoTrim};
|
/// use stm32wlxx_hal::subghz::{TcxoMode, TcxoTrim};
|
||||||
///
|
///
|
||||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new().set_txco_trim(TcxoTrim::Volts1pt6);
|
/// const TCXO_MODE: TcxoMode = TcxoMode::new().set_txco_trim(TcxoTrim::Volts1pt6);
|
||||||
/// # assert_eq!(TCXO_MODE.as_slice()[1], 0x00);
|
/// # assert_eq!(TCXO_MODE.as_slice()[1], 0x00);
|
||||||
|
@ -128,7 +128,7 @@ impl TcxoMode {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::{TcxoMode, Timeout};
|
/// use stm32wlxx_hal::subghz::{TcxoMode, Timeout};
|
||||||
///
|
///
|
||||||
/// // 15.625 ms timeout
|
/// // 15.625 ms timeout
|
||||||
/// const TIMEOUT: Timeout = Timeout::from_duration_sat(Duration::from_millis(15_625));
|
/// const TIMEOUT: Timeout = Timeout::from_duration_sat(Duration::from_millis(15_625));
|
||||||
|
@ -151,7 +151,7 @@ impl TcxoMode {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{TcxoMode, TcxoTrim, Timeout};
|
/// use stm32wlxx_hal::subghz::{TcxoMode, TcxoTrim, Timeout};
|
||||||
///
|
///
|
||||||
/// const TCXO_MODE: TcxoMode = TcxoMode::new()
|
/// const TCXO_MODE: TcxoMode = TcxoMode::new()
|
||||||
/// .set_txco_trim(TcxoTrim::Volts1pt7)
|
/// .set_txco_trim(TcxoTrim::Volts1pt7)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
|
||||||
use crate::subghz::value_error::ValueError;
|
use super::ValueError;
|
||||||
|
|
||||||
const fn abs_diff(a: u64, b: u64) -> u64 {
|
const fn abs_diff(a: u64, b: u64) -> u64 {
|
||||||
if a > b {
|
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
|
/// Each timeout has 3 bytes, with a resolution of 15.625µs per bit, giving a
|
||||||
/// range of 0s to 262.143984375s.
|
/// range of 0s to 262.143984375s.
|
||||||
///
|
///
|
||||||
/// [`set_rx`]: crate::subghz::SubGhz::set_rx
|
/// [`set_rx`]: super::SubGhz::set_rx
|
||||||
/// [`set_tx`]: crate::subghz::SubGhz::set_tx
|
/// [`set_tx`]: super::SubGhz::set_tx
|
||||||
/// [`TcxoMode`]: crate::subghz::TcxoMode
|
/// [`TcxoMode`]: super::TcxoMode
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub struct Timeout {
|
pub struct Timeout {
|
||||||
|
@ -39,7 +39,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// const TIMEOUT: Timeout = Timeout::DISABLED;
|
/// const TIMEOUT: Timeout = Timeout::DISABLED;
|
||||||
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_secs(0));
|
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_secs(0));
|
||||||
|
@ -52,7 +52,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// const TIMEOUT: Timeout = Timeout::MIN;
|
/// const TIMEOUT: Timeout = Timeout::MIN;
|
||||||
/// assert_eq!(TIMEOUT.into_bits(), 1);
|
/// assert_eq!(TIMEOUT.into_bits(), 1);
|
||||||
|
@ -65,7 +65,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// const TIMEOUT: Timeout = Timeout::MAX;
|
/// const TIMEOUT: Timeout = Timeout::MAX;
|
||||||
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_nanos(262_143_984_375));
|
/// assert_eq!(TIMEOUT.as_duration(), Duration::from_nanos(262_143_984_375));
|
||||||
|
@ -80,7 +80,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// Timeout::RESOLUTION.as_nanos(),
|
/// Timeout::RESOLUTION.as_nanos(),
|
||||||
|
@ -97,7 +97,7 @@ impl Timeout {
|
||||||
/// Use [`from_millis_sat`](Self::from_millis_sat) for runtime timeout
|
/// Use [`from_millis_sat`](Self::from_millis_sat) for runtime timeout
|
||||||
/// construction.
|
/// construction.
|
||||||
/// This is not _that_ useful right now, it is simply future proofing for a
|
/// 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
|
/// # Example
|
||||||
///
|
///
|
||||||
|
@ -105,7 +105,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::{Timeout, ValueError};
|
/// use stm32wlxx_hal::subghz::{Timeout, ValueError};
|
||||||
///
|
///
|
||||||
/// const MIN: Duration = Timeout::RESOLUTION;
|
/// const MIN: Duration = Timeout::RESOLUTION;
|
||||||
/// assert_eq!(Timeout::from_duration(MIN).unwrap(), Timeout::MIN);
|
/// assert_eq!(Timeout::from_duration(MIN).unwrap(), Timeout::MIN);
|
||||||
|
@ -115,7 +115,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::{Timeout, ValueError};
|
/// use stm32wlxx_hal::subghz::{Timeout, ValueError};
|
||||||
///
|
///
|
||||||
/// const LOWER_LIMIT_NANOS: u128 = 7813;
|
/// const LOWER_LIMIT_NANOS: u128 = 7813;
|
||||||
/// const TOO_LOW_NANOS: u128 = LOWER_LIMIT_NANOS - 1;
|
/// const TOO_LOW_NANOS: u128 = LOWER_LIMIT_NANOS - 1;
|
||||||
|
@ -130,7 +130,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// 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 UPPER_LIMIT_NANOS: u128 = Timeout::MAX.as_nanos() as u128 + 7812;
|
||||||
/// const TOO_HIGH_NANOS: u128 = UPPER_LIMIT_NANOS + 1;
|
/// const TOO_HIGH_NANOS: u128 = UPPER_LIMIT_NANOS + 1;
|
||||||
|
@ -145,7 +145,8 @@ impl Timeout {
|
||||||
// `core::Duration` were not `const fn`, which leads to the hacks
|
// `core::Duration` were not `const fn`, which leads to the hacks
|
||||||
// you see here.
|
// you see here.
|
||||||
let nanos: u128 = duration.as_nanos();
|
let nanos: u128 = duration.as_nanos();
|
||||||
const UPPER_LIMIT: u128 = Timeout::MAX.as_nanos() as u128 + (Timeout::RESOLUTION_NANOS as u128) / 2;
|
const UPPER_LIMIT: u128 =
|
||||||
|
Timeout::MAX.as_nanos() as u128 + (Timeout::RESOLUTION_NANOS as u128) / 2;
|
||||||
const LOWER_LIMIT: u128 = (((Timeout::RESOLUTION_NANOS as u128) + 1) / 2) as u128;
|
const LOWER_LIMIT: u128 = (((Timeout::RESOLUTION_NANOS as u128) + 1) / 2) as u128;
|
||||||
|
|
||||||
if nanos > UPPER_LIMIT {
|
if nanos > UPPER_LIMIT {
|
||||||
|
@ -186,7 +187,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// const DURATION_MAX_NS: u64 = 262_143_984_376;
|
/// const DURATION_MAX_NS: u64 = 262_143_984_376;
|
||||||
///
|
///
|
||||||
|
@ -245,7 +246,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # 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(0), Timeout::MIN);
|
||||||
/// assert_eq!(Timeout::from_millis_sat(262_144), Timeout::MAX);
|
/// assert_eq!(Timeout::from_millis_sat(262_144), Timeout::MAX);
|
||||||
|
@ -270,7 +271,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # 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(u32::MAX), Timeout::MAX);
|
||||||
/// assert_eq!(Timeout::from_raw(0x00_FF_FF_FF), Timeout::MAX);
|
/// assert_eq!(Timeout::from_raw(0x00_FF_FF_FF), Timeout::MAX);
|
||||||
|
@ -288,7 +289,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Timeout::MAX.as_nanos(), 262_143_984_375);
|
/// assert_eq!(Timeout::MAX.as_nanos(), 262_143_984_375);
|
||||||
/// assert_eq!(Timeout::DISABLED.as_nanos(), 0);
|
/// assert_eq!(Timeout::DISABLED.as_nanos(), 0);
|
||||||
|
@ -304,7 +305,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Timeout::MAX.as_micros(), 262_143_984);
|
/// assert_eq!(Timeout::MAX.as_micros(), 262_143_984);
|
||||||
/// assert_eq!(Timeout::DISABLED.as_micros(), 0);
|
/// assert_eq!(Timeout::DISABLED.as_micros(), 0);
|
||||||
|
@ -320,7 +321,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Timeout::MAX.as_millis(), 262_143);
|
/// assert_eq!(Timeout::MAX.as_millis(), 262_143);
|
||||||
/// assert_eq!(Timeout::DISABLED.as_millis(), 0);
|
/// assert_eq!(Timeout::DISABLED.as_millis(), 0);
|
||||||
|
@ -336,7 +337,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Timeout::MAX.as_secs(), 262);
|
/// assert_eq!(Timeout::MAX.as_secs(), 262);
|
||||||
/// assert_eq!(Timeout::DISABLED.as_secs(), 0);
|
/// assert_eq!(Timeout::DISABLED.as_secs(), 0);
|
||||||
|
@ -353,7 +354,7 @@ impl Timeout {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use core::time::Duration;
|
/// use core::time::Duration;
|
||||||
/// use stm32wl_hal::subghz::Timeout;
|
/// use stm32wlxx_hal::subghz::Timeout;
|
||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// Timeout::MAX.as_duration(),
|
/// Timeout::MAX.as_duration(),
|
||||||
|
@ -371,7 +372,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # 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(u32::MAX).into_bits(), 0x00FF_FFFF);
|
||||||
/// assert_eq!(Timeout::from_raw(1).into_bits(), 1);
|
/// assert_eq!(Timeout::from_raw(1).into_bits(), 1);
|
||||||
|
@ -385,7 +386,7 @@ impl Timeout {
|
||||||
/// # Example
|
/// # 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(u32::MAX).as_bytes(), [0xFF, 0xFF, 0xFF]);
|
||||||
/// assert_eq!(Timeout::from_raw(1).as_bytes(), [0, 0, 1]);
|
/// assert_eq!(Timeout::from_raw(1).as_bytes(), [0, 0, 1]);
|
||||||
|
@ -397,6 +398,34 @@ impl Timeout {
|
||||||
(self.bits & 0xFF) as u8,
|
(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 {
|
impl From<Timeout> for Duration {
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl TxParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::TxParams;
|
/// use stm32wlxx_hal::subghz::TxParams;
|
||||||
///
|
///
|
||||||
/// const TX_PARAMS: TxParams = TxParams::new();
|
/// const TX_PARAMS: TxParams = TxParams::new();
|
||||||
/// assert_eq!(TX_PARAMS, TxParams::default());
|
/// assert_eq!(TX_PARAMS, TxParams::default());
|
||||||
|
@ -136,7 +136,7 @@ impl TxParams {
|
||||||
/// Set the output power to 0 dB.
|
/// 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);
|
/// const TX_PARAMS: TxParams = TxParams::new().set_power(0x00);
|
||||||
/// # assert_eq!(TX_PARAMS.as_slice()[1], 0x00);
|
/// # assert_eq!(TX_PARAMS.as_slice()[1], 0x00);
|
||||||
|
@ -156,7 +156,7 @@ impl TxParams {
|
||||||
/// Set the ramp time to 200 microseconds.
|
/// 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);
|
/// const TX_PARAMS: TxParams = TxParams::new().set_ramp_time(RampTime::Micros200);
|
||||||
/// # assert_eq!(TX_PARAMS.as_slice()[2], 0x04);
|
/// # assert_eq!(TX_PARAMS.as_slice()[2], 0x04);
|
||||||
|
@ -172,7 +172,7 @@ impl TxParams {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::{RampTime, TxParams};
|
/// use stm32wlxx_hal::subghz::{RampTime, TxParams};
|
||||||
///
|
///
|
||||||
/// const TX_PARAMS: TxParams = TxParams::new()
|
/// const TX_PARAMS: TxParams = TxParams::new()
|
||||||
/// .set_ramp_time(RampTime::Micros80)
|
/// .set_ramp_time(RampTime::Micros80)
|
||||||
|
|
|
@ -14,13 +14,13 @@ pub struct ValueError<T> {
|
||||||
impl<T> ValueError<T> {
|
impl<T> ValueError<T> {
|
||||||
/// Create a new `ValueError` for a value that exceeded an upper bound.
|
/// 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.
|
/// guarantees on the value being greater than the limit.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||||
/// assert!(ERROR.over());
|
/// assert!(ERROR.over());
|
||||||
|
@ -36,13 +36,13 @@ impl<T> ValueError<T> {
|
||||||
|
|
||||||
/// Create a new `ValueError` for a value that exceeded a lower bound.
|
/// 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.
|
/// guarantees on the value being less than the limit.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
||||||
/// assert!(ERROR.under());
|
/// assert!(ERROR.under());
|
||||||
|
@ -61,7 +61,7 @@ impl<T> ValueError<T> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||||
/// assert_eq!(ERROR.value(), &101u8);
|
/// assert_eq!(ERROR.value(), &101u8);
|
||||||
|
@ -75,7 +75,7 @@ impl<T> ValueError<T> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||||
/// assert_eq!(ERROR.limit(), &100u8);
|
/// assert_eq!(ERROR.limit(), &100u8);
|
||||||
|
@ -89,7 +89,7 @@ impl<T> ValueError<T> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
|
||||||
/// assert!(ERROR.over());
|
/// assert!(ERROR.over());
|
||||||
|
@ -104,7 +104,7 @@ impl<T> ValueError<T> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use stm32wl_hal::subghz::ValueError;
|
/// use stm32wlxx_hal::subghz::ValueError;
|
||||||
///
|
///
|
||||||
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
/// const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
|
||||||
/// assert!(ERROR.under());
|
/// assert!(ERROR.under());
|
||||||
|
|
Loading…
Reference in a new issue