Skip to content

Commit 03061fb

Browse files
committed
[nrf fromtree] samples: boards: nrf: system_off: Print reset reason.
Add printing reset reason at the beginning of the sample. Makes it easier to determine if sample correctly wakes up from LP mode. Signed-off-by: Bartlomiej Buczek <[email protected]> (cherry picked from commit c08edf7)
1 parent 90e94f4 commit 03061fb

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

samples/boards/nordic/system_off/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ CONFIG_PM_DEVICE=y
22
CONFIG_GPIO=y
33
CONFIG_CRC=y
44
CONFIG_POWEROFF=y
5+
CONFIG_HWINFO=y

samples/boards/nordic/system_off/sample.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ tests:
6868
- "Retained data not supported"
6969
- "Entering system off; wait 2 seconds to restart"
7070
- "system off demo"
71+
- "Wakeup from System OFF by GRTC."
7172
- "Retained data not supported"
7273
- "Entering system off; wait 2 seconds to restart"
7374
sample.boards.nrf.system_off.retained_mem.grtc_wakeup:
@@ -97,6 +98,7 @@ tests:
9798
- "Off count: 1"
9899
- "Active Ticks:"
99100
- "Entering system off; wait 2 seconds to restart"
101+
- "Wakeup from System OFF by GRTC."
100102
sample.boards.nrf.system_off.lpcomp_wakeup:
101103
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_comparator.overlay"
102104
platform_allow:

samples/boards/nordic/system_off/src/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <zephyr/device.h>
1313
#include <zephyr/drivers/gpio.h>
14+
#include <zephyr/drivers/hwinfo.h>
1415
#include <zephyr/drivers/comparator.h>
1516
#include <zephyr/kernel.h>
1617
#include <zephyr/pm/device.h>
@@ -28,6 +29,20 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
2829
static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp));
2930
#endif
3031

32+
void print_reset_cause(void)
33+
{
34+
uint32_t reset_cause;
35+
36+
hwinfo_get_reset_cause(&reset_cause);
37+
if (reset_cause & RESET_DEBUG) {
38+
printf("Reset by debugger.\n");
39+
} else if (reset_cause & RESET_CLOCK) {
40+
printf("Wakeup from System OFF by GRTC.\n");
41+
} else {
42+
printf("Other wake up cause 0x%08X.\n", reset_cause);
43+
}
44+
}
45+
3146
int main(void)
3247
{
3348
int rc;
@@ -39,6 +54,7 @@ int main(void)
3954
}
4055

4156
printf("\n%s system off demo\n", CONFIG_BOARD);
57+
print_reset_cause();
4258

4359
if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
4460
bool retained_ok = retained_validate();
@@ -98,6 +114,7 @@ int main(void)
98114
retained_update();
99115
}
100116

117+
hwinfo_clear_reset_cause();
101118
sys_poweroff();
102119

103120
return 0;

0 commit comments

Comments
 (0)