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 2e69f41
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,4 @@ required-features = ["tim8"] # stm32f446

[[example]]
name = "ist7920_bidi_normal_spi"
required-features = ["rt", "stm32f401"]
required-features = ["device-selected"]
24 changes: 11 additions & 13 deletions examples/analog-stopwatch-with-spi-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ fn main() -> ! {
led4.set_low();
}
StopwatchState::Running => {
led4.set_low();
if state_led {
led4.set_low();
led3.set_high();
} else {
led4.set_low();
led3.set_low();
}
}
Expand Down Expand Up @@ -208,13 +207,12 @@ fn main() -> ! {
}

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

#[interrupt]
Expand Down Expand Up @@ -291,31 +289,31 @@ fn TIM2() {
});
}

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_continue<'cs>(_cs: &'cs CriticalSection) {
fn stopwatch_continue(_cs: &CriticalSection) {
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);
}

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

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

Expand All @@ -332,15 +330,15 @@ 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
}

/// Convert a polar coordinate (angle/distance) into an (X, Y) coordinate centered around `CENTER`
Expand Down
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
2 changes: 1 addition & 1 deletion examples/dwt-blinky.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::empty_loop)]
#![deny(unsafe_code)]
#![no_main]
#![no_std]
Expand All @@ -8,7 +9,6 @@ use crate::hal::{
pac,
prelude::*,
};
use cortex_m;
use cortex_m_rt::entry;
use panic_halt as _;
use stm32f4xx_hal as hal;
Expand Down
1 change: 0 additions & 1 deletion examples/pwm-input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Halt on panic
use panic_halt as _;

use cortex_m;
use cortex_m_rt::entry;
use stm32f4xx_hal::{pac, prelude::*, timer::Timer};

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
1 change: 1 addition & 0 deletions examples/rng-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! Note that this example requires the `--release` build flag because it is too
//! large to fit in the default `memory.x` file provided with this crate.
#![allow(clippy::empty_loop)]
#![no_std]
#![no_main]

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 2e69f41

Please sign in to comment.