[ion] Move Power::standbyConfiguration to N0110 folder to prevent anyone

to use it in N0100
This commit is contained in:
Émilie Feral
2019-06-19 09:05:25 -04:00
parent d67a1d00a7
commit 3aa6775cc1
4 changed files with 52 additions and 24 deletions

View File

@@ -1,5 +1,7 @@
#include <drivers/power.h>
#include <drivers/board.h>
#include <drivers/power.h>
#include <drivers/keyboard.h>
#include <regs/regs.h>
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
}
}
}
}

View File

@@ -0,0 +1,16 @@
#ifndef ION_DEVICE_N0110_POWER_H
#define ION_DEVICE_N0110_POWER_H
#include <ion/src/device/shared/drivers/power.h>
namespace Ion {
namespace Device {
namespace Power {
void standbyConfiguration();
}
}
}
#endif

View File

@@ -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;

View File

@@ -11,7 +11,6 @@ void configWakeUp();
void sleepConfiguration();
void stopConfiguration();
void standbyConfiguration();
void waitUntilOnOffKeyReleased();
void enterLowPowerMode();