# WiringPi
WiringPi is a _performant_ GPIO access library written in C for Raspberry Pi boards.
:warning:️ :construction: on Pi5, PWM support is currently under development and _will not work at this point_. If you're interested in the progress, please check the [corresponding issue](https://github.com/GrazerComputerClub/WiringPi/issues/21).
To compile programs with wiringPi, you need to include `wiringPi.h` as well as link against `wiringPi`:
```c
#include <wiringPi.h> // Include WiringPi library!
int main(void)
{
// uses BCM numbering of the GPIOs and directly accesses the GPIO registers.
wiringPiSetupGpio();
// pin mode ..(INPUT, OUTPUT, PWM_OUTPUT, GPIO_CLOCK)
// set pin 17 to input
pinMode(17, INPUT);
// pull up/down mode (PUD_OFF, PUD_UP, PUD_DOWN) => down
pullUpDnControl(17, PUD_DOWN);
// get state of pin 17
int value = digitalRead(17);
if (HIGH == value)
{
// your code
}
}
```
To compile this code, link against wiringPi:
```sh
gcc -o myapp myapp.c -l wiringPi
```
Be sure to check out the [examples](./examples/), build them using Make:
```sh
cd examples
make <example-name | really-all>
```
The tool `gpio` can be used to set single pins as well as get the state of everything at once:
```
pi@wiringdemo:~ $ gpio readall
+-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 0 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 1 | 11 || 12 | 1 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 1 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 1 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 1 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 1 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 0 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 0 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 0 | 31 || 32 | 1 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 1 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 1 | 35 || 36 | 1 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 1 | 37 || 38 | 1 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 1 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
```
## Installing
You can either build it yourself or use the prebuilt binaries:
### From Source
1. create debian-package
```sh
# fetch the source
sudo apt install git
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
# build the package
./build debian
mv debian-template/wiringpi-3.0-1.deb .
# install it
sudo apt install ./wiringpi-3.0-1.deb
```
### Prebuilt Binaries
Grab the latest release from [here](https://github.com/WiringPi/WiringPi/releases).
Unzip/use the portable prebuilt verison:
```sh
# unzip the archive
tar -xfv wiringpi_3.0.tar.gz
```
Install the debian package:
```sh
# install a dpkg
sudo apt install ./wiringpi-3.0-1.deb
```
## Ports
wiringPi has been wrapped for multiple languages:
* Node - https://github.com/WiringPi/WiringPi-Node
* Perl - https://github.com/WiringPi/WiringPi-Perl
* PHP - https://github.com/WiringPi/WiringPi-PHP
* Python - https://github.com/WiringPi/WiringPi-Python
* Ruby - https://github.com/WiringPi/WiringPi-Ruby
## Support
Please use the [issue system](https://github.com/WiringPi/WiringPi/issues) of GitHub.
If you're not sure whether to create an issue or not, please engage in [discussions](https://github.com/WiringPi/WiringPi/discussions)!
Please do not email Gordon or @Gadgetoid.
Please don't email GC2 for reporting issues, you might [contact us](mailto:wiringpi@gc2.at) for anything that's not meant for the public.
## History
This repository is the continuation of 'Gordon's wiringPi' which has been [deprecated](https://web.archive.org/web/20220405225008/http://wiringpi.com/wiringpi-deprecated/), a while ago.
* The last "old wiringPi" source of Gordon's release can be found at the
[`final_source_2.50`](https://github.com/WiringPi/WiringPi/tree/final_official_2.50) tag.
* The default `master` branch contains code that has been written since version 2.5
to provide support for newer hardware as well as new features.
:information_source:️ Since 2024, [GC2](https://github.com/GrazerComputerClub) has taken over maintenance of the project, supporting new OS versions as well as current hardware generations. We are dedicated to keeping the arguably best-performing GPIO Library for Raspberry Pi running smoothly. We strive to do our best, but please note that this is a community effort, and we cannot provide any guarantees or take responsibility for implementing specific features you may need.
## Debug
WIRINGPI_DEBUG=1 ./my_wiringpi_program
WIRINGPI_DEBUG=1 gpio readall
没有合适的资源?快使用搜索试试~ 我知道了~
树莓派C/C++ GPIO控制WiringPi库源码
共205个文件
c:103个
h:53个
makefile:11个
0 下载量 87 浏览量
2024-04-06
14:38:21
上传
评论
收藏 287KB ZIP 举报
温馨提示
树莓派WiringPi库
资源推荐
资源详情
资源评论
收起资源包目录
树莓派C/C++ GPIO控制WiringPi库源码 (205个子文件)
gpio.1 9KB
build 5KB
wiringPi.c 80KB
gpio.c 38KB
wpiExtensions.c 20KB
lcd128x64.c 14KB
readall.c 12KB
lcd.c 11KB
drcNet.c 10KB
scrollPhat.c 9KB
ads1115.c 9KB
wiringpid.c 8KB
network.c 8KB
lcd-adafruit.c 8KB
wiringPiI2C.c 6KB
ladder.c 6KB
softServo.c 6KB
scphat.c 6KB
lcd.c 6KB
bmp180.c 6KB
rht03.c 6KB
ds1302.c 6KB
wiringSerial.c 6KB
maxdetect.c 6KB
ds1302.c 6KB
wiringPiLegacy.c 5KB
mcp23s17.c 5KB
piGlow1.c 5KB
drcSerial.c 5KB
clock.c 5KB
piglow.c 5KB
mcp23s08.c 5KB
softPwm.c 4KB
mcp23017.c 4KB
7segments.c 4KB
piFaceOld.c 4KB
wiringPiSPI.c 4KB
gertboard.c 4KB
reaction.c 4KB
mcp23016.c 4KB
wfi.c 4KB
mcp23008.c 4KB
htu21d.c 3KB
ds18b20.c 3KB
mcp3422.c 3KB
spiSpeed.c 3KB
softTone.c 3KB
vumeter.c 3KB
isr.c 3KB
piFace.c 3KB
isr-osc.c 3KB
pcf8574.c 3KB
sr595.c 3KB
motor.c 3KB
blink12drcs.c 3KB
runRemote.c 3KB
piGlow.c 3KB
piNes.c 3KB
blink6drcs.c 3KB
test.c 3KB
max31855.c 3KB
buttons.c 3KB
pseudoPins.c 3KB
metro.c 3KB
gertboard.c 3KB
speed.c 3KB
blink12.c 3KB
pcf8591.c 2KB
delayTest.c 2KB
sn3218.c 2KB
max5322.c 2KB
wiringShift.c 2KB
nes.c 2KB
mcp3004.c 2KB
softPwm.c 2KB
mcp4802.c 2KB
rht03.c 2KB
buttons.c 2KB
mcp3002.c 2KB
okLed.c 2KB
temperature.c 2KB
binary.c 2KB
lowPower.c 2KB
serialTest.c 2KB
voltmeter.c 2KB
max31855.c 2KB
piThread.c 2KB
blink8-drcn.c 2KB
button.c 2KB
volts.c 2KB
blink-io.c 2KB
blink.c 2KB
blink8.c 2KB
servo.c 2KB
daemonise.c 2KB
piHiPri.c 2KB
blink-thread.c 2KB
bright.c 2KB
piGlow0.c 2KB
pwm.c 1KB
共 205 条
- 1
- 2
- 3
资源评论
战地小记者
- 粉丝: 54
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
- Linux线程同步机制深度解析与实用指南.zip
- PTA题库C语言解题策略与实战.rar
- SVPWM控制技术的simulink建模与仿真【包括simulink模型,参考文献,操作步骤】
- AI高清修复图片画质易语言易语言源码易语言填表
- 映射窗口.ec易语言易语言模块CPU占用0%游戏监控窗口监控
- 易语言 361窗口模块高效、便捷、自封装、自用
- 易语言 窗口排列 模块 ,简单、高效、体积小
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功