Skip to content

Commit 6e4c2f4

Browse files
committed
fixed it... but... why
1 parent f62b939 commit 6e4c2f4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

examples/serial_echo_irq.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,21 @@ macro_rules! setup_uart {
8080

8181
#[entry]
8282
fn main() -> ! {
83-
let dp = pac::Peripherals::take().unwrap(); // might as well panic if this doesn't work
84-
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
85-
let mut flash = dp.FLASH;
86-
let mut rcc = dp.RCC.configure().sysclk(48.mhz()).freeze(&mut flash);
83+
let mut delay = cortex_m::interrupt::free(|cs| {
84+
let dp = pac::Peripherals::take().unwrap(); // might as well panic if this doesn't work
85+
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
86+
let mut flash = dp.FLASH;
87+
let mut rcc = dp.RCC.configure().sysclk(48.mhz()).freeze(&mut flash);
8788

88-
let gpioa = dp.GPIOA.split(&mut rcc);
89-
let gpiob = dp.GPIOB.split(&mut rcc);
89+
let gpioa = dp.GPIOA.split(&mut rcc);
90+
let gpiob = dp.GPIOB.split(&mut rcc);
9091

91-
let mut delay = Delay::new(cp.SYST, &rcc);
92-
93-
cortex_m::interrupt::free(|cs| {
92+
let delay = Delay::new(cp.SYST, &rcc);
9493
setup_uart!(cs, dp, rcc, gpioa);
9594

9695
init_global!(cs, LED, gpiob.pb3.into_push_pull_output(cs));
96+
97+
delay
9798
});
9899

99100
#[allow(unsafe_code)] // just this once ;)

0 commit comments

Comments
 (0)