Qualcomm products mentioned within this post are offered by
Qualcomm Technologies, Inc. and/or its subsidiaries.
General Purpose Input Output (GPIO) refers to one or more open-ended digital IO pins found on many electronic devices and circuit boards. As the words "General Purpose" suggest, these open-ended pins can be used for a variety of purposes, most commonly, to collect input such as that from sensors or to assert an output signal to control functionality on other device. Given this open-endedness, GPIO pins are often referred to as "uncommitted pins" since their purpose/functionality is often left up to the developer to determine.
GPIO is found in many use cases ranging from toggling devices like actuators or heaters, to reading the state of an external device’s switch, and even implementing various communication protocols. So with such flexibility, it’s not hard to imagine their significance in embedded systems such as IoT devices and robotics.
With this in mind let’s take a closer look at the characteristics of GPIO and how developers commonly work with it.
Characteristics of GPIO
Manufacturers typically expose GPIO pins via:
- "board-level GPIO" consisting of a low-speed expansion connector on the circuit board, which may also contain pins for other purposes; or
- direct integration on microcontrollers (i.e. some or all of the pins on the chip are allocated for GPIO).
Most of Qualcomm Technologies’ system-on-chip products are meant to be integrated onto circuit boards by OEMs who provide board-level GPIO. For example, the DragonBoard 410c development board for the Qualcomm® Snapdragon™ 400 series processor, features a 40-pin low-speed expansion connector, of which, 12 pins are allocated for GPIO while the other pins are used for power, ground, and other interfaces.
GPIO pins are generally meant for reading and writing signals and not for powering things. They operate at 3.3v, where voltage levels around 3.3V mean on, true, or 1 (depending on the system) and voltage levels near 0V mean off, false, or 0. Methods for reading/writing these values to GPIO pins varies by device manufacturer, and can range from memory-mapped IO or specific hardware-level assembly instructions, to high-level commands or functions in languages like C and Python.
Depending on the API provided by the device manufacturer, developers can generally do the following with GPIO pins:
- Enable/disable and read/write to them.
- Perform high-level functionality such as debounce and edge detection.
- Output signals using pulse width modulation to provide analog-like signalling (e.g. for controlling linear operations like diming a light).
- Implement hardware-layer communication protocols using GPIO signaling for other types of interfaces such as I2C, SPI, or even a parallel bus using bit banging.
- Treating an input pin as an interrupt request (IRQ).
Working with GPIO
When developers work with GPIO, they may perform some or all of the following tasks:
- Identify the physical GPIO pins available and their numbering.
- Decide on which GPIO pin(s) to use, and any other pins that may be required such as low-voltage power and ground.
- Connect the pin(s) to external devices.
- Programmatically open a specific GPIO pin and/or designate it’s direction (output or input).
- Specify any additional options exposed by the API such as using GPIO for edge detection or setting up an interrupt handler if the pin is being used for an IRQ. For example, the SIMCom 9206 IoT SDK includes a Qualcomm Technologies API with functions for working with IRQs via GPIO.
- Read or write to the pin.
Once these tasks have been completed, it’s then just a matter of implementing business logic to work with GPIO signals.
GPIO is a rich digital IO mechanism through which embedded systems can gain information about the real world and control other devices. Now that you know a bit more about GPIO, check out some of other Qualcomm Technologies platforms and development kits that support GPIO functionality:
Also, be sure to check out our IoT Merchandise Cart project which uses GPIO in conjunction with sensors to detect changes in product inventory.
-  Note that in some cases where there is a group of GPIO pins, some of them may be pre-assigned for certain functions while others remain free for the developer to use.
-  GPIO does have enough power for simple electronic components such as LEDs.
-  Note: Board-level GPIO configurations often have two types of pin numbering designations: a board-level designation corresponding to the numbering and layout of the physical pins, and chip-specific numbering which is defined by the chip that controls pin signals.
-  See the file qapi_gpioint.h in the qapi folder of this SDK.