This API is used by apps to control general-purpose digital input/output pins.
A GPIO pin typically has one or more of the following features:
Output pins can be driven in three modes:
Pins also have a polarity mode:
The following functions are used to configure the GPIO pin:
To set the level of an output pin, call Activate(), Deactivate(), or SetHighZ().
To poll the value of an input pin, call Read().
Use the ChangeEvent to register a notification callback function to be called when the state of an input pin changes. Thje type of edge detection can then be modified by calling SetEdgeSense() or DisbleEdgeSense()
The following functions can be used to read the current setting for a GPIO Pin. In a Linux environment these values are read from the sysfs and reflect the actual value at the time the function is called.
Each GPIO pin is accessed through a single IPC service. This makes it possible to use bindings to control which GPIO pins each app is allowed to access. It also simplifies the API by removing the need to specify which pin is desired and allows the pins to be named differently in the client and the server, so the client can be more portable. Only one client can connect to pin.
Binding example:
bindings: { ui.frontPanel.powerLed -> gpioService.le_gpio22 }
The GPIOs which are available for use are advertised in the sysfs at
/sys/class/gpio/gpiochip1/mask
For each entry in this bitmask, a service will be advertised to allow use of the pin. However, if a pin needs to be disabled form being accessed, e.g. it carries out some system function that should not be available to apps, then it can be disabled by adding an entry to the config tree.
For example, to disable pin 6 from being used, add the entry
gpioService:/pins/disabled/n
where n is the GPIO number. The value should be set to true to disable that service. If the value is either false or absent then the service will run. Entries can be added using the config tool, for example
config set gpioService:/pins/disabled/13 true bool
will disable the service for pin 13. Note that specifying the type as bool is vital as the config tool defaults to the string type, and hence any value set will default to false.
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.