Skip to content

Commit ba6e6a0

Browse files
therealprofTheZoq2
authored andcommitted
Fix clippy lints
Signed-off-by: Daniel Egger <[email protected]>
1 parent 0b3a0b3 commit ba6e6a0

File tree

8 files changed

+19
-26
lines changed

8 files changed

+19
-26
lines changed

src/i2c.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ impl Mode {
6464
}
6565

6666
pub fn get_frequency(&self) -> Hertz {
67-
match self {
68-
&Mode::Standard { frequency } => frequency,
69-
&Mode::Fast { frequency, .. } => frequency,
67+
match *self {
68+
Mode::Standard { frequency } => frequency,
69+
Mode::Fast { frequency, .. } => frequency,
7070
}
7171
}
7272
}
@@ -211,13 +211,13 @@ fn blocking_i2c<I2C, PINS>(
211211
data_timeout_us: u32,
212212
) -> BlockingI2c<I2C, PINS> {
213213
let sysclk_mhz = clocks.sysclk().0 / 1_000_000;
214-
return BlockingI2c {
214+
BlockingI2c {
215215
nb: i2c,
216216
start_timeout: start_timeout_us * sysclk_mhz,
217217
start_retries,
218218
addr_timeout: addr_timeout_us * sysclk_mhz,
219219
data_timeout: data_timeout_us * sysclk_mhz,
220-
};
220+
}
221221
}
222222

223223
macro_rules! wait_for_flag {
@@ -317,8 +317,8 @@ macro_rules! hal {
317317

318318
self.i2c.ccr.write(|w| {
319319
let (freq, duty) = match duty_cycle {
320-
&DutyCycle::Ratio2to1 => (((self.pclk1 / (freq.0* 3)) as u16).max(1), false),
321-
&DutyCycle::Ratio16to9 => (((self.pclk1 / (freq.0 * 25)) as u16).max(1), true)
320+
DutyCycle::Ratio2to1 => (((self.pclk1 / (freq.0* 3)) as u16).max(1), false),
321+
DutyCycle::Ratio16to9 => (((self.pclk1 / (freq.0 * 25)) as u16).max(1), true)
322322
};
323323

324324
unsafe {
@@ -403,7 +403,7 @@ macro_rules! hal {
403403
while retries_left > 0 {
404404
self.nb.send_start();
405405
last_ret = busy_wait_cycles!(self.nb.wait_after_sent_start(), self.start_timeout);
406-
if let Err(_) = last_ret {
406+
if last_ret.is_err() {
407407
self.nb.reset();
408408
} else {
409409
break;

src/pwm_input.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,8 @@ macro_rules! hal {
249249
{
250250
/// Return the frequency sampled by the timer
251251
pub fn read_frequency(&self, mode : ReadMode, clocks : &Clocks) -> Result<Hertz,Error> {
252-
match mode {
253-
ReadMode::WaitForNextCapture => self.wait_for_capture(),
254-
_ => (),
252+
if let ReadMode::WaitForNextCapture = mode {
253+
self.wait_for_capture();
255254
}
256255

257256
let presc = unsafe { (*$TIMX::ptr()).psc.read().bits() as u16};
@@ -281,9 +280,8 @@ macro_rules! hal {
281280

282281
/// Return the duty in the form of a fraction : (duty_cycle/period)
283282
pub fn read_duty(&self, mode : ReadMode) -> Result<(u16,u16),Error> {
284-
match mode {
285-
ReadMode::WaitForNextCapture => self.wait_for_capture(),
286-
_ => (),
283+
if let ReadMode::WaitForNextCapture = mode {
284+
self.wait_for_capture();
287285
}
288286

289287
// Formulas :

src/rcc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl CFGR {
296296
w.pllmul()
297297
.bits(pllmul_bits)
298298
.pllsrc()
299-
.bit(if self.hse.is_some() { true } else { false })
299+
.bit(self.hse.is_some())
300300
});
301301

302302
rcc.cr.modify(|_, w| w.pllon().set_bit());

src/rtc.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::backup_domain::BackupDomain;
1818
use crate::time::Hertz;
1919

2020
use core::convert::Infallible;
21-
use nb;
2221

2322
// The LSE runs at at 32 768 hertz unless an external clock is provided
2423
const LSE_HERTZ: u32 = 32_768;
@@ -143,7 +142,7 @@ impl Rtc {
143142
/// Reads the current counter
144143
pub fn current_time(&self) -> u32 {
145144
// Wait for the APB1 interface to be ready
146-
while self.regs.crl.read().rsf().bit() == false {}
145+
while !self.regs.crl.read().rsf().bit() {}
147146

148147
self.regs.cnth.read().bits() << 16 | self.regs.cntl.read().bits()
149148
}
@@ -180,7 +179,7 @@ impl Rtc {
180179
```
181180
*/
182181
pub fn wait_alarm(&mut self) -> nb::Result<(), Infallible> {
183-
if self.regs.crl.read().alrf().bit() == true {
182+
if self.regs.crl.read().alrf().bit() {
184183
self.regs.crl.modify(|_, w| w.alrf().clear_bit());
185184
Ok(())
186185
} else {
@@ -195,7 +194,7 @@ impl Rtc {
195194
*/
196195
fn perform_write(&mut self, func: impl Fn(&mut Self)) {
197196
// Wait for the last write operation to be done
198-
while self.regs.crl.read().rtoff().bit() == false {}
197+
while !self.regs.crl.read().rtoff().bit() {}
199198
// Put the clock into config mode
200199
self.regs.crl.modify(|_, w| w.cnf().set_bit());
201200

src/serial.rs

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use core::sync::atomic::{self, Ordering};
4545
use crate::pac::{USART1, USART2, USART3};
4646
use core::convert::Infallible;
4747
use embedded_hal::serial::Write;
48-
use nb;
4948

5049
use crate::afio::MAPR;
5150
use crate::dma::{dma1, CircBuffer, RxDma, Static, Transfer, TxDma, R, W};

src/spi.rs

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
use core::ops::Deref;
3434
use core::ptr;
3535

36-
use nb;
37-
3836
pub use crate::hal::spi::{FullDuplex, Mode, Phase, Polarity};
3937
#[cfg(feature = "high")]
4038
use crate::pac::SPI3;

src/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ impl MonoTimer {
246246
}
247247

248248
/// Returns the frequency at which the monotonic timer is operating at
249-
pub fn frequency(&self) -> Hertz {
249+
pub fn frequency(self) -> Hertz {
250250
self.frequency
251251
}
252252

253253
/// Returns an `Instant` corresponding to "now"
254-
pub fn now(&self) -> Instant {
254+
pub fn now(self) -> Instant {
255255
Instant {
256256
now: DWT::get_cycle_count(),
257257
}
@@ -266,7 +266,7 @@ pub struct Instant {
266266

267267
impl Instant {
268268
/// Ticks elapsed since the `Instant` was created
269-
pub fn elapsed(&self) -> u32 {
269+
pub fn elapsed(self) -> u32 {
270270
DWT::get_cycle_count().wrapping_sub(self.now)
271271
}
272272
}

src/timer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ use crate::rcc::{sealed::RccBus, Clocks, Enable, GetBusFreq, Reset};
7474
use cast::{u16, u32, u64};
7575
use cortex_m::peripheral::syst::SystClkSource;
7676
use cortex_m::peripheral::SYST;
77-
use nb;
7877
use void::Void;
7978

8079
use crate::time::Hertz;

0 commit comments

Comments
 (0)