Power optimization - Improve SPI sleep mode
Calls to Spi::Init() are not needed, pin initialization is already done in ctor(). Remove calls to Spi::Sleep()/Spi::Wakeup() to ensure that SPI CS pins are kept high even in sleep mode.
This commit is contained in:
parent
4c0f897953
commit
62848b33fb
|
@ -10,7 +10,6 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiNorFlash::Init() {
|
void SpiNorFlash::Init() {
|
||||||
spi.Init();
|
|
||||||
device_id = ReadIdentificaion();
|
device_id = ReadIdentificaion();
|
||||||
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
|
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
|
||||||
device_id.manufacturer,
|
device_id.manufacturer,
|
||||||
|
@ -24,12 +23,10 @@ void SpiNorFlash::Uninit() {
|
||||||
void SpiNorFlash::Sleep() {
|
void SpiNorFlash::Sleep() {
|
||||||
auto cmd = static_cast<uint8_t>(Commands::DeepPowerDown);
|
auto cmd = static_cast<uint8_t>(Commands::DeepPowerDown);
|
||||||
spi.Write(&cmd, sizeof(uint8_t));
|
spi.Write(&cmd, sizeof(uint8_t));
|
||||||
spi.Sleep();
|
|
||||||
NRF_LOG_INFO("[SpiNorFlash] Sleep")
|
NRF_LOG_INFO("[SpiNorFlash] Sleep")
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiNorFlash::Wakeup() {
|
void SpiNorFlash::Wakeup() {
|
||||||
spi.Wakeup();
|
|
||||||
// send Commands::ReleaseFromDeepPowerDown then 3 dummy bytes before reading Device ID
|
// send Commands::ReleaseFromDeepPowerDown then 3 dummy bytes before reading Device ID
|
||||||
static constexpr uint8_t cmdSize = 4;
|
static constexpr uint8_t cmdSize = 4;
|
||||||
uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};
|
uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};
|
||||||
|
|
|
@ -10,7 +10,6 @@ St7789::St7789(Spi& spi, uint8_t pinDataCommand) : spi {spi}, pinDataCommand {pi
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::Init() {
|
void St7789::Init() {
|
||||||
spi.Init();
|
|
||||||
nrf_gpio_cfg_output(pinDataCommand);
|
nrf_gpio_cfg_output(pinDataCommand);
|
||||||
nrf_gpio_cfg_output(26);
|
nrf_gpio_cfg_output(26);
|
||||||
nrf_gpio_pin_set(26);
|
nrf_gpio_pin_set(26);
|
||||||
|
@ -188,12 +187,10 @@ void St7789::Sleep() {
|
||||||
SleepIn();
|
SleepIn();
|
||||||
nrf_gpio_cfg_default(pinDataCommand);
|
nrf_gpio_cfg_default(pinDataCommand);
|
||||||
nrf_gpio_cfg_default(26);
|
nrf_gpio_cfg_default(26);
|
||||||
spi.Sleep();
|
|
||||||
NRF_LOG_INFO("[LCD] Sleep");
|
NRF_LOG_INFO("[LCD] Sleep");
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::Wakeup() {
|
void St7789::Wakeup() {
|
||||||
spi.Wakeup();
|
|
||||||
nrf_gpio_cfg_output(pinDataCommand);
|
nrf_gpio_cfg_output(pinDataCommand);
|
||||||
SleepOut();
|
SleepOut();
|
||||||
VerticalScrollStartAddress(verticalScrollingStartAddress);
|
VerticalScrollStartAddress(verticalScrollingStartAddress);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user