Skip to content

Commit

Permalink
Merge pull request #115 from zwyzwm/main
Browse files Browse the repository at this point in the history
docs: duo add gpio control
  • Loading branch information
u0076 authored Dec 6, 2024
2 parents 2372075 + 8fe6249 commit 77792d8
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 62 deletions.
44 changes: 44 additions & 0 deletions docs/duo/getting-started/GPIO-pin-control.md
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`.
31 changes: 0 additions & 31 deletions docs/duo/getting-started/duos.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,6 @@ GPIO on `Header J4` use 1.8V logic levels.

</div>

### Duos GPIO pin control

1. Perform the following operations to configure GPIO:

Take GPIO466 as an example. The 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).

```
$ cd /sys/class/gpio
$ echo 466 > export
```
You can run the command ls /sys/class/gpio to list the GPIO directory and check whether gpio466 appears to 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 level of gpio466 to high.

Run the command `echo "0" > gpio466/value` to set the level of gpio466 to low.

You can check the set level by running the command `cat gpio466/value`.

### Camera interface

DuoS has two CSI camera connectors:
Expand Down
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 `,来查看设置的电平。
Original file line number Diff line number Diff line change
Expand Up @@ -120,37 +120,6 @@ Milk-V 是 SG2000 芯片的全球授权经销商。您可以直接从我们的

</div>

### Duos GPIO 引脚控制

1. 执行以下操作配置 GPIO:

以 GPIO466 为例,序号是[J3排列](https://milkv.io/zh/docs/duo/getting-started/duos#%E6%8E%92%E9%92%88-j3)的 NUM 一列。

```
$ 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 `,来查看设置的电平。

### 摄像头接口

DuoS 有两个 CSI 摄像头接连器:
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const sidebars = {
'duo/getting-started/duo256m',
'duo/getting-started/duos',
'duo/getting-started/duo-module-01',
'duo/getting-started/GPIO-pin-control',
'duo/getting-started/boot',
'duo/getting-started/setup',
'duo/getting-started/buildroot-sdk',
Expand Down

0 comments on commit 77792d8

Please sign in to comment.