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>
This commit is contained in:
Kevin O'Connor 2019-08-28 19:19:13 -04:00
parent 0c247e55e6
commit e90d9c33eb
1 changed files with 1 additions and 4 deletions

View File

@ -80,10 +80,7 @@ gpio_out_reset(struct gpio_out g, uint8_t val)
LPC_GPIO_TypeDef *regs = g.regs; LPC_GPIO_TypeDef *regs = g.regs;
int pin = regs_to_pin(regs, g.bit); int pin = regs_to_pin(regs, g.bit);
irqstatus_t flag = irq_save(); irqstatus_t flag = irq_save();
if (val) regs->FIOPIN = (regs->FIOSET & ~g.bit) | (val ? g.bit : 0);
regs->FIOSET = g.bit;
else
regs->FIOCLR = g.bit;
regs->FIODIR |= g.bit; regs->FIODIR |= g.bit;
gpio_peripheral(pin, 0, 0); gpio_peripheral(pin, 0, 0);
irq_restore(flag); irq_restore(flag);