Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jul 27, 2021
1 parent 991cdc3 commit 4e3221e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions examples/blinky-timer-irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use embedded_hal::timer::CountDown;

// A type definition for the GPIO pin to be used for our LED
// For the onboard nucleo LED, use gpioa::PA5 or gpiob::PB13 depending your model
type LEDPIN = gpioa::PA5<Output<PushPull>>;
type LedPin = gpioa::PA5<Output<PushPull>>;

// Make LED pin globally available
static G_LED: Mutex<RefCell<Option<LEDPIN>>> = Mutex::new(RefCell::new(None));
static G_LED: Mutex<RefCell<Option<LedPin>>> = Mutex::new(RefCell::new(None));

// Make timer interrupt registers globally available
static G_TIM: Mutex<RefCell<Option<CountDownTimer<TIM2>>>> = Mutex::new(RefCell::new(None));
Expand All @@ -42,7 +42,7 @@ static G_TIM: Mutex<RefCell<Option<CountDownTimer<TIM2>>>> = Mutex::new(RefCell:
// This specific interrupt will "trip" when the timer TIM2 times out
#[interrupt]
fn TIM2() {
static mut LED: Option<LEDPIN> = None;
static mut LED: Option<LedPin> = None;
static mut TIM: Option<CountDownTimer<TIM2>> = None;

let led = LED.get_or_insert_with(|| {
Expand Down
2 changes: 1 addition & 1 deletion examples/delay-syst-blinky.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Demonstrate the use of a blocking `Delay` using the SYST (sysclock) timer.

#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

// Halt on panic
use panic_halt as _; // panic handler

use cortex_m;
use cortex_m_rt::entry;
use stm32f4xx_hal as hal;

Expand Down
2 changes: 1 addition & 1 deletion examples/delay-timer-blinky.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Demonstrate the use of a blocking `Delay` using TIM5 general-purpose timer.

#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

// Halt on panic
use panic_halt as _; // panic handler

use cortex_m;
use cortex_m_rt::entry;
use stm32f4xx_hal as hal;

Expand Down
1 change: 0 additions & 1 deletion examples/qei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// Halt on panic
use panic_halt as _;

use cortex_m;
use cortex_m_rt::entry;
use embedded_hal::Direction as RotaryDirection;
use stm32f4xx_hal::{delay::Delay, pac, prelude::*, qei::Qei};
Expand Down
5 changes: 3 additions & 2 deletions examples/ssd1306-image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//!
//! Note that `--release` is required to fix link errors for smaller devices.

#![allow(clippy::empty_loop)]
#![no_std]
#![no_main]

Expand Down Expand Up @@ -87,15 +88,15 @@ fn main() -> ! {
/// Helper function - what rotation flips the screen upside down from
/// the rotation we're in now?
fn get_next_rotation(rotation: DisplayRotation) -> DisplayRotation {
return match rotation {
match rotation {
DisplayRotation::Rotate0 => DisplayRotation::Rotate180,
DisplayRotation::Rotate180 => DisplayRotation::Rotate0,

// Default branch - if for some reason we end up in one of the portrait modes,
// reset to 0 degrees landscape. On most SSD1306 displays, this means down is towards
// the flat flex coming out of the display (and up is towards the breakout board pins).
_ => DisplayRotation::Rotate0,
};
}
}

#[exception]
Expand Down
16 changes: 8 additions & 8 deletions examples/stopwatch-with-ssd1306-and-interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//!
//! Video of this example running: https://imgur.com/a/lQTQFLy

#![allow(clippy::empty_loop)]
#![no_std]
#![no_main]

Expand Down Expand Up @@ -188,23 +189,22 @@ fn EXTI15_10() {
}

fn setup_clocks(rcc: Rcc) -> Clocks {
return rcc
.cfgr
rcc.cfgr
.hclk(48.mhz())
.sysclk(48.mhz())
.pclk1(24.mhz())
.pclk2(24.mhz())
.freeze();
.freeze()
}

fn stopwatch_start<'cs>(cs: &'cs CriticalSection) {
fn stopwatch_start(cs: &CriticalSection) {
ELAPSED_MS.borrow(cs).replace(0);
unsafe {
pac::NVIC::unmask(hal::pac::Interrupt::TIM2);
}
}

fn stopwatch_stop<'cs>(_cs: &'cs CriticalSection) {
fn stopwatch_stop(_cs: &CriticalSection) {
pac::NVIC::mask(hal::pac::Interrupt::TIM2);
}

Expand All @@ -221,13 +221,13 @@ fn format_elapsed(buf: &mut ArrayString<[u8; 10]>, elapsed: u32) {
}

fn elapsed_to_ms(elapsed: u32) -> u32 {
return elapsed % 1000;
elapsed % 1000
}

fn elapsed_to_s(elapsed: u32) -> u32 {
return (elapsed - elapsed_to_ms(elapsed)) % 60000 / 1000;
(elapsed - elapsed_to_ms(elapsed)) % 60000 / 1000
}

fn elapsed_to_m(elapsed: u32) -> u32 {
return elapsed / 60000;
elapsed / 60000
}
3 changes: 2 additions & 1 deletion src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ where
});
Error::Crc.into()
} else if sr.txe().bit_is_set() {
return Ok(self.send_u8(byte));
self.send_u8(byte);
return Ok(());
} else {
nb::Error::WouldBlock
})
Expand Down

0 comments on commit 4e3221e

Please sign in to comment.