diff options
| author | eZio Pan <[email protected]> | 2024-01-06 22:48:21 +0800 |
|---|---|---|
| committer | eZio Pan <[email protected]> | 2024-01-06 22:48:21 +0800 |
| commit | 890a1269d05297993ffa7b537739926eb30d5436 (patch) | |
| tree | c2e0de544570b1172f0786103f6537c7942e592a | |
| parent | 424ddaf3d95417bcfe8b46475c8135aead3792d2 (diff) | |
refactor with clippy
| -rw-r--r-- | embassy-stm32/build.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 15 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs | 2 |
4 files changed, 13 insertions, 14 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 7860ee2ff..fc876afcc 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -936,9 +936,9 @@ fn main() { | |||
| 936 | } else if pin.signal.starts_with("INN") { | 936 | } else if pin.signal.starts_with("INN") { |
| 937 | // TODO handle in the future when embassy supports differential measurements | 937 | // TODO handle in the future when embassy supports differential measurements |
| 938 | None | 938 | None |
| 939 | } else if pin.signal.starts_with("IN") && pin.signal.ends_with("b") { | 939 | } else if pin.signal.starts_with("IN") && pin.signal.ends_with('b') { |
| 940 | // we number STM32L1 ADC bank 1 as 0..=31, bank 2 as 32..=63 | 940 | // we number STM32L1 ADC bank 1 as 0..=31, bank 2 as 32..=63 |
| 941 | let signal = pin.signal.strip_prefix("IN").unwrap().strip_suffix("b").unwrap(); | 941 | let signal = pin.signal.strip_prefix("IN").unwrap().strip_suffix('b').unwrap(); |
| 942 | Some(32u8 + signal.parse::<u8>().unwrap()) | 942 | Some(32u8 + signal.parse::<u8>().unwrap()) |
| 943 | } else if pin.signal.starts_with("IN") { | 943 | } else if pin.signal.starts_with("IN") { |
| 944 | Some(pin.signal.strip_prefix("IN").unwrap().parse().unwrap()) | 944 | Some(pin.signal.strip_prefix("IN").unwrap().parse().unwrap()) |
| @@ -1186,7 +1186,7 @@ fn main() { | |||
| 1186 | ADC3 and higher are assigned to the adc34 clock in the table | 1186 | ADC3 and higher are assigned to the adc34 clock in the table |
| 1187 | The adc3_common cfg directive is added if ADC3_COMMON exists | 1187 | The adc3_common cfg directive is added if ADC3_COMMON exists |
| 1188 | */ | 1188 | */ |
| 1189 | let has_adc3 = METADATA.peripherals.iter().find(|p| p.name == "ADC3_COMMON").is_some(); | 1189 | let has_adc3 = METADATA.peripherals.iter().any(|p| p.name == "ADC3_COMMON"); |
| 1190 | let set_adc345 = HashSet::from(["ADC3", "ADC4", "ADC5"]); | 1190 | let set_adc345 = HashSet::from(["ADC3", "ADC4", "ADC5"]); |
| 1191 | 1191 | ||
| 1192 | for m in METADATA | 1192 | for m in METADATA |
| @@ -1370,6 +1370,7 @@ fn main() { | |||
| 1370 | 1370 | ||
| 1371 | // ======= | 1371 | // ======= |
| 1372 | // ADC3_COMMON is present | 1372 | // ADC3_COMMON is present |
| 1373 | #[allow(clippy::print_literal)] | ||
| 1373 | if has_adc3 { | 1374 | if has_adc3 { |
| 1374 | println!("cargo:rustc-cfg={}", "adc3_common"); | 1375 | println!("cargo:rustc-cfg={}", "adc3_common"); |
| 1375 | } | 1376 | } |
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 71d7110b5..eddce0404 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -54,6 +54,7 @@ pub struct ComplementaryPwm<'d, T> { | |||
| 54 | 54 | ||
| 55 | impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T> { | 55 | impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T> { |
| 56 | /// Create a new complementary PWM driver. | 56 | /// Create a new complementary PWM driver. |
| 57 | #[allow(clippy::too_many_arguments)] | ||
| 57 | pub fn new( | 58 | pub fn new( |
| 58 | tim: impl Peripheral<P = T> + 'd, | 59 | tim: impl Peripheral<P = T> + 'd, |
| 59 | _ch1: Option<PwmPin<'d, T, Ch1>>, | 60 | _ch1: Option<PwmPin<'d, T, Ch1>>, |
| @@ -165,7 +166,7 @@ impl<'d, T: ComplementaryCaptureCompare16bitInstance> embedded_hal_02::Pwm for C | |||
| 165 | } | 166 | } |
| 166 | 167 | ||
| 167 | fn get_period(&self) -> Self::Time { | 168 | fn get_period(&self) -> Self::Time { |
| 168 | self.inner.get_frequency().into() | 169 | self.inner.get_frequency() |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { | 172 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { |
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 957098cde..210bf7153 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -470,20 +470,17 @@ pub enum CountingMode { | |||
| 470 | impl CountingMode { | 470 | impl CountingMode { |
| 471 | /// Return whether this mode is edge-aligned (up or down). | 471 | /// Return whether this mode is edge-aligned (up or down). |
| 472 | pub fn is_edge_aligned(&self) -> bool { | 472 | pub fn is_edge_aligned(&self) -> bool { |
| 473 | match self { | 473 | matches!(self, CountingMode::EdgeAlignedUp | CountingMode::EdgeAlignedDown) |
| 474 | CountingMode::EdgeAlignedUp | CountingMode::EdgeAlignedDown => true, | ||
| 475 | _ => false, | ||
| 476 | } | ||
| 477 | } | 474 | } |
| 478 | 475 | ||
| 479 | /// Return whether this mode is center-aligned. | 476 | /// Return whether this mode is center-aligned. |
| 480 | pub fn is_center_aligned(&self) -> bool { | 477 | pub fn is_center_aligned(&self) -> bool { |
| 481 | match self { | 478 | matches!( |
| 479 | self, | ||
| 482 | CountingMode::CenterAlignedDownInterrupts | 480 | CountingMode::CenterAlignedDownInterrupts |
| 483 | | CountingMode::CenterAlignedUpInterrupts | 481 | | CountingMode::CenterAlignedUpInterrupts |
| 484 | | CountingMode::CenterAlignedBothInterrupts => true, | 482 | | CountingMode::CenterAlignedBothInterrupts |
| 485 | _ => false, | 483 | ) |
| 486 | } | ||
| 487 | } | 484 | } |
| 488 | } | 485 | } |
| 489 | 486 | ||
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 665557354..709278c0c 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -323,7 +323,7 @@ impl<'d, T: CaptureCompare16bitInstance> embedded_hal_02::Pwm for SimplePwm<'d, | |||
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | fn get_period(&self) -> Self::Time { | 325 | fn get_period(&self) -> Self::Time { |
| 326 | self.inner.get_frequency().into() | 326 | self.inner.get_frequency() |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { | 329 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { |
