From aac4562ab0a00941efa4d614d3c02e31d52173db Mon Sep 17 00:00:00 2001 From: Dustin Date: Sun, 2 Apr 2017 23:53:05 -0700 Subject: [PATCH] Clear interrupt flag based on the interrupt used (#815) The previous code would clear the proper interrupt flag assuming interrupt1 was INT0 and interrupt2 was INT1. If interrupt1 was INT1 or interrupt2 was INT0, the sleep bug would be triggered. --- core/MyHwAVR.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/MyHwAVR.cpp b/core/MyHwAVR.cpp index b2b11ef..4bc80bc 100644 --- a/core/MyHwAVR.cpp +++ b/core/MyHwAVR.cpp @@ -163,11 +163,11 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo // to prevent waking immediately again. // Ref: https://forum.arduino.cc/index.php?topic=59217.0 if (interrupt1 != INVALID_INTERRUPT_NUM) { - EIFR = _BV(INTF0); + EIFR = _BV(interrupt1 == 0 ? INTF0 : INTF1); attachInterrupt(interrupt1, wakeUp1, mode1); } if (interrupt2 != INVALID_INTERRUPT_NUM) { - EIFR = _BV(INTF1); + EIFR = _BV(interrupt2 == 0 ? INTF0 : INTF1); attachInterrupt(interrupt2, wakeUp2, mode2); }