GPIO Overview

Introduction

GPIO is short for general-purpose input/output. Generally, a GPIO controller manages all GPIO pins by group. Each group of GPIO pins is associated with one or more registers. The GPIO pins are operated by reading data from and writing data to the registers.

The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including:

  • Setting the pin direction, which can be input or output (High impedance is not supported currently.)

  • Reading and writing level values, which can be low or high

  • Setting an interrupt service routine (ISR) function and interrupt trigger mode for a pin

  • Enabling or disabling a pin interrupt

Available APIs

Table 1 APIs available for the GPIO driver

Capability

Function

Description

GPIO read/write

GpioRead

Reads the level value of a GPIO pin.

GpioWrite

Writes the level value of a GPIO pin.

GPIO settings

GpioSetDir

Sets the direction for a GPIO pin.

GpioGetDir

Obtains the direction for a GPIO pin.

GPIO interrupt settings

GpioSetIrq

Sets the ISR function for a GPIO pin.

GpioUnSetIrq

Cancels the setting of the ISR function for a GPIO pin.

GpioEnableIrq

Enables a GPIO interrupt.

GpioDisableIrq

Disables a GPIO interrupt.

NOTE: All functions provided in this document can be called only in kernel mode.