Skip to content

Commit bb7f122

Browse files
nordic-seglnordicjm
authored andcommitted
tests: benchmarks: multicore: idle_with_pwm: Fix device runtime PM
API for PWM doesn't provide function for enabling/disabling the device. As a result, device runtime PM doesn't know when it shall wake up the device (get) / put device to low power operation (put). Therefore, user must manually call pm_device_runtime_get(&pwm_device); pm_device_runtime_put(&pwm_device); Fix PWM device runtime Power Management test. Signed-off-by: Sebastian Głąb <[email protected]>
1 parent 2015805 commit bb7f122

File tree

1 file changed

+16
-2
lines changed
  • tests/benchmarks/multicore/idle_with_pwm/src

1 file changed

+16
-2
lines changed

tests/benchmarks/multicore/idle_with_pwm/src/main.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,20 @@ int main(void)
6666
LOG_INF("Multicore idle_with_pwm test on %s", CONFIG_BOARD_TARGET);
6767
LOG_INF("Core will sleep for %d ms", CONFIG_TEST_SLEEP_DURATION_MS);
6868

69-
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
69+
#if defined(CONFIG_PM_DEVICE_RUNTIME)
7070
pm_device_runtime_enable(pwm_led.dev);
71-
}
71+
#endif
7272

7373
while (1) {
7474
LOG_INF("Multicore idle_with_pwm test iteration %u", cnt++);
7575

76+
#if defined(CONFIG_PM_DEVICE_RUNTIME)
77+
/* API for PWM doesn't provide function for device enable/disable.
78+
* Thus PM for PWM has to be managed manually.
79+
*/
80+
pm_device_runtime_get(pwm_led.dev);
81+
#endif
82+
7683
/* Light up LED */
7784
current_pulse_width = pulse_min;
7885
for (int i = 0; i < PWM_STEPS_PER_SEC; i++) {
@@ -95,6 +102,13 @@ int main(void)
95102
return ret;
96103
}
97104

105+
#if defined(CONFIG_PM_DEVICE_RUNTIME)
106+
/* API for PWM doesn't provide function for device enable/disable.
107+
* Thus PM for PWM has to be managed manually.
108+
*/
109+
pm_device_runtime_put(pwm_led.dev);
110+
#endif
111+
98112
/* Sleep / enter low power state */
99113
k_msleep(CONFIG_TEST_SLEEP_DURATION_MS);
100114
}

0 commit comments

Comments
 (0)