diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-08-28 19:19:13 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-09-29 17:02:39 -0400 |
commit | e90d9c33ebd685aac87f8d6f0f82086cb5c057f5 (patch) | |
tree | 64787247ed781d8ce8fb6cfd9ae7285f06698fe4 /src/lpc176x/gpio.c | |
parent | 0c247e55e6ec62664d28f1274c553919ce870983 (diff) | |
download | kutter-e90d9c33ebd685aac87f8d6f0f82086cb5c057f5.tar.gz kutter-e90d9c33ebd685aac87f8d6f0f82086cb5c057f5.tar.xz kutter-e90d9c33ebd685aac87f8d6f0f82086cb5c057f5.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'src/lpc176x/gpio.c')
-rw-r--r-- | src/lpc176x/gpio.c | 5 |
1 files changed, 1 insertions, 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); |