@@ -29,15 +29,14 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
2929static const struct device * comp_dev = DEVICE_DT_GET (DT_NODELABEL (comp ));
3030#endif
3131
32- void print_reset_cause (void )
32+ void print_reset_cause (uint32_t reset_cause )
3333{
34- uint32_t reset_cause ;
35-
36- hwinfo_get_reset_cause (& reset_cause );
3734 if (reset_cause & RESET_DEBUG ) {
3835 printf ("Reset by debugger.\n" );
3936 } else if (reset_cause & RESET_CLOCK ) {
4037 printf ("Wakeup from System OFF by GRTC.\n" );
38+ } else if (reset_cause & RESET_LOW_POWER_WAKE ) {
39+ printf ("Wakeup from System OFF by GPIO.\n" );
4140 } else {
4241 printf ("Other wake up cause 0x%08X.\n" , reset_cause );
4342 }
@@ -46,6 +45,7 @@ void print_reset_cause(void)
4645int main (void )
4746{
4847 int rc ;
48+ uint32_t reset_cause ;
4949 const struct device * const cons = DEVICE_DT_GET (DT_CHOSEN (zephyr_console ));
5050
5151 if (!device_is_ready (cons )) {
@@ -54,11 +54,19 @@ int main(void)
5454 }
5555
5656 printf ("\n%s system off demo\n" , CONFIG_BOARD );
57- print_reset_cause ();
57+ hwinfo_get_reset_cause (& reset_cause );
58+ print_reset_cause (reset_cause );
5859
5960 if (IS_ENABLED (CONFIG_APP_USE_RETAINED_MEM )) {
6061 bool retained_ok = retained_validate ();
6162
63+ if (!(reset_cause & (RESET_CLOCK | RESET_LOW_POWER_WAKE ))) {
64+ retained .boots = 0 ;
65+ retained .off_count = 0 ;
66+ retained .uptime_sum = 0 ;
67+ retained .uptime_latest = 0 ;
68+ retained_ok = true;
69+ }
6270 /* Increment for this boot attempt and update. */
6371 retained .boots += 1 ;
6472 retained_update ();
0 commit comments