This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
products:sbc:common:applications:gpio:40pin-header [2022/09/06 00:00] haylrn [Table] |
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 usage examples | ||
<WRAP important > | <WRAP important > | ||
- | This guide are only suitable for vendor kernel. For mainline linux kernel, GPIO numbers | + | Please make sure that the GPIOs you want to use are not configured as other functions, if they are, you can follow [[products: |
</ | </ | ||
- | ===== Introduction ===== | + | When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number '' |
- | The page introduces the number values of the 40 pins on the GPIO Header and leads you to control these pins. | + | ==== Export |
- | ===== Preparation ===== | + | ```shell |
+ | $ echo 111 | sudo tee / | ||
+ | ``` | ||
- | At the beginning, you need to get the correct | + | ==== Set-up |
- | <tabbox VIM1> | + | We can configure direction as input or output. |
- | ^ GPIO ^ Name ^ Physical | + | ```shell |
- | | | 5V | 1 | 21 | GND | + | $ echo out | sudo tee / |
- | | | + | $ echo in |
- | | | + | ``` |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | | + | |
- | | | + | |
- | | 506 | PIN.AO5 | 15 | + | |
- | | 505 | PIN.AO4 | 16 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | <tabbox VIM2> | + | ==== Set GPIO value ==== |
- | + | ||
- | ^ 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 ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | SPDIFOUT | + | |
- | | | + | |
- | | 491 | PIN.Y7 | + | |
- | | 490 | PIN.Y6 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | + | ||
- | <tabbox VIM1S> | + | |
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | 5V | | + | |
- | | | 5V | | + | |
- | | | USB_DM | + | |
- | | | USB_DP | + | |
- | | | | + | |
- | | | VCCMCU | + | |
- | | | MCU_NRST | + | |
- | | | MCU_SWIM | + | |
- | | | | + | |
- | | | | + | |
- | | | VDD1V8 | + | |
- | | | | + | |
- | | | + | |
- | | | | + | |
- | | | + | |
- | | | + | |
- | | | | + | |
- | | | PIN.D1 | + | |
- | | | PIN.D0 | + | |
- | | | | + | |
- | + | ||
- | <tabbox Edge-V> | + | |
- | + | ||
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | SPDIF/ | + | |
- | | | + | |
- | | 50 | + | |
- | | 49 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | <tabbox Edge2> | + | |
- | + | ||
- | ^ GPIO ^ Name ^ Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | SPI1_MOSI_M1/ | + | |
- | | | + | |
- | | 114 | SPI1_CS_M1/ | + | |
- | | 113 | SPI1_CLK_M1/ | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Control | + | |
- | + | ||
- | <WRAP important > | + | |
- | 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 '' | + | |
- | + | ||
- | **Export GPIO:** | + | |
```shell | ```shell | ||
- | $ echo 465 | sudo tee / | + | $ echo 1 | sudo tee / |
+ | $ echo 0 | sudo tee / | ||
``` | ``` | ||
- | **Set GPIO direction: | + | ==== Get GPIO value ==== |
- | You can set the direction input or output. | + | |
```shell | ```shell | ||
- | $ echo out | sudo tee / | + | $ cat / |
- | $ echo in | sudo tee / | + | |
``` | ``` | ||
- | **Set or get GPIO value:** | + | ==== Unexport |
- | ```shell | + | |
- | $ echo 1 | sudo tee / | + | |
- | $ echo 0 | sudo tee / | + | |
- | $ cat / | + | |
- | ``` | + | |
- | **Unexport GPIO:** | ||
```shell | ```shell | ||
- | $ echo 465 | sudo tee / | + | $ echo 111 | sudo tee / |
``` | ``` | ||
- | ===== Troubleshooting | + | ==== 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: | 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: | ||
```shell | ```shell | ||
- | khadas@Khadas: | + | khadas@Khadas: |
tee: / | tee: / | ||
``` | ``` | ||