---
driver number: `0x00004`
---
The GPIO driver allows userspace to synchronously control the output and receive callbacks on changes in the input for a set of GPIO pins.
This is a low-level GPIO driver designed to export "hardware-like" control of GPIO pins to userspace. Not all platforms will expose all or even any pins using this interface to userspace.
Unstable: As this is a low-level interface, the mapping of GPIO pins is currently unstable and unspecified. Users of this driver must consult their board for a mapping from pin identifiers used in this driver to actual hardware pins. This mapping is currently subject to change.
-
Description: Whether GPIO pins are exported by this board.
Argument 1: unused
Argument 2: unused
Returns: Unstable: Most boards return the number of GPIO pins available, however users should consult their board for details of this return value.
ENODEVICE
if this driver is not present on the board. -
Description: Enable output on a GPIO pin. After enabling output, output-related operations on the pin (
set
,clear
,toggle
) are available. Using input operations on a pin in this state is undefined.Argument 1: The identifier of the GPIO pin to enable output for.
Argument 2: unused
Returns: SUCCESS if the command was successful, and
EINVAL
if the argument refers to a non-existent pin. -
Description: Set the output of a GPIO pin (high). Using this command without first enabling output is undefined.
Argument 1: The identifier of the GPIO pin to set.
Argument 2: unused
Returns:
SUCCESS
if the pin identifier is valid,EINVAL
otherwise. -
Description: Clear the output of a GPIO pin (low). Using this command without first enabling output is undefined.
Argument 1: The identifier of the GPIO pin to clear.
Argument 2: unused
Returns:
SUCCESS
if the pin identifier is valid,EINVAL
otherwise. -
Description: Toggle the output of a GPIO pin. If the pin was previously high, this operation clears it. If it was previously low, sets it. Using this command without first enabling output is undefined.
Argument 1: The identifier of the GPIO pin to toggle.
Argument 2: unused
Returns:
SUCCESS
if the pin identifier is valid,EINVAL
otherwise. -
Description: Enable and configure input on a GPIO pin. After enabling input, input-related operations on the pin (e.g.
read
) are available. Using output operations on a pin in this state is undefined.Argument 1: The identifier of the GPIO pin to toggle.
Argument 2: requested resistor to attach to the pin:
0
for pull-none,1
for pull-up, or2
for pull-down. Other values are undefined.Returns:
SUCCESS
if the pin identifier is valid,EINVAL
if it is invalid, andENOSUPPORT
if the resistor configuration is not supported by the hardware. If any error is returned, no state will be changed. -
Description: Read the current value of a GPIO pin.
Argument 1: The identifier of the GPIO pin to read.
Argument 2: unused
Returns:
EINVAL
if the identifier of the pin is invalid,1
if the value of the pin is high or0
if it is low. -
Description: Configure interrupts on a GPIO pin. After enabling interrupts, the callback set in subscribe will be called when the pin level changes. Using this command without first enabling input is undefined.
Argument 1: The identifier of the GPIO pin to read.
Argument 2: Indicates which events trigger callbacks:
0
for either edge,1
for rising edge, or2
for falling edge. Other values are undefined.Returns:
SUCCESS
if the pin identifier is valid,EINVAL
if it is invalid, andENOSUPPORT
if an invalid interrupt mode is passed in the configuration field of the argument. If any error is returned, no state will be changed.
-
Description: Subscribe a callback that will fire when any GPIO pin whose interrupts have been enabled changes level. Registering the callback does not have an effect on whether any GPIO pin interrupts are enabled.
Callback signature: The callback receives two arguments. The first is the identifier of the GPIO pin whose level has changed, and the second is the value of the pin when the interrupt occurred. The second argument has the same semantics as the return value for the
read
command:0
for low,1
for high.Returns: SUCCESS if the subscribe was successful, ENOMEM if the driver cannot support another app, and
EINVAL
if the app is somehow invalid.
Unused for the GPIO driver. Will always return ENOSUPPORT
.