Skip to content

Commit 8f19128

Browse files
authored
Merge pull request #164 from jounathaen/patch-2
Changed Variable name in EXTI example
2 parents fa26e97 + 4a985d2 commit 8f19128

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/exti.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ use stm32f1xx_hal::gpio::*;
2323
// After enabling the interrupt, main() may not have any references to these objects any more.
2424
// For the sake of minimalism, we do not use RTFM here, which would be the better way.
2525
static mut LED : MaybeUninit<stm32f1xx_hal::gpio::gpioc::PC13<Output<PushPull>>> = MaybeUninit::uninit();
26-
static mut EXTI : MaybeUninit<stm32f1xx_hal::gpio::gpioa::PA7<Input<Floating>>> = MaybeUninit::uninit();
26+
static mut INT_PIN : MaybeUninit<stm32f1xx_hal::gpio::gpioa::PA7<Input<Floating>>> = MaybeUninit::uninit();
2727

2828
#[interrupt]
2929
fn EXTI9_5() {
3030
let led = unsafe { &mut *LED.as_mut_ptr()};
31-
let exti = unsafe { &mut *EXTI.as_mut_ptr()};
31+
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr()};
3232

33-
if exti.check_interrupt() {
33+
if int_pin.check_interrupt() {
3434
led.toggle();
3535

3636
// if we don't clear this bit, the ISR would trigger indefinitely
37-
exti.clear_interrupt_pending_bit();
37+
int_pin.clear_interrupt_pending_bit();
3838
}
3939
}
4040

@@ -44,7 +44,7 @@ fn main() -> ! {
4444
let p = pac::Peripherals::take().unwrap();
4545
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
4646
{
47-
// the scope ensures that the exti reference is dropped before the first ISR can be executed.
47+
// the scope ensures that the int_pin reference is dropped before the first ISR can be executed.
4848

4949
let mut rcc = p.RCC.constrain();
5050
let mut gpioa = p.GPIOA.split(&mut rcc.apb2);
@@ -54,11 +54,11 @@ fn main() -> ! {
5454
let led = unsafe { &mut *LED.as_mut_ptr()};
5555
*led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
5656

57-
let exti = unsafe { &mut *EXTI.as_mut_ptr()};
58-
*exti = gpioa.pa7.into_floating_input(&mut gpioa.crl);
59-
exti.make_interrupt_source(&mut afio);
60-
exti.trigger_on_edge(&p.EXTI, Edge::RISING_FALLING);
61-
exti.enable_interrupt(&p.EXTI);
57+
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr()};
58+
*int_pin = gpioa.pa7.into_floating_input(&mut gpioa.crl);
59+
int_pin.make_interrupt_source(&mut afio);
60+
int_pin.trigger_on_edge(&p.EXTI, Edge::RISING_FALLING);
61+
int_pin.enable_interrupt(&p.EXTI);
6262
} // initialization ends here
6363

6464
let mut nvic = cp.NVIC;

0 commit comments

Comments
 (0)