From: Cyprien Laplace Date: Sun, 14 Dec 2014 17:01:11 +0000 (+0100) Subject: Fix : set gpio state only when GPIO is configured as output X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=16cf643246ec7522f33a5476a7935c3def5a6550;p=soft%2Flpc122x%2Fcore Fix : set gpio state only when GPIO is configured as output --- 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); + } } }