Disable SPI, I²C, touch controller and display controller in sleep mode.

Re-enable them on wake up.

Remove delays that were not needed in st7889 driver.

Hopefully, it'll improve the battery life!
This commit is contained in:
JF
2020-01-17 22:16:45 +01:00
parent 69a14a2247
commit c1f3a31b51
9 changed files with 82 additions and 3 deletions
+17
View File
@@ -4,6 +4,9 @@
using namespace Pinetime::Drivers;
bool SpiMaster::Init(const SpiMaster::SpiModule spi, const SpiMaster::Parameters &params) {
configSpiModule = spi;
configParams = params;
/* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */
nrf_gpio_cfg_output(params.pinSCK);
nrf_gpio_cfg_output(params.pinMOSI);
@@ -86,3 +89,17 @@ bool SpiMaster::Write(const uint8_t *data, size_t size) {
return true;
}
void SpiMaster::Sleep() {
while(NRF_SPI0->ENABLE != 0) {
NRF_SPI0->ENABLE = (SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos);
}
nrf_gpio_cfg_default(configParams.pinSCK);
nrf_gpio_cfg_default(configParams.pinMOSI);
nrf_gpio_cfg_default(configParams.pinMISO);
nrf_gpio_cfg_default(configParams.pinCSN);
}
void SpiMaster::Wakeup() {
Init(configSpiModule, configParams);
}