File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
samples/boards/nordic/system_off/src Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,17 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
31
31
static const struct device * comp_dev = DEVICE_DT_GET (DT_NODELABEL (comp ));
32
32
#endif
33
33
34
- void print_reset_cause (uint32_t reset_cause )
34
+ int print_reset_cause (uint32_t reset_cause )
35
35
{
36
+ int32_t ret ;
37
+ uint32_t supported ;
38
+
39
+ ret = hwinfo_get_supported_reset_cause ((uint32_t * ) & supported );
40
+
41
+ if (ret || !(reset_cause & supported )) {
42
+ return - ENOTSUP ;
43
+ }
44
+
36
45
if (reset_cause & RESET_DEBUG ) {
37
46
printf ("Reset by debugger.\n" );
38
47
} else if (reset_cause & RESET_CLOCK ) {
@@ -42,6 +51,8 @@ void print_reset_cause(uint32_t reset_cause)
42
51
} else {
43
52
printf ("Other wake up cause 0x%08X.\n" , reset_cause );
44
53
}
54
+
55
+ return 0 ;
45
56
}
46
57
47
58
int main (void )
@@ -57,7 +68,12 @@ int main(void)
57
68
58
69
printf ("\n%s system off demo\n" , CONFIG_BOARD );
59
70
hwinfo_get_reset_cause (& reset_cause );
60
- print_reset_cause (reset_cause );
71
+ rc = print_reset_cause (reset_cause );
72
+
73
+ if (rc < 0 ) {
74
+ printf ("Reset cause not supported.\n" );
75
+ return 0 ;
76
+ }
61
77
62
78
if (IS_ENABLED (CONFIG_APP_USE_RETAINED_MEM )) {
63
79
bool retained_ok = retained_validate ();
You can’t perform that action at this time.
0 commit comments