Use GPIOTOGGLE to toggle the pin state instead of read, modify and write.

This commit is contained in:
loos 2016-04-19 15:18:31 +00:00
parent 41d99db047
commit 5404d56e14

View File

@ -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