From 70068985a7dc8f9beb0091f2a53b2fbdf359523c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 15 May 2018 17:04:30 -0400 Subject: 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 --- src/pru/gpio.c | 8 +++++++- src/pru/gpio.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/pru') diff --git a/src/pru/gpio.c b/src/pru/gpio.c index ba4ba935..dfa7567b 100644 --- a/src/pru/gpio.c +++ b/src/pru/gpio.c @@ -104,11 +104,17 @@ fail: } void -gpio_out_toggle(struct gpio_out g) +gpio_out_toggle_noirq(struct gpio_out g) { gpio_out_write(g, !(*g.reg & 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) { diff --git a/src/pru/gpio.h b/src/pru/gpio.h index fc5e16b9..b3dd5508 100644 --- a/src/pru/gpio.h +++ b/src/pru/gpio.h @@ -9,6 +9,7 @@ struct gpio_out { uint32_t bit; }; 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); -- cgit v1.2.3-70-g09d2