@@ -0,0 +1,16 @@ | |||||
name: Build | |||||
on: | |||||
pull_request: | |||||
push: | |||||
branches: | |||||
- master | |||||
jobs: | |||||
test: | |||||
runs-on: ubuntu-latest | |||||
steps: | |||||
- uses: actions/checkout@v2 | |||||
- name: Run build | |||||
run: | | |||||
./build |
@@ -23,7 +23,11 @@ To un-install wiringPi: | |||||
./build uninstall | ./build uninstall | ||||
Gordon Henderson | |||||
For help and support see: | |||||
projects@drogon.net | |||||
* https://github.com/WiringPi/WiringPi/issues | |||||
* https://discord.gg/SM4WUVG | |||||
wiringPi originally created by Gordon Henderson | |||||
https://projects.drogon.net/ | https://projects.drogon.net/ |
@@ -1,36 +0,0 @@ | |||||
Note | |||||
==== | |||||
This is an unofficial mirror of WiringPi to support ports (Python/Ruby/etc). | |||||
Please do not email Gordon if you have issues, he will not be able to help. | |||||
Pull-requests are not currently accepted, since this is a mirror. | |||||
For support, comments, questions, etc please join the WiringPi Discord channel: https://discord.gg/SM4WUVG | |||||
wiringPi README | |||||
=============== | |||||
Please note that the official way to get wiringPi is via git from | |||||
git.drogon.net and not GitHub. | |||||
ie. | |||||
git clone git://git.drogon.net/wiringPi | |||||
The version of wiringPi held on GitHub by "Gadgetoid" is used to build the | |||||
wiringPython, Ruby, Perl, etc. wrappers for these other languages. This | |||||
version may lag the official Drogon release. Pull requests may not be | |||||
accepted to Github.... | |||||
Please see | |||||
http://wiringpi.com/ | |||||
for the official documentation, etc. and the best way to submit bug reports, etc. | |||||
is by sending an email to projects@drogon.net | |||||
Thanks! | |||||
-Gordon |
@@ -1,39 +1,19 @@ | |||||
wiringPi README | |||||
=============== | |||||
Please note that the official way to get wiringPi is via git from | |||||
git.drogon.net and not GitHub. | |||||
ie. | |||||
git clone git://git.drogon.net/wiringPi | |||||
The version of wiringPi held on GitHub by "Gadgetoid" is used to build the | |||||
wiringPython, Ruby, Perl, etc. wrappers for these other languages. This | |||||
version may lag the official Drogon release. Pull requests may not be | |||||
accepted to Github.... | |||||
Please see | |||||
http://wiringpi.com/ | |||||
for the official documentation, etc. and the best way to submit bug reports, etc. | |||||
is by sending an email to projects@drogon.net | |||||
Thanks! | |||||
-Gordon | |||||
同步 git://git.drogon.net/wiringPi 最新源代码到项目当中。 | |||||
此修改基于 原来的master 分支 | |||||
` git remote add upstream git://git.drogon.net/wiringPi ` | |||||
` git fetch upstream master:upstream/master ` | |||||
` git merge upstream/master ` | |||||
` git push origin master:master ` | |||||
Unofficial WiringPi Mirror | |||||
========================== | |||||
This is an unofficial mirror of WiringPi to support ports (Python/Ruby/etc). With the | |||||
[end of official development](http://wiringpi.com/wiringpi-deprecated/), this repository | |||||
has become a mirror of the last "official" source release as well as a source for small | |||||
updates to support newer hardware (primarily for use by the ports). | |||||
* The final "official" source 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 that final source | |||||
release to provide support for newer hardware. | |||||
Please do not email Gordon if you have issues, he will not be able to help. | |||||
Pull-requests may be accepted to add or fix support for newer hardware, but new features or | |||||
other changes will not be accepted. | |||||
For support, comments, questions, etc please join the WiringPi Discord channel: https://discord.gg/SM4WUVG |
@@ -1 +1 @@ | |||||
2.46 | |||||
2.60 |
@@ -36,8 +36,8 @@ check_make_ok() { | |||||
echo "" | echo "" | ||||
echo "Make Failed..." | echo "Make Failed..." | ||||
echo "Please check the messages and fix any problems. If you're still stuck," | echo "Please check the messages and fix any problems. If you're still stuck," | ||||
echo "then please email all the output and as many details as you can to" | |||||
echo " projects@drogon.net" | |||||
echo "then raise a GitHub issue with the output and as many details as you can" | |||||
echo " https://github.com/WiringPi/WiringPi/issues" | |||||
echo "" | echo "" | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
@@ -84,14 +84,15 @@ fi | |||||
if [ x$1 = "xdebian" ]; then | if [ x$1 = "xdebian" ]; then | ||||
here=`pwd` | here=`pwd` | ||||
deb_destdir=${here}/debian-template/wiringPi | |||||
cd debian-template/wiringPi | cd debian-template/wiringPi | ||||
rm -rf usr | rm -rf usr | ||||
cd $here/wiringPi | cd $here/wiringPi | ||||
make install-deb | |||||
make install-deb DEB_DESTDIR=${deb_destdir} | |||||
cd $here/devLib | cd $here/devLib | ||||
make install-deb INCLUDE='-I. -I../wiringPi' | |||||
make install-deb INCLUDE='-I. -I../wiringPi' DEB_DESTDIR=${deb_destdir} | |||||
cd $here/gpio | cd $here/gpio | ||||
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib | |||||
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir} | |||||
cd $here/debian-template | cd $here/debian-template | ||||
fakeroot dpkg-deb --build wiringPi | fakeroot dpkg-deb --build wiringPi | ||||
mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb | mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb | ||||
@@ -1,5 +1,5 @@ | |||||
Package: wiringpi | Package: wiringpi | ||||
Version: 2.46 | |||||
Version: 2.60 | |||||
Section: libraries | Section: libraries | ||||
Priority: optional | Priority: optional | ||||
Architecture: armhf | Architecture: armhf | ||||
@@ -36,10 +36,10 @@ DYNAMIC=libwiringPiDev.so.$(VERSION) | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O2 | DEBUG = -O2 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I. | INCLUDE = -I. | ||||
DEFS = -D_GNU_SOURCE | DEFS = -D_GNU_SOURCE | ||||
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC | |||||
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC $(EXTRA_CFLAGS) | |||||
LIBS = | LIBS = | ||||
@@ -105,15 +105,21 @@ install-static: $(STATIC) | |||||
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib | $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib | ||||
$Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib | $Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib | ||||
.PHONY: check-deb-destdir | |||||
check-deb-destdir: | |||||
ifndef DEB_DESTDIR | |||||
$(error DEB_DESTDIR is undefined) | |||||
endif | |||||
.PHONY: install-deb | .PHONY: install-deb | ||||
install-deb: $(DYNAMIC) | |||||
install-deb: $(DYNAMIC) check-deb-destdir | |||||
$Q echo "[Install Headers: deb]" | $Q echo "[Install Headers: deb]" | ||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include | |||||
$Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/include | |||||
$Q install -m 0644 $(HEADERS) $(DEB_DESTDIR)/usr/include | |||||
$Q echo "[Install Dynamic Lib: deb]" | $Q echo "[Install Dynamic Lib: deb]" | ||||
install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib | |||||
install -m 0755 libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) | |||||
ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so | |||||
install -m 0755 -d $(DEB_DESTDIR)/usr/lib | |||||
install -m 0755 libwiringPiDev.so.$(VERSION) $(DEB_DESTDIR)/usr/lib/libwiringPiDev.so.$(VERSION) | |||||
ln -sf $(DEB_DESTDIR)/usr/lib/libwiringPiDev.so.$(VERSION) $(DEB_DESTDIR)/usr/lib/libwiringPiDev.so | |||||
.PHONY: uninstall | .PHONY: uninstall | ||||
uninstall: | uninstall: | ||||
@@ -11,9 +11,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | ||||
@@ -28,9 +28,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt | ||||
@@ -28,9 +28,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | ||||
@@ -28,9 +28,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | ||||
@@ -28,9 +28,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | ||||
@@ -28,9 +28,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O3 | DEBUG = -O3 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I/usr/local/include | INCLUDE = -I/usr/local/include | ||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L/usr/local/lib | LDFLAGS = -L/usr/local/lib | ||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm | ||||
@@ -32,9 +32,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O2 | DEBUG = -O2 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I$(DESTDIR)$(PREFIX)/include | INCLUDE = -I$(DESTDIR)$(PREFIX)/include | ||||
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | ||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt | LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt | ||||
@@ -80,13 +80,19 @@ endif | |||||
$Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 | $Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 | ||||
$Q cp gpio.1 $(DESTDIR)$(PREFIX)/share/man/man1 | $Q cp gpio.1 $(DESTDIR)$(PREFIX)/share/man/man1 | ||||
.PHONY: check-deb-destdir | |||||
check-deb-destdir: | |||||
ifndef DEB_DESTDIR | |||||
$(error DEB_DESTDIR is undefined) | |||||
endif | |||||
.PHONY: install-deb | .PHONY: install-deb | ||||
install-deb: gpio | |||||
install-deb: gpio check-deb-destdir | |||||
$Q echo "[Install: deb]" | $Q echo "[Install: deb]" | ||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/bin | |||||
$Q install -m 0755 gpio ~/wiringPi/debian-template/wiringPi/usr/bin | |||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/share/man/man1 | |||||
$Q install -m 0644 gpio.1 ~/wiringPi/debian-template/wiringPi/usr/share/man/man1 | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/bin | |||||
$Q install -m 0755 gpio $(DEB_DESTDIR)/usr/bin | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/share/man/man1 | |||||
$Q install -m 0644 gpio.1 $(DEB_DESTDIR)/usr/share/man/man1 | |||||
.PHONY: uninstall | .PHONY: uninstall | ||||
uninstall: | uninstall: | ||||
@@ -337,7 +337,7 @@ Gordon Henderson | |||||
.SH "REPORTING BUGS" | .SH "REPORTING BUGS" | ||||
Please report bugs to <projects@drogon.net> | |||||
Please report bugs to https://github.com/WiringPi/WiringPi/issues | |||||
.SH COPYRIGHT | .SH COPYRIGHT | ||||
@@ -80,7 +80,7 @@ static char *alts [] = | |||||
"IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" | "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" | ||||
} ; | } ; | ||||
static int physToWpi [64] = | |||||
static int physToWpi [64] = | |||||
{ | { | ||||
-1, // 0 | -1, // 0 | ||||
-1, -1, // 1, 2 | -1, -1, // 1, 2 | ||||
@@ -113,7 +113,7 @@ static int physToWpi [64] = | |||||
-1, -1, -1, -1, -1, -1, -1, -1, -1 | -1, -1, -1, -1, -1, -1, -1, -1, -1 | ||||
} ; | } ; | ||||
static char *physNames [64] = | |||||
static char *physNames [64] = | |||||
{ | { | ||||
NULL, | NULL, | ||||
@@ -303,10 +303,16 @@ static void plus2header (int model) | |||||
printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; | printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; | ||||
else if (model == PI_MODEL_2) | else if (model == PI_MODEL_2) | ||||
printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; | printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; | ||||
else if (model == PI_MODEL_3) | |||||
printf (" +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_3P) | |||||
printf (" +-----+-----+---------+------+---+---Pi 3+--+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_3B) | |||||
printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_3BP) | |||||
printf (" +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_3AP) | |||||
printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_4B) | |||||
printf (" +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+\n") ; | |||||
else if (model == PI_MODEL_400) | |||||
printf (" +-----+-----+---------+------+---+---Pi 400-+---+------+---------+-----+-----+\n") ; | |||||
else | else | ||||
printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; | printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; | ||||
} | } | ||||
@@ -351,11 +357,13 @@ void doReadall (void) | |||||
/**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B)) | /**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B)) | ||||
abReadall (model, rev) ; | abReadall (model, rev) ; | ||||
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || | else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || | ||||
(model == PI_MODEL_2) || | |||||
(model == PI_MODEL_3) || (model == PI_MODEL_3P) || | |||||
(model == PI_MODEL_2) || | |||||
(model == PI_MODEL_3AP) || | |||||
(model == PI_MODEL_3B) || (model == PI_MODEL_3BP) || | |||||
(model == PI_MODEL_4B) || (model == PI_MODEL_400) || | |||||
(model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) | (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) | ||||
piPlusReadall (model) ; | piPlusReadall (model) ; | ||||
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3)) | |||||
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P) || (model == PI_MODEL_CM4)) | |||||
allReadall () ; | allReadall () ; | ||||
else | else | ||||
printf ("Oops - unable to determine board type... model: %d\n", model) ; | printf ("Oops - unable to determine board type... model: %d\n", model) ; | ||||
@@ -1,3 +1,3 @@ | |||||
#define VERSION "2.46" | |||||
#define VERSION "2.60" | |||||
#define VERSION_MAJOR 2 | #define VERSION_MAJOR 2 | ||||
#define VERSION_MINOR 46 | |||||
#define VERSION_MINOR 60 |
@@ -36,10 +36,10 @@ DYNAMIC=libwiringPi.so.$(VERSION) | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O2 | DEBUG = -O2 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I. | INCLUDE = -I. | ||||
DEFS = -D_GNU_SOURCE | DEFS = -D_GNU_SOURCE | ||||
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC | |||||
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC $(EXTRA_CFLAGS) | |||||
#CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC | #CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC | ||||
LIBS = -lm -lpthread -lrt -lcrypt | LIBS = -lm -lpthread -lrt -lcrypt | ||||
@@ -104,15 +104,21 @@ install: $(DYNAMIC) | |||||
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so | $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so | ||||
$Q $(LDCONFIG) | $Q $(LDCONFIG) | ||||
.PHONY: check-deb-destdir | |||||
check-deb-destdir: | |||||
ifndef DEB_DESTDIR | |||||
$(error DEB_DESTDIR is undefined) | |||||
endif | |||||
.PHONY: install-deb | .PHONY: install-deb | ||||
install-deb: $(DYNAMIC) | |||||
install-deb: $(DYNAMIC) check-deb-destdir | |||||
$Q echo "[Install Headers: deb]" | $Q echo "[Install Headers: deb]" | ||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include | |||||
$Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/include | |||||
$Q install -m 0644 $(HEADERS) $(DEB_DESTDIR)/usr/include | |||||
$Q echo "[Install Dynamic Lib: deb]" | $Q echo "[Install Dynamic Lib: deb]" | ||||
install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib | |||||
install -m 0755 libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) | |||||
ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so | |||||
install -m 0755 -d $(DEB_DESTDIR)/usr/lib | |||||
install -m 0755 libwiringPi.so.$(VERSION) $(DEB_DESTDIR)/usr/lib/libwiringPi.so.$(VERSION) | |||||
ln -sf $(DEB_DESTDIR)/usr/lib/libwiringPi.so.$(VERSION) $(DEB_DESTDIR)/usr/lib/libwiringPi.so | |||||
.PHONY: uninstall | .PHONY: uninstall | ||||
uninstall: | uninstall: | ||||
@@ -213,12 +213,13 @@ volatile unsigned int *_wiringPiTimerIrqRaw ; | |||||
// piGpioBase: | // piGpioBase: | ||||
// The base address of the GPIO memory mapped hardware IO | // The base address of the GPIO memory mapped hardware IO | ||||
#define GPIO_PERI_BASE_OLD 0x20000000 | |||||
#define GPIO_PERI_BASE_NEW 0x3F000000 | |||||
#define GPIO_PERI_BASE_OLD 0x20000000 | |||||
#define GPIO_PERI_BASE_2835 0x3F000000 | |||||
#define GPIO_PERI_BASE_2711 0xFE000000 | |||||
static volatile unsigned int piGpioBase = 0 ; | static volatile unsigned int piGpioBase = 0 ; | ||||
const char *piModelNames [16] = | |||||
const char *piModelNames [21] = | |||||
{ | { | ||||
"Model A", // 0 | "Model A", // 0 | ||||
"Model B", // 1 | "Model B", // 1 | ||||
@@ -233,9 +234,14 @@ const char *piModelNames [16] = | |||||
"CM3", // 10 | "CM3", // 10 | ||||
"Unknown11", // 11 | "Unknown11", // 11 | ||||
"Pi Zero-W", // 12 | "Pi Zero-W", // 12 | ||||
"Pi 3+", // 13 | |||||
"Unknown14", // 14 | |||||
"Pi 3B+", // 13 | |||||
"Pi 3A+", // 14 | |||||
"Unknown15", // 15 | "Unknown15", // 15 | ||||
"CM3+", // 16 | |||||
"Pi 4B", // 17 | |||||
"Unknown18", // 18 | |||||
"Pi 400", // 19 | |||||
"CM4", // 20 | |||||
} ; | } ; | ||||
const char *piRevisionNames [16] = | const char *piRevisionNames [16] = | ||||
@@ -283,9 +289,9 @@ const int piMemorySize [8] = | |||||
256, // 0 | 256, // 0 | ||||
512, // 1 | 512, // 1 | ||||
1024, // 2 | 1024, // 2 | ||||
0, // 3 | |||||
0, // 4 | |||||
0, // 5 | |||||
2048, // 3 | |||||
4096, // 4 | |||||
8192, // 5 | |||||
0, // 6 | 0, // 6 | ||||
0, // 7 | 0, // 7 | ||||
} ; | } ; | ||||
@@ -538,6 +544,14 @@ static uint8_t gpioToFEN [] = | |||||
#define GPPUD 37 | #define GPPUD 37 | ||||
/* 2711 has a different mechanism for pin pull-up/down/enable */ | |||||
#define GPPUPPDN0 57 /* Pin pull-up/down for pins 15:0 */ | |||||
#define GPPUPPDN1 58 /* Pin pull-up/down for pins 31:16 */ | |||||
#define GPPUPPDN2 59 /* Pin pull-up/down for pins 47:32 */ | |||||
#define GPPUPPDN3 60 /* Pin pull-up/down for pins 57:48 */ | |||||
static volatile unsigned int piGpioPupOffset = 0 ; | |||||
// gpioToPUDCLK | // gpioToPUDCLK | ||||
// (Word) offset to the Pull Up Down Clock regsiter | // (Word) offset to the Pull Up Down Clock regsiter | ||||
@@ -814,7 +828,7 @@ int piGpioLayout (void) | |||||
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) | for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) | ||||
*c = 0 ; | *c = 0 ; | ||||
if (wiringPiDebug) | if (wiringPiDebug) | ||||
printf ("piGpioLayout: Revision string: %s\n", line) ; | printf ("piGpioLayout: Revision string: %s\n", line) ; | ||||
@@ -883,7 +897,7 @@ int piBoardRev (void) | |||||
* So the distinction between boards that I can see is: | * So the distinction between boards that I can see is: | ||||
* | * | ||||
* 0000 - Error | * 0000 - Error | ||||
* 0001 - Not used | |||||
* 0001 - Not used | |||||
* | * | ||||
* Original Pi boards: | * Original Pi boards: | ||||
* 0002 - Model B, Rev 1, 256MB, Egoman | * 0002 - Model B, Rev 1, 256MB, Egoman | ||||
@@ -968,7 +982,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) | |||||
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) | for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) | ||||
*c = 0 ; | *c = 0 ; | ||||
if (wiringPiDebug) | if (wiringPiDebug) | ||||
printf ("piBoardId: Revision string: %s\n", line) ; | printf ("piBoardId: Revision string: %s\n", line) ; | ||||
@@ -1007,7 +1021,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) | |||||
bMfg = (revision & (0x0F << 16)) >> 16 ; | bMfg = (revision & (0x0F << 16)) >> 16 ; | ||||
bMem = (revision & (0x07 << 20)) >> 20 ; | bMem = (revision & (0x07 << 20)) >> 20 ; | ||||
bWarranty = (revision & (0x03 << 24)) != 0 ; | bWarranty = (revision & (0x03 << 24)) != 0 ; | ||||
*model = bType ; | *model = bType ; | ||||
*rev = bRev ; | *rev = bRev ; | ||||
*mem = bMem ; | *mem = bMem ; | ||||
@@ -1034,7 +1048,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) | |||||
// If longer than 4, we'll assume it's been overvolted | // If longer than 4, we'll assume it's been overvolted | ||||
*warranty = strlen (c) > 4 ; | *warranty = strlen (c) > 4 ; | ||||
// Extract last 4 characters: | // Extract last 4 characters: | ||||
c = c + strlen (c) - 4 ; | c = c + strlen (c) - 4 ; | ||||
@@ -1074,7 +1088,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) | |||||
else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; } | else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; } | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
@@ -1205,6 +1219,11 @@ void pwmSetRange (unsigned int range) | |||||
void pwmSetClock (int divisor) | void pwmSetClock (int divisor) | ||||
{ | { | ||||
uint32_t pwm_control ; | uint32_t pwm_control ; | ||||
if (piGpioBase == GPIO_PERI_BASE_2711) | |||||
{ | |||||
divisor = 540*divisor/192; | |||||
} | |||||
divisor &= 4095 ; | divisor &= 4095 ; | ||||
if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) | if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) | ||||
@@ -1260,7 +1279,7 @@ void gpioClockSet (int pin, int freq) | |||||
pin = physToGpio [pin] ; | pin = physToGpio [pin] ; | ||||
else if (wiringPiMode != WPI_MODE_GPIO) | else if (wiringPiMode != WPI_MODE_GPIO) | ||||
return ; | return ; | ||||
divi = 19200000 / freq ; | divi = 19200000 / freq ; | ||||
divr = 19200000 % freq ; | divr = 19200000 % freq ; | ||||
divf = (int)((double)divr * 4096.0 / 19200000.0) ; | divf = (int)((double)divr * 4096.0 / 19200000.0) ; | ||||
@@ -1504,11 +1523,36 @@ void pullUpDnControl (int pin, int pud) | |||||
else if (wiringPiMode != WPI_MODE_GPIO) | else if (wiringPiMode != WPI_MODE_GPIO) | ||||
return ; | return ; | ||||
*(gpio + GPPUD) = pud & 3 ; delayMicroseconds (5) ; | |||||
*(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ; | |||||
*(gpio + GPPUD) = 0 ; delayMicroseconds (5) ; | |||||
*(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ; | |||||
if (piGpioPupOffset == GPPUPPDN0) | |||||
{ | |||||
// Pi 4B pull up/down method | |||||
int pullreg = GPPUPPDN0 + (pin>>4); | |||||
int pullshift = (pin & 0xf) << 1; | |||||
unsigned int pullbits; | |||||
unsigned int pull; | |||||
switch (pud) | |||||
{ | |||||
case PUD_OFF: pull = 0; break; | |||||
case PUD_UP: pull = 1; break; | |||||
case PUD_DOWN: pull = 2; break; | |||||
default: return ; /* An illegal value */ | |||||
} | |||||
pullbits = *(gpio + pullreg); | |||||
pullbits &= ~(3 << pullshift); | |||||
pullbits |= (pull << pullshift); | |||||
*(gpio + pullreg) = pullbits; | |||||
} | |||||
else | |||||
{ | |||||
// legacy pull up/down method | |||||
*(gpio + GPPUD) = pud & 3 ; delayMicroseconds (5) ; | |||||
*(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ; | |||||
*(gpio + GPPUD) = 0 ; delayMicroseconds (5) ; | |||||
*(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ; | |||||
} | |||||
} | } | ||||
else // Extension module | else // Extension module | ||||
{ | { | ||||
@@ -1529,7 +1573,6 @@ int digitalRead (int pin) | |||||
{ | { | ||||
char c ; | char c ; | ||||
struct wiringPiNodeStruct *node = wiringPiNodes ; | struct wiringPiNodeStruct *node = wiringPiNodes ; | ||||
if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin | if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin | ||||
{ | { | ||||
/**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode | /**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode | ||||
@@ -1680,7 +1723,7 @@ void pwmWrite (int pin, int value) | |||||
/* | /* | ||||
* analogRead: | * analogRead: | ||||
* Read the analog value of a given Pin. | |||||
* Read the analog value of a given Pin. | |||||
* There is no on-board Pi analog hardware, | * There is no on-board Pi analog hardware, | ||||
* so this needs to go to a new node. | * so this needs to go to a new node. | ||||
********************************************************************************* | ********************************************************************************* | ||||
@@ -1699,7 +1742,7 @@ int analogRead (int pin) | |||||
/* | /* | ||||
* analogWrite: | * analogWrite: | ||||
* Write the analog value to the given Pin. | |||||
* Write the analog value to the given Pin. | |||||
* There is no on-board Pi analog hardware, | * There is no on-board Pi analog hardware, | ||||
* so this needs to go to a new node. | * so this needs to go to a new node. | ||||
********************************************************************************* | ********************************************************************************* | ||||
@@ -1748,7 +1791,7 @@ void pwmToneWrite (int pin, int freq) | |||||
* Write an 8-bit byte to the first 8 GPIO pins - try to do it as | * Write an 8-bit byte to the first 8 GPIO pins - try to do it as | ||||
* fast as possible. | * fast as possible. | ||||
* However it still needs 2 operations to set the bits, so any external | * However it still needs 2 operations to set the bits, so any external | ||||
* hardware must not rely on seeing a change as there will be a change | |||||
* hardware must not rely on seeing a change as there will be a change | |||||
* to set the outputs bits to zero, then another change to set the 1's | * to set the outputs bits to zero, then another change to set the 1's | ||||
* Reading is just bit fiddling. | * Reading is just bit fiddling. | ||||
* These are wiringPi pin numbers 0..7, or BCM_GPIO pin numbers | * These are wiringPi pin numbers 0..7, or BCM_GPIO pin numbers | ||||
@@ -1804,7 +1847,7 @@ unsigned int digitalReadByte (void) | |||||
data = (data << 1) | x ; | data = (data << 1) | x ; | ||||
} | } | ||||
} | } | ||||
else | |||||
else | |||||
{ | { | ||||
raw = *(gpio + gpioToGPLEV [0]) ; // First bank for these pins | raw = *(gpio + gpioToGPLEV [0]) ; // First bank for these pins | ||||
for (pin = 0 ; pin < 8 ; ++pin) | for (pin = 0 ; pin < 8 ; ++pin) | ||||
@@ -1861,7 +1904,7 @@ unsigned int digitalReadByte2 (void) | |||||
data = (data << 1) | x ; | data = (data << 1) | x ; | ||||
} | } | ||||
} | } | ||||
else | |||||
else | |||||
data = ((*(gpio + gpioToGPLEV [0])) >> 20) & 0xFF ; // First bank for these pins | data = ((*(gpio + gpioToGPLEV [0])) >> 20) & 0xFF ; // First bank for these pins | ||||
return data ; | return data ; | ||||
@@ -2006,7 +2049,7 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) | |||||
return wiringPiFailure (WPI_FATAL, "wiringPiISR: Can't find gpio program\n") ; | return wiringPiFailure (WPI_FATAL, "wiringPiISR: Can't find gpio program\n") ; | ||||
} | } | ||||
else // Parent, wait | else // Parent, wait | ||||
wait (NULL) ; | |||||
waitpid (pid, NULL, 0) ; | |||||
} | } | ||||
// Now pre-open the /sys/class node - but it may already be open if | // Now pre-open the /sys/class node - but it may already be open if | ||||
@@ -2239,7 +2282,9 @@ int wiringPiSetup (void) | |||||
piBoardId (&model, &rev, &mem, &maker, &overVolted) ; | piBoardId (&model, &rev, &mem, &maker, &overVolted) ; | ||||
if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3)) | |||||
if ((model == PI_MODEL_CM) || | |||||
(model == PI_MODEL_CM3) || | |||||
(model == PI_MODEL_CM3P)) | |||||
wiringPiMode = WPI_MODE_GPIO ; | wiringPiMode = WPI_MODE_GPIO ; | ||||
else | else | ||||
wiringPiMode = WPI_MODE_PINS ; | wiringPiMode = WPI_MODE_PINS ; | ||||
@@ -2264,16 +2309,25 @@ int wiringPiSetup (void) | |||||
case PI_ALPHA: case PI_MODEL_CM: | case PI_ALPHA: case PI_MODEL_CM: | ||||
case PI_MODEL_ZERO: case PI_MODEL_ZERO_W: | case PI_MODEL_ZERO: case PI_MODEL_ZERO_W: | ||||
piGpioBase = GPIO_PERI_BASE_OLD ; | piGpioBase = GPIO_PERI_BASE_OLD ; | ||||
piGpioPupOffset = GPPUD ; | |||||
break ; | |||||
case PI_MODEL_4B: | |||||
case PI_MODEL_400: | |||||
case PI_MODEL_CM4: | |||||
piGpioBase = GPIO_PERI_BASE_2711 ; | |||||
piGpioPupOffset = GPPUPPDN0 ; | |||||
break ; | break ; | ||||
default: | default: | ||||
piGpioBase = GPIO_PERI_BASE_NEW ; | |||||
piGpioBase = GPIO_PERI_BASE_2835 ; | |||||
piGpioPupOffset = GPPUD ; | |||||
break ; | break ; | ||||
} | } | ||||
// Open the master /dev/ memory control device | // Open the master /dev/ memory control device | ||||
// Device strategy: December 2016: | // Device strategy: December 2016: | ||||
// Try /dev/mem. If that fails, then | |||||
// Try /dev/mem. If that fails, then | |||||
// try /dev/gpiomem. If that fails then game over. | // try /dev/gpiomem. If that fails then game over. | ||||
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC)) < 0) | if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC)) < 0) | ||||
@@ -2311,13 +2365,13 @@ int wiringPiSetup (void) | |||||
pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ; | pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ; | ||||
if (pwm == MAP_FAILED) | if (pwm == MAP_FAILED) | ||||
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ; | return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ; | ||||
// Clock control (needed for PWM) | // Clock control (needed for PWM) | ||||
clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_CLOCK_BASE) ; | clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_CLOCK_BASE) ; | ||||
if (clk == MAP_FAILED) | if (clk == MAP_FAILED) | ||||
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ; | return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ; | ||||
// The drive pads | // The drive pads | ||||
pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ; | pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ; | ||||
@@ -2437,7 +2491,7 @@ int wiringPiSetupSys (void) | |||||
// Open and scan the directory, looking for exported GPIOs, and pre-open | // Open and scan the directory, looking for exported GPIOs, and pre-open | ||||
// the 'value' interface to speed things up for later | // the 'value' interface to speed things up for later | ||||
for (pin = 0 ; pin < 64 ; ++pin) | for (pin = 0 ; pin < 64 ; ++pin) | ||||
{ | { | ||||
sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ; | sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ; | ||||
@@ -95,11 +95,16 @@ | |||||
#define PI_ALPHA 5 | #define PI_ALPHA 5 | ||||
#define PI_MODEL_CM 6 | #define PI_MODEL_CM 6 | ||||
#define PI_MODEL_07 7 | #define PI_MODEL_07 7 | ||||
#define PI_MODEL_3 8 | |||||
#define PI_MODEL_3B 8 | |||||
#define PI_MODEL_ZERO 9 | #define PI_MODEL_ZERO 9 | ||||
#define PI_MODEL_CM3 10 | #define PI_MODEL_CM3 10 | ||||
#define PI_MODEL_ZERO_W 12 | #define PI_MODEL_ZERO_W 12 | ||||
#define PI_MODEL_3P 13 | |||||
#define PI_MODEL_3BP 13 | |||||
#define PI_MODEL_3AP 14 | |||||
#define PI_MODEL_CM3P 16 | |||||
#define PI_MODEL_4B 17 | |||||
#define PI_MODEL_400 19 | |||||
#define PI_MODEL_CM4 20 | |||||
#define PI_VERSION_1 0 | #define PI_VERSION_1 0 | ||||
#define PI_VERSION_1_1 1 | #define PI_VERSION_1_1 1 | ||||
@@ -111,7 +116,7 @@ | |||||
#define PI_MAKER_EMBEST 2 | #define PI_MAKER_EMBEST 2 | ||||
#define PI_MAKER_UNKNOWN 3 | #define PI_MAKER_UNKNOWN 3 | ||||
extern const char *piModelNames [16] ; | |||||
extern const char *piModelNames [21] ; | |||||
extern const char *piRevisionNames [16] ; | extern const char *piRevisionNames [16] ; | ||||
extern const char *piMakerNames [16] ; | extern const char *piMakerNames [16] ; | ||||
extern const int piMemorySize [ 8] ; | extern const int piMemorySize [ 8] ; | ||||
@@ -132,7 +137,7 @@ extern const int piMemorySize [ 8] ; | |||||
// wiringPiNodeStruct: | // wiringPiNodeStruct: | ||||
// This describes additional device nodes in the extended wiringPi | // This describes additional device nodes in the extended wiringPi | ||||
// 2.0 scheme of things. | // 2.0 scheme of things. | ||||
// It's a simple linked list for now, but will hopefully migrate to | |||||
// It's a simple linked list for now, but will hopefully migrate to | |||||
// a binary tree for efficiency reasons - but then again, the chances | // a binary tree for efficiency reasons - but then again, the chances | ||||
// of more than 1 or 2 devices being added are fairly slim, so who | // of more than 1 or 2 devices being added are fairly slim, so who | ||||
// knows.... | // knows.... | ||||
@@ -209,7 +214,7 @@ extern void pwmWrite (int pin, int value) ; | |||||
extern int analogRead (int pin) ; | extern int analogRead (int pin) ; | ||||
extern void analogWrite (int pin, int value) ; | extern void analogWrite (int pin, int value) ; | ||||
// PiFace specifics | |||||
// PiFace specifics | |||||
// (Deprecated) | // (Deprecated) | ||||
extern int wiringPiSetupPiFace (void) ; | extern int wiringPiSetupPiFace (void) ; | ||||
@@ -23,7 +23,9 @@ | |||||
*/ | */ | ||||
#include <stdio.h> | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <stdlib.h> | |||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <string.h> | #include <string.h> | ||||
@@ -39,8 +41,8 @@ | |||||
// The SPI bus parameters | // The SPI bus parameters | ||||
// Variables as they need to be passed as pointers later on | // Variables as they need to be passed as pointers later on | ||||
static const char *spiDev0 = "/dev/spidev0.0" ; | |||||
static const char *spiDev1 = "/dev/spidev0.1" ; | |||||
//static const char *spiDev0 = "/dev/spidev0.0" ; | |||||
//static const char *spiDev1 = "/dev/spidev0.1" ; | |||||
static const uint8_t spiBPW = 8 ; | static const uint8_t spiBPW = 8 ; | ||||
static const uint16_t spiDelay = 0 ; | static const uint16_t spiDelay = 0 ; | ||||
@@ -100,11 +102,16 @@ int wiringPiSPIDataRW (int channel, unsigned char *data, int len) | |||||
int wiringPiSPISetupMode (int channel, int speed, int mode) | int wiringPiSPISetupMode (int channel, int speed, int mode) | ||||
{ | { | ||||
int fd ; | int fd ; | ||||
char spiDev [32] ; | |||||
mode &= 3 ; // Mode is 0, 1, 2 or 3 | mode &= 3 ; // Mode is 0, 1, 2 or 3 | ||||
channel &= 1 ; // Channel is 0 or 1 | |||||
if ((fd = open (channel == 0 ? spiDev0 : spiDev1, O_RDWR)) < 0) | |||||
// Channel can be anything - lets hope for the best | |||||
// channel &= 1 ; // Channel is 0 or 1 | |||||
snprintf (spiDev, 31, "/dev/spidev0.%d", channel) ; | |||||
if ((fd = open (spiDev, O_RDWR)) < 0) | |||||
return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; | return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; | ||||
spiSpeeds [channel] = speed ; | spiSpeeds [channel] = speed ; | ||||
@@ -31,9 +31,9 @@ endif | |||||
#DEBUG = -g -O0 | #DEBUG = -g -O0 | ||||
DEBUG = -O2 | DEBUG = -O2 | ||||
CC = gcc | |||||
CC ?= gcc | |||||
INCLUDE = -I$(DESTDIR)$(PREFIX)/include | INCLUDE = -I$(DESTDIR)$(PREFIX)/include | ||||
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe | |||||
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS) | |||||
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib | ||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt | LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt | ||||
@@ -78,10 +78,10 @@ install: wiringpid | |||||
.PHONY: install-deb | .PHONY: install-deb | ||||
install-deb: gpio | install-deb: gpio | ||||
$Q echo "[Install: deb]" | $Q echo "[Install: deb]" | ||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/bin | |||||
$Q install -m 0755 gpio ~/wiringPi/debian-template/wiringPi/usr/bin | |||||
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/man/man1 | |||||
$Q install -m 0644 gpio.1 ~/wiringPi/debian-template/wiringPi/man/man1 | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/bin | |||||
$Q install -m 0755 gpio $(DEB_DESTDIR)/usr/bin | |||||
$Q install -m 0755 -d $(DEB_DESTDIR)/man/man1 | |||||
$Q install -m 0644 gpio.1 $(DEB_DESTDIR)/man/man1 | |||||
.PHONY: uninstall | .PHONY: uninstall | ||||
uninstall: | uninstall: | ||||
@@ -40,5 +40,4 @@ struct drcNetComStruct | |||||
uint32_t pin ; | uint32_t pin ; | ||||
uint32_t cmd ; | uint32_t cmd ; | ||||
uint32_t data ; | uint32_t data ; | ||||
} comDat ; | |||||
}; |