diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c index f735cf0b4f..bad3d2b0fd 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c @@ -34,6 +34,7 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +#include "common-hal/alarm/__init__.h" // This variable stores whether a PinAlarm woke in light sleep or fake deep sleep // It CANNOT detect if the program woke from deep sleep. @@ -52,9 +53,6 @@ void pin_alarm_callback(uint8_t num) { // parameters can be changed // the trigger. This will only work for light sleep/fake deep // sleep, in conjunction with the find_triggered_alarm function - // Turn off interrupts while in handler - // printf("Woke up from pin!!\n"); - // printf("EIC Flags: %lu\n",EIC->INTFLAG.reg); if (pinalarm_on) { // clear flag and interrupt setting RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_TAMPER; diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h index 0157280e63..f3cd4cf27b 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h @@ -27,14 +27,6 @@ #ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_PINALARM_H #define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_PINALARM_H -// This is the first byte of the BKUP register bank. -// We use it to store which alarms are set. -#ifndef SAMD_ALARM_FLAG -#define SAMD_ALARM_FLAG (RTC->MODE0.BKUP[0].reg) -#define SAMD_ALARM_FLAG_TIME (_U_(0x1) << 0) -#define SAMD_ALARM_FLAG_PIN (_U_(0x1) << 1) -#endif - #include "py/obj.h" #include "py/objtuple.h" diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c index 62022d9034..49ce90a0b6 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -30,6 +30,7 @@ #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/time/__init__.h" +#include "common-hal/alarm/__init__.h" #include "supervisor/port.h" STATIC volatile bool woke_up; diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h index 36ae7121cf..a6102dee6b 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h @@ -27,14 +27,6 @@ #ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TIMEALARM_H #define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TIMEALARM_H -// This is the first byte of the BKUP register bank. -// We use it to store which alarms are set. -#ifndef SAMD_ALARM_FLAG -#define SAMD_ALARM_FLAG (RTC->MODE0.BKUP[0].reg) -#define SAMD_ALARM_FLAG_TIME (_U_(0x1) << 0) -#define SAMD_ALARM_FLAG_PIN (_U_(0x1) << 1) -#endif - #include "py/obj.h" typedef struct { diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 9485f94468..5d9275ca17 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -53,7 +53,6 @@ #error Unknown chip family #endif -#include "common-hal/alarm/__init__.h" #include "common-hal/analogio/AnalogIn.h" #include "common-hal/analogio/AnalogOut.h" #include "common-hal/audiobusio/PDMIn.h" @@ -66,6 +65,9 @@ #include "common-hal/pwmio/PWMOut.h" #include "common-hal/ps2io/Ps2.h" #include "common-hal/rtc/RTC.h" +#include "common-hal/alarm/__init__.h" +#include "common-hal/alarm/time/TimeAlarm.h" +#include "common-hal/alarm/pin/PinAlarm.h" #if CIRCUITPY_TOUCHIO_USE_NATIVE #include "common-hal/touchio/TouchIn.h" @@ -78,8 +80,6 @@ #include "samd/dma.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/rtc/__init__.h" -#include "shared-bindings/alarm/time/TimeAlarm.h" -#include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared_timers.h" #include "reset.h" @@ -194,7 +194,7 @@ static void rtc_init(void) { #endif #ifdef SAM_D5X_E5X hri_mclk_set_APBAMASK_RTC_bit(MCLK); - // Cache TAMPID? + // Cache TAMPID for wake up cause (void)alarm_get_wakeup_cause(); RTC->MODE0.CTRLA.bit.SWRST = true; while (RTC->MODE0.SYNCBUSY.bit.SWRST != 0) {