Skip to content

Commit d96a466

Browse files
authored
Fix warnings (#76)
* Fix all warnings * Fix all warnings in examples * Format * Fix more warnings * Resolve comments
1 parent a92f938 commit d96a466

File tree

18 files changed

+64
-59
lines changed

18 files changed

+64
-59
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ optional = true
5858
[dev-dependencies]
5959
cortex-m-rt = "0.7.2"
6060
defmt-rtt = "0.4.0"
61-
cortex-m-rtic = "0.5.8"
61+
cortex-m-rtic = "1.1.4"
6262
cortex-m-semihosting = "0.3.5"
6363
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
6464
panic-semihosting = "0.5.3"
@@ -101,3 +101,7 @@ debug = false
101101
codegen-units = 1
102102
incremental = false
103103
lto = true
104+
105+
[[example]]
106+
name = "flash_with_rtic"
107+
required-features = ["stm32g474"]

examples/can-echo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn main() -> ! {
120120

121121
loop {
122122
if let Ok(rxheader) = block!(can.receive0(&mut buffer)) {
123-
block!(can.transmit(rxheader.unwrap().to_tx_header(None), &mut buffer)).unwrap();
123+
block!(can.transmit(rxheader.unwrap().to_tx_header(None), &buffer)).unwrap();
124124
}
125125
}
126126
}

examples/flash_with_rtic.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ mod app {
1616

1717
const LOG_LEVEL: log::LevelFilter = log::LevelFilter::Info;
1818

19-
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
20-
2119
// Resources shared between tasks
2220
#[shared]
2321
struct Shared {}

examples/hello.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use utils::logger::println;
1616

1717
#[entry]
1818
fn main() -> ! {
19-
let _ = println!("Hello, STM32G4!");
19+
println!("Hello, STM32G4!");
2020

2121
#[allow(clippy::empty_loop)]
2222
loop {}

examples/i2c-bme680.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ fn main() -> ! {
5252
.with_run_gas(true)
5353
.build();
5454

55-
let profile_dur = dev.get_profile_dur(&settings.0).unwrap();
55+
let _profile_dur = dev.get_profile_dur(&settings.0).unwrap();
5656
dev.set_sensor_settings(&mut delayer, settings).unwrap();
5757
dev.set_sensor_mode(&mut delayer, PowerMode::ForcedMode)
5858
.unwrap();
59-
let sensor_settings = dev.get_sensor_settings(settings.1);
59+
let _sensor_settings = dev.get_sensor_settings(settings.1);
6060

6161
loop {
6262
delay.delay_ms(500u32);
63-
let power_mode = dev.get_sensor_mode();
63+
let _power_mode = dev.get_sensor_mode();
6464
dev.set_sensor_mode(&mut delayer, PowerMode::ForcedMode)
6565
.unwrap();
6666
let (data, _state) = dev.get_sensor_data(&mut delayer).unwrap();

examples/opamp.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() -> ! {
5858
);
5959

6060
// Configure op with pa7 as non-inverting input and set gain to x4
61-
let mut opamp2 = opamp2.pga(
61+
let opamp2 = opamp2.pga(
6262
pa7,
6363
PgaModeInternal::gain(NonInvertingGain::Gain4),
6464
Option::<PA6<Analog>>::None, // Do not route output to any external pin, use internal AD instead
@@ -72,7 +72,7 @@ fn main() -> ! {
7272
loop {
7373
// Here we can sample the output of opamp2 as if it was a regular AD pin
7474
let sample = adc.convert(
75-
&mut opamp2,
75+
&opamp2,
7676
stm32g4xx_hal::adc::config::SampleTime::Cycles_640_5,
7777
);
7878

@@ -87,6 +87,8 @@ fn main() -> ! {
8787
let (_opamp1, _pa1, _mode, _some_pa2) = _opamp1.disable();
8888
let (_opamp2, _pa7, _mode, _none) = opamp2.disable();
8989

90-
loop {}
90+
loop {
91+
delay.delay_ms(100);
92+
}
9193
}
9294
}

examples/pwm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ use hal::prelude::*;
1010
use hal::stm32;
1111
use hal::time::RateExtU32;
1212
use stm32g4xx_hal as hal;
13-
mod utils;
1413
extern crate cortex_m_rt as rt;
1514

15+
#[macro_use]
16+
mod utils;
17+
1618
#[entry]
1719
fn main() -> ! {
20+
utils::logger::init();
21+
1822
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
1923
let mut rcc = dp.RCC.constrain();
2024
let gpioa = dp.GPIOA.split(&mut rcc);

examples/spi-sd.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,30 @@
55

66
extern crate embedded_sdmmc;
77

8+
use fugit::RateExtU32;
89
use hal::gpio::gpiob::PB14;
910
use hal::gpio::gpiob::PB15;
10-
use hal::gpio::gpiof::PF8;
1111
use hal::gpio::gpiof::PF9;
1212
use hal::gpio::Alternate;
1313
use hal::gpio::AF5;
1414
use hal::prelude::*;
1515
use hal::rcc::Config;
1616
use hal::spi;
17-
use hal::stm32;
17+
1818
use hal::stm32::Peripherals;
19-
use hal::time::RateExtU32;
20-
use hal::timer::Timer;
2119
use stm32g4xx_hal as hal;
2220

23-
use embedded_sdmmc::{
24-
Block, BlockCount, BlockDevice, BlockIdx, Controller, Error, Mode, TimeSource, Timestamp,
25-
VolumeIdx,
26-
};
21+
use embedded_sdmmc::{TimeSource, Timestamp};
2722

2823
use cortex_m_rt::entry;
29-
use log::info;
3024

3125
#[macro_use]
3226
mod utils;
3327

3428
#[entry]
3529
fn main() -> ! {
30+
utils::logger::init();
31+
3632
let dp = Peripherals::take().unwrap();
3733
let rcc = dp.RCC.constrain();
3834
let mut rcc = rcc.freeze(Config::hsi());
@@ -49,7 +45,7 @@ fn main() -> ! {
4945
let miso: PB14<Alternate<AF5>> = gpiob.pb14.into_alternate();
5046
let mosi: PB15<Alternate<AF5>> = gpiob.pb15.into_alternate();
5147

52-
let mut spi = dp
48+
let spi = dp
5349
.SPI2
5450
.spi((sck, miso, mosi), spi::MODE_0, 400.kHz(), &mut rcc);
5551

@@ -70,6 +66,8 @@ fn main() -> ! {
7066

7167
let mut cont = embedded_sdmmc::Controller::new(embedded_sdmmc::SdMmcSpi::new(spi, cs), Clock);
7268

73-
cont.device().init();
69+
cont.device().init().unwrap();
70+
71+
#[allow(clippy::empty_loop)]
7472
loop {}
7573
}

examples/utils/logger.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ cfg_if::cfg_if! {
55
pub use defmt::println as println;
66
} else {
77
pub use log::{info, trace, warn, debug, error};
8-
pub use cortex_m_semihosting::hprintln as println;
8+
9+
#[allow(unused_macros)]
10+
macro_rules! println {
11+
($($tt:tt)*) => {
12+
$crate::cortex_m_semihosting::hprintln!($($tt,)*).unwrap();
13+
};
14+
}
915
}
1016
}
1117

src/adc.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ pub mod config {
571571
}
572572

573573
/// Sets the input type per channel
574-
#[derive(Debug, Clone, Copy)]
574+
#[derive(Debug, Clone, Copy, Default)]
575575
pub struct DifferentialSelection(pub(crate) u32);
576576
impl DifferentialSelection {
577577
/// Set pin to Single-Ended or Differential
@@ -614,12 +614,6 @@ pub mod config {
614614
}
615615
}
616616

617-
impl Default for DifferentialSelection {
618-
fn default() -> Self {
619-
DifferentialSelection(0)
620-
}
621-
}
622-
623617
/// Configuration for the adc.
624618
/// There are some additional parameters on the adc peripheral that can be
625619
/// added here when needed but this covers several basic usecases.

0 commit comments

Comments
 (0)