From e90d9c33ebd685aac87f8d6f0f82086cb5c057f5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 28 Aug 2019 19:19:13 -0400 Subject: [PATCH] lpc176x: Use FIOPIN to set start value on gpio_out_reset() The FIOSET and FIOCLR registers may not set an initial value if the pin is not in an output mode. So, use FIOPIN to set the initial value. Signed-off-by: Kevin O'Connor --- src/lpc176x/gpio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lpc176x/gpio.c b/src/lpc176x/gpio.c index 35a5a226..0b6d0345 100644 --- a/src/lpc176x/gpio.c +++ b/src/lpc176x/gpio.c @@ -80,10 +80,7 @@ gpio_out_reset(struct gpio_out g, uint8_t val) LPC_GPIO_TypeDef *regs = g.regs; int pin = regs_to_pin(regs, g.bit); irqstatus_t flag = irq_save(); - if (val) - regs->FIOSET = g.bit; - else - regs->FIOCLR = g.bit; + regs->FIOPIN = (regs->FIOSET & ~g.bit) | (val ? g.bit : 0); regs->FIODIR |= g.bit; gpio_peripheral(pin, 0, 0); irq_restore(flag);