Skip to content

Commit 710c89e

Browse files
Finwoodfabiobaltieri
authored andcommitted
fix: initialize gpio_keys input from pin state
Some kind of race condition caused the gpio_keys input module to occasionally miss an event after boot. This is fixed by initializing the pin state variable in the input_gpio_keys module. Related to https://github.com/starcopter/bms-firmware/issues/6 Signed-off-by: Lasse Fröhner <lasse@starcopter.com>
1 parent 2ef8c4e commit 710c89e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/input/input_gpio_keys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void gpio_keys_poll_pin(const struct device *dev, int key_index)
6262
struct gpio_keys_pin_data *pin_data = &cfg->pin_data[key_index];
6363
int new_pressed;
6464

65-
new_pressed = gpio_pin_get(pin_cfg->spec.port, pin_cfg->spec.pin);
65+
new_pressed = gpio_pin_get_dt(&pin_cfg->spec);
6666

6767
LOG_DBG("%s: pin_state=%d, new_pressed=%d, key_index=%d", dev->name,
6868
pin_data->cb_data.pin_state, new_pressed, key_index);
@@ -145,7 +145,7 @@ static int gpio_keys_interrupt_configure(const struct gpio_dt_spec *gpio_spec,
145145
return ret;
146146
}
147147

148-
cb->pin_state = -1;
148+
cb->pin_state = gpio_pin_get_dt(gpio_spec);
149149

150150
LOG_DBG("port=%s, pin=%d", gpio_spec->port->name, gpio_spec->pin);
151151

0 commit comments

Comments
 (0)