From 38c9d0344e5c4fa533d1309c22ac0a1ddd39fc28 Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Fri, 6 Dec 2024 11:25:59 +0000 Subject: [PATCH] ta_disable_irq_handler should unarm its timer --- src/rp2_common/pico_time_adapter/include/pico/time_adapter.h | 1 + test/pico_time_test/pico_time_test.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rp2_common/pico_time_adapter/include/pico/time_adapter.h b/src/rp2_common/pico_time_adapter/include/pico/time_adapter.h index 63dc39e30..bc9caf1ad 100644 --- a/src/rp2_common/pico_time_adapter/include/pico/time_adapter.h +++ b/src/rp2_common/pico_time_adapter/include/pico/time_adapter.h @@ -76,6 +76,7 @@ static inline void ta_enable_irq_handler(alarm_pool_timer_t *timer, uint alarm_n static inline void ta_disable_irq_handler(alarm_pool_timer_t *timer, uint alarm_num, irq_handler_t irq_handler) { uint irq_num = timer_hardware_alarm_get_irq_num(timer, alarm_num); + timer_hw_from_timer(timer)->armed = 1u << alarm_num; // disarm the timer hw_clear_bits(&timer_hw_from_timer(timer)->inte, 1u << alarm_num); irq_set_enabled(irq_num, true); irq_remove_handler(irq_num, irq_handler); diff --git a/test/pico_time_test/pico_time_test.c b/test/pico_time_test/pico_time_test.c index d73867122..53b69d8cd 100644 --- a/test/pico_time_test/pico_time_test.c +++ b/test/pico_time_test/pico_time_test.c @@ -355,8 +355,8 @@ int issue_2118_test(void) { } PICOTEST_CHECK(counter_2118 >= 100, "Repeating timer failure"); - cancel_repeating_timer(&timer); alarm_pool_destroy(pool); + hard_assert(timer0_hw->armed == 0); // check destroying the pool unarms its timer set_sys_clock_hz(SYS_CLK_HZ, true); setup_default_uart();