Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:edge-2l:applications:gpio:40pin-header

Edge-2L IO GPIO header

An Edge-2L IO board is required.

The Edge-2L IO board features a 16-pin GPIO header for interfacing with various external devices.

Reference table

GPIO num Name Pin Pin Name GPIO num
SARADC 9 1 VCC_3V3
VCC_1V8 10 2 DEBUG_TX 28
45 SPI1_MOSI 11 3 DEBUG_RX 29
46 SPI1_MISO 12 4 GND
47 SPI1_CSO 13 5 GND
44 SPI1_CLK 14 6 MCUSWDIO
17 I2C6_SCL 15 7 MCUSWCLK
18 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
Last modified: 2026/05/11 02:39 by nick