From 70dcc13c092288d06b6bb6255756f26ffd07b0fb Mon Sep 17 00:00:00 2001 From: Konrad Kuchciak Date: Wed, 18 Sep 2019 13:58:46 +0200 Subject: [PATCH] gpio: init pin after export This will fully initialize the pin. The problem is that edge attribute cannot be modified without explicitly defining pin's direction after boot. It seems like a kernel issue. This is just a workaround. Change-Id: I6c9a2c8d20757c3f9d04779a820015c839b8ea5c Signed-off-by: Konrad Kuchciak --- src/interface/peripheral_interface_gpio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index c1e966f..ce9be7f 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -37,6 +37,15 @@ int peripheral_interface_gpio_set_initial_direction_into_handle(peripheral_gpio_ if (!strncmp(gpio_buf, types[index].type, types[index].len)) { // PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH and PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW : out type gpio->direction = (peripheral_gpio_direction_e)index; + + /* + * Also write to direction for the very first time after boot + * to ensure that the pin is fully initialized. + * Without this, writing to 'edge' is not possible. + */ + ret = write(gpio->fd_direction, types[index].type, types[index].len); + CHECK_ERROR(ret != types[index].len); + return PERIPHERAL_ERROR_NONE; } } -- 2.34.1