Snapdragon® Telematics Application Framework (TelAF) Interface Specification
|
This API is used by apps to control general-purpose digital input/output pins.
A GPIO pin typically has one of the following features:
Pins also have a polarity mode:
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().
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.