Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mdbook/src/15-interrupts/examples/count-debounce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ fn main() -> ! {
unsafe { pac::NVIC::unmask(pac::Interrupt::GPIOTE) };
pac::NVIC::unpend(pac::Interrupt::GPIOTE);

// Because we're not disabling GPIOTE interrupts even during the debounce timer countdown,
// we can get extra button interrupts even during the debounce interval.
// It would be reasonable to disable button interrupts when the debounce timer is started
// and re-enable them when it expires, but this would require a debounce timer interrupt handler.
// To make a simple "fix" for this that doesn't hurt the readability,
// we introduce the cur_count "guard" variable.
let mut cur_count = 0;
loop {
// "wait for interrupt": CPU goes to sleep until an interrupt.
Expand Down
Loading