liam-geotab opened a new pull request, #19988:
URL: https://github.com/apache/nuttx/pull/19988
## Summary
**Implement PM STOP.** When waking from stop, execution resumes. stm32h7's
`stm32_pmstop` has a `bool lpds` parameter. There is no LPDS on stm32h5 but
there is the same lower-power voltage scaling value (SVOS5) that H7 uses in
conjunction with LPDS, so keep the parameter for stm32h5 but rename it to svos5
which uses SVOS5 without LPDS present. It allows chosing between SVOS3 and
SVOS5.
**Implement PM STANDBY.** When waking from standby, it's always a reset.
It's similar to STM32H7 except that it has a slightly simpler power control
register.
Add arm_pminitialize implementation with default pm subsystem initialization.
Don't update the docs to say PM supported since PM SLEEP is not added yet.
Maybe I should still update the docs to say PM is supported anyways? I see that
most idle loops (e.g. stm32l4/stm32l4_idle.c) don't use stm32_pmsleep despite
supporting it.
## Impact
It's additive. It's missing stm32_pmsleep.
stm32_pmstop has a parameter like stm32h7, but the semantics are slightly
different.
## Testing
`nucleo-h563zi:nsh` with the following enabled:
```
CONFIG_PM=y
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_IRQPRIO=y
```
### nucleo-h563zi current consumption measurements
Normal baseline: 165.2 mA
`stm32_pmstop(false)` (SVOS3): 132.2 mA
`stm32_pmstop(true)` (SVOS5): 132.0 mA
`stm32_pmstandby()`: 131.6 mA
### STOP
Make button trigger interrupt, not event.
```diff
diff --git a/boards/arm/stm32h5/nucleo-h563zi/src/stm32_buttons.c
b/boards/arm/stm32h5/nucleo-h563zi/src/stm32_buttons.c
index d0899271aa..2a1b29cb6b 100644
--- a/boards/arm/stm32h5/nucleo-h563zi/src/stm32_buttons.c
+++ b/boards/arm/stm32h5/nucleo-h563zi/src/stm32_buttons.c
@@ -105,7 +105,7 @@ int board_button_irq(int id, xcpt_t irqhandler, void
*arg)
if (id == BUTTON_USER)
{
- ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
+ ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, false,
irqhandler, arg);
}
```
Setup the button to trigger a high-enough priority interrupt to wake from
stop. Both `stm32_pmstop(false)` (SVOS3) and `stm32_pmstop(true)` (SVOS5) were
tested.
```c
static int xcpt(int irq, FAR void *context, FAR void *arg)
{
return 0;
}
static void up_idlepm(void)
{
irqstate_t flags;
board_button_initialize();
board_button_irq(0, xcpt, NULL);
up_prioritize_irq(STM32_IRQ_EXTI13, NVIC_SYSH_HIGH_PRIORITY);
flags = enter_critical_section();
stm32_pmstop(false);
stm32_clockenable();
leave_critical_section(flags);
syslog(LOG_DEBUG, "woke up");
up_mdelay(100);
}
```
It triggers on both edges.
```
ABCG
NuttShel(Nwoke up
SH) NuttX-13.0.1-RC0
nsh> woke up
woke up
woke up
woke up
woke up
woke up
woke up
```
### STANDBY
Standby is deeper than stop. Use a WKUP pin to cause a reset from standby
mode.
```c
static void up_idlepm(void)
{
irqstate_t flags;
flags = enter_critical_section();
/* Enable WKUP1 to trigger reset from standby
* by PA0 going high. Specify pullup.
*/
modifyreg32(STM32_PWR_WUCR,
PWR_WUCR_MASK_WUPPUPD(1),
PWR_WUCR_PU_WUPPUPD(1) | PWR_WUCR_WUPEN(1));
up_mdelay(1);
stm32_pmstandby();
/* unreachable because standby can only be left by reset. */
}
```
It enters standby before all startup UART data can be sent. Disconnecting
PA0 from ground causes reset.
```
ABCG
NuttShellABCG
NuttShellABCG
NuttShellABCG
NuttShell
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]