aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/SpiNorFlash.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2023-05-07 18:24:34 +0200
committerJF <JF002@users.noreply.github.com>2023-06-04 17:22:27 +0200
commit4c0f897953aa8d478f3c941e75d3b2eb5611531d (patch)
tree28c926cf8e0319ce5b5369382af6dbf935e17918 /src/drivers/SpiNorFlash.cpp
parent2fa3aaa1617849dd29fe55c844d5250df0cba955 (diff)
Power optimization - Improve SPI sleep mode
Ensure that all pins are set to their default configuration during sleep mode. Disable the workaround for FTPAN58 (SPI freezes when transfering a single byte) at the end of the transfer. This disables the resources needed for the workaround. Those changes reduce the power usage by 430-490µA.
Diffstat (limited to 'src/drivers/SpiNorFlash.cpp')
-rw-r--r--src/drivers/SpiNorFlash.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/drivers/SpiNorFlash.cpp b/src/drivers/SpiNorFlash.cpp
index 28f82fe6..525b812c 100644
--- a/src/drivers/SpiNorFlash.cpp
+++ b/src/drivers/SpiNorFlash.cpp
@@ -10,6 +10,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} {
}
void SpiNorFlash::Init() {
+ spi.Init();
device_id = ReadIdentificaion();
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
device_id.manufacturer,
@@ -23,10 +24,12 @@ void SpiNorFlash::Uninit() {
void SpiNorFlash::Sleep() {
auto cmd = static_cast<uint8_t>(Commands::DeepPowerDown);
spi.Write(&cmd, sizeof(uint8_t));
+ spi.Sleep();
NRF_LOG_INFO("[SpiNorFlash] Sleep")
}
void SpiNorFlash::Wakeup() {
+ spi.Wakeup();
// send Commands::ReleaseFromDeepPowerDown then 3 dummy bytes before reading Device ID
static constexpr uint8_t cmdSize = 4;
uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};