GPIO commands allow control of the function and direction of the GPIOs.

Typically, particular GPIOs are hard-wired to components such as LEDs and buttons. Other GPIOs are configurable for input and output.

GPIOs can be used for special system functions, including (but not limited to):

GPIO Functions and Pins

In the following examples, the BGX EXP evaluation board is used to demonstrate GPIO functions.

Viewing GPIO Usage

To see the current GPIO usage, read the GPIO usage variable. The default BGX EXP usage is:

> get gp u
!  # Description
#  0 none
#  1 none
#  2 none
#  3 none
#  4 none
#  5 none
#  6 none
#  7 none

Setting GPIO Function

Use the GPIO function command to set a single GPIO to a specific function.

After using gfu, it may be necessary to save then reboot depending on the alternate function (some functions are only configured at boot up).

Use gdis command to set the direction for multiple GPIOs configured as stdio. See Setting and Getting Multiple STDIO GPIO Values below.

Available functions are listed in the gfu command documentation.

The gfu command fails if the GPIO is already configured for an alternate function. Disable the alternate function first by using `gfu

<GPIO#> none`.

For example, to enable GPIO 5 to operate as stdio:

> gfu 5 stdio

To use LED0 to indicate when stream mode is on:

> gfu 0 str_activity_led

Setting and Getting a Single STDIO GPIO Value

To set and get the value of a single GPIO, use the gse and gge commands.

Note that to set a GPIO, the GPIO must have stdio function and the output direction. To get the value, the GPIO must have stdio function. See Setting GPIO Function.

For example, set and clear GPIO 1 to turn LED1 on and off:

> gfu 1 stdio
> gdi 1 olo
> gge 1
> gse 1 1
> gge 1

Setting and Getting Multiple STDIO GPIO Values

To set and get multiple stdio GPIO values, use the gses and gges commands.

For example, set GPIO 0 (LED0) and GPIO 1 (LED1) as stdio open-drain outputs with no pull-ups, and GPIO 2 (BTN0) and GPIO 3 (BTN1) as stdio inputs with pull-ups.

> gfu 0 stdio
> gfu 1 stdio
> gfu 2 stdio
> gfu 3 stdio
> gdis 4400XXXX

With no buttons pressed, get the values of the stdio GPIOs:

> gges

Now turn the LED0 on:

> gses 0111XXXX

Press both buttons and get the values of the stdio GPIOs:

> gges