Skip to content

Commit 1357e5a

Browse files
authored
Merge pull request #204 from torkeldanielsson/rustfmt
rustfmt
2 parents c89f804 + 89600ec commit 1357e5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+364
-454
lines changed

examples/adc-dma-circ.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ use panic_halt as _;
77

88
use cortex_m::{asm, singleton};
99

10-
use stm32f1xx_hal::{
11-
prelude::*,
12-
pac,
13-
adc,
14-
dma::Half,
15-
};
1610
use cortex_m_rt::entry;
11+
use stm32f1xx_hal::{adc, dma::Half, pac, prelude::*};
1712

1813
#[entry]
1914
fn main() -> ! {
@@ -58,4 +53,4 @@ fn main() -> ! {
5853
asm::bkpt();
5954

6055
loop {}
61-
}
56+
}

examples/adc-dma-rx.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ use panic_halt as _;
77

88
use cortex_m::{asm, singleton};
99

10-
use stm32f1xx_hal::{
11-
prelude::*,
12-
pac,
13-
adc,
14-
};
1510
use cortex_m_rt::entry;
11+
use stm32f1xx_hal::{adc, pac, prelude::*};
1612

1713
#[entry]
1814
fn main() -> ! {
@@ -48,7 +44,7 @@ fn main() -> ! {
4844
// one can call the is_done method of RxDma and only call wait after that method returns true.
4945
let (_buf, adc_dma) = adc_dma.read(buf).wait();
5046
asm::bkpt();
51-
47+
5248
// Consumes the AdcDma struct, restores adc configuration to previous state and returns the
5349
// Adc struct in normal mode.
5450
let (_adc1, _adc_ch0, _dma_ch1) = adc_dma.split();

examples/adc.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
use panic_semihosting as _;
66

7-
use stm32f1xx_hal::{
8-
prelude::*,
9-
pac,
10-
adc,
11-
};
127
use cortex_m_rt::entry;
8+
use stm32f1xx_hal::{adc, pac, prelude::*};
139

1410
use cortex_m_semihosting::hprintln;
1511

examples/adc_temperature.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
use panic_semihosting as _;
66

7-
use stm32f1xx_hal::{
8-
prelude::*,
9-
pac,
10-
adc,
11-
};
127
use cortex_m_rt::entry;
8+
use stm32f1xx_hal::{adc, pac, prelude::*};
139

1410
use cortex_m_semihosting::hprintln;
1511

@@ -20,7 +16,13 @@ fn main() -> ! {
2016
let mut flash = p.FLASH.constrain();
2117
let mut rcc = p.RCC.constrain();
2218

23-
let clocks = rcc.cfgr.use_hse(8.mhz()).sysclk(56.mhz()).pclk1(28.mhz()).adcclk(14.mhz()).freeze(&mut flash.acr);
19+
let clocks = rcc
20+
.cfgr
21+
.use_hse(8.mhz())
22+
.sysclk(56.mhz())
23+
.pclk1(28.mhz())
24+
.adcclk(14.mhz())
25+
.freeze(&mut flash.acr);
2426
hprintln!("sysclk freq: {}", clocks.sysclk().0).unwrap();
2527
hprintln!("adc freq: {}", clocks.adcclk().0).unwrap();
2628

examples/blinky.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ use panic_halt as _;
1313

1414
use nb::block;
1515

16-
use stm32f1xx_hal::{
17-
prelude::*,
18-
pac,
19-
timer::Timer,
20-
};
2116
use cortex_m_rt::entry;
2217
use embedded_hal::digital::v2::OutputPin;
18+
use stm32f1xx_hal::{pac, prelude::*, timer::Timer};
2319

2420
#[entry]
2521
fn main() -> ! {

examples/blinky_generic.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ use panic_halt as _;
88

99
use nb::block;
1010

11-
use stm32f1xx_hal::{
12-
prelude::*,
13-
pac,
14-
timer::Timer,
15-
};
1611
use cortex_m_rt::entry;
1712
use embedded_hal::digital::v2::OutputPin;
13+
use stm32f1xx_hal::{pac, prelude::*, timer::Timer};
1814

1915
#[entry]
2016
fn main() -> ! {
@@ -36,7 +32,7 @@ fn main() -> ! {
3632
// Create an array of LEDS to blink
3733
let mut leds = [
3834
gpioc.pc13.into_push_pull_output(&mut gpioc.crh).downgrade(),
39-
gpioa.pa1.into_push_pull_output(&mut gpioa.crl).downgrade()
35+
gpioa.pa1.into_push_pull_output(&mut gpioa.crl).downgrade(),
4036
];
4137

4238
// Wait for the timer to trigger an update and change the state of the LED

examples/blinky_rtc.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212

1313
use panic_halt as _;
1414

15-
use stm32f1xx_hal::{
16-
prelude::*,
17-
pac,
18-
rtc::Rtc,
19-
};
15+
use stm32f1xx_hal::{pac, prelude::*, rtc::Rtc};
2016

21-
use nb::block;
2217
use cortex_m_rt::entry;
2318
use embedded_hal::digital::v2::OutputPin;
19+
use nb::block;
2420

2521
#[entry]
2622
fn main() -> ! {
@@ -49,8 +45,7 @@ fn main() -> ! {
4945
if led_on {
5046
led.set_low().unwrap();
5147
led_on = false;
52-
}
53-
else {
48+
} else {
5449
led.set_high().unwrap();
5550
led_on = true;
5651
}

examples/blinky_timer_irq.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ use stm32f1xx_hal as hal;
1414

1515
use crate::hal::{
1616
gpio::*,
17-
prelude::*,
1817
pac::{interrupt, Interrupt, Peripherals, TIM2},
18+
prelude::*,
1919
timer::*,
2020
};
2121

2222
use core::cell::RefCell;
23-
use cortex_m::{
24-
asm::wfi,
25-
interrupt::Mutex,
26-
peripheral::Peripherals as c_m_Peripherals};
23+
use cortex_m::{asm::wfi, interrupt::Mutex, peripheral::Peripherals as c_m_Peripherals};
2724
use cortex_m_rt::entry;
2825

2926
// NOTE You can uncomment 'hprintln' here and in the code below for a bit more

examples/delay.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66

77
use panic_halt as _;
88

9-
use stm32f1xx_hal::{
10-
prelude::*,
11-
pac,
12-
delay::Delay,
13-
};
149
use cortex_m_rt::entry;
1510
use embedded_hal::digital::v2::OutputPin;
11+
use stm32f1xx_hal::{delay::Delay, pac, prelude::*};
1612

1713
#[entry]
1814
fn main() -> ! {

examples/exti.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,25 @@
88

99
use panic_halt as _;
1010

11-
use stm32f1xx_hal::{
12-
prelude::*,
13-
pac
14-
};
11+
use core::mem::MaybeUninit;
1512
use cortex_m_rt::entry;
1613
use pac::interrupt;
17-
use core::mem::MaybeUninit;
1814
use stm32f1xx_hal::gpio::*;
15+
use stm32f1xx_hal::{pac, prelude::*};
1916

2017
// These two are owned by the ISR. main() may only access them during the initialization phase,
2118
// where the interrupt is not yet enabled (i.e. no concurrent accesses can occur).
2219
// After enabling the interrupt, main() may not have any references to these objects any more.
2320
// For the sake of minimalism, we do not use RTFM here, which would be the better way.
24-
static mut LED : MaybeUninit<stm32f1xx_hal::gpio::gpioc::PC13<Output<PushPull>>> = MaybeUninit::uninit();
25-
static mut INT_PIN : MaybeUninit<stm32f1xx_hal::gpio::gpioa::PA7<Input<Floating>>> = MaybeUninit::uninit();
21+
static mut LED: MaybeUninit<stm32f1xx_hal::gpio::gpioc::PC13<Output<PushPull>>> =
22+
MaybeUninit::uninit();
23+
static mut INT_PIN: MaybeUninit<stm32f1xx_hal::gpio::gpioa::PA7<Input<Floating>>> =
24+
MaybeUninit::uninit();
2625

2726
#[interrupt]
2827
fn EXTI9_5() {
29-
let led = unsafe { &mut *LED.as_mut_ptr()};
30-
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr()};
28+
let led = unsafe { &mut *LED.as_mut_ptr() };
29+
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr() };
3130

3231
if int_pin.check_interrupt() {
3332
led.toggle().unwrap();
@@ -50,17 +49,19 @@ fn main() -> ! {
5049
let mut gpioc = p.GPIOC.split(&mut rcc.apb2);
5150
let mut afio = p.AFIO.constrain(&mut rcc.apb2);
5251

53-
let led = unsafe { &mut *LED.as_mut_ptr()};
52+
let led = unsafe { &mut *LED.as_mut_ptr() };
5453
*led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
5554

56-
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr()};
55+
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr() };
5756
*int_pin = gpioa.pa7.into_floating_input(&mut gpioa.crl);
5857
int_pin.make_interrupt_source(&mut afio);
5958
int_pin.trigger_on_edge(&p.EXTI, Edge::RISING_FALLING);
6059
int_pin.enable_interrupt(&p.EXTI);
6160
} // initialization ends here
6261

63-
unsafe { pac::NVIC::unmask(pac::Interrupt::EXTI9_5); }
62+
unsafe {
63+
pac::NVIC::unmask(pac::Interrupt::EXTI9_5);
64+
}
6465

6566
loop {}
6667
}

examples/hello.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use panic_semihosting as _;
88

9-
use stm32f1xx_hal as _;
109
use cortex_m_semihosting::hprintln;
10+
use stm32f1xx_hal as _;
1111

1212
use cortex_m_rt::entry;
1313

examples/itm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#![no_main]
33
#![no_std]
44

5-
use panic_itm as _;
65
use cortex_m::iprintln;
6+
use panic_itm as _;
77
use stm32f1xx_hal as _;
88

99
use cortex_m_rt::entry;

examples/led.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515

1616
use panic_halt as _;
1717

18-
use stm32f1xx_hal::{
19-
prelude::*,
20-
pac,
21-
};
2218
use cortex_m_rt::entry;
2319
use embedded_hal::digital::v2::OutputPin;
20+
use stm32f1xx_hal::{pac, prelude::*};
2421

2522
#[entry]
2623
fn main() -> ! {
@@ -30,13 +27,25 @@ fn main() -> ! {
3027
let mut gpioc = p.GPIOC.split(&mut rcc.apb2);
3128

3229
#[cfg(feature = "stm32f100")]
33-
gpioc.pc9.into_push_pull_output(&mut gpioc.crh).set_high().unwrap();
30+
gpioc
31+
.pc9
32+
.into_push_pull_output(&mut gpioc.crh)
33+
.set_high()
34+
.unwrap();
3435

3536
#[cfg(feature = "stm32f101")]
36-
gpioc.pc9.into_push_pull_output(&mut gpioc.crh).set_high().unwrap();
37+
gpioc
38+
.pc9
39+
.into_push_pull_output(&mut gpioc.crh)
40+
.set_high()
41+
.unwrap();
3742

3843
#[cfg(feature = "stm32f103")]
39-
gpioc.pc13.into_push_pull_output(&mut gpioc.crh).set_low().unwrap();
44+
gpioc
45+
.pc13
46+
.into_push_pull_output(&mut gpioc.crh)
47+
.set_low()
48+
.unwrap();
4049

4150
loop {}
4251
}

examples/mfrc522.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ use panic_itm as _;
66

77
use cortex_m::iprintln;
88

9-
use stm32f1xx_hal::{
10-
prelude::*,
11-
pac,
12-
spi::Spi,
13-
};
14-
use mfrc522::Mfrc522;
159
use cortex_m_rt::entry;
1610
use embedded_hal::digital::{v1_compat::OldOutputPin, v2::OutputPin};
11+
use mfrc522::Mfrc522;
12+
use stm32f1xx_hal::{pac, prelude::*, spi::Spi};
1713

1814
#[entry]
1915
fn main() -> ! {

examples/nojtag.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66

77
use panic_halt as _;
88

9-
use stm32f1xx_hal::{
10-
prelude::*,
11-
pac,
12-
};
139
use cortex_m_rt::entry;
10+
use stm32f1xx_hal::{pac, prelude::*};
1411

1512
#[entry]
1613
fn main() -> ! {

examples/panics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use panic_semihosting as _;
88
//use panic_itm as _;
9-
use stm32f1xx_hal as _;
109
use cortex_m_semihosting::hprintln;
10+
use stm32f1xx_hal as _;
1111

1212
use cortex_m_rt::{entry, exception, ExceptionFrame};
1313

examples/pwm.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
use panic_halt as _;
88

99
use cortex_m::asm;
10+
use cortex_m_rt::entry;
1011
use stm32f1xx_hal::{
11-
prelude::*,
1212
pac,
13-
timer::{Tim2NoRemap, Timer},
13+
prelude::*,
14+
pwm::Channel,
1415
time::U32Ext,
15-
pwm::Channel
16+
timer::{Tim2NoRemap, Timer},
1617
};
17-
use cortex_m_rt::entry;
1818

1919
#[entry]
2020
fn main() -> ! {
@@ -50,8 +50,11 @@ fn main() -> ! {
5050
// let c3 = gpiob.pb8.into_alternate_push_pull(&mut gpiob.crh);
5151
// let c4 = gpiob.pb9.into_alternate_push_pull(&mut gpiob.crh);
5252

53-
let mut pwm = Timer::tim2(p.TIM2, &clocks, &mut rcc.apb1)
54-
.pwm::<Tim2NoRemap, _, _, _>(pins, &mut afio.mapr, 1.khz());
53+
let mut pwm = Timer::tim2(p.TIM2, &clocks, &mut rcc.apb1).pwm::<Tim2NoRemap, _, _, _>(
54+
pins,
55+
&mut afio.mapr,
56+
1.khz(),
57+
);
5558

5659
//// Operations affecting all defined channels on the Timer
5760

@@ -85,7 +88,6 @@ fn main() -> ! {
8588

8689
asm::bkpt();
8790

88-
8991
// Extract the PwmChannel for C3
9092
let mut pwm_channel = pwm.split().2;
9193

0 commit comments

Comments
 (0)