Skip to content

Commit 889911d

Browse files
committed
machine/esp32c3: clear GPIO STATUS before dispatching pin callbacks
Move STATUS_W1TC clear to before the callback loop so that new GPIO events arriving during handler execution generate a fresh edge on the CPU interrupt line and are not lost. Matches the same fix applied to ESP32-S3. Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent a4dd38d commit 889911d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/machine/machine_esp32c3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ func setupPinInterrupt() error {
261261
esp.INTERRUPT_CORE0.GPIO_INTERRUPT_PRO_MAP.Set(cpuInterruptFromPin)
262262
return interrupt.New(cpuInterruptFromPin, func(interrupt.Interrupt) {
263263
status := esp.GPIO.STATUS.Get()
264+
// Clear before processing so new edges during callbacks are not lost.
265+
esp.GPIO.STATUS_W1TC.SetBits(status)
264266
for i, mask := 0, uint32(1); i < maxPin; i, mask = i+1, mask<<1 {
265267
if (status&mask) != 0 && pinCallbacks[i] != nil {
266268
pinCallbacks[i](Pin(i))
267269
}
268270
}
269-
// clear interrupt bit
270-
esp.GPIO.STATUS_W1TC.SetBits(status)
271271
}).Enable()
272272
}
273273

0 commit comments

Comments
 (0)