Skip to content

Commit cb8bc0b

Browse files
committed
Fix a number of clippy lints
Signed-off-by: Daniel Egger <[email protected]>
1 parent 8b46c37 commit cb8bc0b

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

src/adc.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const VTEMPCAL30: *const u16 = 0x1FFF_F7B8 as *const u16;
4242
const VTEMPCAL110: *const u16 = 0x1FFF_F7C2 as *const u16;
4343
const VDD_CALIB: u16 = 3300;
4444

45-
use core::ptr;
45+
use core::{ptr, default};
4646

4747
use embedded_hal::{
4848
adc::{Channel, OneShot},
@@ -93,9 +93,9 @@ pub enum AdcSampleTime {
9393
T_239,
9494
}
9595

96-
impl AdcSampleTime {
96+
impl default::Default for AdcSampleTime {
9797
/// Get the default sample time (currently 239.5 cycles)
98-
pub fn default() -> Self {
98+
fn default() -> Self {
9999
AdcSampleTime::T_239
100100
}
101101
}
@@ -138,9 +138,9 @@ pub enum AdcAlign {
138138
LeftAsRM,
139139
}
140140

141-
impl AdcAlign {
141+
impl default::Default for AdcAlign {
142142
/// Get the default alignment (currently right aligned)
143-
pub fn default() -> Self {
143+
fn default() -> Self {
144144
AdcAlign::Right
145145
}
146146
}
@@ -168,9 +168,9 @@ pub enum AdcPrecision {
168168
B_6,
169169
}
170170

171-
impl AdcPrecision {
171+
impl default::Default for AdcPrecision {
172172
/// Get the default precision (currently 12 bit precision)
173-
pub fn default() -> Self {
173+
fn default() -> Self {
174174
AdcPrecision::B_12
175175
}
176176
}
@@ -247,7 +247,7 @@ adc_pins!(
247247
impl VTemp {
248248
/// Init a new VTemp
249249
pub fn new() -> Self {
250-
VTemp::default()
250+
Self {}
251251
}
252252

253253
/// Enable the internal temperature sense, this has a wake up time
@@ -316,7 +316,7 @@ impl VTemp {
316316
impl VRef {
317317
/// Init a new VRef
318318
pub fn new() -> Self {
319-
VRef::default()
319+
Self {}
320320
}
321321

322322
/// Enable the internal voltage reference, remember to disable when not in use.
@@ -408,7 +408,7 @@ adc_pins!(
408408
impl VBat {
409409
/// Init a new VBat
410410
pub fn new() -> Self {
411-
VBat::default()
411+
Self {}
412412
}
413413

414414
/// Enable the internal VBat sense, remember to disable when not in use
@@ -514,10 +514,10 @@ impl Adc {
514514
/// Returns the largest possible sample value for the current settings
515515
pub fn max_sample(&self) -> u16 {
516516
match self.align {
517-
AdcAlign::Left => u16::max_value(),
517+
AdcAlign::Left => u16::MAX,
518518
AdcAlign::LeftAsRM => match self.precision {
519-
AdcPrecision::B_6 => u16::from(u8::max_value()),
520-
_ => u16::max_value(),
519+
AdcPrecision::B_6 => u16::from(u8::MAX),
520+
_ => u16::MAX,
521521
},
522522
AdcAlign::Right => match self.precision {
523523
AdcPrecision::B_12 => (1 << 12) - 1,

src/rcc.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ pub enum HSEBypassMode {
6161
#[allow(clippy::upper_case_acronyms)]
6262
pub enum USBClockSource {
6363
#[cfg(feature = "stm32f070")]
64-
/// USB peripheral's tranceiver is disabled
64+
/// USB peripheral's transceiver is disabled
6565
Disabled,
6666
#[cfg(not(feature = "stm32f070"))]
67-
/// HSI48 is used as USB peripheral tranceiver clock
67+
/// HSI48 is used as USB peripheral transceiver clock
6868
HSI48,
69-
/// PLL output is used as USB peripheral tranceiver clock
69+
/// PLL output is used as USB peripheral transceiver clock
7070
PLL,
7171
}
7272
/// RCC for F0x0 devices
@@ -465,7 +465,7 @@ impl CFGR {
465465
let pllmul = (2 * pllprediv * self.sysclk.unwrap_or(src_clk_freq) + src_clk_freq)
466466
/ src_clk_freq
467467
/ 2;
468-
let pllmul = core::cmp::min(core::cmp::max(pllmul, 2), 16);
468+
let pllmul = pllmul.clamp(2, 16);
469469
r_sysclk = pllmul * src_clk_freq / pllprediv;
470470

471471
pllmul_bits = Some(pllmul as u8 - 2)
@@ -562,17 +562,14 @@ impl CFGR {
562562
feature = "stm32f091",
563563
feature = "stm32f098",
564564
))]
565-
match self.crs {
566-
Some(crs) => {
567-
self.rcc.apb1enr.modify(|_, w| w.crsen().set_bit());
568-
569-
// Initialize clock recovery
570-
// Set autotrim enabled.
571-
crs.cr.modify(|_, w| w.autotrimen().set_bit());
572-
// Enable CR
573-
crs.cr.modify(|_, w| w.cen().set_bit());
574-
}
575-
_ => {}
565+
if let Some(crs) = self.crs {
566+
self.rcc.apb1enr.modify(|_, w| w.crsen().set_bit());
567+
568+
// Initialize clock recovery
569+
// Set autotrim enabled.
570+
crs.cr.modify(|_, w| w.autotrimen().set_bit());
571+
// Enable CR
572+
crs.cr.modify(|_, w| w.cen().set_bit());
576573
}
577574

578575
// use HSI as source

0 commit comments

Comments
 (0)