diff --git a/cpu/sam0_common/periph/gpio_ll_irq.c b/cpu/sam0_common/periph/gpio_ll_irq.c index e1b426034702..98304c5a8cce 100644 --- a/cpu/sam0_common/periph/gpio_ll_irq.c +++ b/cpu/sam0_common/periph/gpio_ll_irq.c @@ -181,8 +181,11 @@ void gpio_ll_irq_unmask_and_clear(gpio_port_t port, uint8_t pin) int exti_num = get_exti_num(port_num, pin); assume(exti_num >= 0); - EIC_SEC->INTENSET.reg = 1U << exti_num; - EIC_SEC->INTFLAG.reg = 1U << exti_num; + unsigned irq_state = irq_disable(); + uint32_t mask = 1U << exti_num; + EIC_SEC->INTFLAG.reg = mask; + EIC_SEC->INTENSET.reg = mask; + irq_restore(irq_state); } int gpio_ll_irq(gpio_port_t port, uint8_t pin, gpio_irq_trig_t trig,