-
Notifications
You must be signed in to change notification settings - Fork 54
STM32 Low Power library #1
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
Conversation
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
src/STM32LowPower.cpp
Outdated
|
||
/** | ||
* @brief Enable a wire interface as a wakeup source. | ||
* @param serial: pointer to a TwoWire |
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.
src/STM32LowPower.cpp
Outdated
|
||
/** | ||
* @brief Attach a callback to a RTC alarm. | ||
* @param serial: pointer to a STM32RTC |
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.
=> @param rtc: pointer to a STM32RTC
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.
Few comments and questions raised
src/STM32LowPower.cpp
Outdated
LowPower_EnableWakeUpUart(&(serial->_serial), callback); | ||
} | ||
|
||
#if 0 |
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.
Add a comment or limitation description rather than code behind #if 0
* @param millis: delay before leave the idle mode. | ||
* @retval None | ||
*/ | ||
void STM32LowPower::idle(uint32_t millis) |
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.
shouldn't the idle / sleep function return something ? en error in case something went wrong ?
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.
We can't because HAL functions don't return status.
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.
ok
examples/TimedWakeup/TimedWakeup.ino
Outdated
|
||
void loop() { | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
delay(500); |
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.
I would rather propose to write loop like:
digitalWrite(LED_BUILTIN, HIGH);
LowPower.deepSleep(500);
digitalWrite(LED_BUILTIN, LOW);
LowPower.deepSleep(500);
README.md
Outdated
|
||
* **`void begin()`**: configure the Low Power | ||
|
||
* **`void idle(uint32_t millis)`**: enter sleep mode |
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.
to describe idle / sleep / deepsleep and shutdown modes, I think we also need to define associated HW states (clocks / internal memories / voltage supplies / peripherals ...) and latencies for each of the state.
Something like :
In Idle mode : low wake-up latency (µs range) (e.g. ARM WFI), mémories and voltage supplies are retained. minimal Power saving mainly on the core itself.
In sleep mode : medium latency (ms range), clocks are gated to reduced. memories and voltage supplies are retained. If supported, Peripherals wake-up is possible (UART, I2C ...).
In deep sleep mode: higher wake-up latency ( ), Most memories content are lost and and voltage supplies are shut down. Available with internal clock input (LSI).
In shutdown mode: high wake-up latency (posible hundereds of ms or second timeframe ), voltage supplies are cut except always-on domain, memory content are lost and system basically reboots. . Only available with external clock input (LSE).
When writing this, I am wondering whether the mapping to STM32 low power modes could be changed to:
- idle => sleep WI ok
- sleep => could be sleep with PWR_LOWPOWERREGULATOR_ON
- deep_sleep => could be stop mode
- shutdown => standby / shutdown mode depending whether LSE is available or not.
I am open to discussion ...
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.
Description can't be very detailed because depends on chip used.
When writing this, I am wondering whether the mapping to STM32 low power modes could be changed to:
- idle => sleep WI ok
- sleep => could be sleep with PWR_LOWPOWERREGULATOR_ON
- deep_sleep => could be stop mode
- shutdown => standby / shutdown mode depending whether LSE is available or not.
We will lose a part of the compatibility with the Arduino Low Power library. But why to not rename all methods to be more compliant with STM32 low power mode names:
- idle => sleep
- sleep => stop
- deep_sleep => standby
- shutdown
LSE is only required for shutdown. LSI is still available with standby.
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.
I don't understand you point about breaking compatibility, can you explain more ?
My view is that if the boards has LSE, you will use shutdown. If the board doesn't have LSE, then you will use LSI. So you would either use LSE or LSI, not both of them. This choice can be done at the variant level so that Arduino application will always use shutdown().
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.
Ok I understood. We will make the changes.
We just need to study how know if LSE is available or not. Something automatic if possible.
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Hi @fpistm |
This library allows to enter the board in Low Power mode.
Low Power mode:
Possibility to:
This library is based on the low power driver and the RTC library.