Skip to content

Commit 0e5ef0f

Browse files
authored
Fix hardware_alarm_irq_handler when using Timer 1 (#1949)
Correct the logic for determining `timer_num`. Previously this would always evaluate to 0 due to using `alarm_num` instead of `irq_num`. Fixes #1948.
1 parent a0f828f commit 0e5ef0f

File tree

1 file changed

+3
-2
lines changed
  • src/rp2_common/hardware_timer

1 file changed

+3
-2
lines changed

src/rp2_common/hardware_timer/timer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ void busy_wait_until(absolute_time_t t) {
145145

146146
static void hardware_alarm_irq_handler(void) {
147147
// Determine which timer this IRQ is for
148-
uint alarm_num = TIMER_ALARM_NUM_FROM_IRQ(__get_current_exception() - VTABLE_FIRST_IRQ);
148+
uint irq_num = __get_current_exception() - VTABLE_FIRST_IRQ;
149+
uint alarm_num = TIMER_ALARM_NUM_FROM_IRQ(irq_num);
149150
check_hardware_alarm_num_param(alarm_num);
150-
uint timer_num = TIMER_NUM_FROM_IRQ(alarm_num);
151+
uint timer_num = TIMER_NUM_FROM_IRQ(irq_num);
151152
timer_hw_t *timer = timer_get_instance(timer_num);
152153
hardware_alarm_callback_t callback = NULL;
153154

0 commit comments

Comments
 (0)