Skip to content

Commit

Permalink
tests: device_wakeup_api: Use DTS overlay for power state
Browse files Browse the repository at this point in the history
Define the power state needed in the test in DT.

Signed-off-by: Flavio Ceolin <[email protected]>
  • Loading branch information
Flavio Ceolin committed Aug 3, 2023
1 parent fdc7c56 commit 5a1143e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 15 additions & 0 deletions tests/subsys/pm/device_wakeup_api/boards/native_posix.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
cpus {
power-states {
state0: state0 {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-ram";
zephyr,pm-device-enabled;
};
};
};
};

&gpio0 {
compatible = "zephyr,gpio-emul";
gpio-controller;
wakeup-source;
};

&cpu0 {
cpu-power-states = <&state0>;
};
10 changes: 4 additions & 6 deletions tests/subsys/pm/device_wakeup_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)

const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks)
{
static const struct pm_state_info state = {
.state = PM_STATE_SUSPEND_TO_RAM,
.pm_device_enabled = true,
};
const struct pm_state_info *cpu_states;

ARG_UNUSED(cpu);
zassert_true(pm_state_cpu_get_all(cpu, &cpu_states) == 1,
"There is no power state defined");

while (sleep_count < 3) {
sleep_count++;
return &state;
return &cpu_states[0];
}

return NULL;
Expand Down

0 comments on commit 5a1143e

Please sign in to comment.