This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:common:applications:gpio:40pin-header [2022/08/10 03:09] nick [Table] |
products:sbc:common:applications:gpio:40pin-header [2024/08/12 03:08] (current) william [Troubleshooting] |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{indexmenu_n> | {{indexmenu_n> | ||
- | ====== | + | ====== |
- | <WRAP important > | + | ====== GPIO usage examples |
- | This guide are only suitable for vendor kernel. For mainline linux kernel, GPIO numbers are different. | + | |
- | </ | + | |
- | + | ||
- | ===== Introduction | + | |
- | + | ||
- | The page introduces the number values of the 40 pins on the GPIO Header and leads you to control these pins. | + | |
- | + | ||
- | ===== Preparation ===== | + | |
- | + | ||
- | At the beginning, you need to get the correct GPIO numbers of the GPIOs you want to use. You can get them from the table below. | + | |
- | + | ||
- | <tabbox VIM1> | + | |
- | + | ||
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | | + | |
- | | | + | |
- | | 506 | PIN.AO5 | 15 | + | |
- | | 505 | PIN.AO4 | 16 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM2> | + | |
- | + | ||
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 470 | PIN.DV21 | + | |
- | | 471 | PIN.DV22 | + | |
- | | 472 | PIN.DV23 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | PIN.H4 | + | |
- | | | + | |
- | | 506 | PIN.AO5 | + | |
- | | 505 | PIN.AO4 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM3/ | + | |
- | + | ||
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 506 | PIN.AO10 | + | |
- | | | + | |
- | | 433 | PIN.H6 | + | |
- | | 434 | PIN.H7 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM4> | + | |
- | ^ GPIO ^ Name ^ Pin ^ Pin ^ Name ^ GPIO ^ | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | SPDIFOUT | + | |
- | | | + | |
- | | 491 | PIN.Y7 | + | |
- | | 490 | PIN.Y6 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | <tabbox Edge1> | + | |
- | + | ||
- | ^GPIO ^Name ^Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Control GPIO ===== | + | |
<WRAP important > | <WRAP important > | ||
Line 144: | Line 11: | ||
When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number '' | When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number '' | ||
- | **Export GPIO:** | + | ===== Export GPIO ===== |
```shell | ```shell | ||
Line 150: | Line 17: | ||
``` | ``` | ||
- | **Set GPIO direction:**\\ | + | ===== Set-up GPIO direction |
- | You can set the direction input or output. | + | |
+ | We can configure | ||
```shell | ```shell | ||
$ echo out | sudo tee / | $ echo out | sudo tee / | ||
- | $ echo in | sudo tee / | + | $ echo in | sudo tee / |
``` | ``` | ||
- | **Set or get GPIO value:** | + | ===== Set GPIO value ===== |
```shell | ```shell | ||
$ echo 1 | sudo tee / | $ echo 1 | sudo tee / | ||
$ echo 0 | sudo tee / | $ echo 0 | sudo tee / | ||
+ | ``` | ||
+ | |||
+ | ===== Get GPIO value ===== | ||
+ | |||
+ | ```shell | ||
$ cat / | $ cat / | ||
``` | ``` | ||
- | **Unexport GPIO:** | + | ===== Unexport GPIO ===== |
```shell | ```shell | ||
$ echo 465 | sudo tee / | $ echo 465 | sudo tee / | ||
Line 175: | Line 50: | ||
```shell | ```shell | ||
- | khadas@Khadas: | + | $ echo 465 | sudo tee / |
tee: / | tee: / | ||
``` | ``` | ||