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);
3131static const struct device * comp_dev = DEVICE_DT_GET (DT_NODELABEL (comp ));
3232#endif
3333
34- void print_reset_cause (uint32_t reset_cause )
34+ int print_reset_cause (uint32_t reset_cause )
3535{
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+
3645 if (reset_cause & RESET_DEBUG ) {
3746 printf ("Reset by debugger.\n" );
3847 } else if (reset_cause & RESET_CLOCK ) {
@@ -42,6 +51,8 @@ void print_reset_cause(uint32_t reset_cause)
4251 } else {
4352 printf ("Other wake up cause 0x%08X.\n" , reset_cause );
4453 }
54+
55+ return 0 ;
4556}
4657
4758int main (void )
@@ -57,7 +68,12 @@ int main(void)
5768
5869 printf ("\n%s system off demo\n" , CONFIG_BOARD );
5970 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+ }
6177
6278 if (IS_ENABLED (CONFIG_APP_USE_RETAINED_MEM )) {
6379 bool retained_ok = retained_validate ();
You can’t perform that action at this time.
0 commit comments