-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from zwyzwm/main
docs: duo add gpio control
- Loading branch information
Showing
5 changed files
with
88 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
sidebar_label: 'GPIO pin control' | ||
sidebar_position: 3 | ||
--- | ||
|
||
# GPIO pin control | ||
|
||
The Duos serial number is the NUM column of [J3 arrangement](https://milkv.io/zh/docs/duo/getting-started/duos#%E6%8E%92%E9%92%88-j3). | ||
|
||
The Duo serial number is the NUM column of [GPIO pin distribution](https://milkv.io/zh/docs/duo/getting-started/duo#gpio-%E5%BC%95%E8%84%9A%E5%88%86%E5%B8%83). | ||
|
||
The serial number of Duo256M is the NUM column of [GPIO pin distribution](https://milkv.io/zh/docs/duo/getting-started/duo256m#duo256m-gpio-%E5%BC%95%E8%84%9A%E5%88%86%E9%85%8D). | ||
|
||
The serial number of Duo Module 01 is the NUM column of [26 PIN pin header](https://milkv.io/zh/docs/duo/getting-started/duo-module-01#26-pin-%E6%8E%92%E9%92%88). | ||
|
||
Take Duos, GPIO466 as an example, | ||
|
||
1. Perform the following operations to configure GPIO | ||
|
||
``` | ||
$ cd /sys/class/gpio | ||
$ echo 466 > export | ||
``` | ||
You can run the command ls /sys/class/gpio to list the GPIO directory, check whether gpio466 appears, and confirm that the export is successful. | ||
|
||
Run the command `echo 466 > unexport` to cancel the export of the gpio466 pin. | ||
|
||
2. Set the direction of GPIO | ||
|
||
Run the command `echo "out" > gpio466/direction` to set the gpio466 direction to output. | ||
|
||
Run the command `echo "in" > gpio466/direction` to set the gpio466 direction to input. | ||
|
||
You can check the set direction by running the command `cat gpio466/direction`. | ||
|
||
3. Set the GPIO level | ||
|
||
Run the command `echo "1" > gpio466/value` to set the gpio466 level to high. | ||
|
||
Run the command `echo "0" > gpio466/value` to set the gpio466 level to low. | ||
|
||
You can view the set level by running the command `cat gpio466/value`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../docusaurus-plugin-content-docs/current/duo/getting-started/GPIO-pin-control.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
sidebar_label: 'GPIO 引脚控制' | ||
sidebar_position: 3 | ||
--- | ||
|
||
# GPIO 引脚控制 | ||
|
||
Duos 序号为[J3排列](https://milkv.io/zh/docs/duo/getting-started/duos#%E6%8E%92%E9%92%88-j3)的 NUM 一列。 | ||
|
||
Duo 序号为[GPIO 引脚分布](https://milkv.io/zh/docs/duo/getting-started/duo#gpio-%E5%BC%95%E8%84%9A%E5%88%86%E5%B8%83)的 NUM 一列。 | ||
|
||
Duo256M 序号为[GPIO 引脚分布](https://milkv.io/zh/docs/duo/getting-started/duo256m#duo256m-gpio-%E5%BC%95%E8%84%9A%E5%88%86%E9%85%8D)的 NUM 一列。 | ||
|
||
Duo Module 01 序号为[26 PIN 排针](https://milkv.io/zh/docs/duo/getting-started/duo-module-01#26-pin-%E6%8E%92%E9%92%88)的 NUM 一列。 | ||
|
||
以 Duos ,GPIO466 为例, | ||
|
||
1. 执行以下操作配置 GPIO | ||
|
||
``` | ||
$ cd /sys/class/gpio | ||
$ echo 466 > export | ||
``` | ||
可以运行命令 ls /sys/class/gpio,列出 GPIO 目录,检查是否出现 gpio466,确认导出成功。 | ||
|
||
运行命令 `echo 466 > unexport`,可以取消 gpio466 引脚的导出。 | ||
|
||
2. 设置 GPIO 的方向 | ||
|
||
运行命令 `echo "out" > gpio466/direction`,将 gpio466 方向设置为输出。 | ||
|
||
运行命令 `echo "in" > gpio466/direction`,将 gpio466 方向设置为输入。 | ||
|
||
可以通过运行命令 `cat gpio466/direction `,来查看设置的方向。 | ||
|
||
3. 设置 GPIO 的电平 | ||
|
||
运行命令 `echo "1" > gpio466/value`,将 gpio466 的电平设置为高。 | ||
|
||
运行命令 `echo "0" > gpio466/value`,将 gpio466 的电平设置为低。 | ||
|
||
可以通过运行命令 `cat gpio466/value `,来查看设置的电平。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters