aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-05-15 17:04:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-05-15 17:09:11 -0400
commit70068985a7dc8f9beb0091f2a53b2fbdf359523c (patch)
tree8900af0be29376aa6e652f2219976fe12c5ffc96 /src/avr
parent907cfb91053acdd6f751e7a03134295b29360a0f (diff)
downloadkutter-70068985a7dc8f9beb0091f2a53b2fbdf359523c.tar.gz
kutter-70068985a7dc8f9beb0091f2a53b2fbdf359523c.tar.xz
kutter-70068985a7dc8f9beb0091f2a53b2fbdf359523c.zip
stepper: Introduce and use gpio_out_toggle_noirq()
The gpio_out_toggle() function in the sam3x8e and stm32f1 code was only valid if it was called with irqs disabled. Commits 018c5daa and 9c52ad43 enabled the lcd code which called gpio_out_toggle() with irqs enabled. This could cause corruption of the gpio state. Introduce a gpio_out_toggle_noirq() function that will only be invoked with irqs disabled, and fix gpio_out_toggle() on sam3x8e and stm32f1 so that it safe to call even if irqs are enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/avr')
-rw-r--r--src/avr/gpio.c8
-rw-r--r--src/avr/gpio.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/src/avr/gpio.c b/src/avr/gpio.c
index 0ae7e52f..ce89b1be 100644
--- a/src/avr/gpio.c
+++ b/src/avr/gpio.c
@@ -63,12 +63,18 @@ fail:
}
void
-gpio_out_toggle(struct gpio_out g)
+gpio_out_toggle_noirq(struct gpio_out g)
{
g.regs->in = g.bit;
}
void
+gpio_out_toggle(struct gpio_out g)
+{
+ gpio_out_toggle_noirq(g);
+}
+
+void
gpio_out_write(struct gpio_out g, uint8_t val)
{
irqstatus_t flag = irq_save();
diff --git a/src/avr/gpio.h b/src/avr/gpio.h
index 6e12efe0..515e4c9a 100644
--- a/src/avr/gpio.h
+++ b/src/avr/gpio.h
@@ -9,6 +9,7 @@ struct gpio_out {
uint8_t bit : 8;
};
struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val);
+void gpio_out_toggle_noirq(struct gpio_out g);
void gpio_out_toggle(struct gpio_out g);
void gpio_out_write(struct gpio_out g, uint8_t val);