Skip to content

Commit da5a41c

Browse files
alstrzebonskinordicjm
authored andcommitted
caf: buttons: Fix incorrect GPIO API usage
GPIO API does not allow for configuring or setting GPIOs from ISR context. The call has been moved to system workqueue context to fix the issue. Jira: NCSDK-32667 Signed-off-by: Aleksander Strzebonski <[email protected]>
1 parent a9f4cd6 commit da5a41c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

subsys/caf/modules/buttons.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,6 @@ static void button_pressed_isr(const struct device *gpio_dev,
449449
return;
450450
}
451451

452-
/* Scanning will be scheduled, switch off pins */
453-
if (set_cols(0)) {
454-
LOG_ERR("Cannot control pins");
455-
err = -EFAULT;
456-
}
457-
458452
/* This is a workaround. Zephyr will set any pin triggering interrupt
459453
* at the moment. Not only our pins.
460454
*/
@@ -486,8 +480,17 @@ static void button_pressed_isr(const struct device *gpio_dev,
486480

487481
static void button_pressed_fn(struct k_work *work)
488482
{
489-
int err = callback_ctrl(0);
483+
int err;
484+
485+
/* Scanning will be scheduled, switch off pins */
486+
err = set_cols(0);
487+
if (err) {
488+
LOG_ERR("Cannot control pins");
489+
module_set_state(MODULE_STATE_ERROR);
490+
return;
491+
}
490492

493+
err = callback_ctrl(0);
491494
if (err) {
492495
LOG_ERR("Cannot disable callbacks");
493496
module_set_state(MODULE_STATE_ERROR);

0 commit comments

Comments
 (0)