gpio是个很神奇的东西,在Linux的某个时候呗纳入了规范,它可以直接的操作io口,读或者写,它可以就像文件协议一样的控制它,这就是Linux神奇的玩意。
目录 |
简介
这是非常有趣的,GPIO看起来就像是linux的一种主板接口。
想法
- 这是openwrt的某种硬件端口内部编号,比如reset按钮,都有自己的gpio编号。
- 关于定义,似乎是芯片级别上的。
Openwrt
WR703的GPIO
致谢
感谢伟大的Squonk(Michel)。
BOM
请到这里: WR703 BOM
裸板PCB布线
Openwrt官方Wiki
http://wiki.openwrt.org/toh/tp-link/tl-wr703n_pcb
元件
U5、U6
发现
CPU
这里有AR9331的引脚图:
GPIO
- GPIO 发现的:
- GPIO7: R15(带下拉电阻)
- GPIO29: R17
- GPIO0: R4
A guess would be they are used for POR (Power-On Reset) identification/function selection, but this is infirmed by the fact that R15 has been identified by imperfect as being a pull-down resistor for the GPIO7 signal, and R17 for the GPIO29 signal. though R4 has been identified by imperfect as a pull-down resistor for the GPIO0 signal.
一个更大的列表
原始表:http://wiki.openwrt.org/toh/tp-link/tl-wr703n#gpios
GPIO | WR703N 上的功能 | AR9331 引脚 | POR 值 | WR703N 名称 | 描述 | MR3020 名称 |
---|---|---|---|---|---|---|
0 | R4-E | A78 | 0 | 系统引导的时候必须为低电平 | WLAN LED/LED4 | |
1 | R2-S | A77 | 1 | 系统引导的时候必须为高电平 | ||
2 | VIA | B49 | SPI_CS_0 | 用于 SPI Flash | SPI_CS_0 | |
3 | VIA | B51 | SPI_CLK | 用于 SPI Flash | SPI_CLK | |
4 | VIA | A57 | SPI_MOSI | 用于 SPI Flash | SPI_MOSI | |
5 | R57-S/R60-S | B50 | SPI_MISO | 用于 SPI Flash | SPI_MISO | |
6 | R16-S | B46 | LDO | 连接到 U6 的 LDO | LDO | |
7 | R15-S | A54 | 0 | |||
8 | R18-E | A52 | USB_POWER | 连接到 USB 主机电源 | USB_POWER | |
9 | R82-N | B68 | 1 | TP_IN | 也就是TTL接口UART的 RXD | TP_IN |
10 | C55-W | A79 | TP_OUT | 也就是TTL接口UART的TXD | TP_OUT | |
11 | R92-E | B48 | RESET SW | 软复位开关 | WPS/RESET SW | |
12 | VIA | A56 | 0 | 系统引导的时候必须为低电平 | ||
13 | R3-S | B66 | 1 | 系统引导的时候必须为高电平 | ||
14 | R11-N | A76 | 0 | |||
15 | R12-N | B65 | 0 | |||
16 | R13-N | A75 | 0 | 系统引导的时候必须为低电平 | ||
17 | R14-N | B64 | 1 | LAN LED/LED5 | ||
18 | NC | A28 | N/A | 侧边栏 SW1 | ||
19 | ||||||
20 | NC | A27 | N/A | 侧边栏 SW2 | ||
21 | ||||||
22 | ||||||
23 | ||||||
24 | ||||||
25 | ||||||
26 | ||||||
27 | LED2-S/LED3-S | B44 | LED2/LED3 | Blue PCB LED | 3G LED/LED3 | |
28 | VIA | A74 | 0 | 系统引导的时候必须为低电平 | ||
29 | R17-S | A53 | 0 |
上面有些有趣的玩意
Antenna Matching Network
Several RF filter networks can be identified: C33 / C34 / L6 / L7 / L8 / L9, in parallel to C19 / C22 / C23 / C25 / L2 / L4, followed by C7 / C20 / C21 / C26 / C27 / C28 / C30 / L3 / L7.
J1 is a 0 ohm resistor shunt that provides a convenient way to disconnect the printed antenna on the other side of the PCB from the chip. Its pad closest to the U1 chip and the large GND pad on its right can then be used to solder an external antenna.
资源项目
-
luaGpio,一套专门的gpio库,lua的
- https://github.com/rsisto/luaGpio
-
lua-rpi-gpio 一套lua的库,为那个什么莓而特定的
- https://github.com/craigbarnes/lua-rpi-gpio
-
一个关于lua和openwrt和gpioled的试验
- http://gauchoacomecable.wordpress.com/2012/06/25/gpio-and-leds-in-linux-and-lua/
见识
OpenWrt / (TL-WR703n / GPIO / Misc) AR9331 pinouts? 沿途见识[1]
How to use your Raspberry Pi like an Arduino 沿途见识,Arduino控制gpio[2]
sudo su -
echo "4" > /sys/class/gpio/export
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
echo "1" > /sys/class/gpio/gpio4/value
echo "0" > /sys/class/gpio/gpio4/value
GPIO到文件系统的映射_karl321-ChinaUnix博客 沿途见识[3]
GPIO到文件系统的映射 (2011-06-18 16:19)
标签: 文件系统 寄存器 shell 成功 分类: ARM Linux Fs
控制GPIO的目录位于:
/sys/class/gpio/sys/class/gpio/export
文件用于通知系统需要导出控制的GPIO引脚编号
/sys/class/gpio/unexport
用于通知系统取消导出
/sys/class/gpio/gpiochipX
目录保存系统中GPIO寄存器的信息,
包括每个寄存器控制引脚的起始编号base,寄存器名称,引脚总数
导出一个引脚的操作步骤
1.计算此引脚编号,引脚编号 = 控制引脚的寄存器基数 + 控制引脚寄存器位数
2.向/sys/class/gpio/export写入此编号,比如12号引脚,在shell中可以通过以下命令实现,命令成功后生成/sys/class/gpio/gpio12目录,如果没有出现相应的目录,说明此引脚不可导出:
echo 12 > /sys/class/gpio/export
3.direction文件,定义输入输入方向,可以通过下面命令定义为输出
echo out > direction
注意:direction接受的参数:in, out, high, low。high/low同时设置方向为输出,
并将value设置为相应的1或0。
引用信息
相关航海日志: