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
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; } int ownThread_resume(const struct device *dev) { int ret; struct nau7802_data *data = dev->data; k_thread_resume(&data->thread); data->threadState = THREAD_RUNNING; LOG_INF("NAU7802_THREAD_RESUMED"); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { /* Check if device runtime power managemeng is enabled */ ret = pm_device_runtime_get(dev); if (ret != 0) { LOG_DBG("PM_DEVICE_ACTION_Resuming Failed %d", ret); } } return 0; }