mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
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>
This commit is contained in:
@@ -261,13 +261,13 @@ func setupPinInterrupt() error {
|
|||||||
esp.INTERRUPT_CORE0.GPIO_INTERRUPT_PRO_MAP.Set(cpuInterruptFromPin)
|
esp.INTERRUPT_CORE0.GPIO_INTERRUPT_PRO_MAP.Set(cpuInterruptFromPin)
|
||||||
return interrupt.New(cpuInterruptFromPin, func(interrupt.Interrupt) {
|
return interrupt.New(cpuInterruptFromPin, func(interrupt.Interrupt) {
|
||||||
status := esp.GPIO.STATUS.Get()
|
status := esp.GPIO.STATUS.Get()
|
||||||
|
// Clear before processing so new edges during callbacks are not lost.
|
||||||
|
esp.GPIO.STATUS_W1TC.SetBits(status)
|
||||||
for i, mask := 0, uint32(1); i < maxPin; i, mask = i+1, mask<<1 {
|
for i, mask := 0, uint32(1); i < maxPin; i, mask = i+1, mask<<1 {
|
||||||
if (status&mask) != 0 && pinCallbacks[i] != nil {
|
if (status&mask) != 0 && pinCallbacks[i] != nil {
|
||||||
pinCallbacks[i](Pin(i))
|
pinCallbacks[i](Pin(i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clear interrupt bit
|
|
||||||
esp.GPIO.STATUS_W1TC.SetBits(status)
|
|
||||||
}).Enable()
|
}).Enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user