Hi there, I´m totally new to Zephyr & Nordic, started with some Trainings on NRF52840DK and jumped in with a device driver developement where I took a availalbe out of Tree driver of nuvton, nau7802 and enhanced it to my purposes.
I took the the latest sensor api to orient myself here with the implementation. (Some things still to do to come fullfill the requirements)
https://docs.zephyrproject.org/latest/hardware/peripherals/sensor/index.html
Since I use here the Trigger_own Thread method my intention was to Power the nau7802 up if the device_thread is active and power the nau7802 down if thread is suspended.
I have not figured out a better way as using a method to start/stop the thread from normal_user and hook in with the
calls of
- pm_device_runtime_put(dev);
- pm_device_runtime_get(dev);
for powering up/down the nau7802 device.
What is the intended way to achive the power management on device level? I saw examples where the power up/down hooks are withing sample fetch but in IMO for higher sample rates that´s not suitable.
Full Example Can be Found here: github.com/.../nordic_fw
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int ownThread_suspend(const struct device *dev)
{
int ret;
struct nau7802_data *data = dev->data;
k_thread_suspend(&data->thread);
data->threadState = THREAD_SUSPENDED;
LOG_INF("NAU7802_THREAD_SUSPENDED");
/* Check if device runtime power managemeng is enabled */
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME))
{
/* let power management system know that device is no longer needed needed */
ret = pm_device_runtime_put(dev);
if (ret != 0)
{
LOG_DBG("PM_DEVICE_ACTION_Resuming Failed %d", ret);
}
}
return 0;