diff options
| author | Ulf Lilleengen <[email protected]> | 2021-09-14 14:58:37 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-09-15 12:46:20 +0200 |
| commit | fb697a265752644d835edce27efbb20d5557b297 (patch) | |
| tree | c41773891e97de2664688a7719a6e45aa61fc41b | |
| parent | bb72f7eb98ed0431a6b6adf3c59831aed0c4825a (diff) | |
Updates
24 files changed, 158 insertions, 43 deletions
diff --git a/embassy-stm32/src/rcc/wl5x/mod.rs b/embassy-stm32/src/rcc/wl5x/mod.rs index 8ed0cb957..86fb3f586 100644 --- a/embassy-stm32/src/rcc/wl5x/mod.rs +++ b/embassy-stm32/src/rcc/wl5x/mod.rs | |||
| @@ -113,6 +113,17 @@ impl<'d> Rcc<'d> { | |||
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | pub fn enable_lsi(&mut self) { | ||
| 117 | let rcc = pac::RCC; | ||
| 118 | unsafe { | ||
| 119 | let csr = rcc.csr().read(); | ||
| 120 | if !csr.lsion() { | ||
| 121 | rcc.csr().modify(|w| w.set_lsion(true)); | ||
| 122 | while !rcc.csr().read().lsirdy() {} | ||
| 123 | } | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 116 | // Safety: RCC init must have been called | 127 | // Safety: RCC init must have been called |
| 117 | pub fn clocks(&self) -> &'static Clocks { | 128 | pub fn clocks(&self) -> &'static Clocks { |
| 118 | unsafe { get_freqs() } | 129 | unsafe { get_freqs() } |
diff --git a/embassy-stm32/src/subghz/cad_params.rs b/embassy-stm32/src/subghz/cad_params.rs index fc887a245..bbfe62c22 100644 --- a/embassy-stm32/src/subghz/cad_params.rs +++ b/embassy-stm32/src/subghz/cad_params.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::subghz::timeout::Timeout; | 1 | use super::Timeout; |
| 2 | 2 | ||
| 3 | /// Number of symbols used for channel activity detection scans. | 3 | /// Number of symbols used for channel activity detection scans. |
| 4 | /// | 4 | /// |
diff --git a/embassy-stm32/src/subghz/hse_trim.rs b/embassy-stm32/src/subghz/hse_trim.rs index 101baa860..8ead73855 100644 --- a/embassy-stm32/src/subghz/hse_trim.rs +++ b/embassy-stm32/src/subghz/hse_trim.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::subghz::value_error::ValueError; | 1 | use super::ValueError; |
| 2 | 2 | ||
| 3 | /// HSE32 load capacitor trimming. | 3 | /// HSE32 load capacitor trimming. |
| 4 | /// | 4 | /// |
diff --git a/embassy-stm32/src/subghz/mod.rs b/embassy-stm32/src/subghz/mod.rs index c37c0e8e2..ba333c70d 100644 --- a/embassy-stm32/src/subghz/mod.rs +++ b/embassy-stm32/src/subghz/mod.rs | |||
| @@ -240,6 +240,14 @@ impl<'d, Tx, Rx> SubGhz<'d, Tx, Rx> { | |||
| 240 | 240 | ||
| 241 | SubGhz { spi } | 241 | SubGhz { spi } |
| 242 | } | 242 | } |
| 243 | |||
| 244 | pub fn is_busy(&mut self) -> bool { | ||
| 245 | rfbusys() | ||
| 246 | } | ||
| 247 | |||
| 248 | pub fn reset(&mut self) { | ||
| 249 | Self::pulse_radio_reset(); | ||
| 250 | } | ||
| 243 | } | 251 | } |
| 244 | 252 | ||
| 245 | impl<'d> SubGhz<'d, NoDma, NoDma> { | 253 | impl<'d> SubGhz<'d, NoDma, NoDma> { |
diff --git a/embassy-stm32/src/subghz/mod_params.rs b/embassy-stm32/src/subghz/mod_params.rs index 3a5cb199a..0bfcb43ba 100644 --- a/embassy-stm32/src/subghz/mod_params.rs +++ b/embassy-stm32/src/subghz/mod_params.rs | |||
| @@ -561,6 +561,16 @@ impl FskModParams { | |||
| 561 | bw > br + 2 * fdev + freq_err | 561 | bw > br + 2 * fdev + freq_err |
| 562 | } | 562 | } |
| 563 | 563 | ||
| 564 | /// Returns `true` if the modulation parameters are valid for a worst-case | ||
| 565 | /// crystal tolerance. | ||
| 566 | /// | ||
| 567 | /// This is equivalent to [`is_valid`](Self::is_valid) with a `ppm` argument | ||
| 568 | /// of 30. | ||
| 569 | #[must_use = "the return value indicates if the modulation parameters are valid"] | ||
| 570 | pub const fn is_valid_worst_case(&self) -> bool { | ||
| 571 | self.is_valid(30) | ||
| 572 | } | ||
| 573 | |||
| 564 | /// Extracts a slice containing the packet. | 574 | /// Extracts a slice containing the packet. |
| 565 | /// | 575 | /// |
| 566 | /// # Example | 576 | /// # Example |
| @@ -613,11 +623,11 @@ pub enum SpreadingFactor { | |||
| 613 | /// Spreading factor 9. | 623 | /// Spreading factor 9. |
| 614 | Sf9 = 0x09, | 624 | Sf9 = 0x09, |
| 615 | /// Spreading factor 10. | 625 | /// Spreading factor 10. |
| 616 | Sf10 = 0xA0, | 626 | Sf10 = 0x0A, |
| 617 | /// Spreading factor 11. | 627 | /// Spreading factor 11. |
| 618 | Sf11 = 0xB0, | 628 | Sf11 = 0x0B, |
| 619 | /// Spreading factor 12. | 629 | /// Spreading factor 12. |
| 620 | Sf12 = 0xC0, | 630 | Sf12 = 0x0C, |
| 621 | } | 631 | } |
| 622 | 632 | ||
| 623 | impl From<SpreadingFactor> for u8 { | 633 | impl From<SpreadingFactor> for u8 { |
diff --git a/embassy-stm32/src/subghz/ocp.rs b/embassy-stm32/src/subghz/ocp.rs index 88eea1a2a..81e89c217 100644 --- a/embassy-stm32/src/subghz/ocp.rs +++ b/embassy-stm32/src/subghz/ocp.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Used by [`set_pa_ocp`]. | 3 | /// Used by [`set_pa_ocp`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_pa_ocp`]: crate::subghz::SubGhz::set_pa_ocp | 5 | /// [`set_pa_ocp`]: super::SubGhz::set_pa_ocp |
| 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | #[repr(u8)] | 8 | #[repr(u8)] |
diff --git a/embassy-stm32/src/subghz/op_error.rs b/embassy-stm32/src/subghz/op_error.rs index 35ebda8a0..f7d7e7417 100644 --- a/embassy-stm32/src/subghz/op_error.rs +++ b/embassy-stm32/src/subghz/op_error.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Returned by [`op_error`]. | 3 | /// Returned by [`op_error`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`op_error`]: crate::subghz::SubGhz::op_error | 5 | /// [`op_error`]: super::SubGhz::op_error |
| 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | #[repr(u8)] | 8 | #[repr(u8)] |
diff --git a/embassy-stm32/src/subghz/pa_config.rs b/embassy-stm32/src/subghz/pa_config.rs index 83c510aac..8da4ba400 100644 --- a/embassy-stm32/src/subghz/pa_config.rs +++ b/embassy-stm32/src/subghz/pa_config.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_pa_config`]. | 3 | /// Argument of [`set_pa_config`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_pa_config`]: crate::subghz::SubGhz::set_pa_config | 5 | /// [`set_pa_config`]: super::SubGhz::set_pa_config |
| 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | pub struct PaConfig { | 8 | pub struct PaConfig { |
| @@ -10,6 +10,62 @@ pub struct PaConfig { | |||
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | impl PaConfig { | 12 | impl PaConfig { |
| 13 | /// Optimal settings for +15dBm output power with the low-power PA. | ||
| 14 | /// | ||
| 15 | /// This must be used with [`TxParams::LP_15`](super::TxParams::LP_15). | ||
| 16 | pub const LP_15: PaConfig = PaConfig::new() | ||
| 17 | .set_pa_duty_cycle(0x6) | ||
| 18 | .set_hp_max(0x0) | ||
| 19 | .set_pa(PaSel::Lp); | ||
| 20 | |||
| 21 | /// Optimal settings for +14dBm output power with the low-power PA. | ||
| 22 | /// | ||
| 23 | /// This must be used with [`TxParams::LP_14`](super::TxParams::LP_14). | ||
| 24 | pub const LP_14: PaConfig = PaConfig::new() | ||
| 25 | .set_pa_duty_cycle(0x4) | ||
| 26 | .set_hp_max(0x0) | ||
| 27 | .set_pa(PaSel::Lp); | ||
| 28 | |||
| 29 | /// Optimal settings for +10dBm output power with the low-power PA. | ||
| 30 | /// | ||
| 31 | /// This must be used with [`TxParams::LP_10`](super::TxParams::LP_10). | ||
| 32 | pub const LP_10: PaConfig = PaConfig::new() | ||
| 33 | .set_pa_duty_cycle(0x1) | ||
| 34 | .set_hp_max(0x0) | ||
| 35 | .set_pa(PaSel::Lp); | ||
| 36 | |||
| 37 | /// Optimal settings for +22dBm output power with the high-power PA. | ||
| 38 | /// | ||
| 39 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | ||
| 40 | pub const HP_22: PaConfig = PaConfig::new() | ||
| 41 | .set_pa_duty_cycle(0x4) | ||
| 42 | .set_hp_max(0x7) | ||
| 43 | .set_pa(PaSel::Hp); | ||
| 44 | |||
| 45 | /// Optimal settings for +20dBm output power with the high-power PA. | ||
| 46 | /// | ||
| 47 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | ||
| 48 | pub const HP_20: PaConfig = PaConfig::new() | ||
| 49 | .set_pa_duty_cycle(0x3) | ||
| 50 | .set_hp_max(0x5) | ||
| 51 | .set_pa(PaSel::Hp); | ||
| 52 | |||
| 53 | /// Optimal settings for +17dBm output power with the high-power PA. | ||
| 54 | /// | ||
| 55 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | ||
| 56 | pub const HP_17: PaConfig = PaConfig::new() | ||
| 57 | .set_pa_duty_cycle(0x2) | ||
| 58 | .set_hp_max(0x3) | ||
| 59 | .set_pa(PaSel::Hp); | ||
| 60 | |||
| 61 | /// Optimal settings for +14dBm output power with the high-power PA. | ||
| 62 | /// | ||
| 63 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | ||
| 64 | pub const HP_14: PaConfig = PaConfig::new() | ||
| 65 | .set_pa_duty_cycle(0x2) | ||
| 66 | .set_hp_max(0x2) | ||
| 67 | .set_pa(PaSel::Hp); | ||
| 68 | |||
| 13 | /// Create a new `PaConfig` struct. | 69 | /// Create a new `PaConfig` struct. |
| 14 | /// | 70 | /// |
| 15 | /// This is the same as `default`, but in a `const` function. | 71 | /// This is the same as `default`, but in a `const` function. |
diff --git a/embassy-stm32/src/subghz/packet_params.rs b/embassy-stm32/src/subghz/packet_params.rs index 712dbaee5..ae84ea26a 100644 --- a/embassy-stm32/src/subghz/packet_params.rs +++ b/embassy-stm32/src/subghz/packet_params.rs | |||
| @@ -76,7 +76,7 @@ pub enum CrcType { | |||
| 76 | 76 | ||
| 77 | /// Packet parameters for [`set_packet_params`]. | 77 | /// Packet parameters for [`set_packet_params`]. |
| 78 | /// | 78 | /// |
| 79 | /// [`set_packet_params`]: crate::subghz::SubGhz::set_packet_params | 79 | /// [`set_packet_params`]: super::SubGhz::set_packet_params |
| 80 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 80 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 81 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 81 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 82 | pub struct GenericPacketParams { | 82 | pub struct GenericPacketParams { |
| @@ -311,7 +311,7 @@ impl Default for GenericPacketParams { | |||
| 311 | 311 | ||
| 312 | /// Packet parameters for [`set_lora_packet_params`]. | 312 | /// Packet parameters for [`set_lora_packet_params`]. |
| 313 | /// | 313 | /// |
| 314 | /// [`set_lora_packet_params`]: crate::subghz::SubGhz::set_lora_packet_params | 314 | /// [`set_lora_packet_params`]: super::SubGhz::set_lora_packet_params |
| 315 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 315 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 316 | pub struct LoRaPacketParams { | 316 | pub struct LoRaPacketParams { |
| 317 | buf: [u8; 7], | 317 | buf: [u8; 7], |
| @@ -470,7 +470,7 @@ impl Default for LoRaPacketParams { | |||
| 470 | 470 | ||
| 471 | /// Packet parameters for [`set_lora_packet_params`]. | 471 | /// Packet parameters for [`set_lora_packet_params`]. |
| 472 | /// | 472 | /// |
| 473 | /// [`set_lora_packet_params`]: crate::subghz::SubGhz::set_lora_packet_params | 473 | /// [`set_lora_packet_params`]: super::SubGhz::set_lora_packet_params |
| 474 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 474 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 475 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 475 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 476 | pub struct BpskPacketParams { | 476 | pub struct BpskPacketParams { |
diff --git a/embassy-stm32/src/subghz/packet_status.rs b/embassy-stm32/src/subghz/packet_status.rs index c5316dc5f..46eded6f1 100644 --- a/embassy-stm32/src/subghz/packet_status.rs +++ b/embassy-stm32/src/subghz/packet_status.rs | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | use embassy_hal_common::ratio::Ratio; | 1 | use super::Ratio; |
| 2 | 2 | ||
| 3 | use crate::subghz::status::Status; | 3 | use super::Status; |
| 4 | 4 | ||
| 5 | /// (G)FSK packet status. | 5 | /// (G)FSK packet status. |
| 6 | /// | 6 | /// |
| 7 | /// Returned by [`fsk_packet_status`]. | 7 | /// Returned by [`fsk_packet_status`]. |
| 8 | /// | 8 | /// |
| 9 | /// [`fsk_packet_status`]: crate::subghz::SubGhz::fsk_packet_status | 9 | /// [`fsk_packet_status`]: super::SubGhz::fsk_packet_status |
| 10 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 10 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 11 | pub struct FskPacketStatus { | 11 | pub struct FskPacketStatus { |
| 12 | buf: [u8; 4], | 12 | buf: [u8; 4], |
| @@ -37,7 +37,7 @@ impl FskPacketStatus { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | /// Returns `true` if a preabmle error occured. | 39 | /// Returns `true` if a preabmle error occured. |
| 40 | pub const fn preamble_error(&self) -> bool { | 40 | pub const fn preamble_err(&self) -> bool { |
| 41 | (self.buf[1] & (1 << 7)) != 0 | 41 | (self.buf[1] & (1 << 7)) != 0 |
| 42 | } | 42 | } |
| 43 | 43 | ||
| @@ -47,7 +47,7 @@ impl FskPacketStatus { | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | /// Returns `true` if an address error occured. | 49 | /// Returns `true` if an address error occured. |
| 50 | pub const fn adrs_err(&self) -> bool { | 50 | pub const fn addr_err(&self) -> bool { |
| 51 | (self.buf[1] & (1 << 5)) != 0 | 51 | (self.buf[1] & (1 << 5)) != 0 |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -76,6 +76,11 @@ impl FskPacketStatus { | |||
| 76 | (self.buf[1] & 1) != 0 | 76 | (self.buf[1] & 1) != 0 |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /// Returns `true` if any error occured. | ||
| 80 | pub const fn any_err(&self) -> bool { | ||
| 81 | (self.buf[1] & 0xFC) != 0 | ||
| 82 | } | ||
| 83 | |||
| 79 | /// RSSI level when the synchronization address is detected. | 84 | /// RSSI level when the synchronization address is detected. |
| 80 | /// | 85 | /// |
| 81 | /// Units are in dBm. | 86 | /// Units are in dBm. |
| @@ -118,9 +123,9 @@ impl defmt::Format for FskPacketStatus { | |||
| 118 | fmt, | 123 | fmt, |
| 119 | r#"FskPacketStatus {{ | 124 | r#"FskPacketStatus {{ |
| 120 | status: {}, | 125 | status: {}, |
| 121 | preamble_error: {}, | 126 | preamble_err: {}, |
| 122 | sync_err: {}, | 127 | sync_err: {}, |
| 123 | adrs_err: {}, | 128 | addr_err: {}, |
| 124 | crc_err: {}, | 129 | crc_err: {}, |
| 125 | length_err: {}, | 130 | length_err: {}, |
| 126 | abort_err: {}, | 131 | abort_err: {}, |
| @@ -130,9 +135,9 @@ impl defmt::Format for FskPacketStatus { | |||
| 130 | rssi_avg: {}, | 135 | rssi_avg: {}, |
| 131 | }}"#, | 136 | }}"#, |
| 132 | self.status(), | 137 | self.status(), |
| 133 | self.preamble_error(), | 138 | self.preamble_err(), |
| 134 | self.sync_err(), | 139 | self.sync_err(), |
| 135 | self.adrs_err(), | 140 | self.addr_err(), |
| 136 | self.crc_err(), | 141 | self.crc_err(), |
| 137 | self.length_err(), | 142 | self.length_err(), |
| 138 | self.abort_err(), | 143 | self.abort_err(), |
| @@ -148,9 +153,9 @@ impl core::fmt::Display for FskPacketStatus { | |||
| 148 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 153 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 149 | f.debug_struct("FskPacketStatus") | 154 | f.debug_struct("FskPacketStatus") |
| 150 | .field("status", &self.status()) | 155 | .field("status", &self.status()) |
| 151 | .field("preamble_error", &self.preamble_error()) | 156 | .field("preamble_err", &self.preamble_err()) |
| 152 | .field("sync_err", &self.sync_err()) | 157 | .field("sync_err", &self.sync_err()) |
| 153 | .field("adrs_err", &self.adrs_err()) | 158 | .field("addr_err", &self.addr_err()) |
| 154 | .field("crc_err", &self.crc_err()) | 159 | .field("crc_err", &self.crc_err()) |
| 155 | .field("length_err", &self.length_err()) | 160 | .field("length_err", &self.length_err()) |
| 156 | .field("abort_err", &self.abort_err()) | 161 | .field("abort_err", &self.abort_err()) |
| @@ -166,7 +171,7 @@ impl core::fmt::Display for FskPacketStatus { | |||
| 166 | /// | 171 | /// |
| 167 | /// Returned by [`lora_packet_status`]. | 172 | /// Returned by [`lora_packet_status`]. |
| 168 | /// | 173 | /// |
| 169 | /// [`lora_packet_status`]: crate::subghz::SubGhz::lora_packet_status | 174 | /// [`lora_packet_status`]: super::SubGhz::lora_packet_status |
| 170 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 175 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 171 | pub struct LoRaPacketStatus { | 176 | pub struct LoRaPacketStatus { |
| 172 | buf: [u8; 4], | 177 | buf: [u8; 4], |
diff --git a/embassy-stm32/src/subghz/packet_type.rs b/embassy-stm32/src/subghz/packet_type.rs index d953a6b9e..4a4e1072d 100644 --- a/embassy-stm32/src/subghz/packet_type.rs +++ b/embassy-stm32/src/subghz/packet_type.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_packet_type`] | 3 | /// Argument of [`set_packet_type`] |
| 4 | /// | 4 | /// |
| 5 | /// [`set_packet_type`]: crate::subghz::SubGhz::set_packet_type | 5 | /// [`set_packet_type`]: super::SubGhz::set_packet_type |
| 6 | #[repr(u8)] | 6 | #[repr(u8)] |
| 7 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 7 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
diff --git a/embassy-stm32/src/subghz/pkt_ctrl.rs b/embassy-stm32/src/subghz/pkt_ctrl.rs index b4775d574..0d3fa4dae 100644 --- a/embassy-stm32/src/subghz/pkt_ctrl.rs +++ b/embassy-stm32/src/subghz/pkt_ctrl.rs | |||
| @@ -22,7 +22,7 @@ impl Default for InfSeqSel { | |||
| 22 | 22 | ||
| 23 | /// Generic packet control. | 23 | /// Generic packet control. |
| 24 | /// | 24 | /// |
| 25 | /// Argument of [`set_pkt_ctrl`](crate::subghz::SubGhz::set_pkt_ctrl). | 25 | /// Argument of [`set_pkt_ctrl`](super::SubGhz::set_pkt_ctrl). |
| 26 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 26 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 27 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 27 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 28 | pub struct PktCtrl { | 28 | pub struct PktCtrl { |
diff --git a/embassy-stm32/src/subghz/pmode.rs b/embassy-stm32/src/subghz/pmode.rs index 990be2fc1..0c07f3195 100644 --- a/embassy-stm32/src/subghz/pmode.rs +++ b/embassy-stm32/src/subghz/pmode.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_rx_gain`]. | 3 | /// Argument of [`set_rx_gain`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_rx_gain`]: crate::subghz::SubGhz::set_rx_gain | 5 | /// [`set_rx_gain`]: super::SubGhz::set_rx_gain |
| 6 | #[repr(u8)] | 6 | #[repr(u8)] |
| 7 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 7 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
diff --git a/embassy-stm32/src/subghz/pwr_ctrl.rs b/embassy-stm32/src/subghz/pwr_ctrl.rs index d0de06f1f..2e188a960 100644 --- a/embassy-stm32/src/subghz/pwr_ctrl.rs +++ b/embassy-stm32/src/subghz/pwr_ctrl.rs | |||
| @@ -46,7 +46,7 @@ impl Default for CurrentLim { | |||
| 46 | 46 | ||
| 47 | /// Power control. | 47 | /// Power control. |
| 48 | /// | 48 | /// |
| 49 | /// Argument of [`set_bit_sync`](crate::subghz::SubGhz::set_bit_sync). | 49 | /// Argument of [`set_bit_sync`](super::SubGhz::set_bit_sync). |
| 50 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 50 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 51 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 51 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 52 | pub struct PwrCtrl { | 52 | pub struct PwrCtrl { |
diff --git a/embassy-stm32/src/subghz/rf_frequency.rs b/embassy-stm32/src/subghz/rf_frequency.rs index 7face3d0d..54c03dcd8 100644 --- a/embassy-stm32/src/subghz/rf_frequency.rs +++ b/embassy-stm32/src/subghz/rf_frequency.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_rf_frequency`]. | 3 | /// Argument of [`set_rf_frequency`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_rf_frequency`]: crate::subghz::SubGhz::set_rf_frequency | 5 | /// [`set_rf_frequency`]: super::SubGhz::set_rf_frequency |
| 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)] | 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | pub struct RfFreq { | 8 | pub struct RfFreq { |
diff --git a/embassy-stm32/src/subghz/rx_timeout_stop.rs b/embassy-stm32/src/subghz/rx_timeout_stop.rs index f057d3573..1d4aaecee 100644 --- a/embassy-stm32/src/subghz/rx_timeout_stop.rs +++ b/embassy-stm32/src/subghz/rx_timeout_stop.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Used by [`set_rx_timeout_stop`]. | 3 | /// Used by [`set_rx_timeout_stop`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_rx_timeout_stop`]: crate::subghz::SubGhz::set_rx_timeout_stop | 5 | /// [`set_rx_timeout_stop`]: super::SubGhz::set_rx_timeout_stop |
| 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | #[repr(u8)] | 8 | #[repr(u8)] |
diff --git a/embassy-stm32/src/subghz/sleep_cfg.rs b/embassy-stm32/src/subghz/sleep_cfg.rs index 1aaa2c943..3fdcc7133 100644 --- a/embassy-stm32/src/subghz/sleep_cfg.rs +++ b/embassy-stm32/src/subghz/sleep_cfg.rs | |||
| @@ -27,7 +27,7 @@ impl Default for Startup { | |||
| 27 | /// | 27 | /// |
| 28 | /// Argument of [`set_sleep`]. | 28 | /// Argument of [`set_sleep`]. |
| 29 | /// | 29 | /// |
| 30 | /// [`set_sleep`]: crate::subghz::SubGhz::set_sleep | 30 | /// [`set_sleep`]: super::SubGhz::set_sleep |
| 31 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 31 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 32 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 32 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 33 | pub struct SleepCfg(u8); | 33 | pub struct SleepCfg(u8); |
diff --git a/embassy-stm32/src/subghz/smps.rs b/embassy-stm32/src/subghz/smps.rs index 59947f2a3..3d843b017 100644 --- a/embassy-stm32/src/subghz/smps.rs +++ b/embassy-stm32/src/subghz/smps.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /// SMPS maximum drive capability. | 1 | /// SMPS maximum drive capability. |
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_smps_drv`](crate::subghz::SubGhz::set_smps_drv). | 3 | /// Argument of [`set_smps_drv`](super::SubGhz::set_smps_drv). |
| 4 | #[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Clone, Copy)] | 4 | #[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Clone, Copy)] |
| 5 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 5 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 6 | #[repr(u8)] | 6 | #[repr(u8)] |
diff --git a/embassy-stm32/src/subghz/standby_clk.rs b/embassy-stm32/src/subghz/standby_clk.rs index 2e6a03306..c130bbee4 100644 --- a/embassy-stm32/src/subghz/standby_clk.rs +++ b/embassy-stm32/src/subghz/standby_clk.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Used by [`set_standby`]. | 3 | /// Used by [`set_standby`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`set_standby`]: crate::subghz::SubGhz::set_standby | 5 | /// [`set_standby`]: super::SubGhz::set_standby |
| 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | #[repr(u8)] | 8 | #[repr(u8)] |
diff --git a/embassy-stm32/src/subghz/stats.rs b/embassy-stm32/src/subghz/stats.rs index 52a2252f8..46dc2bdfe 100644 --- a/embassy-stm32/src/subghz/stats.rs +++ b/embassy-stm32/src/subghz/stats.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::subghz::status::Status; | 1 | use super::Status; |
| 2 | 2 | ||
| 3 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 3 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 4 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 4 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -24,8 +24,8 @@ impl FskStats { | |||
| 24 | /// | 24 | /// |
| 25 | /// Returned by [`fsk_stats`] and [`lora_stats`]. | 25 | /// Returned by [`fsk_stats`] and [`lora_stats`]. |
| 26 | /// | 26 | /// |
| 27 | /// [`fsk_stats`]: crate::subghz::SubGhz::fsk_stats | 27 | /// [`fsk_stats`]: super::SubGhz::fsk_stats |
| 28 | /// [`lora_stats`]: crate::subghz::SubGhz::lora_stats | 28 | /// [`lora_stats`]: super::SubGhz::lora_stats |
| 29 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 29 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 30 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 30 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 31 | pub struct Stats<ModType> { | 31 | pub struct Stats<ModType> { |
| @@ -169,7 +169,7 @@ impl core::fmt::Display for Stats<FskStats> { | |||
| 169 | 169 | ||
| 170 | #[cfg(test)] | 170 | #[cfg(test)] |
| 171 | mod test { | 171 | mod test { |
| 172 | use crate::subghz::{CmdStatus, LoRaStats, Stats, StatusMode}; | 172 | use super::super::{CmdStatus, LoRaStats, Stats, StatusMode}; |
| 173 | 173 | ||
| 174 | #[test] | 174 | #[test] |
| 175 | fn mixed() { | 175 | fn mixed() { |
diff --git a/embassy-stm32/src/subghz/status.rs b/embassy-stm32/src/subghz/status.rs index 0b8e6da73..ae50c5193 100644 --- a/embassy-stm32/src/subghz/status.rs +++ b/embassy-stm32/src/subghz/status.rs | |||
| @@ -115,7 +115,7 @@ impl CmdStatus { | |||
| 115 | /// | 115 | /// |
| 116 | /// This is returned by [`status`]. | 116 | /// This is returned by [`status`]. |
| 117 | /// | 117 | /// |
| 118 | /// [`status`]: crate::subghz::SubGhz::status | 118 | /// [`status`]: super::SubGhz::status |
| 119 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 119 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 120 | pub struct Status(u8); | 120 | pub struct Status(u8); |
| 121 | 121 | ||
diff --git a/embassy-stm32/src/subghz/tcxo_mode.rs b/embassy-stm32/src/subghz/tcxo_mode.rs index a80c493f5..64d7d3298 100644 --- a/embassy-stm32/src/subghz/tcxo_mode.rs +++ b/embassy-stm32/src/subghz/tcxo_mode.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::subghz::timeout::Timeout; | 1 | use super::Timeout; |
| 2 | 2 | ||
| 3 | /// TCXO trim. | 3 | /// TCXO trim. |
| 4 | /// | 4 | /// |
| @@ -78,7 +78,7 @@ impl TcxoTrim { | |||
| 78 | /// | 78 | /// |
| 79 | /// Argument of [`set_tcxo_mode`]. | 79 | /// Argument of [`set_tcxo_mode`]. |
| 80 | /// | 80 | /// |
| 81 | /// [`set_tcxo_mode`]: crate::subghz::SubGhz::set_tcxo_mode | 81 | /// [`set_tcxo_mode`]: super::SubGhz::set_tcxo_mode |
| 82 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 82 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 83 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 83 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 84 | pub struct TcxoMode { | 84 | pub struct TcxoMode { |
diff --git a/embassy-stm32/src/subghz/tx_params.rs b/embassy-stm32/src/subghz/tx_params.rs index 17f052bcb..278d49bf7 100644 --- a/embassy-stm32/src/subghz/tx_params.rs +++ b/embassy-stm32/src/subghz/tx_params.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /// Power amplifier ramp time for FSK, MSK, and LoRa modulation. | 1 | /// Power amplifier ramp time for FSK, MSK, and LoRa modulation. |
| 2 | /// | 2 | /// |
| 3 | /// Argument of [`set_ramp_time`][`crate::subghz::TxParams::set_ramp_time`]. | 3 | /// Argument of [`set_ramp_time`][`super::TxParams::set_ramp_time`]. |
| 4 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] | 4 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] |
| 5 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 5 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 6 | #[repr(u8)] | 6 | #[repr(u8)] |
| @@ -60,7 +60,7 @@ impl From<RampTime> for embassy::time::Duration { | |||
| 60 | } | 60 | } |
| 61 | /// Transmit parameters, output power and power amplifier ramp up time. | 61 | /// Transmit parameters, output power and power amplifier ramp up time. |
| 62 | /// | 62 | /// |
| 63 | /// Argument of [`set_tx_params`][`crate::subghz::SubGhz::set_tx_params`]. | 63 | /// Argument of [`set_tx_params`][`super::SubGhz::set_tx_params`]. |
| 64 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 64 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 65 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 65 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 66 | pub struct TxParams { | 66 | pub struct TxParams { |
| @@ -68,6 +68,31 @@ pub struct TxParams { | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | impl TxParams { | 70 | impl TxParams { |
| 71 | /// Optimal power setting for +15dBm output power with the low-power PA. | ||
| 72 | /// | ||
| 73 | /// This must be used with [`PaConfig::LP_15`](super::PaConfig::LP_15). | ||
| 74 | pub const LP_15: TxParams = TxParams::new().set_power(0x0E); | ||
| 75 | |||
| 76 | /// Optimal power setting for +14dBm output power with the low-power PA. | ||
| 77 | /// | ||
| 78 | /// This must be used with [`PaConfig::LP_14`](super::PaConfig::LP_14). | ||
| 79 | pub const LP_14: TxParams = TxParams::new().set_power(0x0E); | ||
| 80 | |||
| 81 | /// Optimal power setting for +10dBm output power with the low-power PA. | ||
| 82 | /// | ||
| 83 | /// This must be used with [`PaConfig::LP_10`](super::PaConfig::LP_10). | ||
| 84 | pub const LP_10: TxParams = TxParams::new().set_power(0x0D); | ||
| 85 | |||
| 86 | /// Optimal power setting for the high-power PA. | ||
| 87 | /// | ||
| 88 | /// This must be used with one of: | ||
| 89 | /// | ||
| 90 | /// * [`PaConfig::HP_22`](super::PaConfig::HP_22) | ||
| 91 | /// * [`PaConfig::HP_20`](super::PaConfig::HP_20) | ||
| 92 | /// * [`PaConfig::HP_17`](super::PaConfig::HP_17) | ||
| 93 | /// * [`PaConfig::HP_14`](super::PaConfig::HP_14) | ||
| 94 | pub const HP: TxParams = TxParams::new().set_power(0x16); | ||
| 95 | |||
| 71 | /// Create a new `TxParams` struct. | 96 | /// Create a new `TxParams` struct. |
| 72 | /// | 97 | /// |
| 73 | /// This is the same as `default`, but in a `const` function. | 98 | /// This is the same as `default`, but in a `const` function. |
| @@ -117,7 +142,7 @@ impl TxParams { | |||
| 117 | /// # assert_eq!(TX_PARAMS.as_slice()[1], 0x00); | 142 | /// # assert_eq!(TX_PARAMS.as_slice()[1], 0x00); |
| 118 | /// ``` | 143 | /// ``` |
| 119 | /// | 144 | /// |
| 120 | /// [`set_pa_config`]: crate::subghz::SubGhz::set_pa_config | 145 | /// [`set_pa_config`]: super::SubGhz::set_pa_config |
| 121 | #[must_use = "set_power returns a modified TxParams"] | 146 | #[must_use = "set_power returns a modified TxParams"] |
| 122 | pub const fn set_power(mut self, power: u8) -> TxParams { | 147 | pub const fn set_power(mut self, power: u8) -> TxParams { |
| 123 | self.buf[1] = power; | 148 | self.buf[1] = power; |
diff --git a/embassy-stm32/src/subghz/value_error.rs b/embassy-stm32/src/subghz/value_error.rs index 0c470cfae..8ad910081 100644 --- a/embassy-stm32/src/subghz/value_error.rs +++ b/embassy-stm32/src/subghz/value_error.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /// | 2 | /// |
| 3 | /// Used by [`Timeout::from_duration`]. | 3 | /// Used by [`Timeout::from_duration`]. |
| 4 | /// | 4 | /// |
| 5 | /// [`Timeout::from_duration`]: crate::subghz::Timeout::from_duration | 5 | /// [`Timeout::from_duration`]: super::Timeout::from_duration |
| 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 6 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | pub struct ValueError<T> { | 8 | pub struct ValueError<T> { |
