Skip to content

Commit 2437ab9

Browse files
committed
update frequencyin interrupt handler
1 parent a106074 commit 2437ab9

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ void frequencyin_reference_tc_init() {
154154
if (dpll_gclk == 0xff) {
155155
frequencyin_samd51_start_dpll();
156156
}
157-
turn_on_clocks(true, reference_tc, dpll_gclk, TC_HANDLER_FREQUENCYIN);
157+
set_timer_handler(reference_tc, dpll_gclk, TC_HANDLER_FREQUENCYIN);
158+
turn_on_clocks(true, reference_tc, dpll_gclk);
158159
#endif
159160

160161
Tc *tc = tc_insts[reference_tc];
@@ -289,15 +290,17 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
289290
// SAMD21: We use GCLK0 generated from DFLL running at 48mhz
290291
// SAMD51: We use a GCLK generated from DPLL1 running at <100mhz
291292
#ifdef SAMD21
292-
turn_on_clocks(true, timer_index, 0, TC_HANDLER_NO_INTERRUPT);
293+
set_timer_handler(timer_index, 0, TC_HANDLER_NO_INTERRUPT);
294+
turn_on_clocks(true, timer_index, 0);
293295
#endif
294296
#ifdef SAMD51
295297
frequencyin_samd51_start_dpll();
296298
if (dpll_gclk == 0xff && !clock_get_enabled(0, GCLK_SOURCE_DPLL1)) {
297299
common_hal_frequencyio_frequencyin_deinit(self);
298300
mp_raise_RuntimeError(translate("No available clocks"));
299301
}
300-
turn_on_clocks(true, timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT);
302+
set_timer_handler(timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT);
303+
turn_on_clocks(true, timer_index, dpll_gclk);
301304
#endif
302305

303306
// Ensure EIC is on

ports/atmel-samd/timer_handler.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
4646
uint8_t handler = tc_handler[index];
4747
if (handler == TC_HANDLER_PULSEOUT) {
4848
pulseout_interrupt_handler(index);
49+
} else if (handler == TC_HANDLER_FREQUENCYIN) {
50+
frequencyin_interrupt_handler(index);
4951
}
5052
}
5153
}

ports/atmel-samd/timer_handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#define TC_HANDLER_NO_INTERRUPT 0x0
3030
#define TC_HANDLER_PULSEOUT 0x1
31+
#define TC_HANDLER_FREQUENCYIN 0x2
3132

3233
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
3334
void shared_timer_handler(bool is_tc, uint8_t index);

0 commit comments

Comments
 (0)