Table of Contents

Edge2 IO GPIO header

An Edge2 IO board is needed.

Edge2 IO board 16 pins GPIO header, used for communication between board and different external devices.

Reference table

GPIO num Name Pin Pin Name GPIO num
SARADC 9 1 VCC_3V3
VCC_1V8 10 2 DEBUG_TX 13
111 SPI1_MOSI 11 3 DEBUG_RX 14
112 SPI1_MISO 12 4 GND
114 SPI1_CSO 13 5 GND
113 SPI1_CLK 14 6 MCUSWDIO
24 I2C6_SCL 15 7 MCUSWCLK
23 I2C6_SDA 16 8 VCCMCU

GPIO usage examples

Please make sure that the GPIOs you want to use are not configured as other functions, if they are, you can follow Device Tree Overlay to configure them as normal GPIOs.

When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number 465 as an example.

Export GPIO

$ echo 465 | sudo tee /sys/class/gpio/export

Set-up GPIO direction

We can configure direction as input or output.

$ echo out | sudo tee /sys/class/gpio/gpio465/direction # Set GPIO output
$ echo in  | sudo tee /sys/class/gpio/gpio465/direction # Set GPIO input

Set GPIO value

$ echo 1 | sudo tee /sys/class/gpio/gpio465/value # Set GPIO output high
$ echo 0 | sudo tee /sys/class/gpio/gpio465/value # Set GPIO output low

Get GPIO value

$ cat /sys/class/gpio/gpio465/value # Get GPIO input value

Unexport GPIO

$ echo 465 | sudo tee /sys/class/gpio/unexport

Troubleshooting

If you got the similar error below, it means that the PIN you try to export is used for another function, you need to edit Device Tree Overlay configuration file to set the PIN as normal GPIO.

$ echo 465 | sudo tee /sys/class/gpio/export 
tee: /sys/class/gpio/export: Invalid argument
2022/06/30 00:01 · nick