This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
products:sbc:common:applications:gpio:40pin-header [2022/07/12 00:02] nick |
products:sbc:common:applications:gpio:40pin-header [2023/08/16 06:31] jacobe [Set GPIO value] |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{indexmenu_n> | {{indexmenu_n> | ||
+ | ====== GPIO Header ====== | ||
- | ====== 40-Pin Header ====== | + | ===== GPIO usage examples |
<WRAP important > | <WRAP important > | ||
- | This documentation only for OS with vendor kernel. | + | Please make sure that the GPIOs you want to use are not configured as other functions, if they are, you can follow [[products: |
</ | </ | ||
+ | When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number '' | ||
- | ===== Introduction ===== | + | ==== Export GPIO ==== |
- | This document will introduce the 40-Pin GPIO Header of Khadas SBC. You can find the GPIO number of the available GPIOs on the 40-Pin Header and will show you how the usage. | + | ```shell |
+ | $ echo 111 | sudo tee / | ||
+ | ``` | ||
- | ===== Preparation ===== | + | ==== Set-up GPIO direction |
- | First of all, you need to get the correct GPIO numbers of the GPIOs you want to use. You can get them from the table below. | + | We can configure direction as input or output. |
- | <tabbox VIM1> | + | ```shell |
+ | $ echo out | sudo tee / | ||
+ | $ echo in | sudo tee / | ||
+ | ``` | ||
- | ^ GPIO | + | ==== Set GPIO value ==== |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | | + | |
- | | | + | |
- | | 506 | PIN.AO5 | 15 | + | |
- | | 505 | PIN.AO4 | 16 | + | |
- | | | + | |
- | | 502 | PIN.AO1 | 18 | + | |
- | | 503 | PIN.AO2 | 19 | + | |
- | | | + | |
- | <tabbox VIM2> | + | ```shell |
+ | $ echo 1 | sudo tee / | ||
+ | $ echo 0 | sudo tee / | ||
+ | ``` | ||
- | ^GPIO ^Name ^Physical | + | ==== Get GPIO value ==== |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 470 | PIN.DV21 | + | |
- | | 471 | PIN.DV22 | + | |
- | | 472 | PIN.DV23 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | PIN.H4 | + | |
- | | | + | |
- | | 506 | | + | |
- | | 505 | | + | |
- | | | + | |
- | | 502 | | + | |
- | | 501 | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM3/ | + | |
- | + | ||
- | ^GPIO ^Name ^Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 506 | PIN.AO10 | + | |
- | | | + | |
- | | 433 | PIN.H6 | + | |
- | | 434 | PIN.H7 | + | |
- | | | + | |
- | | 497 | | + | |
- | | 496 | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM4> | + | |
- | ^GPIO ^Name ^Pin ^Pin ^Name ^GPIO ^ | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | SPDIFOUT | + | |
- | | | + | |
- | | 491 | PIN.Y7 | + | |
- | | 490 | PIN.Y6 | + | |
- | | | + | |
- | | 413 | PIN.D1 | + | |
- | | 414 | PIN.D2 | + | |
- | | | + | |
- | + | ||
- | <tabbox Edge1> | + | |
- | + | ||
- | ^GPIO ^Name ^Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Control | + | |
- | + | ||
- | When you get the GPIO number, you can follow the steps below to control it. Here will take GPIO number '' | + | |
- | + | ||
- | **Export GPIO:** | + | |
```shell | ```shell | ||
- | $ echo 465 | sudo tee / | + | $ cat / |
``` | ``` | ||
- | **Set GPIO direction: | + | |
- | You can set the direction input or output. | + | ==== Unexport GPIO ==== |
```shell | ```shell | ||
- | $ echo out | sudo tee / | + | $ echo 111 | sudo tee / |
- | $ echo in | sudo tee / | + | |
``` | ``` | ||
- | **Set or get GPIO value:** | + | ==== 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 [[products:sbc: | ||
```shell | ```shell | ||
- | $ echo 1 | sudo tee / | + | khadas@Khadas: |
- | $ echo 0 | sudo tee / | + | tee: / |
- | $ cat / | + | |
``` | ``` | ||
- | **Unexport GPIO:** | ||
- | ```shell | ||
- | $ echo 465 | sudo tee / | ||
- | ``` |