Skip to content

Commit 53e64ae

Browse files
committed
Fix: irqn is negative for exceptions and positive for interrupts
-> no need to subtract 16
1 parent 213d5e0 commit 53e64ae

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/interrupts/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ pub mod primask_mutex;
3030

3131
#[exception]
3232
fn DefaultHandler(irqn: i16) {
33-
if irqn < 16 {
33+
if irqn < 0 {
3434
panic!("Unhandled exception (IRQn = {})", irqn);
3535
} else {
36-
// irqs 0-15 are exceptions
37-
let interrupt_number = irqn - 16;
3836
unsafe {
39-
match ISRS[usize::try_from(interrupt_number).unwrap()] {
37+
match ISRS[usize::try_from(irqn).unwrap()] {
4038
Some(ref mut isr) => isr(),
41-
None => default_interrupt_handler(interrupt_number.try_into().unwrap()),
39+
None => default_interrupt_handler(irqn.try_into().unwrap()),
4240
}
4341
}
4442
}

0 commit comments

Comments
 (0)