# GPIO Service

- [API reference](https://docs.qualcomm.com/doc/80-41102-2/topic/_doxygen_rst_file__doxygen_sources_taf_gpio_interface_h.html#file-taf-gpio-interface-h)

[HAL APIs](https://docs.qualcomm.com/doc/80-41102-2/topic/_doxygen_rst_file__doxygen_sources_include_vhal_tafHalGpio_h.html#file-tafhalgpio-h)

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
    }
    Copy to clipboard

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

- [taf\_gpio\_SetInput()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a606f2d113b0e9583fe4625b33d8f9e0b.html#Documentationa00500_1a606f2d113b0e9583fe4625b33d8f9e0b) - Configures the pin as an input pin.
- [taf\_gpio\_SetEdgeSense()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1affc2346a1ba6af61252a648c1c7ae80b.html#Documentationa00500_1affc2346a1ba6af61252a648c1c7ae80b) - Sets the edge sensing on an input pin (only works if you have an EventHandler).

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);
    Copy to clipboard

To set the level of an output pin and lock the pin from being used by other clients, call [taf\_gpio\_Activate()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1ae951ac6010946794a0c8cd7d7507e116.html#Documentationa00500_1ae951ac6010946794a0c8cd7d7507e116) or [taf\_gpio\_Deactivate()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1af1fd2315e8b211723667c5d6f1f0c506.html#Documentationa00500_1af1fd2315e8b211723667c5d6f1f0c506).

To poll the value of an input pin, call [taf\_gpio\_Read()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1ae1eac719d69f8b2c0494c0ff169d19cb.html#Documentationa00500_1ae1eac719d69f8b2c0494c0ff169d19cb).

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()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1affc2346a1ba6af61252a648c1c7ae80b.html#Documentationa00500_1affc2346a1ba6af61252a648c1c7ae80b) or [taf\_gpio\_DisableEdgeSense()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a445cf74e8d7541ad992e92cbdeeb7e2f.html#Documentationa00500_1a445cf74e8d7541ad992e92cbdeeb7e2f). **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);
    Copy to clipboard

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.

- [taf\_gpio\_IsOutput()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a361ca6f90b651aa23a1282f76d21b285.html#Documentationa00500_1a361ca6f90b651aa23a1282f76d21b285) - Is the pin currently an output?
- [taf\_gpio\_IsInput()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1acc8d8965c28fbea46455cc882c37f60d.html#Documentationa00500_1acc8d8965c28fbea46455cc882c37f60d) - Is the pin currently an input?
- [taf\_gpio\_IsActive()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a7243cd682bb8a786e2a00346001a9329.html#Documentationa00500_1a7243cd682bb8a786e2a00346001a9329) - Is an output pin currently being driven? (corresponds to the value file in sysfs)
- [taf\_gpio\_GetPolarity()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a84742d9da5d7857b899755465d2bb8d0.html#Documentationa00500_1a84742d9da5d7857b899755465d2bb8d0) - Retrieves the current polarity (active-low or active-high).
- [taf\_gpio\_GetEdgeSense()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00500_1a7097193c4a41fc3f1cfd804869d22fd3.html#Documentationa00500_1a7097193c4a41fc3f1cfd804869d22fd3) - What edge sensing has been enabled on an input pin?

Last Published: Jun 09, 2026

[Previous Topic
FS-Crypt Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafFSCrypt.md) [Next Topic
Health Monitor Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafhms.md)