@@ -129,9 +129,7 @@ static void buttons_scan_fn(struct k_work *work)
129129 static bool initial_run = true;
130130 uint32_t button_scan ;
131131
132- __ASSERT_NO_MSG (!IS_ENABLED (CONFIG_DK_LIBRARY_BUTTON_NO_ISR ) || !irq_enabled );
133-
134- if (!IS_ENABLED (CONFIG_DK_LIBRARY_BUTTON_NO_ISR ) && irq_enabled ) {
132+ if (irq_enabled ) {
135133 /* Disable GPIO interrupts for edge triggered devices.
136134 * Devices that are configured with active high interrupts are already disabled.
137135 */
@@ -159,7 +157,7 @@ static void buttons_scan_fn(struct k_work *work)
159157
160158 last_button_scan = button_scan ;
161159
162- if (IS_ENABLED ( CONFIG_DK_LIBRARY_BUTTON_NO_ISR ) || ( button_scan != 0 ) ) {
160+ if (button_scan != 0 ) {
163161 k_work_reschedule (& buttons_scan ,
164162 K_MSEC (CONFIG_DK_LIBRARY_BUTTON_SCAN_INTERVAL ));
165163 } else {
@@ -238,6 +236,7 @@ static void button_pressed(const struct device *gpio_dev, struct gpio_callback *
238236
239237int dk_buttons_init (button_handler_t button_handler )
240238{
239+ uint32_t pin_mask = 0 ;
241240 int err ;
242241
243242 button_handler_cb = button_handler ;
@@ -259,31 +258,27 @@ int dk_buttons_init(button_handler_t button_handler)
259258 }
260259 }
261260
262- if (!IS_ENABLED (CONFIG_DK_LIBRARY_BUTTON_NO_ISR )) {
263- uint32_t pin_mask = 0 ;
264-
265- for (size_t i = 0 ; i < ARRAY_SIZE (buttons ); i ++ ) {
266- /* Module starts in scanning mode and will switch to
267- * callback mode if no button is pressed.
268- */
269- err = gpio_pin_interrupt_configure_dt (& buttons [i ],
270- GPIO_INT_DISABLE );
271- if (err ) {
272- LOG_ERR ("Cannot disable callbacks()" );
273- return err ;
274- }
275-
276- pin_mask |= BIT (buttons [i ].pin );
261+ for (size_t i = 0 ; i < ARRAY_SIZE (buttons ); i ++ ) {
262+ /* Module starts in scanning mode and will switch to
263+ * callback mode if no button is pressed.
264+ */
265+ err = gpio_pin_interrupt_configure_dt (& buttons [i ],
266+ GPIO_INT_DISABLE );
267+ if (err ) {
268+ LOG_ERR ("Cannot disable callbacks()" );
269+ return err ;
277270 }
278271
279- gpio_init_callback (& gpio_cb , button_pressed , pin_mask );
272+ pin_mask |= BIT (buttons [i ].pin );
273+ }
280274
281- for (size_t i = 0 ; i < ARRAY_SIZE (buttons ); i ++ ) {
282- err = gpio_add_callback (buttons [i ].port , & gpio_cb );
283- if (err ) {
284- LOG_ERR ("Cannot add callback" );
285- return err ;
286- }
275+ gpio_init_callback (& gpio_cb , button_pressed , pin_mask );
276+
277+ for (size_t i = 0 ; i < ARRAY_SIZE (buttons ); i ++ ) {
278+ err = gpio_add_callback (buttons [i ].port , & gpio_cb );
279+ if (err ) {
280+ LOG_ERR ("Cannot add callback" );
281+ return err ;
287282 }
288283 }
289284
0 commit comments