@@ -58,7 +58,7 @@ void user_push_button_intr_callback(const struct device *port, struct gpio_callb
5858 push_button_isr_count ++ ;
5959 if (print_edges ) {
6060 printk ("\r%s interrupt (%d): %s edge%s\n" , port -> name , push_button_isr_count ,
61- button_state .current ? " rising " : "falling " ,
61+ button_state .current ? "falling " : "rising " ,
6262 button_state .current == button_state .previous ? " (bounce detected)" : "" );
6363 }
6464 button_state .previous = button_state .current ;
@@ -89,7 +89,11 @@ static void setup(void)
8989 return ;
9090 }
9191
92- ret = gpio_pin_configure_dt (& button , GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_EDGE_BOTH );
92+ ret = gpio_pin_configure_dt (& button , GPIO_INPUT
93+ #if defined(CONFIG_PUSHBUTTON_ADDITIONAL_PULL_UP ) && (CONFIG_PUSHBUTTON_ADDITIONAL_PULL_UP )
94+ | GPIO_PULL_UP
95+ #endif
96+ );
9397 if (ret != 0 ) {
9498 printk ("Error %d: failed to configure %s pin %d\n" , ret , button .port -> name ,
9599 button .pin );
@@ -165,12 +169,11 @@ static void phase2()
165169 /* Enable the interrupt edge printing mechanism */
166170 print_edges = true;
167171
168- /* Enable Energy Mode 2 (EM2) -- Deep Sleep Mode */
169- pm_state_force (0u , & (struct pm_state_info ){PM_STATE_SUSPEND_TO_IDLE , 0 , 0 });
170-
171172 /* Maintain sleep */
172173 while (true) {
173174 puts ("Entering EM2 sleep...\n" );
175+ /* Enable Energy Mode 2 (EM2) -- Deep Sleep Mode */
176+ pm_state_force (0u , & (struct pm_state_info ){PM_STATE_SUSPEND_TO_IDLE , 0 , 0 });
174177 k_msleep (1 );
175178 puts ("Awake from EM2 sleep..." );
176179 }
0 commit comments