Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/boards/nordic/system_off/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ CONFIG_PM_DEVICE=y
CONFIG_GPIO=y
CONFIG_CRC=y
CONFIG_POWEROFF=y
CONFIG_HWINFO=y
2 changes: 2 additions & 0 deletions samples/boards/nordic/system_off/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tests:
- "Retained data not supported"
- "Entering system off; wait 2 seconds to restart"
- "system off demo"
- "Wakeup from System OFF by GRTC."
- "Retained data not supported"
- "Entering system off; wait 2 seconds to restart"
sample.boards.nrf.system_off.retained_mem.grtc_wakeup:
Expand Down Expand Up @@ -97,6 +98,7 @@ tests:
- "Off count: 1"
- "Active Ticks:"
- "Entering system off; wait 2 seconds to restart"
- "Wakeup from System OFF by GRTC."
sample.boards.nrf.system_off.lpcomp_wakeup:
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_comparator.overlay"
platform_allow:
Expand Down
17 changes: 17 additions & 0 deletions samples/boards/nordic/system_off/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/hwinfo.h>
#include <zephyr/drivers/comparator.h>
#include <zephyr/kernel.h>
#include <zephyr/pm/device.h>
Expand All @@ -28,6 +29,20 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp));
#endif

void print_reset_cause(void)
{
uint32_t reset_cause;

hwinfo_get_reset_cause(&reset_cause);
if (reset_cause & RESET_DEBUG) {
printf("Reset by debugger.\n");
} else if (reset_cause & RESET_CLOCK) {
printf("Wakeup from System OFF by GRTC.\n");
} else {
printf("Other wake up cause 0x%08X.\n", reset_cause);
}
}

int main(void)
{
int rc;
Expand All @@ -39,6 +54,7 @@ int main(void)
}

printf("\n%s system off demo\n", CONFIG_BOARD);
print_reset_cause();

if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
bool retained_ok = retained_validate();
Expand Down Expand Up @@ -98,6 +114,7 @@ int main(void)
retained_update();
}

hwinfo_clear_reset_cause();
sys_poweroff();

return 0;
Expand Down