diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-06-19 03:07:26 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-06-19 03:22:12 +0200 |
| commit | 558918651ee99024876fb1f85a559d46edba9548 (patch) | |
| tree | a93d38e4ef400c66a47e624b87818063f86a4226 /docs | |
| parent | adaed307b4d81ed09611e496524b1d96ad04c60d (diff) | |
stm32: update stm32-metapac.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs index 743d0c342..aecba0755 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs | |||
| @@ -20,13 +20,13 @@ fn main() -> ! { | |||
| 20 | let led = Output::new(p.PB14, Level::Low, Speed::Low); | 20 | let led = Output::new(p.PB14, Level::Low, Speed::Low); |
| 21 | let mut button = Input::new(p.PC13, Pull::Up); | 21 | let mut button = Input::new(p.PC13, Pull::Up); |
| 22 | 22 | ||
| 23 | cortex_m::interrupt::free(|cs| unsafe { | 23 | cortex_m::interrupt::free(|cs| { |
| 24 | enable_interrupt(&mut button); | 24 | enable_interrupt(&mut button); |
| 25 | 25 | ||
| 26 | LED.borrow(cs).borrow_mut().replace(led); | 26 | LED.borrow(cs).borrow_mut().replace(led); |
| 27 | BUTTON.borrow(cs).borrow_mut().replace(button); | 27 | BUTTON.borrow(cs).borrow_mut().replace(button); |
| 28 | 28 | ||
| 29 | NVIC::unmask(pac::Interrupt::EXTI15_10); | 29 | unsafe { NVIC::unmask(pac::Interrupt::EXTI15_10) }; |
| 30 | }); | 30 | }); |
| 31 | 31 | ||
| 32 | loop { | 32 | loop { |
| @@ -64,25 +64,21 @@ const PORT: u8 = 2; | |||
| 64 | const PIN: usize = 13; | 64 | const PIN: usize = 13; |
| 65 | fn check_interrupt<P: Pin>(_pin: &mut Input<'static, P>) -> bool { | 65 | fn check_interrupt<P: Pin>(_pin: &mut Input<'static, P>) -> bool { |
| 66 | let exti = pac::EXTI; | 66 | let exti = pac::EXTI; |
| 67 | unsafe { | 67 | let pin = PIN; |
| 68 | let pin = PIN; | 68 | let lines = exti.pr(0).read(); |
| 69 | let lines = exti.pr(0).read(); | 69 | lines.line(pin) |
| 70 | lines.line(pin) | ||
| 71 | } | ||
| 72 | } | 70 | } |
| 73 | 71 | ||
| 74 | fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { | 72 | fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { |
| 75 | let exti = pac::EXTI; | 73 | let exti = pac::EXTI; |
| 76 | unsafe { | 74 | let pin = PIN; |
| 77 | let pin = PIN; | 75 | let mut lines = exti.pr(0).read(); |
| 78 | let mut lines = exti.pr(0).read(); | 76 | lines.set_line(pin, true); |
| 79 | lines.set_line(pin, true); | 77 | exti.pr(0).write_value(lines); |
| 80 | exti.pr(0).write_value(lines); | ||
| 81 | } | ||
| 82 | } | 78 | } |
| 83 | 79 | ||
| 84 | fn enable_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { | 80 | fn enable_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { |
| 85 | cortex_m::interrupt::free(|_| unsafe { | 81 | cortex_m::interrupt::free(|_| { |
| 86 | let rcc = pac::RCC; | 82 | let rcc = pac::RCC; |
| 87 | rcc.apb2enr().modify(|w| w.set_syscfgen(true)); | 83 | rcc.apb2enr().modify(|w| w.set_syscfgen(true)); |
| 88 | 84 | ||
