From c4839d320a5645f3a6e0752c2a4c060af6bbc01c Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Tue, 19 Apr 2016 15:18:31 +0000 Subject: [PATCH] Use GPIOTOGGLE to toggle the pin state instead of read, modify and write. --- lib/libgpio/gpio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libgpio/gpio.c b/lib/libgpio/gpio.c index 7ec0955b096b..8170822d4404 100644 --- a/lib/libgpio/gpio.c +++ b/lib/libgpio/gpio.c @@ -181,14 +181,14 @@ gpio_pin_set(gpio_handle_t handle, gpio_pin_t pin, gpio_value_t value) int gpio_pin_toggle(gpio_handle_t handle, gpio_pin_t pin) { - gpio_value_t value; + struct gpio_req gpreq; - value = gpio_pin_get(handle, pin); - if (value == GPIO_VALUE_INVALID) + bzero(&gpreq, sizeof(gpreq)); + gpreq.gp_pin = pin; + if (ioctl(handle, GPIOTOGGLE, &gpreq) < 0) return (-1); - value = !value; - return (gpio_pin_set(handle, pin, value)); + return (0); } int