Hi!
I am trying to subscribe to the power management events that correspond to the following log lines (which I can clearly see in the log):
I: POWER event ready I: POWER event removed I: SUSPEND state detected I: RESUMING from suspend
I have been trying with this code:
#include "power.h" #include <zephyr/logging/log.h> #include <zephyr/drivers/gpio.h> #include <zephyr/sys/util.h> #include <zephyr/pm/device.h> #include <zephyr/pm/state.h> #include <zephyr/pm/pm.h> LOG_MODULE_REGISTER(my_module, LOG_LEVEL_INF); void pm_notifier_cb(enum pm_state state) { printk("PM: %i", state); } static struct pm_notifier notifier = { .state_entry = pm_notifier_cb, .state_exit = pm_notifier_cb, }; void InitPower(void) { printk("Power Init"); pm_notifier_register(¬ifier); }
I have extended prj.conf with:
CONFIG_PM_DEVICE_RUNTIME=y CONFIG_PM_DEVICE=y CONFIG_PM=y
Results:
- - "Power Init" is getting printed just fine
- - but the callback is never called.
Setup:
- - NCS_VERSION=v2.6.0
- - Running from Ubuntu
- - Any other info needed?
Any idea what I am doing wrong?