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:
@@ -4,6 +4,9 @@
|
||||
using namespace Pinetime::Drivers;
|
||||
|
||||
bool SpiMaster::Init(const SpiMaster::SpiModule spi, const SpiMaster::Parameters ¶ms) {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user