aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32
diff options
context:
space:
mode:
authorUwe Hermann2011-02-09 01:53:53 +0100
committerUwe Hermann2011-02-09 02:48:50 +0100
commite0a488f586abd24c8b3448ceb0fc94a10c572cc0 (patch)
treedbd46478a3baeb715911b6bd0f56f702f2024870 /lib/stm32
parentd67795f383c2757082b0481816789ca12a866172 (diff)
gpio_toggle(): Add support for multiple GPIOs.
Thanks Marko Kraljevic <krasnaya.zvezda@gmail.com> for the patch!
Diffstat (limited to 'lib/stm32')
-rw-r--r--lib/stm32/gpio.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/stm32/gpio.c b/lib/stm32/gpio.c
index 333fcaf..52c0c66 100644
--- a/lib/stm32/gpio.c
+++ b/lib/stm32/gpio.c
@@ -26,7 +26,7 @@
* gpio_set(GPIOB, GPIO4);
* gpio_clear(GPIOG, GPIO2 | GPIO9);
* gpio_get(GPIOC, GPIO1);
- * gpio_toggle(GPIOA, GPIO7);
+ * gpio_toggle(GPIOA, GPIO7 | GPIO8);
* reg16 = gpio_port_read(GPIOD);
* gpio_port_write(GPIOF, 0xc8fe);
*
@@ -88,13 +88,9 @@ u16 gpio_get(u32 gpioport, u16 gpios)
return gpio_port_read(gpioport) & gpios;
}
-/* TODO: Should work for multiple GPIOs? */
-void gpio_toggle(u32 gpioport, u16 gpio)
+void gpio_toggle(u32 gpioport, u16 gpios)
{
- if ((gpio_port_read(gpioport) & gpio) == gpio)
- gpio_clear(gpioport, gpio);
- else
- gpio_set(gpioport, gpio);
+ GPIO_ODR(gpioport) = GPIO_IDR(gpioport) ^ gpios;
}
u16 gpio_port_read(u32 gpioport)