Fix a number of clippy warnings

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
This commit is contained in:
Daniel Egger 2019-11-04 00:49:43 +01:00
parent 4c3504c8e1
commit 1e649bbc0b
16 changed files with 42 additions and 64 deletions

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -25,11 +24,11 @@ fn main() -> ! {
loop {
// Turn PA1 on a million times in a row
for _ in 0..1_000_000 {
led.set_high();
led.set_high().ok();
}
// Then turn PA1 off a million times in a row
for _ in 0..1_000_000 {
led.set_low();
led.set_low().ok();
}
}
}

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused_imports)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -32,7 +31,7 @@ fn main() -> ! {
let mut adc = Adc::new(p.ADC, &mut rcc);
loop {
led.toggle();
led.toggle().ok();
let val: u16 = adc.read(&mut an_in).unwrap();

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -26,7 +25,7 @@ fn main() -> ! {
let mut delay = Delay::new(cp.SYST, &rcc);
loop {
led.toggle();
led.toggle().ok();
delay.delay_ms(1_000_u16);
}
});

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -33,12 +32,12 @@ fn main() -> ! {
let mut leds = [led1.downgrade(), led2.downgrade()];
loop {
for l in &mut leds {
l.set_high();
l.set_high().ok();
}
delay.delay_ms(1_000_u16);
for l in &mut leds {
l.set_low();
l.set_low().ok();
}
delay.delay_ms(1_000_u16);
}

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -25,7 +24,7 @@ fn main() -> ! {
let mut timer = Timer::tim1(p.TIM1, Hertz(1), &mut rcc);
loop {
led.toggle();
led.toggle().ok();
// Wait for the timer to expire
nb::block!(timer.wait()).ok();

View File

@ -4,14 +4,13 @@
use cortex_m;
use cortex_m_rt as rt;
#[allow(unused_imports)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::stm32;
use crate::hal::prelude::*;
use crate::hal::dac::*;
use crate::hal::prelude::*;
use crate::hal::stm32;
use rt::entry;
@ -59,4 +58,4 @@ fn main() -> ! {
loop {
continue;
}
}
}

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -69,13 +68,13 @@ fn SysTick() -> ! {
// Check state variable, keep LED off most of the time and turn it on every 10th tick
if *STATE < 10 {
// Turn off the LED
led.set_low();
led.set_low().ok();
// And now increment state variable
*STATE += 1;
} else {
// Turn on the LED
led.set_high();
led.set_high().ok();
// And set new state variable back to 0
*STATE = 0;

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -73,13 +72,13 @@ fn SysTick() -> ! {
// Check state variable, keep LED off most of the time and turn it on every 10th tick
if *STATE < 10 {
// Turn off the LED
led.set_low();
led.set_low().ok();
// And now increment state variable
*STATE += 1;
} else {
// Turn on the LED
led.set_high();
led.set_high().ok();
// And set new state variable back to 0
*STATE = 0;

View File

@ -1,16 +1,11 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::{
prelude::*,
i2c::I2c,
stm32,
};
use crate::hal::{i2c::I2c, prelude::*, stm32};
use cortex_m_rt::entry;
@ -38,16 +33,13 @@ fn main() -> ! {
// The write method sends the specified address and checks for acknowledgement;
// if no ack is given by the slave device the result is Err(), otherwise Ok()
// Since we only care for an acknowledgement the data sent can be empty
match i2c.write(add, &[]) {
Ok(_) => {
_devices += 1;
},
Err(_) => (),
if i2c.write(add, &[]).is_ok() {
_devices += 1;
}
}
// Here the variable "_devices" counts how many i2c addresses were a hit
});
});
}
loop {

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
@ -50,15 +49,13 @@ fn main() -> ! {
let mut led = gpioa.pa1.into_push_pull_output(cs);
// Turn off LED
led.set_low();
led.set_low().ok();
// Initialise delay provider
let delay = Delay::new(cp.SYST, &rcc);
// Enable external interrupt for PB1
syscfg
.exticr1
.modify(|_, w| unsafe { w.exti1().bits(1) });
syscfg.exticr1.modify(|_, w| unsafe { w.exti1().bits(1) });
// Set interrupt request mask for line 1
exti.imr.modify(|_, w| w.mr1().set_bit());
@ -73,8 +70,10 @@ fn main() -> ! {
// Enable EXTI IRQ, set prio 1 and clear any pending IRQs
let mut nvic = cp.NVIC;
nvic.enable(Interrupt::EXTI0_1);
unsafe { nvic.set_priority(Interrupt::EXTI0_1, 1) };
unsafe {
nvic.set_priority(Interrupt::EXTI0_1, 1);
cortex_m::peripheral::NVIC::unmask(Interrupt::EXTI0_1);
}
cortex_m::peripheral::NVIC::unpend(Interrupt::EXTI0_1);
});
}
@ -97,13 +96,13 @@ fn EXTI0_1() {
INT.borrow(cs).borrow_mut().deref_mut(),
) {
// Turn on LED
led.set_high();
led.set_high().ok();
// Wait a second
delay.delay_ms(1_000_u16);
// Turn off LED
led.set_low();
led.set_low().ok();
// Clear event triggering the interrupt
exti.pr.write(|w| w.pif1().set_bit());

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;

View File

@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;

View File

@ -600,5 +600,5 @@ fn read(usart: *const SerialRegisterBlock) -> nb::Result<u8, Error> {
})
};
return Err(err);
Err(err)
}