Skip to content

Commit be8a886

Browse files
committed
clippy
1 parent 3f853e0 commit be8a886

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

src/adc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,15 @@ impl<ADC: Instance> Adc<ADC> {
532532

533533
//Set the sample time for the channel
534534
let st = sample_time as u8;
535-
let ch = channel as u8;
536535
match channel {
537536
0..=9 => self
538537
.adc_reg
539538
.smpr2()
540-
.modify(|_, w| unsafe { w.smp(ch).bits(st) }),
539+
.modify(|_, w| unsafe { w.smp(channel).bits(st) }),
541540
10..=18 => self
542541
.adc_reg
543542
.smpr1()
544-
.modify(|_, w| unsafe { w.smp(ch - 10).bits(st) }),
543+
.modify(|_, w| unsafe { w.smp(channel - 10).bits(st) }),
545544
_ => unimplemented!(),
546545
};
547546
}

src/fmpi2c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn calculate_timing(
198198
let mut presc: u8;
199199
// if ratio is > (scll+sclh)*presc. that frequancy is not possible to generate. so
200200
// minimum frequancy possible is generated
201-
if product > 8192 as f32 {
201+
if product > 8192_f32 {
202202
// TODO: should we panic or use minimum allowed frequancy
203203
scl_l = 0x7fu8;
204204
scl_h = 0x7fu8;
@@ -214,7 +214,7 @@ fn calculate_timing(
214214
let deviation = product % tmp_presc as f32;
215215
if min_deviation > deviation {
216216
min_deviation = deviation;
217-
presc = tmp_presc as u8;
217+
presc = tmp_presc;
218218
}
219219
}
220220
// now that we have optimal prescalar value. optimal scl_l and scl_h

src/rcc/f4/enable.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ macro_rules! bus_enable {
2020
}
2121
#[inline(always)]
2222
fn is_enabled() -> bool {
23-
let rcc = pac::RCC::ptr();
23+
let rcc = RCC::ptr();
2424
(Self::Bus::enr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
2525
}
2626
}
@@ -45,7 +45,7 @@ macro_rules! bus_lpenable {
4545
}
4646
#[inline(always)]
4747
fn is_enabled_in_low_power() -> bool {
48-
let rcc = pac::RCC::ptr();
48+
let rcc = RCC::ptr();
4949
(Self::Bus::lpenr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
5050
}
5151
}
@@ -56,9 +56,10 @@ macro_rules! bus_reset {
5656
impl Reset for crate::pac::$PER {
5757
#[inline(always)]
5858
fn reset(rcc: &mut RCC) {
59+
let rstr = Self::Bus::rstr(rcc);
5960
unsafe {
60-
bb::set(Self::Bus::rstr(rcc), $bit);
61-
bb::clear(Self::Bus::rstr(rcc), $bit);
61+
bb::set(rstr, $bit);
62+
bb::clear(rstr, $bit);
6263
}
6364
}
6465
}

src/rcc/f4/mod.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::pac::rcc::cfgr::{HPRE, SW};
2+
use crate::pac::rcc::RegisterBlock as RccRB;
23
use crate::pac::{self, rcc, RCC};
34

45
use super::{BusClock, BusTimerClock, RccBus};
@@ -9,10 +10,8 @@ use fugit::RateExtU32;
910
mod pll;
1011

1112
mod enable;
12-
use crate::pac::rcc::RegisterBlock as RccRB;
1313

1414
/// Enable/disable peripheral
15-
#[allow(clippy::missing_safety_doc)]
1615
pub trait Enable: RccBus {
1716
/// Enables peripheral
1817
fn enable(rcc: &mut RCC);
@@ -33,21 +32,20 @@ pub trait Enable: RccBus {
3332
///
3433
/// Enables peripheral. Takes access to RCC internally
3534
unsafe fn enable_unchecked() {
36-
let mut rcc = pac::RCC::steal();
35+
let mut rcc = RCC::steal();
3736
Self::enable(&mut rcc);
3837
}
3938

4039
/// # Safety
4140
///
4241
/// Disables peripheral. Takes access to RCC internally
4342
unsafe fn disable_unchecked() {
44-
let mut rcc = pac::RCC::steal();
43+
let mut rcc = RCC::steal();
4544
Self::disable(&mut rcc);
4645
}
4746
}
4847

4948
/// Low power enable/disable peripheral
50-
#[allow(clippy::missing_safety_doc)]
5149
pub trait LPEnable: RccBus {
5250
/// Enables peripheral in low power mode
5351
fn enable_in_low_power(rcc: &mut RCC);
@@ -68,21 +66,20 @@ pub trait LPEnable: RccBus {
6866
///
6967
/// Enables peripheral in low power mode. Takes access to RCC internally
7068
unsafe fn enable_in_low_power_unchecked() {
71-
let mut rcc = pac::RCC::steal();
69+
let mut rcc = RCC::steal();
7270
Self::enable_in_low_power(&mut rcc);
7371
}
7472

7573
/// # Safety
7674
///
7775
/// Disables peripheral in low power mode. Takes access to RCC internally
7876
unsafe fn disable_in_low_power_unchecked() {
79-
let mut rcc = pac::RCC::steal();
77+
let mut rcc = RCC::steal();
8078
Self::disable_in_low_power(&mut rcc);
8179
}
8280
}
8381

8482
/// Reset peripheral
85-
#[allow(clippy::missing_safety_doc)]
8683
pub trait Reset: RccBus {
8784
/// Resets peripheral
8885
fn reset(rcc: &mut RCC);
@@ -91,7 +88,7 @@ pub trait Reset: RccBus {
9188
///
9289
/// Resets peripheral. Takes access to RCC internally
9390
unsafe fn reset_unchecked() {
94-
let mut rcc = pac::RCC::steal();
91+
let mut rcc = RCC::steal();
9592
Self::reset(&mut rcc);
9693
}
9794
}
@@ -103,14 +100,12 @@ pub trait RccExt {
103100
}
104101

105102
macro_rules! bus_struct {
106-
($( $(#[$attr:meta])* $busX:ident => ($EN:ident, $en:ident, $LPEN:ident, $lpen:ident, $RST:ident, $rst:ident, $doc:literal),)+) => {
103+
($($busX:ident => ($EN:ident, $en:ident, $LPEN:ident, $lpen:ident, $RST:ident, $rst:ident, $doc:literal),)+) => {
107104
$(
108-
$(#[$attr])*
109105
#[doc = $doc]
110106
#[non_exhaustive]
111107
pub struct $busX;
112108

113-
$(#[$attr])*
114109
impl $busX {
115110
pub(crate) fn enr(rcc: &RccRB) -> &rcc::$EN {
116111
rcc.$en()
@@ -132,11 +127,13 @@ bus_struct! {
132127
APB1 => (APB1ENR, apb1enr, APB1LPENR, apb1lpenr, APB1RSTR, apb1rstr, "Advanced Peripheral Bus 1 (APB1) registers"),
133128
APB2 => (APB2ENR, apb2enr, APB2LPENR, apb2lpenr, APB2RSTR, apb2rstr, "Advanced Peripheral Bus 2 (APB2) registers"),
134129
AHB1 => (AHB1ENR, ahb1enr, AHB1LPENR, ahb1lpenr, AHB1RSTR, ahb1rstr, "Advanced High-performance Bus 1 (AHB1) registers"),
135-
#[cfg(not(feature = "gpio-f410"))]
136-
AHB2 => (AHB2ENR, ahb2enr, AHB2LPENR, ahb2lpenr, AHB2RSTR, ahb2rstr, "Advanced High-performance Bus 2 (AHB2) registers"),
137130
//#[cfg(any(feature = "fsmc", feature = "fmc"))]
138131
//AHB3 => (AHB3ENR, ahb3enr, AHB3LPENR, ahb3lpenr, AHB3RSTR, ahb3rstr, "Advanced High-performance Bus 3 (AHB3) registers"),
139132
}
133+
#[cfg(not(feature = "gpio-f410"))]
134+
bus_struct! {
135+
AHB2 => (AHB2ENR, ahb2enr, AHB2LPENR, ahb2lpenr, AHB2RSTR, ahb2rstr, "Advanced High-performance Bus 2 (AHB2) registers"),
136+
}
140137

141138
/// AMBA High-performance Bus 3 (AHB3) registers
142139
#[cfg(any(feature = "fsmc", feature = "fmc"))]

0 commit comments

Comments
 (0)