diff options
| author | Ulf Lilleengen <[email protected]> | 2022-06-15 09:01:22 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-06-15 09:01:22 +0200 |
| commit | faa59efbf623b4551e064a61c087294f73dbb123 (patch) | |
| tree | 38ede12e48b39ec59d06c9ec5331d5b2c483dacc | |
| parent | 3696226fe833d885f75f00056ca1a754c1b83e2c (diff) | |
Cargo fmt
| -rw-r--r-- | embassy-stm32/src/subghz/pa_config.rs | 35 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/packet_params.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/rf_frequency.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/sleep_cfg.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/status.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/timeout.rs | 3 |
6 files changed, 12 insertions, 47 deletions
diff --git a/embassy-stm32/src/subghz/pa_config.rs b/embassy-stm32/src/subghz/pa_config.rs index eccd065d7..875827bd4 100644 --- a/embassy-stm32/src/subghz/pa_config.rs +++ b/embassy-stm32/src/subghz/pa_config.rs | |||
| @@ -13,58 +13,37 @@ impl PaConfig { | |||
| 13 | /// Optimal settings for +15dBm output power with the low-power PA. | 13 | /// Optimal settings for +15dBm output power with the low-power PA. |
| 14 | /// | 14 | /// |
| 15 | /// This must be used with [`TxParams::LP_15`](super::TxParams::LP_15). | 15 | /// This must be used with [`TxParams::LP_15`](super::TxParams::LP_15). |
| 16 | pub const LP_15: PaConfig = PaConfig::new() | 16 | pub const LP_15: PaConfig = PaConfig::new().set_pa_duty_cycle(0x6).set_hp_max(0x0).set_pa(PaSel::Lp); |
| 17 | .set_pa_duty_cycle(0x6) | ||
| 18 | .set_hp_max(0x0) | ||
| 19 | .set_pa(PaSel::Lp); | ||
| 20 | 17 | ||
| 21 | /// Optimal settings for +14dBm output power with the low-power PA. | 18 | /// Optimal settings for +14dBm output power with the low-power PA. |
| 22 | /// | 19 | /// |
| 23 | /// This must be used with [`TxParams::LP_14`](super::TxParams::LP_14). | 20 | /// This must be used with [`TxParams::LP_14`](super::TxParams::LP_14). |
| 24 | pub const LP_14: PaConfig = PaConfig::new() | 21 | pub const LP_14: PaConfig = PaConfig::new().set_pa_duty_cycle(0x4).set_hp_max(0x0).set_pa(PaSel::Lp); |
| 25 | .set_pa_duty_cycle(0x4) | ||
| 26 | .set_hp_max(0x0) | ||
| 27 | .set_pa(PaSel::Lp); | ||
| 28 | 22 | ||
| 29 | /// Optimal settings for +10dBm output power with the low-power PA. | 23 | /// Optimal settings for +10dBm output power with the low-power PA. |
| 30 | /// | 24 | /// |
| 31 | /// This must be used with [`TxParams::LP_10`](super::TxParams::LP_10). | 25 | /// This must be used with [`TxParams::LP_10`](super::TxParams::LP_10). |
| 32 | pub const LP_10: PaConfig = PaConfig::new() | 26 | pub const LP_10: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp); |
| 33 | .set_pa_duty_cycle(0x1) | ||
| 34 | .set_hp_max(0x0) | ||
| 35 | .set_pa(PaSel::Lp); | ||
| 36 | 27 | ||
| 37 | /// Optimal settings for +22dBm output power with the high-power PA. | 28 | /// Optimal settings for +22dBm output power with the high-power PA. |
| 38 | /// | 29 | /// |
| 39 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | 30 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). |
| 40 | pub const HP_22: PaConfig = PaConfig::new() | 31 | pub const HP_22: PaConfig = PaConfig::new().set_pa_duty_cycle(0x4).set_hp_max(0x7).set_pa(PaSel::Hp); |
| 41 | .set_pa_duty_cycle(0x4) | ||
| 42 | .set_hp_max(0x7) | ||
| 43 | .set_pa(PaSel::Hp); | ||
| 44 | 32 | ||
| 45 | /// Optimal settings for +20dBm output power with the high-power PA. | 33 | /// Optimal settings for +20dBm output power with the high-power PA. |
| 46 | /// | 34 | /// |
| 47 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | 35 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). |
| 48 | pub const HP_20: PaConfig = PaConfig::new() | 36 | pub const HP_20: PaConfig = PaConfig::new().set_pa_duty_cycle(0x3).set_hp_max(0x5).set_pa(PaSel::Hp); |
| 49 | .set_pa_duty_cycle(0x3) | ||
| 50 | .set_hp_max(0x5) | ||
| 51 | .set_pa(PaSel::Hp); | ||
| 52 | 37 | ||
| 53 | /// Optimal settings for +17dBm output power with the high-power PA. | 38 | /// Optimal settings for +17dBm output power with the high-power PA. |
| 54 | /// | 39 | /// |
| 55 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | 40 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). |
| 56 | pub const HP_17: PaConfig = PaConfig::new() | 41 | pub const HP_17: PaConfig = PaConfig::new().set_pa_duty_cycle(0x2).set_hp_max(0x3).set_pa(PaSel::Hp); |
| 57 | .set_pa_duty_cycle(0x2) | ||
| 58 | .set_hp_max(0x3) | ||
| 59 | .set_pa(PaSel::Hp); | ||
| 60 | 42 | ||
| 61 | /// Optimal settings for +14dBm output power with the high-power PA. | 43 | /// Optimal settings for +14dBm output power with the high-power PA. |
| 62 | /// | 44 | /// |
| 63 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). | 45 | /// This must be used with [`TxParams::HP`](super::TxParams::HP). |
| 64 | pub const HP_14: PaConfig = PaConfig::new() | 46 | pub const HP_14: PaConfig = PaConfig::new().set_pa_duty_cycle(0x2).set_hp_max(0x2).set_pa(PaSel::Hp); |
| 65 | .set_pa_duty_cycle(0x2) | ||
| 66 | .set_hp_max(0x2) | ||
| 67 | .set_pa(PaSel::Hp); | ||
| 68 | 47 | ||
| 69 | /// Create a new `PaConfig` struct. | 48 | /// Create a new `PaConfig` struct. |
| 70 | /// | 49 | /// |
diff --git a/embassy-stm32/src/subghz/packet_params.rs b/embassy-stm32/src/subghz/packet_params.rs index eef2f3dbf..d63641c45 100644 --- a/embassy-stm32/src/subghz/packet_params.rs +++ b/embassy-stm32/src/subghz/packet_params.rs | |||
| @@ -147,10 +147,7 @@ impl GenericPacketParams { | |||
| 147 | /// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x4); | 147 | /// # assert_eq!(PKT_PARAMS.as_slice()[3], 0x4); |
| 148 | /// ``` | 148 | /// ``` |
| 149 | #[must_use = "set_preamble_detection returns a modified GenericPacketParams"] | 149 | #[must_use = "set_preamble_detection returns a modified GenericPacketParams"] |
| 150 | pub const fn set_preamble_detection( | 150 | pub const fn set_preamble_detection(mut self, pb_det: PreambleDetection) -> GenericPacketParams { |
| 151 | mut self, | ||
| 152 | pb_det: PreambleDetection, | ||
| 153 | ) -> GenericPacketParams { | ||
| 154 | self.buf[3] = pb_det as u8; | 151 | self.buf[3] = pb_det as u8; |
| 155 | self | 152 | self |
| 156 | } | 153 | } |
diff --git a/embassy-stm32/src/subghz/rf_frequency.rs b/embassy-stm32/src/subghz/rf_frequency.rs index 97633c6b1..3de2f50c4 100644 --- a/embassy-stm32/src/subghz/rf_frequency.rs +++ b/embassy-stm32/src/subghz/rf_frequency.rs | |||
| @@ -89,10 +89,7 @@ impl RfFreq { | |||
| 89 | 89 | ||
| 90 | // Get the frequency bit value. | 90 | // Get the frequency bit value. |
| 91 | const fn as_bits(&self) -> u32 { | 91 | const fn as_bits(&self) -> u32 { |
| 92 | ((self.buf[1] as u32) << 24) | 92 | ((self.buf[1] as u32) << 24) | ((self.buf[2] as u32) << 16) | ((self.buf[3] as u32) << 8) | (self.buf[4] as u32) |
| 93 | | ((self.buf[2] as u32) << 16) | ||
| 94 | | ((self.buf[3] as u32) << 8) | ||
| 95 | | (self.buf[4] as u32) | ||
| 96 | } | 93 | } |
| 97 | 94 | ||
| 98 | /// Get the actual frequency. | 95 | /// Get the actual frequency. |
diff --git a/embassy-stm32/src/subghz/sleep_cfg.rs b/embassy-stm32/src/subghz/sleep_cfg.rs index 0b67304b7..0a50e9704 100644 --- a/embassy-stm32/src/subghz/sleep_cfg.rs +++ b/embassy-stm32/src/subghz/sleep_cfg.rs | |||
| @@ -49,9 +49,7 @@ impl SleepCfg { | |||
| 49 | /// # assert_eq!(u8::from(SLEEP_CFG), 0b101); | 49 | /// # assert_eq!(u8::from(SLEEP_CFG), 0b101); |
| 50 | /// ``` | 50 | /// ``` |
| 51 | pub const fn new() -> SleepCfg { | 51 | pub const fn new() -> SleepCfg { |
| 52 | SleepCfg(0) | 52 | SleepCfg(0).set_startup(Startup::Warm).set_rtc_wakeup_en(true) |
| 53 | .set_startup(Startup::Warm) | ||
| 54 | .set_rtc_wakeup_en(true) | ||
| 55 | } | 53 | } |
| 56 | 54 | ||
| 57 | /// Set the startup mode. | 55 | /// Set the startup mode. |
diff --git a/embassy-stm32/src/subghz/status.rs b/embassy-stm32/src/subghz/status.rs index f352d6fb6..b84034f68 100644 --- a/embassy-stm32/src/subghz/status.rs +++ b/embassy-stm32/src/subghz/status.rs | |||
| @@ -192,11 +192,6 @@ impl core::fmt::Debug for Status { | |||
| 192 | #[cfg(feature = "defmt")] | 192 | #[cfg(feature = "defmt")] |
| 193 | impl defmt::Format for Status { | 193 | impl defmt::Format for Status { |
| 194 | fn format(&self, fmt: defmt::Formatter) { | 194 | fn format(&self, fmt: defmt::Formatter) { |
| 195 | defmt::write!( | 195 | defmt::write!(fmt, "Status {{ mode: {}, cmd: {} }}", self.mode(), self.cmd()) |
| 196 | fmt, | ||
| 197 | "Status {{ mode: {}, cmd: {} }}", | ||
| 198 | self.mode(), | ||
| 199 | self.cmd() | ||
| 200 | ) | ||
| 201 | } | 196 | } |
| 202 | } | 197 | } |
diff --git a/embassy-stm32/src/subghz/timeout.rs b/embassy-stm32/src/subghz/timeout.rs index ccec3bbf2..9dbdc6374 100644 --- a/embassy-stm32/src/subghz/timeout.rs +++ b/embassy-stm32/src/subghz/timeout.rs | |||
| @@ -145,8 +145,7 @@ impl Timeout { | |||
| 145 | // `core::Duration` were not `const fn`, which leads to the hacks | 145 | // `core::Duration` were not `const fn`, which leads to the hacks |
| 146 | // you see here. | 146 | // you see here. |
| 147 | let nanos: u128 = duration.as_nanos(); | 147 | let nanos: u128 = duration.as_nanos(); |
| 148 | const UPPER_LIMIT: u128 = | 148 | const UPPER_LIMIT: u128 = Timeout::MAX.as_nanos() as u128 + (Timeout::RESOLUTION_NANOS as u128) / 2; |
| 149 | Timeout::MAX.as_nanos() as u128 + (Timeout::RESOLUTION_NANOS as u128) / 2; | ||
| 150 | const LOWER_LIMIT: u128 = (((Timeout::RESOLUTION_NANOS as u128) + 1) / 2) as u128; | 149 | const LOWER_LIMIT: u128 = (((Timeout::RESOLUTION_NANOS as u128) + 1) / 2) as u128; |
| 151 | 150 | ||
| 152 | if nanos > UPPER_LIMIT { | 151 | if nanos > UPPER_LIMIT { |
