aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/avr/gpio.c')
-rw-r--r--src/avr/gpio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/avr/gpio.c b/src/avr/gpio.c
index d10fc2a1..f5225177 100644
--- a/src/avr/gpio.c
+++ b/src/avr/gpio.c
@@ -70,8 +70,10 @@ void
gpio_out_reset(struct gpio_out g, uint8_t val)
{
irqstatus_t flag = irq_save();
- g.regs->out = val ? (g.regs->out | g.bit) : (g.regs->out & ~g.bit);
- g.regs->mode |= g.bit;
+ uint8_t newmode = g.regs->mode | g.bit;
+ uint8_t newout = val ? (g.regs->out | g.bit) : (g.regs->out & ~g.bit);
+ g.regs->out = newout;
+ g.regs->mode = newmode;
irq_restore(flag);
}
@@ -114,8 +116,10 @@ void
gpio_in_reset(struct gpio_in g, int8_t pull_up)
{
irqstatus_t flag = irq_save();
- g.regs->out = pull_up > 0 ? (g.regs->out | g.bit) : (g.regs->out & ~g.bit);
- g.regs->mode &= ~g.bit;
+ uint8_t newout = pull_up>0 ? (g.regs->out | g.bit) : (g.regs->out & ~g.bit);
+ uint8_t newmode = g.regs->mode & ~g.bit;
+ g.regs->mode = newmode;
+ g.regs->out = newout;
irq_restore(flag);
}