From cbed4edd5d41ae34b966806135ae232844f545f1 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Mon, 5 Jun 2023 21:43:04 +0200 Subject: [PATCH] Fix all warnings in examples --- examples/can-echo.rs | 2 +- examples/i2c-bme680.rs | 6 +++--- examples/panic.rs | 2 +- examples/pwm.rs | 6 +++++- examples/spi-sd.rs | 18 ++++++++++-------- examples/utils/logger.rs | 1 - 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/examples/can-echo.rs b/examples/can-echo.rs index d458a3ed..954c45c0 100644 --- a/examples/can-echo.rs +++ b/examples/can-echo.rs @@ -120,7 +120,7 @@ fn main() -> ! { loop { if let Ok(rxheader) = block!(can.receive0(&mut buffer)) { - block!(can.transmit(rxheader.unwrap().to_tx_header(None), &mut buffer)).unwrap(); + block!(can.transmit(rxheader.unwrap().to_tx_header(None), &buffer)).unwrap(); } } } diff --git a/examples/i2c-bme680.rs b/examples/i2c-bme680.rs index fd6aa9bb..5c982c00 100644 --- a/examples/i2c-bme680.rs +++ b/examples/i2c-bme680.rs @@ -51,15 +51,15 @@ fn main() -> ! { .with_run_gas(true) .build(); - let profile_dur = dev.get_profile_dur(&settings.0).unwrap(); + let _profile_dur = dev.get_profile_dur(&settings.0).unwrap(); dev.set_sensor_settings(&mut delayer, settings).unwrap(); dev.set_sensor_mode(&mut delayer, PowerMode::ForcedMode) .unwrap(); - let sensor_settings = dev.get_sensor_settings(settings.1); + let _sensor_settings = dev.get_sensor_settings(settings.1); loop { delay.delay_ms(500u32); - let power_mode = dev.get_sensor_mode(); + let _power_mode = dev.get_sensor_mode(); dev.set_sensor_mode(&mut delayer, PowerMode::ForcedMode) .unwrap(); let (data, _state) = dev.get_sensor_data(&mut delayer).unwrap(); diff --git a/examples/panic.rs b/examples/panic.rs index a5a4ca4a..c04bc628 100644 --- a/examples/panic.rs +++ b/examples/panic.rs @@ -7,7 +7,7 @@ use panic_probe as _; use stm32g4 as _; -use defmt::Format; + #[defmt::panic_handler] fn panic() -> ! { diff --git a/examples/pwm.rs b/examples/pwm.rs index 5b08beff..0c0223dc 100644 --- a/examples/pwm.rs +++ b/examples/pwm.rs @@ -9,11 +9,15 @@ use hal::gpio::AF6; use hal::prelude::*; use hal::stm32; use stm32g4xx_hal as hal; -mod utils; extern crate cortex_m_rt as rt; +#[macro_use] +mod utils; + #[entry] fn main() -> ! { + utils::logger::init(); + let dp = stm32::Peripherals::take().expect("cannot take peripherals"); let mut rcc = dp.RCC.constrain(); let gpioa = dp.GPIOA.split(&mut rcc); diff --git a/examples/spi-sd.rs b/examples/spi-sd.rs index cd1281be..4ac251d4 100644 --- a/examples/spi-sd.rs +++ b/examples/spi-sd.rs @@ -7,31 +7,31 @@ extern crate embedded_sdmmc; use hal::gpio::gpiob::PB14; use hal::gpio::gpiob::PB15; -use hal::gpio::gpiof::PF8; use hal::gpio::gpiof::PF9; use hal::gpio::Alternate; use hal::gpio::AF5; use hal::prelude::*; use hal::rcc::Config; use hal::spi; -use hal::stm32; + use hal::stm32::Peripherals; -use hal::timer::Timer; + use stm32g4xx_hal as hal; use embedded_sdmmc::{ - Block, BlockCount, BlockDevice, BlockIdx, Controller, Error, Mode, TimeSource, Timestamp, - VolumeIdx, + TimeSource, Timestamp, }; use cortex_m_rt::entry; -use log::info; + #[macro_use] mod utils; #[entry] fn main() -> ! { + utils::logger::init(); + let dp = Peripherals::take().unwrap(); let rcc = dp.RCC.constrain(); let mut rcc = rcc.freeze(Config::hsi()); @@ -48,7 +48,7 @@ fn main() -> ! { let miso: PB14> = gpiob.pb14.into_alternate(); let mosi: PB15> = gpiob.pb15.into_alternate(); - let mut spi = dp + let spi = dp .SPI2 .spi((sck, miso, mosi), spi::MODE_0, 400.khz(), &mut rcc); @@ -69,6 +69,8 @@ fn main() -> ! { let mut cont = embedded_sdmmc::Controller::new(embedded_sdmmc::SdMmcSpi::new(spi, cs), Clock); - cont.device().init(); + cont.device().init().unwrap(); + + #[allow(clippy::empty_loop)] loop {} } diff --git a/examples/utils/logger.rs b/examples/utils/logger.rs index 7e0dc1bd..9553ffb5 100644 --- a/examples/utils/logger.rs +++ b/examples/utils/logger.rs @@ -55,7 +55,6 @@ cfg_if::cfg_if! { impl log::Log for Logger { fn enabled(&self, metadata: &Metadata) -> bool { metadata.level() <= self.level - } fn log(&self, record: &Record) {