From 3aa6775cc1af66ee3801a1b2d377680ef4290fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 19 Jun 2019 09:05:25 -0400 Subject: [PATCH] [ion] Move Power::standbyConfiguration to N0110 folder to prevent anyone to use it in N0100 --- ion/src/device/n0110/drivers/power.cpp | 37 ++++++++++++++++++++++++- ion/src/device/n0110/drivers/power.h | 16 +++++++++++ ion/src/device/shared/drivers/power.cpp | 22 --------------- ion/src/device/shared/drivers/power.h | 1 - 4 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 ion/src/device/n0110/drivers/power.h diff --git a/ion/src/device/n0110/drivers/power.cpp b/ion/src/device/n0110/drivers/power.cpp index 18968518e..22a8aff86 100644 --- a/ion/src/device/n0110/drivers/power.cpp +++ b/ion/src/device/n0110/drivers/power.cpp @@ -1,5 +1,7 @@ -#include #include +#include +#include +#include namespace Ion { namespace Power { @@ -17,3 +19,36 @@ void standby() { } } + +namespace Ion { +namespace Device { +namespace Power { + +// Public Power methods +using namespace Device::Regs; + +void standbyConfiguration() { + PWR.CR()->setPPDS(true); // Select standby when the CPU enters deepsleep + PWR.CR()->setCSBF(true); // Clear Standby flag + PWR.CSR()->setBRE(false); // Unable back up RAM (lower power consumption in standby) + PWR.CSR()->setEIWUP(false); // Unable RTC (lower power consumption in standby) + + /* The pin A0 is about to be configured as a wakeup pin. However, the matrix + * keyboard connects pin A0 (row B) with other pins (column 1, column 3...). + * We thus shutdown this pins to avoid the potential pull-up on pin A0 due to + * a keyboard event. For example, if the "Home" key is down, pin A0 is + * pulled-up so enabling it as the wake up pin would trigger a wake up flag + * instantly. */ + Device::Keyboard::shutdown(); +#if REGS_PWR_CONFIG_ADDITIONAL_FIELDS + PWR.CSR2()->setEWUP1(true); // Enable PA0 as wakeup pin + PWR.CR2()->setWUPP1(false); // Define PA0 (wakeup) pin polarity (rising edge) + PWR.CR2()->setCWUPF1(true); // Clear wakeup pin flag for PA0 (if device has already been in standby and woke up) +#endif + + CORTEX.SCR()->setSLEEPDEEP(true); // Allow Cortex-M7 deepsleep state +} + +} +} +} diff --git a/ion/src/device/n0110/drivers/power.h b/ion/src/device/n0110/drivers/power.h new file mode 100644 index 000000000..a3d142bc1 --- /dev/null +++ b/ion/src/device/n0110/drivers/power.h @@ -0,0 +1,16 @@ +#ifndef ION_DEVICE_N0110_POWER_H +#define ION_DEVICE_N0110_POWER_H + +#include + +namespace Ion { +namespace Device { +namespace Power { + +void standbyConfiguration(); + +} +} +} + +#endif diff --git a/ion/src/device/shared/drivers/power.cpp b/ion/src/device/shared/drivers/power.cpp index e72a96e13..9e8a7aa1a 100644 --- a/ion/src/device/shared/drivers/power.cpp +++ b/ion/src/device/shared/drivers/power.cpp @@ -160,28 +160,6 @@ void sleepConfiguration() { CORTEX.SCR()->setSLEEPDEEP(false); } -void standbyConfiguration() { - PWR.CR()->setPPDS(true); // Select standby when the CPU enters deepsleep - PWR.CR()->setCSBF(true); // Clear Standby flag - PWR.CSR()->setBRE(false); // Unable back up RAM (lower power consumption in standby) - PWR.CSR()->setEIWUP(false); // Unable RTC (lower power consumption in standby) - - /* The pin A0 is about to be configured as a wakeup pin. However, the matrix - * keyboard connects pin A0 (row B) with other pins (column 1, column 3...). - * We thus shutdown this pins to avoid the potential pull-up on pin A0 due to - * a keyboard event. For example, if the "Home" key is down, pin A0 is - * pulled-up so enabling it as the wake up pin would trigger a wake up flag - * instantly. */ - Device::Keyboard::shutdown(); -#if REGS_PWR_CONFIG_ADDITIONAL_FIELDS - PWR.CSR2()->setEWUP1(true); // Enable PA0 as wakeup pin - PWR.CR2()->setWUPP1(false); // Define PA0 (wakeup) pin polarity (rising edge) - PWR.CR2()->setCWUPF1(true); // Clear wakeup pin flag for PA0 (if device has already been in standby and woke up) -#endif - - CORTEX.SCR()->setSLEEPDEEP(true); // Allow Cortex-M7 deepsleep state -} - void waitUntilOnOffKeyReleased() { /* Wait until power is released to avoid restarting just after suspending */ bool isPowerDown = true; diff --git a/ion/src/device/shared/drivers/power.h b/ion/src/device/shared/drivers/power.h index b90de0950..bc3b226ed 100644 --- a/ion/src/device/shared/drivers/power.h +++ b/ion/src/device/shared/drivers/power.h @@ -11,7 +11,6 @@ void configWakeUp(); void sleepConfiguration(); void stopConfiguration(); -void standbyConfiguration(); void waitUntilOnOffKeyReleased(); void enterLowPowerMode();