-
-
Save trimoq/73f9fb23b4efcb280d351721e830d7f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
static G_LED: Mutex<RefCell<Option<LedPin>>> = Mutex::new(RefCell::new(None)); | |
#[entry] | |
fn main() -> ! { | |
// ... | |
let mut led = setup.gpioa.pa5.into_push_pull_output(); | |
cortex_m::interrupt::free(|cs| { | |
*G_LED.borrow(cs).borrow_mut() = Some(led); | |
}); | |
unsafe { | |
cortex_m::peripheral::NVIC::unmask(pac::Interrupt::EXTI15_10); | |
} | |
loop { | |
wfi(); // do nothing | |
} | |
} | |
#[interrupt] | |
fn EXTI15_10() { | |
cortex_m::interrupt::free(|cs| { | |
G_LED | |
.borrow(cs) | |
.borrow_mut() | |
.as_mut() | |
.unwrap() | |
.toggle(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment