Skip to content

Commit 9203a77

Browse files
committed
Turn off interrupts while in handler
1 parent 45dee6e commit 9203a77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ static void pulsein_set_config(pulseio_pulsein_obj_t* self, bool first_edge) {
7777
}
7878

7979
void pulsein_interrupt_handler(uint8_t channel) {
80+
// turn off interrupts while in the handler
81+
common_hal_mcu_disable_interrupts();
8082
// Grab the current time first.
8183
uint32_t current_overflow = overflow_count;
8284
Tc* tc = tc_insts[pulsein_tc_index];
@@ -89,6 +91,7 @@ void pulsein_interrupt_handler(uint8_t channel) {
8991

9092
pulseio_pulsein_obj_t* self = get_eic_channel_data(channel);
9193
if (!supervisor_background_tasks_ok() ) {
94+
common_hal_mcu_enable_interrupts();
9295
mp_raise_RuntimeError(translate("Input taking too long"));
9396
return;
9497
}
@@ -122,6 +125,7 @@ void pulsein_interrupt_handler(uint8_t channel) {
122125
}
123126
self->last_overflow = current_overflow;
124127
self->last_count = current_count;
128+
common_hal_mcu_enable_interrupts();
125129
}
126130

127131
void pulsein_reset() {

0 commit comments

Comments
 (0)