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/07/06 05:45] nick |
products:sbc:common:applications:gpio:40pin-header [2024/08/12 03:08] (current) william [Troubleshooting] |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{indexmenu_n> | {{indexmenu_n> | ||
+ | ====== GPIO Header ====== | ||
- | ====== | + | ====== |
- | ===== Introduction ===== | + | <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: | ||
+ | </ | ||
- | This document will introduce **how to control | + | When you get the GPIO number, you can follow the steps below to control |
- | ===== Preparation | + | ===== Export GPIO ===== |
- | Before controlling the GPIO, we first need to get to the number of the GPIO. Refer to the table below to find the number value of the GPIO you need to control. | + | ```shell |
+ | $ echo 465 | sudo tee / | ||
+ | ``` | ||
- | <tabbox VIM1> | + | ===== Set-up GPIO direction ===== |
- | ^ GPIO ^ Name ^ Physical | + | We can configure direction as input or output. |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | | + | |
- | | | + | |
- | | 506 | PIN.AO5 | 15 | + | |
- | | 505 | PIN.AO4 | 16 | + | |
- | | | + | |
- | | 502 | PIN.AO1 | 18 | + | |
- | | 503 | PIN.AO2 | 19 | + | |
- | | | + | |
- | <tabbox VIM2> | + | ```shell |
+ | $ echo out | sudo tee / | ||
+ | $ echo in | sudo tee / | ||
+ | ``` | ||
- | ^GPIO | + | ===== Set GPIO value ===== |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 470 | PIN.DV21 | + | |
- | | 471 | PIN.DV22 | + | |
- | | 472 | PIN.DV23 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | PIN.H4 | + | |
- | | | + | |
- | | 506 | | + | |
- | | 505 | | + | |
- | | | + | |
- | | 502 | | + | |
- | | 501 | | + | |
- | | | + | |
- | <tabbox VIM3/3L> | + | ```shell |
+ | $ echo 1 | sudo tee /sys/ | ||
+ | $ echo 0 | sudo tee / | ||
+ | ``` | ||
- | ^GPIO | + | ===== Get GPIO value ===== |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 506 | PIN.AO10 | + | |
- | | | + | |
- | | 433 | PIN.H6 | + | |
- | | 434 | PIN.H7 | + | |
- | | | + | |
- | | 497 | | + | |
- | | 496 | | + | |
- | | | + | |
- | <tabbox VIM4> | + | ```shell |
- | {{ : | + | $ cat /sys/class/gpio/ |
- | ^GPIO ^Name ^Pin ^Pin ^Name ^GPIO ^ | + | ``` |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | SPDIFOUT | + | |
- | | | + | |
- | | 491 | PIN.Y7 | + | |
- | | 490 | PIN.Y6 | + | |
- | | | + | |
- | | 413 | PIN.D1 | + | |
- | | 414 | PIN.D2 | + | |
- | | | + | |
- | <tabbox Edge1> | + | ===== Unexport GPIO ===== |
- | ^GPIO ^Name ^Physical | + | ```shell |
- | | | | + | $ echo 465 | sudo tee /sys/class/gpio/unexport |
- | | | + | ``` |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | </ | + | ===== Troubleshooting ===== |
- | ===== Control | + | 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: |
- | When you get the GPIO number, you can follow the steps below to control it. Here will take GPIO number '' | + | ```shell |
- | + | $ echo 465 | sudo tee / | |
- | **Export GPIO:** | + | tee: / |
- | + | ||
- | ```sh | + | |
- | $ echo 465 | sudo tee / | + | |
``` | ``` | ||
- | **Set GPIO direction: | ||
- | You can set the direction input or output. | ||
- | ```sh | ||
- | $ echo out | sudo tee / | ||
- | $ echo in | sudo tee / | ||
- | ``` | ||
- | |||
- | **Set or get GPIO value:** | ||
- | ```sh | ||
- | $ echo 1 | sudo tee / | ||
- | $ echo 0 | sudo tee / | ||
- | $ cat / | ||
- | ``` | ||
- | |||
- | **Unexport GPIO:** | ||
- | ```sh | ||
- | $ echo 465 | sudo tee / | ||
- | ``` |