mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-14 20:37:06 +00:00
Use GPIOTOGGLE to toggle the pin state instead of read, modify and write.
This commit is contained in:
parent
e848a50ce6
commit
c4839d320a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298272
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue