Snapdragon® Telematics Application Framework (TelAF) Interface Specification
GPIO Service

API Reference


This API is used by apps to control general-purpose digital input/output pins.

A GPIO pin typically has one of the following features:

  • Configured as an input pin or an output pin.
  • If configured as an output, can be activated or deactivated.
  • If configured as an input, can trigger an interrupt (asynchronous notification of state change).

Pins also have a polarity mode:

  • active-high polarity pin is read/written as a digital 1 (true) when its voltage is "high" and 0 (false) when its voltage is "low" (grounded).
  • active-low pin is read/written as a digital 1 (true) when its voltage is "low" (grounded) and 0 (false) when its voltage is "high".

IPC interfaces binding

The functions of this API are provided by the tafGpioSvc application service.

The following example illustrates how to bind to GPIO services.

bindings:
{
    clientExe.clientComponent.taf_gpio -> tafGpioSvc.taf_gpio
}

The following functions are used to configure the GPIO pin and lock the pin from being used by other clients.

res = taf_gpio_SetInput(inPinNum, TAF_GPIO_ACTIVE_HIGH, false);
 if(res == LE_OK) {
     LE_INFO("Gpio pin %d SetInput Successful", inPinNum);
 } else if (res == LE_BUSY) {
     LE_INFO("Gpio pin %d SetInput results in GPIO_BUSY", inPinNum);
 } else if (res == LE_OUT_OF_RANGE) {
     LE_INFO("Gpio pin %d is out of range", outPinNum);
 }  else
     LE_INFO("Gpio pin %d SetInput results in IO ERROR", inPinNum);

To set the level of an output pin and lock the pin from being used by other clients, call taf_gpio_Activate() or taf_gpio_Deactivate().

To poll the value of an input pin, call taf_gpio_Read().

Use the ChangeEvent to register a notification callback function to be called when the state of an input pin changes. The type of edge detection can then be modified by calling taf_gpio_SetEdgeSense() or taf_gpio_DisableEdgeSense().

Note
The client will be killed in the following scenarios.
  • If the GPIO object reference is NULL or not initialized.
  • When unable to set edge detection correctly.
gpiohandlerRef = taf_gpio_AddChangeEventHandler(inPinNum, TAF_GPIO_EDGE_BOTH, false,
         GpioChangeCallback, NULL);

The following functions can be used to read the current setting for a GPIO pin even if the GPIO pin is locked by another client. In a Linux environment these values are read from the sysfs and reflect the actual value at the time the function is called.