Skip to content

Commit f62b939

Browse files
committed
formatting...
1 parent 3e56826 commit f62b939

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

examples/serial_echo_irq.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@
55
#![deny(unsafe_code)]
66
#![allow(non_camel_case_types)]
77

8-
use panic_halt as _;
9-
use nb::block;
108
use core::cell::RefCell;
9+
use nb::block;
10+
use panic_halt as _;
1111

1212
use cortex_m::interrupt::Mutex;
1313
use cortex_m_rt::entry;
1414

15-
use stm32f0xx_hal as hal;
1615
use hal::{
17-
pac::{ self, interrupt, Interrupt, USART1 },
16+
delay::Delay,
17+
gpio::{
18+
gpioa::{PA15, PA2},
19+
gpiob::PB3,
20+
Alternate, Output, PushPull, AF1,
21+
},
22+
pac::{self, interrupt, Interrupt, USART1},
1823
prelude::*,
19-
serial::Serial, gpio::{gpioa::{PA2, PA15}, Alternate, AF1, Output, PushPull, gpiob::PB3},
20-
delay::Delay
24+
serial::Serial,
2125
};
26+
use stm32f0xx_hal as hal;
2227

2328
// setup some types for our globally shared resources
2429
type LED_PIN = PB3<Output<PushPull>>;
@@ -57,13 +62,16 @@ macro_rules! with_global_mut {
5762
// a helper macro to generalize the initialization of a UART
5863
macro_rules! setup_uart {
5964
( $CS:ident, $DP:ident, $RCC:ident, $GPIOx:ident ) => {
60-
let (tx, rx) =
61-
(
62-
$GPIOx.pa2.into_alternate_af1($CS),
63-
$GPIOx.pa15.into_alternate_af1($CS),
64-
);
65-
66-
init_global!($CS, SER_PORT, Serial::usart1($DP.USART1, (tx, rx), 9_600.bps(), &mut $RCC));
65+
let (tx, rx) = (
66+
$GPIOx.pa2.into_alternate_af1($CS),
67+
$GPIOx.pa15.into_alternate_af1($CS),
68+
);
69+
70+
init_global!(
71+
$CS,
72+
SER_PORT,
73+
Serial::usart1($DP.USART1, (tx, rx), 9_600.bps(), &mut $RCC)
74+
);
6775
with_global_mut!($CS, SER_PORT, ser, {
6876
ser.listen(hal::serial::Event::Rxne);
6977
});
@@ -89,7 +97,9 @@ fn main() -> ! {
8997
});
9098

9199
#[allow(unsafe_code)] // just this once ;)
92-
unsafe { cortex_m::peripheral::NVIC::unmask(Interrupt::USART1); }
100+
unsafe {
101+
cortex_m::peripheral::NVIC::unmask(Interrupt::USART1);
102+
}
93103

94104
loop {
95105
cortex_m::interrupt::free(|cs| {
@@ -118,4 +128,4 @@ fn USART1() {
118128
}
119129
});
120130
});
121-
}
131+
}

0 commit comments

Comments
 (0)