Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6501213f0 | |||
| 6b2edc5b4e | |||
| 5c6bab7d42 | |||
| 6d9ce35f00 | |||
| f9ff3b4d35 | |||
| 50b7c5ed7d | |||
| 7d8188d0bf | |||
| 33fbcd7e50 | |||
| 5bbb6e34b8 | |||
| 651136a110 | |||
| 1f908c5eed | |||
| 2a8e57a1c7 | |||
| 16a23e3688 | |||
| 9aed9a4415 | |||
| 41f941a78e | |||
| a49f696232 | |||
| aca883a051 |
-36
@@ -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
|
||||
@@ -0,0 +1,33 @@
|
||||
WiringPi (Unofficial Mirror/Fork)
|
||||
=================================
|
||||
|
||||
This is an unofficial mirror/fork 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, plus a fork facilitating updates
|
||||
to support newer hardware (primarily for use by the ports) and fix bugs.
|
||||
|
||||
* 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.
|
||||
|
||||
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 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 may not be accepted.
|
||||
|
||||
For support, comments, questions, etc please join the WiringPi Discord channel: https://discord.gg/SM4WUVG
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash -e
|
||||
#!/bin/sh -e
|
||||
|
||||
# build
|
||||
# Simple wiringPi build and install script
|
||||
@@ -43,47 +43,6 @@ check_make_ok() {
|
||||
fi
|
||||
}
|
||||
|
||||
select_boards()
|
||||
{
|
||||
local cnt=0
|
||||
local choice
|
||||
local call=${1}
|
||||
|
||||
boards=("clockworkpi-a04" "clockworkpi-a06" )
|
||||
|
||||
if [[ -f /etc/armbian-release ]]; then
|
||||
|
||||
source /etc/armbian-release
|
||||
|
||||
else
|
||||
|
||||
printf "All available boards:\n"
|
||||
for var in ${boards[@]} ; do
|
||||
printf "%4d. %s\n" $cnt ${boards[$cnt]}
|
||||
((cnt+=1))
|
||||
done
|
||||
|
||||
while true ; do
|
||||
read -p "Choice: " choice
|
||||
if [ -z "${choice}" ] ; then
|
||||
continue
|
||||
fi
|
||||
if [ -z "${choice//[0-9]/}" ] ; then
|
||||
if [ $choice -ge 0 -a $choice -lt $cnt ] ; then
|
||||
export BOARD="${boards[$choice]}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
printf "Invalid input ...\n"
|
||||
done
|
||||
fi
|
||||
|
||||
[[ $BOARD == clockworkpi-a04 ]] && BOARD=clockworkpi-a04-h6
|
||||
[[ $BOARD == clockworkpi-a06 ]] && BOARD=clockworkpi-a06-rk3399
|
||||
|
||||
export BOARD="${BOARD}"
|
||||
}
|
||||
|
||||
sudo=${WIRINGPI_SUDO-sudo}
|
||||
|
||||
if [ x$1 = "xclean" ]; then
|
||||
@@ -125,14 +84,15 @@ fi
|
||||
|
||||
if [ x$1 = "xdebian" ]; then
|
||||
here=`pwd`
|
||||
deb_destdir=${here}/debian-template/wiringPi
|
||||
cd debian-template/wiringPi
|
||||
rm -rf usr
|
||||
cd $here/wiringPi
|
||||
make install-deb
|
||||
make install-deb DEB_DESTDIR=${deb_destdir}
|
||||
cd $here/devLib
|
||||
make install-deb INCLUDE='-I. -I../wiringPi'
|
||||
make install-deb INCLUDE='-I. -I../wiringPi' DEB_DESTDIR=${deb_destdir}
|
||||
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
|
||||
fakeroot dpkg-deb --build wiringPi
|
||||
mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
|
||||
@@ -144,8 +104,6 @@ if [ x$1 != "x" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
select_boards
|
||||
|
||||
echo "wiringPi Build script"
|
||||
echo "====================="
|
||||
echo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package: wiringpi
|
||||
Version: 2.50
|
||||
Version: 2.60
|
||||
Section: libraries
|
||||
Priority: optional
|
||||
Architecture: armhf
|
||||
|
||||
Regular → Executable
Regular → Executable
+14
-8
@@ -36,10 +36,10 @@ DYNAMIC=libwiringPiDev.so.$(VERSION)
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O2
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I.
|
||||
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 =
|
||||
|
||||
@@ -105,15 +105,21 @@ install-static: $(STATIC)
|
||||
$Q install -m 0755 -d $(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
|
||||
install-deb: $(DYNAMIC)
|
||||
install-deb: $(DYNAMIC) check-deb-destdir
|
||||
$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]"
|
||||
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
|
||||
uninstall:
|
||||
|
||||
@@ -11,9 +11,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt
|
||||
|
||||
@@ -28,9 +28,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
|
||||
@@ -28,9 +28,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
|
||||
@@ -28,9 +28,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
|
||||
@@ -28,9 +28,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O3
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I/usr/local/include
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
|
||||
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
|
||||
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
#ifndef _CPI_H_
|
||||
#define _CPI_H_
|
||||
|
||||
extern int wiringPiSetupRaw (void);
|
||||
extern void CPiBoardId (int *model, int *rev, int *mem, int *maker, int *warranty);
|
||||
extern int CPi_get_gpio_mode(int pin);
|
||||
extern int CPi_digitalRead(int pin);
|
||||
extern void CPi_digitalWrite(int pin, int value);
|
||||
extern void CPiReadAll(void);
|
||||
extern void CPiReadAllRaw(void);
|
||||
|
||||
#endif
|
||||
@@ -1,141 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <wiringPi.h>
|
||||
#include "CPi.h"
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
|
||||
int bcmToGpioCPi[64] =
|
||||
{
|
||||
106, 107, // 0, 1
|
||||
104, 10, // 2, 3
|
||||
3, 9, // 4 5
|
||||
4, 90, // 6, 7
|
||||
92, 158, // 8, 9
|
||||
156, 105, //10,11
|
||||
146, 150, //12,13
|
||||
81, 80, //14,15
|
||||
|
||||
82, 83, //16,17
|
||||
131, 132, //18,19
|
||||
134, 135, //20,21
|
||||
89, 88, //22,23
|
||||
84, 85, //24,25
|
||||
86, 87, //26,27
|
||||
112, 113, //28,29
|
||||
109, 157, //30,31
|
||||
|
||||
148, 147, //32,33
|
||||
100, 101, //34,35
|
||||
102, 103, //36,37
|
||||
97, 98, //38,39
|
||||
99, 96, //40,41
|
||||
110, 111, //42,43
|
||||
64, 65, //44,45
|
||||
-1, -1, //46,47
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
int bcmToGpioCPi[64] =
|
||||
{
|
||||
106, 107, // 0, 1
|
||||
104, 10, // 2, 3
|
||||
3, 9, // 4 5
|
||||
4, 90, // 6, 7
|
||||
92, 158, // 8, 9
|
||||
156, 105, //10,11
|
||||
146, 150, //12,13
|
||||
81, 80, //14,15
|
||||
|
||||
82, 83, //16,17
|
||||
131, 132, //18,19
|
||||
134, 135, //20,21
|
||||
89, 88, //22,23
|
||||
84, 85, //24,25
|
||||
86, 87, //26,27
|
||||
112, 113, //28,29
|
||||
109, 157, //30,31
|
||||
|
||||
148, 147, //32,33
|
||||
100, 101, //34,35
|
||||
102, 103, //36,37
|
||||
97, 98, //38,39
|
||||
99, 96, //40,41
|
||||
110, 111, //42,43
|
||||
64, 65, //44,45
|
||||
-1, -1, //46,47
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static char *alts [] =
|
||||
{
|
||||
"IN", "OUT", "ALT2", "ALT3", "ALT4", "ALT5", "ALT6", "OFF"
|
||||
} ;
|
||||
|
||||
void CPiReadAll(void)
|
||||
{
|
||||
int pin, pin2;
|
||||
int tmp = wiringPiDebug;
|
||||
wiringPiDebug = FALSE;
|
||||
|
||||
printf (" +-----+------+------+---+-----+------+------+---+\n");
|
||||
printf (" | BCM | GPIO | Mode | V | BCM | GPIO | Mode | V |\n");
|
||||
printf (" +-----+------+------+---+-----+------+------+---+\n");
|
||||
|
||||
for (pin = 0 ; pin < 23; pin ++) {
|
||||
printf (" | %3d", pin);
|
||||
printf (" | %4d", bcmToGpioCPi[pin]);
|
||||
printf (" | %4s", alts [CPi_get_gpio_mode(bcmToGpioCPi[pin])]);
|
||||
printf (" | %d", CPi_digitalRead(bcmToGpioCPi[pin])) ;
|
||||
pin2 = pin + 23;
|
||||
printf (" | %3d", pin2);
|
||||
printf (" | %4d", bcmToGpioCPi[pin2]);
|
||||
printf (" | %4s", alts [CPi_get_gpio_mode(bcmToGpioCPi[pin2])]);
|
||||
printf (" | %d", CPi_digitalRead(bcmToGpioCPi[pin2])) ;
|
||||
printf (" |\n") ;
|
||||
}
|
||||
|
||||
printf (" +-----+------+------+---+-----+------+------+---+\n");
|
||||
printf (" | BCM | GPIO | Mode | V | BCM | GPIO | Mode | V |\n");
|
||||
printf (" +-----+------+------+---+-----+------+------+---+\n");
|
||||
|
||||
wiringPiDebug = tmp;
|
||||
}
|
||||
|
||||
void CPiReadAllRaw(void)
|
||||
{
|
||||
int pin, pin2, i;
|
||||
int tmp = wiringPiDebug;
|
||||
wiringPiDebug = FALSE;
|
||||
|
||||
printf (" +------+------+---+------+------+---+------+------+---+------+------+---+------+------+---+\n");
|
||||
printf (" | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V |\n");
|
||||
printf (" +------+------+---+------+------+---+------+------+---+------+------+---+------+------+---+\n");
|
||||
|
||||
for (pin = 0 ; pin < 32; pin++) {
|
||||
pin2 = pin;
|
||||
for(i = 0; i < 5; i++) {
|
||||
printf (" | %4d", pin2) ;
|
||||
printf (" | %4s", alts [CPi_get_gpio_mode(pin2)]) ;
|
||||
printf (" | %d", CPi_digitalRead(pin2)) ;
|
||||
pin2 += 32;
|
||||
}
|
||||
printf (" |\n") ;
|
||||
}
|
||||
|
||||
printf (" +------+------+---+------+------+---+------+------+---+------+------+---+------+------+---+\n");
|
||||
printf (" | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V | GPIO | Mode | V |\n");
|
||||
printf (" +------+------+---+------+------+---+------+------+---+------+------+---+------+------+---+\n");
|
||||
|
||||
wiringPiDebug = tmp;
|
||||
}
|
||||
|
||||
+15
-23
@@ -32,31 +32,17 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O2
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
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
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
|
||||
|
||||
ifeq ($(BOARD),)
|
||||
BOARD = clockworkpi-a06-rk3399
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD), clockworkpi-a04-h6)
|
||||
EXTRA_CFLAGS = -DCONFIG_CLOCKWORKPI_A04
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD), clockworkpi-a06-rk3399)
|
||||
EXTRA_CFLAGS = -DCONFIG_CLOCKWORKPI_A06
|
||||
endif
|
||||
|
||||
EXTRA_CFLAGS += -DCONFIG_CLOCKWORKPI
|
||||
|
||||
# May not need to alter anything below this line
|
||||
###############################################################################
|
||||
|
||||
SRC = gpio.c readall.c CPi_readall.c
|
||||
SRC = gpio.c readall.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
@@ -71,7 +57,7 @@ gpio: $(OBJ)
|
||||
|
||||
.c.o:
|
||||
$Q echo [Compile] $<
|
||||
$Q $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@
|
||||
$Q $(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@@ -94,13 +80,19 @@ endif
|
||||
$Q mkdir -p $(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
|
||||
install-deb: gpio
|
||||
install-deb: gpio check-deb-destdir
|
||||
$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
|
||||
uninstall:
|
||||
|
||||
+4
-124
@@ -42,10 +42,6 @@
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
#include "CPi.h"
|
||||
#endif
|
||||
|
||||
extern int wiringPiDebug ;
|
||||
|
||||
// External functions I can't be bothered creating a separate .h file for:
|
||||
@@ -746,18 +742,7 @@ void doMode (int argc, char *argv [])
|
||||
pin = atoi (argv [2]) ;
|
||||
|
||||
mode = argv [3] ;
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "input") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "out") == 0) pinMode (pin, OUTPUT) ;
|
||||
else if (strcasecmp (mode, "output") == 0) pinMode (pin, OUTPUT) ;
|
||||
else if (strcasecmp (mode, "alt2") == 0) pinModeAlt (pin, 0b010) ;
|
||||
else if (strcasecmp (mode, "alt3") == 0) pinModeAlt (pin, 0b011) ;
|
||||
else if (strcasecmp (mode, "alt4") == 0) pinModeAlt (pin, 0b100) ;
|
||||
else if (strcasecmp (mode, "alt5") == 0) pinModeAlt (pin, 0b101) ;
|
||||
else if (strcasecmp (mode, "alt6") == 0) pinModeAlt (pin, 0b110) ;
|
||||
else if (strcasecmp (mode, "alt7") == 0) pinModeAlt (pin, 0b111) ;
|
||||
#else
|
||||
|
||||
/**/ if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "input") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "out") == 0) pinMode (pin, OUTPUT) ;
|
||||
@@ -775,7 +760,6 @@ void doMode (int argc, char *argv [])
|
||||
else if (strcasecmp (mode, "alt3") == 0) pinModeAlt (pin, 0b111) ;
|
||||
else if (strcasecmp (mode, "alt4") == 0) pinModeAlt (pin, 0b011) ;
|
||||
else if (strcasecmp (mode, "alt5") == 0) pinModeAlt (pin, 0b010) ;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Invalid mode: %s. Should be in/out/pwm/clock/up/down/tri\n", argv [1], mode) ;
|
||||
@@ -1315,90 +1299,6 @@ static void doVersion (char *argv [])
|
||||
printf (" * Root or sudo required for GPIO access.\n") ;
|
||||
}
|
||||
|
||||
static void doReadRaw (int argc, char *argv [])
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
int pin, val ;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf (stderr, "Usage: %s readraw pin\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
pin = atoi (argv [2]) ;
|
||||
val = CPi_digitalRead(pin);
|
||||
|
||||
printf ("%s\n", val == 0 ? "0" : "1") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void doWriteRaw (int argc, char *argv [])
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
int pin, val ;
|
||||
|
||||
if (argc != 4) {
|
||||
fprintf (stderr, "Usage: %s writeraw pin value\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
pin = atoi (argv [2]) ;
|
||||
|
||||
if ((strcasecmp (argv [3], "up") == 0) || (strcasecmp (argv [3], "on") == 0))
|
||||
val = 1 ;
|
||||
else if ((strcasecmp (argv [3], "down") == 0) || (strcasecmp (argv [3], "off") == 0))
|
||||
val = 0 ;
|
||||
else
|
||||
val = atoi (argv [3]) ;
|
||||
|
||||
if (val == 0)
|
||||
CPi_digitalWrite (pin, LOW) ;
|
||||
else
|
||||
CPi_digitalWrite (pin, HIGH) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void doModeRaw (int argc, char *argv [])
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
int pin ;
|
||||
char *mode ;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s mode pin mode\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
wiringPiSetupRaw();
|
||||
|
||||
pin = atoi (argv [2]) ;
|
||||
|
||||
mode = argv [3] ;
|
||||
|
||||
/**/ if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "input") == 0) pinMode (pin, INPUT) ;
|
||||
else if (strcasecmp (mode, "out") == 0) pinMode (pin, OUTPUT) ;
|
||||
else if (strcasecmp (mode, "output") == 0) pinMode (pin, OUTPUT) ;
|
||||
else if (strcasecmp (mode, "pwm") == 0) pinMode (pin, PWM_OUTPUT) ;
|
||||
else if (strcasecmp (mode, "pwmTone") == 0) pinMode (pin, PWM_TONE_OUTPUT) ;
|
||||
else if (strcasecmp (mode, "clock") == 0) pinMode (pin, GPIO_CLOCK) ;
|
||||
else if (strcasecmp (mode, "up") == 0) pullUpDnControl (pin, PUD_UP) ;
|
||||
else if (strcasecmp (mode, "down") == 0) pullUpDnControl (pin, PUD_DOWN) ;
|
||||
else if (strcasecmp (mode, "tri") == 0) pullUpDnControl (pin, PUD_OFF) ;
|
||||
else if (strcasecmp (mode, "off") == 0) pullUpDnControl (pin, PUD_OFF) ;
|
||||
else if (strcasecmp (mode, "alt2") == 0) pinModeAlt (pin, 0b010) ;
|
||||
else if (strcasecmp (mode, "alt3") == 0) pinModeAlt (pin, 0b011) ;
|
||||
else if (strcasecmp (mode, "alt4") == 0) pinModeAlt (pin, 0b100) ;
|
||||
else if (strcasecmp (mode, "alt5") == 0) pinModeAlt (pin, 0b101) ;
|
||||
else if (strcasecmp (mode, "alt6") == 0) pinModeAlt (pin, 0b110) ;
|
||||
else if (strcasecmp (mode, "alt7") == 0) pinModeAlt (pin, 0b111) ;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Invalid mode: %s. Should be in/out/pwm/clock/up/down/tri\n", argv [1], mode) ;
|
||||
exit (1) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* main:
|
||||
@@ -1476,7 +1376,7 @@ int main (int argc, char *argv [])
|
||||
fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
|
||||
exit (EXIT_FAILURE) ;
|
||||
}
|
||||
#ifndef CONFIG_CLOCKWORKPI
|
||||
|
||||
// Initial test for /sys/class/gpio operations:
|
||||
|
||||
/**/ if (strcasecmp (argv [1], "exports" ) == 0) { doExports (argc, argv) ; return 0 ; }
|
||||
@@ -1498,7 +1398,7 @@ int main (int argc, char *argv [])
|
||||
|
||||
if (strcasecmp (argv [1], "gbr" ) == 0) { doGbr (argc, argv) ; return 0 ; }
|
||||
if (strcasecmp (argv [1], "gbw" ) == 0) { doGbw (argc, argv) ; return 0 ; }
|
||||
#endif
|
||||
|
||||
// Check for allreadall command, force Gpio mode
|
||||
|
||||
if (strcasecmp (argv [1], "allreadall") == 0)
|
||||
@@ -1553,16 +1453,7 @@ int main (int argc, char *argv [])
|
||||
--argc ;
|
||||
wpMode = WPI_MODE_UNINITIALISED ;
|
||||
}
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
else if (strcasecmp (argv [1], "-r") == 0)
|
||||
{
|
||||
wiringPiSetupRaw();
|
||||
for (i = 2 ; i < argc ; ++i)
|
||||
argv [i - 1] = argv [i] ;
|
||||
--argc ;
|
||||
wpMode = WPI_MODE_GPIO ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Default to wiringPi mode
|
||||
|
||||
else
|
||||
@@ -1603,16 +1494,6 @@ int main (int argc, char *argv [])
|
||||
exit (EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
/**/ if (strcasecmp (argv [1], "mode" ) == 0) doMode (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "moderaw" ) == 0) doModeRaw (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "read" ) == 0) doRead (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "readraw" ) == 0) doReadRaw (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "write" ) == 0) doWrite (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "writeraw" ) == 0) doWriteRaw (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "readall" ) == 0) CPiReadAll () ;
|
||||
else if (strcasecmp (argv [1], "readallraw" ) == 0) CPiReadAllRaw () ;
|
||||
#else
|
||||
// Core wiringPi functions
|
||||
|
||||
/**/ if (strcasecmp (argv [1], "mode" ) == 0) doMode (argc, argv) ;
|
||||
@@ -1647,7 +1528,6 @@ int main (int argc, char *argv [])
|
||||
else if (strcasecmp (argv [1], "rbd" ) == 0) doReadByte (argc, argv, FALSE) ;
|
||||
else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ;
|
||||
else if (strcasecmp (argv [1], "wfi" ) == 0) doWfi (argc, argv) ;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
|
||||
|
||||
+6
-10
@@ -35,10 +35,6 @@
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
#include "CPi.h"
|
||||
#endif
|
||||
|
||||
extern int wpMode ;
|
||||
|
||||
#ifndef TRUE
|
||||
@@ -84,7 +80,7 @@ static char *alts [] =
|
||||
"IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3"
|
||||
} ;
|
||||
|
||||
static int physToWpi [64] =
|
||||
static int physToWpi [64] =
|
||||
{
|
||||
-1, // 0
|
||||
-1, -1, // 1, 2
|
||||
@@ -117,7 +113,7 @@ static int physToWpi [64] =
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
} ;
|
||||
|
||||
static char *physNames [64] =
|
||||
static char *physNames [64] =
|
||||
{
|
||||
NULL,
|
||||
|
||||
@@ -313,6 +309,8 @@ static void plus2header (int model)
|
||||
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
|
||||
printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ;
|
||||
}
|
||||
@@ -345,9 +343,7 @@ static void piPlusReadall (int model)
|
||||
void doReadall (void)
|
||||
{
|
||||
int model, rev, mem, maker, overVolted ;
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiReadAll();
|
||||
#else
|
||||
|
||||
if (wiringPiNodes != NULL) // External readall
|
||||
{
|
||||
doReadallExternal () ;
|
||||
@@ -362,13 +358,13 @@ void doReadall (void)
|
||||
(model == PI_MODEL_2) ||
|
||||
(model == PI_MODEL_3AP) ||
|
||||
(model == PI_MODEL_3B) || (model == PI_MODEL_3BP) ||
|
||||
(model == PI_MODEL_4B) ||
|
||||
(model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W))
|
||||
piPlusReadall (model) ;
|
||||
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || ((model == PI_MODEL_CM3P)))
|
||||
allReadall () ;
|
||||
else
|
||||
printf ("Oops - unable to determine board type... model: %d\n", model) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#define VERSION "2.50"
|
||||
#define VERSION "2.60"
|
||||
#define VERSION_MAJOR 2
|
||||
#define VERSION_MINOR 50
|
||||
#define VERSION_MINOR 60
|
||||
|
||||
+16
-25
@@ -36,28 +36,14 @@ DYNAMIC=libwiringPi.so.$(VERSION)
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O2
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
INCLUDE = -I.
|
||||
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
|
||||
|
||||
LIBS = -lm -lpthread -lrt -lcrypt
|
||||
|
||||
ifeq ($(BOARD),)
|
||||
BOARD = clockworkpi-a06-rk3399
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD), clockworkpi-a04-h6)
|
||||
EXTRA_CFLAGS = -DCONFIG_CLOCKWORKPI_A04
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD), clockworkpi-a06-rk3399)
|
||||
EXTRA_CFLAGS = -DCONFIG_CLOCKWORKPI_A06
|
||||
endif
|
||||
|
||||
EXTRA_CFLAGS += -DCONFIG_CLOCKWORKPI
|
||||
|
||||
###############################################################################
|
||||
|
||||
SRC = wiringPi.c \
|
||||
@@ -75,8 +61,7 @@ SRC = wiringPi.c \
|
||||
bmp180.c htu21d.c ds18b20.c rht03.c \
|
||||
drcSerial.c drcNet.c \
|
||||
pseudoPins.c \
|
||||
wpiExtensions.c \
|
||||
wiringCPi.c
|
||||
wpiExtensions.c
|
||||
|
||||
HEADERS = $(shell ls *.h)
|
||||
|
||||
@@ -94,7 +79,7 @@ $(DYNAMIC): $(OBJ)
|
||||
|
||||
.c.o:
|
||||
$Q echo [Compile] $<
|
||||
$Q $(CC) -c $(EXTRA_CFLAGS) $(CFLAGS) $< -o $@
|
||||
$Q $(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
@@ -119,15 +104,21 @@ install: $(DYNAMIC)
|
||||
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
|
||||
$Q $(LDCONFIG)
|
||||
|
||||
.PHONY: check-deb-destdir
|
||||
check-deb-destdir:
|
||||
ifndef DEB_DESTDIR
|
||||
$(error DEB_DESTDIR is undefined)
|
||||
endif
|
||||
|
||||
.PHONY: install-deb
|
||||
install-deb: $(DYNAMIC)
|
||||
install-deb: $(DYNAMIC) check-deb-destdir
|
||||
$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]"
|
||||
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
|
||||
uninstall:
|
||||
|
||||
@@ -1,632 +0,0 @@
|
||||
#include "wiringPi.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "wiringCPi.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <limits.h>
|
||||
#include "softPwm.h"
|
||||
#include "softTone.h"
|
||||
|
||||
|
||||
static int wpimode = -1 ;
|
||||
#define WPI_MODE_BCM 0
|
||||
#define WPI_MODE_RAW 1
|
||||
#define BLOCK_SIZE (4*1024)
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
|
||||
int CPI_PIN_MASK[12][32] = //[BANK] [INDEX]
|
||||
{
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,16,-1,18,-1,-1,21,22,23,24,25,26,-1,-1,-1,-1,-1,},//PD
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PG
|
||||
{-1,-1,-1, 3, 4, 5, 6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PH
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PI
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PJ
|
||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PK
|
||||
{-1,-1, 2, 3,-1,-1,-1,-1, 8,-1,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
int bcmToGpioCPi[64] =
|
||||
{
|
||||
106, 107, // 0, 1
|
||||
104, 10, // 2, 3
|
||||
3, 9, // 4 5
|
||||
4, 90, // 6, 7
|
||||
92, 158, // 8, 9
|
||||
156, 105, //10,11
|
||||
146, 150, //12,13
|
||||
81, 80, //14,15
|
||||
|
||||
82, 83, //16,17
|
||||
131, 132, //18,19
|
||||
134, 135, //20,21
|
||||
89, 88, //22,23
|
||||
84, 85, //24,25
|
||||
86, 87, //26,27
|
||||
112, 113, //28,29
|
||||
109, 157, //30,31
|
||||
|
||||
148, 147, //32,33
|
||||
100, 101, //34,35
|
||||
102, 103, //36,37
|
||||
97, 98, //38,39
|
||||
99, 96, //40,41
|
||||
110, 111, //42,43
|
||||
64, 65, //44,45
|
||||
-1, -1, //46,47
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
|
||||
};
|
||||
|
||||
int CPI_PIN_MASK[5][32] = //[BANK] [INDEX]
|
||||
{
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},//PA
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},//PB
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},//PC
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},//PD
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},//PD
|
||||
};
|
||||
|
||||
volatile uint32_t *cru_base;
|
||||
volatile uint32_t *grf_base;
|
||||
volatile uint32_t *pmugrf_base;
|
||||
volatile uint32_t *pmucru_base;
|
||||
volatile uint32_t *gpio0_base;
|
||||
volatile uint32_t *gpio1_base;
|
||||
volatile uint32_t *gpio2_base;
|
||||
volatile uint32_t *gpio3_base;
|
||||
volatile uint32_t *gpio4_base;
|
||||
#endif
|
||||
|
||||
static unsigned int readR(unsigned int addr)
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
unsigned int val = 0;
|
||||
unsigned int mmap_base = (addr & ~MAP_MASK);
|
||||
unsigned int mmap_seek = (addr - mmap_base);
|
||||
|
||||
if(mmap_base == CRU_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)cru_base + mmap_seek));
|
||||
else if(mmap_base == GRF_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)grf_base + mmap_seek));
|
||||
else if(mmap_base == PMUCRU_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)pmucru_base + mmap_seek));
|
||||
else if(mmap_base == PMUGRF_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)pmugrf_base + mmap_seek));
|
||||
else if(mmap_base == GPIO0_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)gpio0_base + mmap_seek));
|
||||
else if(mmap_base == GPIO1_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)gpio1_base + mmap_seek));
|
||||
else if(mmap_base == GPIO2_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)gpio2_base + mmap_seek));
|
||||
else if(mmap_base == GPIO3_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)gpio3_base + mmap_seek));
|
||||
else if(mmap_base == GPIO4_BASE)
|
||||
val = *((unsigned int *)((unsigned char *)gpio4_base + mmap_seek));
|
||||
|
||||
return val;
|
||||
|
||||
#elif (defined CONFIG_CLOCKWORKPI_A04)
|
||||
uint32_t val = 0;
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void writeR(unsigned int val, unsigned int addr)
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
unsigned int mmap_base = (addr & ~MAP_MASK);
|
||||
unsigned int mmap_seek = (addr - mmap_base);
|
||||
|
||||
if(mmap_base == CRU_BASE)
|
||||
*((unsigned int *)((unsigned char *)cru_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GRF_BASE)
|
||||
*((unsigned int *)((unsigned char *)grf_base + mmap_seek)) = val;
|
||||
else if(mmap_base == PMUCRU_BASE)
|
||||
*((unsigned int *)((unsigned char *)pmucru_base + mmap_seek)) = val;
|
||||
else if(mmap_base == PMUGRF_BASE)
|
||||
*((unsigned int *)((unsigned char *)pmugrf_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GPIO0_BASE)
|
||||
*((unsigned int *)((unsigned char *)gpio0_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GPIO1_BASE)
|
||||
*((unsigned int *)((unsigned char *)gpio1_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GPIO2_BASE)
|
||||
*((unsigned int *)((unsigned char *)gpio2_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GPIO3_BASE)
|
||||
*((unsigned int *)((unsigned char *)gpio3_base + mmap_seek)) = val;
|
||||
else if(mmap_base == GPIO4_BASE)
|
||||
*((unsigned int *)((unsigned char *)gpio4_base + mmap_seek)) = val;
|
||||
|
||||
#elif (defined CONFIG_CLOCKWORKPI_A04)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int CPi_get_gpio_mode(int pin)
|
||||
{
|
||||
unsigned int regval = 0;
|
||||
unsigned int bank = pin >> 5;
|
||||
unsigned int index = pin - (bank << 5);
|
||||
unsigned int phyaddr = 0;
|
||||
unsigned char mode = -1;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
unsigned int grf_phyaddr = 0, ddr_phyaddr = 0;
|
||||
int offset = ((index - ((index >> 3) << 3)));
|
||||
|
||||
if(bank == 0){
|
||||
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2);
|
||||
ddr_phyaddr = GPIO0_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 1){
|
||||
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2) + 0x10;
|
||||
ddr_phyaddr = GPIO1_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 2){
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2);
|
||||
ddr_phyaddr = GPIO2_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 3){
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x10;
|
||||
ddr_phyaddr = GPIO3_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 4){
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x20;
|
||||
ddr_phyaddr = GPIO4_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
regval = readR(grf_phyaddr);
|
||||
mode = (regval >> (offset << 1)) & 0x3;
|
||||
if(mode == 0){
|
||||
regval = readR(ddr_phyaddr);
|
||||
return (regval >> index) & 1;
|
||||
}
|
||||
return mode + 1;
|
||||
}
|
||||
|
||||
#elif (defined CONFIG_CLOCKWORKPI_A04)
|
||||
|
||||
int offset = ((index - ((index >> 3) << 3)) << 2);
|
||||
|
||||
if (bank == 11) {
|
||||
phyaddr = GPIOL_BASE + ((index >> 3) << 2);
|
||||
}
|
||||
else
|
||||
phyaddr = GPIO_BASE_MAP + (bank * 36) + ((index >> 3) << 2);
|
||||
|
||||
/* Ignore unused gpio */
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
regval = readR(phyaddr);
|
||||
mode = (regval >> offset) & 7;
|
||||
}
|
||||
|
||||
return mode;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Set GPIO Mode
|
||||
*/
|
||||
int CPi_set_gpio_mode(int pin, int mode)
|
||||
{
|
||||
unsigned int regval = 0;
|
||||
unsigned int bank = pin >> 5;
|
||||
unsigned int index = pin - (bank << 5);
|
||||
unsigned int phyaddr = 0;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
int offset = ((index - ((index >> 3) << 3)));
|
||||
unsigned int cru_phyaddr, grf_phyaddr, gpio_phyaddr;
|
||||
#elif (defined CONFIG_CLOCKWORKPI_A04)
|
||||
int offset = ((index - ((index >> 3) << 3)) << 2);
|
||||
|
||||
if (bank == 11) {
|
||||
phyaddr = GPIOL_BASE + ((index >> 3) << 2);
|
||||
} else {
|
||||
phyaddr = GPIO_BASE_MAP + (bank * 36) + ((index >> 3) << 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
if(bank == 0){
|
||||
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET;
|
||||
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2);
|
||||
gpio_phyaddr = GPIO0_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 1){
|
||||
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET;
|
||||
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2) + 0x10;
|
||||
gpio_phyaddr = GPIO1_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 2){
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2);
|
||||
gpio_phyaddr = GPIO2_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 3){
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x10;
|
||||
gpio_phyaddr = GPIO3_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
else if(bank == 4){
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x20;
|
||||
gpio_phyaddr = GPIO4_BASE + GPIO_SWPORTA_DDR_OFFSET;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("Before read reg val: 0x%x offset:%d\n",regval,offset);
|
||||
#endif
|
||||
if (wiringPiDebug)
|
||||
printf("Register[%#x]: %#x index:%d\n", phyaddr, regval, index);
|
||||
|
||||
/* Set Input */
|
||||
if (INPUT == mode) {
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
writeR(0xffff0180, cru_phyaddr);
|
||||
regval = readR(grf_phyaddr);
|
||||
regval |= 0x3 << ((offset << 1) | 0x10);
|
||||
regval &= ~(0x3 << (offset << 1));
|
||||
writeR(regval, grf_phyaddr);
|
||||
regval = readR(gpio_phyaddr);
|
||||
regval &= ~(1 << index);
|
||||
writeR(regval, gpio_phyaddr);
|
||||
if (wiringPiDebug){
|
||||
regval = readR(gpio_phyaddr);
|
||||
printf("Input mode set over reg val: %#x\n",regval);
|
||||
}
|
||||
#else
|
||||
regval &= ~(7 << offset);
|
||||
writeR(regval, phyaddr);
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("Input mode set over reg val: %#x\n",regval);
|
||||
#endif
|
||||
} else if (OUTPUT == mode) { /* Set Output */
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
writeR(0xffff0180, cru_phyaddr);
|
||||
regval = readR(grf_phyaddr);
|
||||
regval |= 0x3 << ((offset << 1) | 0x10);
|
||||
regval &= ~(0x3 << (offset << 1));
|
||||
writeR(regval, grf_phyaddr);
|
||||
regval = readR(gpio_phyaddr);
|
||||
regval |= 1 << index;
|
||||
writeR(regval, gpio_phyaddr);
|
||||
if (wiringPiDebug){
|
||||
regval = readR(gpio_phyaddr);
|
||||
printf("Out mode get value: 0x%x\n",regval);
|
||||
}
|
||||
#else
|
||||
regval &= ~(7 << offset);
|
||||
regval |= (1 << offset);
|
||||
if (wiringPiDebug)
|
||||
printf("Out mode ready set val: 0x%x\n",regval);
|
||||
writeR(regval, phyaddr);
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("Out mode get value: 0x%x\n",regval);
|
||||
#endif
|
||||
}else
|
||||
printf("Unknow mode\n");
|
||||
} else
|
||||
printf("unused pin\n");
|
||||
}
|
||||
|
||||
int CPi_set_gpio_alt(int pin, int mode)
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
unsigned int regval = 0;
|
||||
unsigned int bank = pin >> 5;
|
||||
unsigned int index = pin - (bank << 5);
|
||||
unsigned int phyaddr = 0;
|
||||
int offset = ((index - ((index >> 3) << 3)) << 2);
|
||||
|
||||
if (bank == 11) {
|
||||
phyaddr = GPIOL_BASE + ((index >> 3) << 2);
|
||||
}else
|
||||
phyaddr = GPIO_BASE_MAP + (bank * 36) + ((index >> 3) << 2);
|
||||
|
||||
/* Ignore unused gpio */
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
if (wiringPiDebug)
|
||||
printf("Register[%#x]: %#x index:%d\n", phyaddr, regval, index);
|
||||
|
||||
regval = readR(phyaddr);
|
||||
regval &= ~(7 << offset);
|
||||
regval |= (mode << offset);
|
||||
writeR(regval, phyaddr);
|
||||
} else
|
||||
printf("Pin alt mode failed!\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* CPi Digital write
|
||||
*/
|
||||
void CPi_digitalWrite(int pin, int value)
|
||||
{
|
||||
unsigned int bank = pin >> 5;
|
||||
unsigned int index = pin - (bank << 5);
|
||||
unsigned int phyaddr = 0;
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
unsigned int regval = 0;
|
||||
unsigned int cru_phyaddr = 0;
|
||||
|
||||
#else
|
||||
unsigned int regval = 0;
|
||||
|
||||
if (bank == 11) {
|
||||
phyaddr = GPIOL_BASE + 0x10;
|
||||
}
|
||||
else
|
||||
phyaddr = GPIO_BASE_MAP + (bank * 36) + 0x10;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
|
||||
if(bank == 0){
|
||||
phyaddr = GPIO0_BASE + GPIO_SWPORTA_DR_OFFSET;
|
||||
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET;
|
||||
}
|
||||
else if(bank == 1){
|
||||
phyaddr = GPIO1_BASE + GPIO_SWPORTA_DR_OFFSET;
|
||||
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET;
|
||||
}
|
||||
else if(bank == 2){
|
||||
phyaddr = GPIO2_BASE + GPIO_SWPORTA_DR_OFFSET;
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
}
|
||||
else if(bank == 3){
|
||||
phyaddr = GPIO3_BASE + GPIO_SWPORTA_DR_OFFSET;
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
}
|
||||
else if(bank == 4){
|
||||
phyaddr = GPIO4_BASE + GPIO_SWPORTA_DR_OFFSET;
|
||||
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
writeR(0xffff0180, cru_phyaddr);
|
||||
#endif
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf("pin: %d, bank: %d, index: %d, phyaddr: 0x%x\n", pin, bank, index, phyaddr);
|
||||
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("befor write reg val: 0x%x,index:%d\n", regval, index);
|
||||
if(0 == value) {
|
||||
regval &= ~(1 << index);
|
||||
writeR(regval, phyaddr);
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("LOW val set over reg val: 0x%x\n", regval);
|
||||
} else {
|
||||
regval |= (1 << index);
|
||||
writeR(regval, phyaddr);
|
||||
regval = readR(phyaddr);
|
||||
if (wiringPiDebug)
|
||||
printf("HIGH val set over reg val: 0x%x\n", regval);
|
||||
}
|
||||
|
||||
} else
|
||||
printf("unused pin\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* CPi Digital Read
|
||||
*/
|
||||
int CPi_digitalRead(int pin)
|
||||
{
|
||||
int bank = pin >> 5;
|
||||
int index = pin - (bank << 5);
|
||||
int val;
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
|
||||
unsigned int phyaddr;
|
||||
|
||||
if (bank == 11) {
|
||||
phyaddr = GPIOL_BASE + 0x10;
|
||||
} else {
|
||||
phyaddr = GPIO_BASE_MAP + (bank * 36) + 0x10;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
unsigned int phyaddr;
|
||||
if(bank == 0)
|
||||
phyaddr = GPIO0_BASE + GPIO_EXT_PORTA_OFFSET;
|
||||
else if(bank == 1)
|
||||
phyaddr = GPIO1_BASE + GPIO_EXT_PORTA_OFFSET;
|
||||
else if(bank == 2)
|
||||
phyaddr = GPIO2_BASE + GPIO_EXT_PORTA_OFFSET;
|
||||
else if(bank == 3)
|
||||
phyaddr = GPIO3_BASE + GPIO_EXT_PORTA_OFFSET;
|
||||
else if(bank == 4)
|
||||
phyaddr = GPIO4_BASE + GPIO_EXT_PORTA_OFFSET;
|
||||
#endif
|
||||
|
||||
if (CPI_PIN_MASK[bank][index] != -1) {
|
||||
val = readR(phyaddr);
|
||||
val = val >> index;
|
||||
val &= 1;
|
||||
if (wiringPiDebug)
|
||||
printf("Read reg val: 0x%#x, bank:%d, index:%d\n", val, bank, index);
|
||||
return val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CPiSetup(int fd)
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
|
||||
|
||||
|
||||
#elif defined(CONFIG_CLOCKWORKPI_A06)
|
||||
gpio0_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO0_BASE);
|
||||
if ((int32_t)(unsigned long)gpio0_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GPIO0_BASE) failed: %s\n", strerror(errno));
|
||||
gpio1_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO1_BASE);
|
||||
if ((int32_t)(unsigned long)grf_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GPIO1_BASE) failed: %s\n", strerror(errno));
|
||||
gpio2_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO2_BASE);
|
||||
if ((int32_t)(unsigned long)gpio2_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GPIO2_BASE) failed: %s\n", strerror(errno));
|
||||
gpio3_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO3_BASE);
|
||||
if ((int32_t)(unsigned long)gpio3_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GPIO3_BASE) failed: %s\n", strerror(errno));
|
||||
gpio4_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO4_BASE);
|
||||
if ((int32_t)(unsigned long)gpio4_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GPIO4_BASE) failed: %s\n", strerror(errno));
|
||||
|
||||
cru_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, CRU_BASE);
|
||||
if ((int32_t)(unsigned long)cru_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (CRU_BASE) failed: %s\n", strerror(errno));
|
||||
pmucru_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, PMUCRU_BASE);
|
||||
if ((int32_t)(unsigned long)pmucru_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (PMUCRU_BASE) failed: %s\n", strerror(errno));
|
||||
grf_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GRF_BASE);
|
||||
if ((int32_t)(unsigned long)grf_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (GRF_BASE) failed: %s\n", strerror(errno));
|
||||
pmugrf_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, PMUGRF_BASE);
|
||||
if ((int32_t)(unsigned long)pmugrf_base == -1)
|
||||
return wiringPiFailure(WPI_ALMOST, "wiringPiSetup: mmap (PMUGRF_BASE) failed: %s\n", strerror(errno));
|
||||
#endif
|
||||
wpimode = WPI_MODE_BCM;
|
||||
}
|
||||
|
||||
void CPiSetupRaw(void)
|
||||
{
|
||||
wpimode = WPI_MODE_RAW;
|
||||
}
|
||||
|
||||
void CPiPinMode(int pin, int mode)
|
||||
{
|
||||
if (wiringPiDebug)
|
||||
printf("CPiPinMode: pin:%d,mode:%d\n", pin, mode);
|
||||
|
||||
if (pin >= GPIO_NUM) {
|
||||
printf("CPiPinMode: invaild pin:%d\n", pin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wpimode == WPI_MODE_BCM) {
|
||||
if(pin >= sizeof(bcmToGpioCPi)/sizeof(bcmToGpioCPi[0])) {
|
||||
printf("CPiPinMode: invaild pin:%d\n", pin);
|
||||
return;
|
||||
}
|
||||
pin = bcmToGpioCPi[pin];
|
||||
}
|
||||
|
||||
CPi_set_gpio_mode(pin, mode);
|
||||
}
|
||||
|
||||
void CPiDigitalWrite(int pin, int value)
|
||||
{
|
||||
if (wiringPiDebug)
|
||||
printf("CPiDigitalWrite: pin:%d,value:%d\n", pin, value);
|
||||
|
||||
if (pin >= GPIO_NUM) {
|
||||
printf("CPiDigitalWrite: invaild pin:%d\n", pin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wpimode == WPI_MODE_BCM) {
|
||||
if(pin >= sizeof(bcmToGpioCPi)/sizeof(bcmToGpioCPi[0])) {
|
||||
printf("CPiDigitalWrite: invaild pin:%d\n", pin);
|
||||
return;
|
||||
}
|
||||
pin = bcmToGpioCPi[pin];
|
||||
}
|
||||
|
||||
CPi_digitalWrite(pin, value);
|
||||
}
|
||||
|
||||
int CPiDigitalRead(int pin)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (pin >= GPIO_NUM) {
|
||||
printf("CPiDigitalRead: invaild pin:%d\n", pin);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (wpimode == WPI_MODE_BCM) {
|
||||
if(pin >= sizeof(bcmToGpioCPi)/sizeof(bcmToGpioCPi[0])) {
|
||||
printf("CPiDigitalRead: invaild pin:%d\n", pin);
|
||||
return -1;
|
||||
}
|
||||
pin = bcmToGpioCPi[pin];
|
||||
}
|
||||
|
||||
value = CPi_digitalRead(pin);
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf("CPiDigitalRead: pin:%d,value:%d\n", pin, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void pinModeAltCP(int pin, int mode)
|
||||
{
|
||||
}
|
||||
|
||||
void CPiBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
{
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
*model = CPI_MODEL_A04;
|
||||
*rev = PI_VERSION_1;
|
||||
*mem = 3;
|
||||
*maker = 3;
|
||||
#elif defined(CONFIG_CLOCKWORKPI_A06)
|
||||
*model = CPI_MODEL_A06;
|
||||
*rev = PI_VERSION_1;
|
||||
*mem = 4;
|
||||
*maker = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef _WIRING_CPI_H
|
||||
#define _WIRING_CPI_H
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A04
|
||||
#define GPIOA_BASE (0x0300B000)
|
||||
#define GPIO_NUM (0x40)
|
||||
#define GPIO_BASE_MAP (0x0300B000)
|
||||
#define MEM_INFO (1024)
|
||||
#define GPIOL_BASE (0x07022000)
|
||||
#define GPIOL_BASE_MAP (0x07022000)
|
||||
#define MAP_SIZE_L (4096 * 1)
|
||||
#define GPIO_PWM_OP (0x0300A000)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
#define GPIO0_BASE 0xff720000
|
||||
#define GPIO1_BASE 0xff730000
|
||||
#define GPIO2_BASE 0xff780000
|
||||
#define GPIO3_BASE 0xff788000
|
||||
#define GPIO4_BASE 0xff790000
|
||||
#define GPIO_NUM (160)
|
||||
#define GPIO_SWPORTA_DR_OFFSET 0x00
|
||||
#define GPIO_SWPORTA_DDR_OFFSET 0x04
|
||||
#define GPIO_EXT_PORTA_OFFSET 0x50
|
||||
#define PMUGRF_BASE 0xff320000
|
||||
#define GRF_BASE 0xff77e000
|
||||
#define CRU_BASE 0xff760000
|
||||
#define PMUCRU_BASE 0xff750000
|
||||
#define CRU_CLKGATE_CON31_OFFSET 0x037c //bit 3 4 5
|
||||
#define PMUCRU_CLKGATE_CON1_OFFSET 0x0104
|
||||
#endif
|
||||
|
||||
#define MAP_SIZE_L (4*1024)
|
||||
#define MAP_SIZE MAP_SIZE_L
|
||||
#define MAP_MASK (MAP_SIZE - 1)
|
||||
|
||||
extern int CPi_set_gpio_mode(int pin, int mode);
|
||||
extern int CPi_set_gpio_alt(int pin, int mode);
|
||||
extern int CPi_get_gpio_mode(int pin);
|
||||
extern void CPi_digitalWrite(int pin, int value);
|
||||
extern int CPi_digitalRead(int pin);
|
||||
extern void CPiSetupRaw(void);
|
||||
|
||||
#endif
|
||||
+77
-86
@@ -77,10 +77,6 @@
|
||||
#include "wiringPi.h"
|
||||
#include "../version.h"
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
#include "wiringCPi.h"
|
||||
#endif
|
||||
|
||||
// Environment Variables
|
||||
|
||||
#define ENV_DEBUG "WIRINGPI_DEBUG"
|
||||
@@ -217,8 +213,9 @@ volatile unsigned int *_wiringPiTimerIrqRaw ;
|
||||
// piGpioBase:
|
||||
// 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 ;
|
||||
|
||||
@@ -241,15 +238,9 @@ const char *piModelNames [20] =
|
||||
"Pi 3A+", // 14
|
||||
"Unknown15", // 15
|
||||
"CM3+", // 16
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
"CPi A04", // 17
|
||||
"CPi A06", // 18
|
||||
"Unknown", // 19
|
||||
#else
|
||||
"Unknown17", // 17
|
||||
"Unknown18", // 18
|
||||
"Unknown19", // 19
|
||||
#endif
|
||||
"Pi 4B", // 17
|
||||
"Unknown18", // 18
|
||||
"Unknown19", // 19
|
||||
} ;
|
||||
|
||||
const char *piRevisionNames [16] =
|
||||
@@ -552,6 +543,14 @@ static uint8_t gpioToFEN [] =
|
||||
|
||||
#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
|
||||
// (Word) offset to the Pull Up Down Clock regsiter
|
||||
|
||||
@@ -735,7 +734,7 @@ static void usingGpioMemCheck (const char *what)
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
void piGpioLayoutOops (const char *why)
|
||||
static void piGpioLayoutOops (const char *why)
|
||||
{
|
||||
fprintf (stderr, "Oops: Unable to determine board revision from /proc/cpuinfo\n") ;
|
||||
fprintf (stderr, " -> %s\n", why) ;
|
||||
@@ -765,12 +764,6 @@ int piGpioLayout (void)
|
||||
if (strncmp (line, "Hardware", 8) == 0)
|
||||
break ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI_A06
|
||||
strcpy(line, "Hardware : Rockchip rk3399 Family");
|
||||
#elif defined(CONFIG_CLOCKWORKPI_A04)
|
||||
strcpy(line, "Hardware : Allwinner H6 Family");
|
||||
#endif
|
||||
|
||||
if (strncmp (line, "Hardware", 8) != 0)
|
||||
piGpioLayoutOops ("No \"Hardware\" line") ;
|
||||
|
||||
@@ -827,10 +820,6 @@ int piGpioLayout (void)
|
||||
|
||||
fclose (cpuFd) ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
strcpy(line, "Revision : 0000");
|
||||
#endif
|
||||
|
||||
if (strncmp (line, "Revision", 8) != 0)
|
||||
piGpioLayoutOops ("No \"Revision\" line") ;
|
||||
|
||||
@@ -838,7 +827,7 @@ int piGpioLayout (void)
|
||||
|
||||
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
|
||||
*c = 0 ;
|
||||
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf ("piGpioLayout: Revision string: %s\n", line) ;
|
||||
|
||||
@@ -907,7 +896,7 @@ int piBoardRev (void)
|
||||
* So the distinction between boards that I can see is:
|
||||
*
|
||||
* 0000 - Error
|
||||
* 0001 - Not used
|
||||
* 0001 - Not used
|
||||
*
|
||||
* Original Pi boards:
|
||||
* 0002 - Model B, Rev 1, 256MB, Egoman
|
||||
@@ -974,11 +963,6 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
// Will deal with the properly later on - for now, lets just get it going...
|
||||
// unsigned int modelNum ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiBoardId(model, rev, mem, maker);
|
||||
return;
|
||||
#endif
|
||||
|
||||
(void)piGpioLayout () ; // Call this first to make sure all's OK. Don't care about the result.
|
||||
|
||||
if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
|
||||
@@ -997,7 +981,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
|
||||
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
|
||||
*c = 0 ;
|
||||
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf ("piBoardId: Revision string: %s\n", line) ;
|
||||
|
||||
@@ -1036,7 +1020,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
bMfg = (revision & (0x0F << 16)) >> 16 ;
|
||||
bMem = (revision & (0x07 << 20)) >> 20 ;
|
||||
bWarranty = (revision & (0x03 << 24)) != 0 ;
|
||||
|
||||
|
||||
*model = bType ;
|
||||
*rev = bRev ;
|
||||
*mem = bMem ;
|
||||
@@ -1063,7 +1047,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
// If longer than 4, we'll assume it's been overvolted
|
||||
|
||||
*warranty = strlen (c) > 4 ;
|
||||
|
||||
|
||||
// Extract last 4 characters:
|
||||
|
||||
c = c + strlen (c) - 4 ;
|
||||
@@ -1103,7 +1087,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
||||
else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -1234,6 +1218,11 @@ void pwmSetRange (unsigned int range)
|
||||
void pwmSetClock (int divisor)
|
||||
{
|
||||
uint32_t pwm_control ;
|
||||
|
||||
if (piGpioBase == GPIO_PERI_BASE_2711)
|
||||
{
|
||||
divisor = 540*divisor/192;
|
||||
}
|
||||
divisor &= 4095 ;
|
||||
|
||||
if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))
|
||||
@@ -1289,7 +1278,7 @@ void gpioClockSet (int pin, int freq)
|
||||
pin = physToGpio [pin] ;
|
||||
else if (wiringPiMode != WPI_MODE_GPIO)
|
||||
return ;
|
||||
|
||||
|
||||
divi = 19200000 / freq ;
|
||||
divr = 19200000 % freq ;
|
||||
divf = (int)((double)divr * 4096.0 / 19200000.0) ;
|
||||
@@ -1445,11 +1434,6 @@ void pinMode (int pin, int mode)
|
||||
|
||||
setupCheck ("pinMode") ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiPinMode(pin, mode);
|
||||
return;
|
||||
#endif
|
||||
|
||||
if ((pin & PI_GPIO_MASK) == 0) // On-board pin
|
||||
{
|
||||
/**/ if (wiringPiMode == WPI_MODE_PINS)
|
||||
@@ -1538,11 +1522,36 @@ void pullUpDnControl (int pin, int pud)
|
||||
else if (wiringPiMode != WPI_MODE_GPIO)
|
||||
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
|
||||
{
|
||||
@@ -1563,11 +1572,6 @@ int digitalRead (int pin)
|
||||
{
|
||||
char c ;
|
||||
struct wiringPiNodeStruct *node = wiringPiNodes ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
return CPiDigitalRead(pin);
|
||||
#endif
|
||||
|
||||
if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
|
||||
{
|
||||
/**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode
|
||||
@@ -1631,11 +1635,6 @@ void digitalWrite (int pin, int value)
|
||||
{
|
||||
struct wiringPiNodeStruct *node = wiringPiNodes ;
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiDigitalWrite(pin, value);
|
||||
return;
|
||||
#endif
|
||||
|
||||
if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
|
||||
{
|
||||
/**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode
|
||||
@@ -1723,7 +1722,7 @@ void pwmWrite (int pin, int value)
|
||||
|
||||
/*
|
||||
* 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,
|
||||
* so this needs to go to a new node.
|
||||
*********************************************************************************
|
||||
@@ -1742,7 +1741,7 @@ int analogRead (int pin)
|
||||
|
||||
/*
|
||||
* 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,
|
||||
* so this needs to go to a new node.
|
||||
*********************************************************************************
|
||||
@@ -1791,7 +1790,7 @@ void pwmToneWrite (int pin, int freq)
|
||||
* Write an 8-bit byte to the first 8 GPIO pins - try to do it as
|
||||
* fast as possible.
|
||||
* 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
|
||||
* Reading is just bit fiddling.
|
||||
* These are wiringPi pin numbers 0..7, or BCM_GPIO pin numbers
|
||||
@@ -1847,7 +1846,7 @@ unsigned int digitalReadByte (void)
|
||||
data = (data << 1) | x ;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
raw = *(gpio + gpioToGPLEV [0]) ; // First bank for these pins
|
||||
for (pin = 0 ; pin < 8 ; ++pin)
|
||||
@@ -1904,7 +1903,7 @@ unsigned int digitalReadByte2 (void)
|
||||
data = (data << 1) | x ;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
data = ((*(gpio + gpioToGPLEV [0])) >> 20) & 0xFF ; // First bank for these pins
|
||||
|
||||
return data ;
|
||||
@@ -2282,7 +2281,9 @@ int wiringPiSetup (void)
|
||||
|
||||
piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
|
||||
|
||||
if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P))
|
||||
if ((model == PI_MODEL_CM) ||
|
||||
(model == PI_MODEL_CM3) ||
|
||||
(model == PI_MODEL_CM3P))
|
||||
wiringPiMode = WPI_MODE_GPIO ;
|
||||
else
|
||||
wiringPiMode = WPI_MODE_PINS ;
|
||||
@@ -2307,16 +2308,23 @@ int wiringPiSetup (void)
|
||||
case PI_ALPHA: case PI_MODEL_CM:
|
||||
case PI_MODEL_ZERO: case PI_MODEL_ZERO_W:
|
||||
piGpioBase = GPIO_PERI_BASE_OLD ;
|
||||
piGpioPupOffset = GPPUD ;
|
||||
break ;
|
||||
|
||||
case PI_MODEL_4B:
|
||||
piGpioBase = GPIO_PERI_BASE_2711 ;
|
||||
piGpioPupOffset = GPPUPPDN0 ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
piGpioBase = GPIO_PERI_BASE_NEW ;
|
||||
piGpioBase = GPIO_PERI_BASE_2835 ;
|
||||
piGpioPupOffset = GPPUD ;
|
||||
break ;
|
||||
}
|
||||
|
||||
// Open the master /dev/ memory control device
|
||||
// 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.
|
||||
|
||||
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC)) < 0)
|
||||
@@ -2333,9 +2341,6 @@ int wiringPiSetup (void)
|
||||
" Try running with sudo?\n", strerror (errno)) ;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiSetup(fd);
|
||||
#else
|
||||
// Set the offsets into the memory interface.
|
||||
|
||||
GPIO_PADS = piGpioBase + 0x00100000 ;
|
||||
@@ -2357,13 +2362,13 @@ int wiringPiSetup (void)
|
||||
pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ;
|
||||
if (pwm == MAP_FAILED)
|
||||
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ;
|
||||
|
||||
|
||||
// Clock control (needed for PWM)
|
||||
|
||||
clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_CLOCK_BASE) ;
|
||||
if (clk == MAP_FAILED)
|
||||
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ;
|
||||
|
||||
|
||||
// The drive pads
|
||||
|
||||
pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ;
|
||||
@@ -2391,7 +2396,6 @@ int wiringPiSetup (void)
|
||||
_wiringPiClk = clk ;
|
||||
_wiringPiPads = pads ;
|
||||
_wiringPiTimer = timer ;
|
||||
#endif
|
||||
|
||||
initialiseEpoch () ;
|
||||
|
||||
@@ -2420,19 +2424,6 @@ int wiringPiSetupGpio (void)
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int wiringPiSetupRaw (void)
|
||||
{
|
||||
(void)wiringPiSetup () ;
|
||||
|
||||
if (wiringPiDebug)
|
||||
printf ("wiringPi: wiringPiSetupRaw called\n") ;
|
||||
|
||||
wiringPiMode = WPI_MODE_GPIO ;
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
CPiSetupRaw();
|
||||
#endif
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/*
|
||||
* wiringPiSetupPhys:
|
||||
@@ -2497,7 +2488,7 @@ int wiringPiSetupSys (void)
|
||||
|
||||
// Open and scan the directory, looking for exported GPIOs, and pre-open
|
||||
// the 'value' interface to speed things up for later
|
||||
|
||||
|
||||
for (pin = 0 ; pin < 64 ; ++pin)
|
||||
{
|
||||
sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ;
|
||||
|
||||
+4
-14
@@ -44,10 +44,6 @@
|
||||
|
||||
// Handy defines
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
extern int wiringPiDebug;
|
||||
#endif
|
||||
|
||||
// wiringPi modes
|
||||
|
||||
#define WPI_MODE_PINS 0
|
||||
@@ -106,10 +102,8 @@ extern int wiringPiDebug;
|
||||
#define PI_MODEL_3BP 13
|
||||
#define PI_MODEL_3AP 14
|
||||
#define PI_MODEL_CM3P 16
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
#define CPI_MODEL_A04 24
|
||||
#define CPI_MODEL_A06 26
|
||||
#endif
|
||||
#define PI_MODEL_4B 17
|
||||
|
||||
#define PI_VERSION_1 0
|
||||
#define PI_VERSION_1_1 1
|
||||
#define PI_VERSION_1_2 2
|
||||
@@ -141,7 +135,7 @@ extern const int piMemorySize [ 8] ;
|
||||
// wiringPiNodeStruct:
|
||||
// This describes additional device nodes in the extended wiringPi
|
||||
// 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
|
||||
// of more than 1 or 2 devices being added are fairly slim, so who
|
||||
// knows....
|
||||
@@ -194,10 +188,6 @@ extern "C" {
|
||||
|
||||
// Internal
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
extern void piGpioLayoutOops (const char *why);
|
||||
#endif
|
||||
|
||||
extern int wiringPiFailure (int fatal, const char *message, ...) ;
|
||||
|
||||
// Core wiringPi functions
|
||||
@@ -222,7 +212,7 @@ extern void pwmWrite (int pin, int value) ;
|
||||
extern int analogRead (int pin) ;
|
||||
extern void analogWrite (int pin, int value) ;
|
||||
|
||||
// PiFace specifics
|
||||
// PiFace specifics
|
||||
// (Deprecated)
|
||||
|
||||
extern int wiringPiSetupPiFace (void) ;
|
||||
|
||||
@@ -109,11 +109,7 @@ int wiringPiSPISetupMode (int channel, int speed, int mode)
|
||||
// Channel can be anything - lets hope for the best
|
||||
// channel &= 1 ; // Channel is 0 or 1
|
||||
|
||||
#ifdef CONFIG_CLOCKWORKPI
|
||||
snprintf (spiDev, 31, "/dev/spidev2.%d", channel) ;
|
||||
#else
|
||||
snprintf (spiDev, 31, "/dev/spidev0.%d", channel) ;
|
||||
#endif
|
||||
|
||||
if ((fd = open (spiDev, O_RDWR)) < 0)
|
||||
return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ;
|
||||
|
||||
+6
-6
@@ -31,9 +31,9 @@ endif
|
||||
|
||||
#DEBUG = -g -O0
|
||||
DEBUG = -O2
|
||||
CC = gcc
|
||||
CC ?= gcc
|
||||
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
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
|
||||
@@ -78,10 +78,10 @@ install: wiringpid
|
||||
.PHONY: install-deb
|
||||
install-deb: gpio
|
||||
$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
|
||||
uninstall:
|
||||
|
||||
Reference in New Issue
Block a user