From 16cf643246ec7522f33a5476a7935c3def5a6550 Mon Sep 17 00:00:00 2001 From: Cyprien Laplace Date: Sun, 14 Dec 2014 18:01:11 +0100 Subject: [PATCH] Fix : set gpio state only when GPIO is configured as output --- drivers/gpio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio.c b/drivers/gpio.c index 5c98697..eae48d2 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -74,17 +74,17 @@ void config_gpio(const struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini struct lpc_gpio* gpio_port = LPC_GPIO_REGS(gpio->port); /* Configure as GPIO */ - config_pio(gpio, mode); + config_pio(gpio, mode | LPC_IO_DIGITAL); if (dir == GPIO_DIR_IN) { gpio_port->data_dir &= ~(1 << gpio->pin); } else { gpio_port->data_dir |= (1 << gpio->pin); - } - if (ini_val == 0) { - gpio_port->clear = (1 << gpio->pin); - } else { - gpio_port->set = (1 << gpio->pin); + if (ini_val == 0) { + gpio_port->clear = (1 << gpio->pin); + } else { + gpio_port->set = (1 << gpio->pin); + } } } -- 2.43.0