From bd707c45363f5773a24952af5304509ffe37f584 Mon Sep 17 00:00:00 2001 From: sago35 Date: Sat, 30 May 2020 06:30:06 +0900 Subject: [PATCH 1/2] sam: fix register access for interrupts pins in samd51 --- src/machine/machine_atsamd51.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go index 6489403efe..6c59ec4cd4 100644 --- a/src/machine/machine_atsamd51.go +++ b/src/machine/machine_atsamd51.go @@ -335,7 +335,7 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error { pinCallbacks[extint] = callback interruptPins[extint] = p - if (sam.EIC.CTRLA.Get() & 0x02) == 0 { + if (sam.EIC.CTRLA.Get() & sam.EIC_CTRLA_ENABLE) == 0 { // EIC peripheral has not yet been initialized. Initialize it now. // The EIC needs two clocks: CLK_EIC_APB and GCLK_EIC. CLK_EIC_APB is @@ -349,7 +349,7 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error { } // CONFIG register is enable-protected, so disable EIC. - sam.EIC.CTRLA.Set(0) + sam.EIC.CTRLA.ClearBits(sam.EIC_CTRLA_ENABLE) // Configure this pin. Set the 4 bits of the EIC.CONFIGx register to the // sense value (filter bit set to 0, sense bits set to the change value). From c9b37632aaf6fba0559d7f5e48948d1b5c68a274 Mon Sep 17 00:00:00 2001 From: sago35 Date: Sat, 30 May 2020 18:58:58 +0900 Subject: [PATCH 2/2] use HasBits() --- src/machine/machine_atsamd51.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go index 6c59ec4cd4..786174442d 100644 --- a/src/machine/machine_atsamd51.go +++ b/src/machine/machine_atsamd51.go @@ -335,7 +335,7 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error { pinCallbacks[extint] = callback interruptPins[extint] = p - if (sam.EIC.CTRLA.Get() & sam.EIC_CTRLA_ENABLE) == 0 { + if !sam.EIC.CTRLA.HasBits(sam.EIC_CTRLA_ENABLE) { // EIC peripheral has not yet been initialized. Initialize it now. // The EIC needs two clocks: CLK_EIC_APB and GCLK_EIC. CLK_EIC_APB is