Skip to content

Commit 8cebd99

Browse files
JordanYateskartben
authored andcommitted
samples: st: power_mgmt: blinky: enable PM on GPIOs
Enable runtime PM on each GPIO port to preserve the legacy PM GPIO behaviour for this sample. Signed-off-by: Jordan Yates <[email protected]>
1 parent 41fe3b9 commit 8cebd99

File tree

1 file changed

+9
-0
lines changed
  • samples/boards/st/power_mgmt/blinky/src

1 file changed

+9
-0
lines changed

samples/boards/st/power_mgmt/blinky/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <zephyr/devicetree.h>
1010
#include <zephyr/drivers/gpio.h>
1111
#include <zephyr/sys/printk.h>
12+
#include <zephyr/pm/device_runtime.h>
1213

1314
/* define SLEEP_TIME_MS higher than <st,counter-value> in ms */
1415
#if DT_PROP(DT_NODELABEL(stm32_lp_tick_source), st_counter_value)
@@ -17,6 +18,9 @@
1718
#define SLEEP_TIME_MS 2000
1819
#endif
1920

21+
#define STM32_GPIO_PM_ENABLE(node_id) \
22+
pm_device_runtime_enable(DEVICE_DT_GET(node_id));
23+
2024
static const struct gpio_dt_spec led =
2125
GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
2226

@@ -26,6 +30,11 @@ int main(void)
2630

2731
__ASSERT_NO_MSG(gpio_is_ready_dt(&led));
2832

33+
/* Enable device runtime PM on each GPIO port.
34+
* GPIO configuration is lost but it may result in lower power consumption.
35+
*/
36+
DT_FOREACH_STATUS_OKAY(st_stm32_gpio, STM32_GPIO_PM_ENABLE)
37+
2938
printk("Device ready\n");
3039

3140
while (true) {

0 commit comments

Comments
 (0)