-
-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Power optimization - Improve SPI sleep mode #1758
Conversation
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.
Build size and comparison to main:
|
commit 5587ce3 Author: Jean-François Milants <jf@codingfield.com> Date: Sun May 7 18:24:34 2023 +0200 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much do each of the changes contribute to reducing the power consumption separately?
This PR basically contains 2 changes : reset the CS pin configuration during sleep (and restore it at wake up) and disable the "workaround for FTPAN58" (disable the PPI channel). As I said in responses to your reviews, resetting the CS pin config is probably wrong as CS pins must be kept high whenever we don't want devices to listen to the bus, so I'll remove those change. Most of the power usage reduction comes from disabling the PPI channel : from 900µA to 410µA in sleep mode with BLE disabled. |
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.
ST7789 driver : replace the constant '26' with a named constant to specify the pin number of the reset pin of the LCD controller.
Fix formatting issue in St7789.cpp
void St7789::HardwareReset() { | ||
nrf_gpio_pin_clear(26); | ||
nrf_gpio_pin_clear(pinReset); | ||
nrf_delay_ms(10); | ||
nrf_gpio_pin_set(26); | ||
nrf_gpio_pin_set(pinReset); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we configure the pin only at the beginning of this function, and reset back to default before returning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pins needs to be kept at a high level to ensure the display controller won't reset unexpectedly, so I guess we can't configure the pins to default (input, no pull up/down) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's true, wouldn't that mean we shouldn't default configure the pin in the sleep function either or anywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, I fixed this in 3c668ca.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there's still nrf_gpio_cfg_default in the St7789::Sleep() function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, right, I guess we shouldn't default the reset pin!
Fix RecoveryLoader.
commit 5587ce3 Author: Jean-François Milants <jf@codingfield.com> Date: Sun May 7 18:24:34 2023 +0200 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.
As of InfiniTimeOrg/InfiniTime#1758 ST7789 driver constructor has a pinReset argument.
As of InfiniTimeOrg/InfiniTime#1758 ST7789 driver constructor has a pinReset argument. Update the InfiniTime submodule to the state after the update of the ST7789 driver. Fixes: InfiniTimeOrg#107
Thanks for these improvements! It seems like my pinetime is really holding out very long on one charge now, I am very happy about that. 😊 |
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.