Преглед на файлове

Updates based on latest RPi revision codes

pull/158/head
Jim Parziale преди 2 години
родител
ревизия
1584f9315e
променени са 21 файла, в които са добавени 1964 реда и са изтрити 2222 реда
  1. +0
    -33
      People
  2. +1
    -1
      VERSION
  3. +1
    -1
      debian-template/wiringPi/DEBIAN/control
  4. +0
    -0
      debian-template/wiringPi/DEBIAN/postinst
  5. +0
    -0
      debian-template/wiringPi/DEBIAN/postrm
  6. +0
    -0
      examples/Makefile
  7. +0
    -0
      examples/blink.sh
  8. +0
    -0
      examples/pwm.c
  9. +0
    -0
      examples/q2w/blink.sh
  10. +0
    -0
      examples/servo.c
  11. +0
    -0
      gpio/Makefile
  12. +620
    -647
      gpio/gpio.c
  13. +0
    -0
      gpio/pintest
  14. +48
    -48
      gpio/readall.c
  15. +2
    -2
      version.h
  16. +33
    -26
      wiringPi/Makefile
  17. +5
    -7
      wiringPi/drcNet.c
  18. +0
    -0
      wiringPi/softServo.c
  19. +1049
    -1253
      wiringPi/wiringPi.c
  20. +205
    -204
      wiringPi/wiringPi.h
  21. +0
    -0
      wiringPi/wiringPiSPI.c

+ 0
- 33
People Целия файл

@@ -1,33 +0,0 @@

Just a quick note to some people who've provided help, suggestions,
bug-fixes, etc. along the way...

Nick Lott: (And others)
Hints about making it work with C++

Philipp Stefan Neininger:
Minor bug in the Makefile to do with cross compiling

Chris McSweeny
Hints and tips about the use of arithmetic in gettimeofday()
inside the dealyMicrosecondsHard() function.
And spotting a couple of schoolboy errors in the (experimental)
softServo code, prompting me to completely re-write it.

Armin (Via projects website)
Some pointers about the i2c-dev.h files.

Arno Wagner
Suggestions for the mmap calls in wiringPiSetup()

CHARLES Thibaut:
A small issue in softTone

Xian Stannard
Fixing some typos in the man page!

Andre Crone
Suggested the __WIRING_PI.H__ round wiringPi.h

Rik Teerling
Pointing out some silly mistooks in the I2C code...

+ 1
- 1
VERSION Целия файл

@@ -1 +1 @@
2.71
2.72

+ 1
- 1
debian-template/wiringPi/DEBIAN/control Целия файл

@@ -1,5 +1,5 @@
Package: wiringpi
Version: 2.71
Version: 2.72
Section: libraries
Priority: optional
Architecture: armhf


+ 0
- 0
debian-template/wiringPi/DEBIAN/postinst Целия файл


+ 0
- 0
debian-template/wiringPi/DEBIAN/postrm Целия файл


+ 0
- 0
examples/Makefile Целия файл


+ 0
- 0
examples/blink.sh Целия файл


+ 0
- 0
examples/pwm.c Целия файл


+ 0
- 0
examples/q2w/blink.sh Целия файл


+ 0
- 0
examples/servo.c Целия файл


+ 0
- 0
gpio/Makefile Целия файл


+ 620
- 647
gpio/gpio.c
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 0
- 0
gpio/pintest Целия файл


+ 48
- 48
gpio/readall.c Целия файл

@@ -75,15 +75,15 @@ static void doReadallExternal (void)
*********************************************************************************
*/

static char *alts [] =
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
-1, // 0
-1, -1, // 1, 2
8, -1,
9, -1,
7, 15,
@@ -95,48 +95,48 @@ static int physToWpi [64] =
12, -1,
13, 6,
14, 10,
-1, 11, // 25, 26
-1, 11, // 25, 26
30, 31, // Actually I2C, but not used
21, -1,
22, 26,
23, -1,
24, 27,
25, 28,
-1, 29,
-1, -1,
-1, 29, // 39, 40

-1, -1, // 41, 42
-1, -1,
-1, -1,
-1, -1,
-1, -1,
17, 18,
19, 20,
19, 20, // 53, 54
-1, -1, -1, -1, -1, -1, -1, -1, -1
} ;

static char *physNames [64] =
static char *physNames[64] =
{
NULL,

" 3.3v", "5v ",
" SDA.1", "5v ",
" SCL.1", "0v ",
" SCL.1", "GND ",
"GPIO. 7", "TxD ",
" 0v", "RxD ",
" GND", "RxD ",
"GPIO. 0", "GPIO. 1",
"GPIO. 2", "0v ",
"GPIO. 2", "GND ",
"GPIO. 3", "GPIO. 4",
" 3.3v", "GPIO. 5",
" MOSI", "0v ",
" MOSI", "GND ",
" MISO", "GPIO. 6",
" SCLK", "CE0 ",
" 0v", "CE1 ",
" GND", "CE1 ",
" SDA.0", "SCL.0 ",
"GPIO.21", "0v ",
"GPIO.21", "GND ",
"GPIO.22", "GPIO.26",
"GPIO.23", "0v ",
"GPIO.23", "GND ",
"GPIO.24", "GPIO.27",
"GPIO.25", "GPIO.28",
" 0v", "GPIO.29",
" GND", "GPIO.29",
NULL, NULL,
NULL, NULL,
NULL, NULL,
@@ -162,22 +162,22 @@ static void readallPhys (int physPin)
if (physPinToGpio (physPin) == -1)
printf (" | | ") ;
else
printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi [physPin]) ;
printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi[physPin]) ;

printf (" | %s", physNames [physPin]) ;
printf (" | %s", physNames[physPin]) ;

if (physToWpi [physPin] == -1)
if (physToWpi[physPin] == -1)
printf (" | | ") ;
else
{
/**/ if (wpMode == WPI_MODE_GPIO)
if (wpMode == WPI_MODE_GPIO)
pin = physPinToGpio (physPin) ;
else if (wpMode == WPI_MODE_PHYS)
pin = physPin ;
else
pin = physToWpi [physPin] ;
pin = physToWpi[physPin] ;

printf (" | %4s", alts [getAlt (pin)]) ;
printf (" | %4s", alts[getAlt (pin)]) ;
printf (" | %d", digitalRead (pin)) ;
}

@@ -189,27 +189,27 @@ static void readallPhys (int physPin)

// Same, reversed

if (physToWpi [physPin] == -1)
if (physToWpi[physPin] == -1)
printf (" | | ") ;
else
{
/**/ if (wpMode == WPI_MODE_GPIO)
if (wpMode == WPI_MODE_GPIO)
pin = physPinToGpio (physPin) ;
else if (wpMode == WPI_MODE_PHYS)
pin = physPin ;
else
pin = physToWpi [physPin] ;
pin = physToWpi[physPin] ;

printf (" | %d", digitalRead (pin)) ;
printf (" | %-4s", alts [getAlt (pin)]) ;
printf (" | %-4s", alts[getAlt (pin)]) ;
}

printf (" | %-5s", physNames [physPin]) ;
printf (" | %-5s", physNames[physPin]) ;

if (physToWpi [physPin] == -1)
if (physToWpi [physPin] == -1)
printf (" | | ") ;
else
printf (" | %-3d | %-3d", physToWpi [physPin], physPinToGpio (physPin)) ;
printf (" | %-3d | %-3d", physToWpi[physPin], physPinToGpio (physPin)) ;

printf (" |\n") ;
}
@@ -233,11 +233,11 @@ static void allReadall (void)
for (pin = 0 ; pin < 27 ; ++pin)
{
printf ("| %3d ", pin) ;
printf ("| %-4s ", alts [getAlt (pin)]) ;
printf ("| %-4s ", alts[getAlt (pin)]) ;
printf ("| %s ", digitalRead (pin) == HIGH ? "High" : "Low ") ;
printf ("| ") ;
printf ("| %3d ", pin + 27) ;
printf ("| %-4s ", alts [getAlt (pin + 27)]) ;
printf ("| %-4s ", alts[getAlt (pin + 27)]) ;
printf ("| %s ", digitalRead (pin + 27) == HIGH ? "High" : "Low ") ;
printf ("|\n") ;
}
@@ -303,7 +303,7 @@ static void plus2header (int model)
printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_ZERO_2W)
printf (" +-----+-----+---------+------+---+Pi Zero 2W+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_2)
else if (model == PI_MODEL_2B)
printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_3B)
printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n") ;
@@ -346,7 +346,7 @@ static void piPlusReadall (int model)

void doReadall (void)
{
int model, rev, mem, maker, overVolted ;
int model, proc, rev, mem, maker, overVolted ;

if (wiringPiNodes != NULL) // External readall
{
@@ -354,18 +354,18 @@ void doReadall (void)
return ;
}

piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
piBoardId (&model, &proc, &rev, &mem, &maker, &overVolted) ;

/**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B))
if ((model == PI_MODEL_A) || (model == PI_MODEL_B))
abReadall (model, rev) ;
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) ||
(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_CM4) ||
(model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W) || (model == PI_MODEL_ZERO_2W))
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) ||
(model == PI_MODEL_2B) ||
(model == PI_MODEL_3AP) ||
(model == PI_MODEL_3B) || (model == PI_MODEL_3BP) ||
(model == PI_MODEL_4B) || (model == PI_MODEL_400) || (model == PI_MODEL_CM4) ||
(model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W) || (model == PI_MODEL_ZERO_2W))
piPlusReadall (model) ;
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P) )
else if ((model == PI_MODEL_CM1) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P) )
allReadall () ;
else
printf ("Oops - unable to determine board type... model: %d\n", model) ;
@@ -390,16 +390,16 @@ void doAllReadall (void)
*********************************************************************************
*/

void doQmode (int argc, char *argv [])
void doQmode (int argc, char *argv[])
{
int pin ;

if (argc != 3)
{
fprintf (stderr, "Usage: %s qmode pin\n", argv [0]) ;
fprintf (stderr, "Usage: %s qmode pin\n", argv[0]) ;
exit (EXIT_FAILURE) ;
}

pin = atoi (argv [2]) ;
printf ("%s\n", alts [getAlt (pin)]) ;
pin = atoi (argv[2]) ;
printf ("%s\n", alts[getAlt (pin)]) ;
}

+ 2
- 2
version.h Целия файл

@@ -1,3 +1,3 @@
#define VERSION "2.71"
#define VERSION "2.72"
#define VERSION_MAJOR 2
#define VERSION_MINOR 71
#define VERSION_MINOR 72

+ 33
- 26
wiringPi/Makefile Целия файл

@@ -1,4 +1,4 @@
#
#################################################################################
# Makefile:
# wiringPi - Wiring Compatable library for the Raspberry Pi
#
@@ -27,11 +27,11 @@ PREFIX?=/local

LDCONFIG?=ldconfig

# Specify "V=1" on the make command line to enable
ifneq ($V,1)
Q ?= @
endif

STATIC=libwiringPi.a
DYNAMIC=libwiringPi.so.$(VERSION)

#DEBUG = -g -O0
@@ -46,28 +46,30 @@ LIBS = -lm -lpthread -lrt -lcrypt

###############################################################################

SRC = wiringPi.c \
wiringSerial.c wiringShift.c \
SRC = wiringPi.c \
wiringSerial.c wiringShift.c \
piHiPri.c piThread.c \
wiringPiSPI.c wiringPiI2C.c \
softPwm.c softTone.c \
mcp23008.c mcp23016.c mcp23017.c \
mcp23008.c mcp23016.c mcp23017.c \
mcp23s08.c mcp23s17.c \
sr595.c \
pcf8574.c pcf8591.c \
mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
max31855.c max5322.c ads1115.c \
sn3218.c \
bmp180.c htu21d.c ds18b20.c rht03.c \
sr595.c \
pcf8574.c pcf8591.c \
mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
max31855.c max5322.c ads1115.c \
sn3218.c \
bmp180.c htu21d.c ds18b20.c rht03.c \
drcSerial.c drcNet.c \
pseudoPins.c \
pseudoPins.c \
wpiExtensions.c

HEADERS = $(shell ls *.h)

OBJ = $(SRC:.c=.o)

all: $(DYNAMIC)
#################################################################################

all: $(DYNAMIC)

.PHONY: static
static:
@@ -81,27 +83,29 @@ $(DYNAMIC): $(OBJ)
$Q echo [Compile] $<
$Q $(CC) -c $(CFLAGS) $< -o $@

#################################################################################

.PHONY: clean
clean:
$Q echo "[Clean]"
$Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
$Q rm -vf $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*

.PHONY: tags
tags: $(SRC)
$Q echo [ctags]
$Q ctags $(SRC)

#################################################################################

.PHONY: install
install: $(DYNAMIC)
$Q echo "[Install Headers]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
$Q echo "[Install Dynamic Lib]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
$Q $(LDCONFIG)

.PHONY: check-deb-destdir
@@ -113,18 +117,18 @@ endif
.PHONY: install-deb
install-deb: $(DYNAMIC) check-deb-destdir
$Q echo "[Install Headers: deb]"
$Q install -m 0755 -d $(DEB_DESTDIR)/usr/include
$Q install -m 0644 $(HEADERS) $(DEB_DESTDIR)/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 $(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
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:
$Q echo "[UnInstall]"
$Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
$Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.*
$Q cd $(DESTDIR)$(PREFIX)/include/ && rm -vf $(HEADERS)
$Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -vf libwiringPi.*
$Q $(LDCONFIG)


@@ -132,6 +136,7 @@ uninstall:
depend:
makedepend -Y $(SRC) $(SRC_I2C)

#################################################################################
# DO NOT DELETE

wiringPi.o: softPwm.h softTone.h wiringPi.h ../version.h
@@ -169,3 +174,5 @@ wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h
wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h ads1115.h sn3218.h
wpiExtensions.o: drcSerial.h pseudoPins.h bmp180.h htu21d.h ds18b20.h
wpiExtensions.o: wpiExtensions.h

#################################################################################

+ 5
- 7
wiringPi/drcNet.c Целия файл

@@ -104,26 +104,24 @@ static int authenticate (int fd, const char *pass)
{
char *challenge ;
char *encrypted ;
char salted [1024] ;
char salted [1024+4] ; // Need to hold 4 more chars - see sprintf below

if ((challenge = getChallenge (fd)) == NULL)
return -1 ;

sprintf (salted, "$6$%s$", challenge) ;
encrypted = crypt (pass, salted) ;
// This is an assertion, or sanity check on my part...
// The '20' comes from the $6$ then the 16 characters of the salt,
// then the terminating $.

// Assertion:
// The '20' comes from the $6$ then the 16 characters of the salt,
// then the terminating $.
if (strncmp (encrypted, salted, 20) != 0)
{
errno = EBADE ;
return -1 ;
}

// 86 characters is the length of the SHA-256 hash

// 86 characters is the length of the SHA-256 hash
if (write (fd, encrypted + 20, 86) == 86)
return 0 ;
else


+ 0
- 0
wiringPi/softServo.c Целия файл


+ 1049
- 1253
wiringPi/wiringPi.c
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 205
- 204
wiringPi/wiringPi.h Целия файл

@@ -1,191 +1,201 @@
/*
* wiringPi.h:
* Arduino like Wiring library for the Raspberry Pi.
* Copyright (c) 2012-2017 Gordon Henderson
* Arduino like Wiring library for the Raspberry Pi.
* Copyright (c) 2012-2017 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://github.com/WiringPi/WiringPi/
* https://github.com/WiringPi/WiringPi/
*
* wiringPi is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* wiringPi is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wiringPi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* wiringPi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Lesser General Public License
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************
*/

#ifndef __WIRING_PI_H__
#define __WIRING_PI_H__
#ifndef __WIRING_PI_H__
#define __WIRING_PI_H__

// C doesn't have true/false by default and I can never remember which
// way round they are, so ...
// (and yes, I know about stdbool.h but I like capitals for these and I'm old)

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#include <stdbool.h>
#ifndef TRUE
# define TRUE true
# define FALSE false
#endif

// GCC warning suppressor
#define UNU __attribute__((unused))
// GCC warning suppressor - don't warn about unused parameters (-Wunused-parameter)
// @TODO Remove this and fix instances where parameters are unused.
#define UNU __attribute__((unused))

// Mask for the bottom 64 pins which belong to the Raspberry Pi
// The others are available for the other devices
// The others are available for the other devices
// @TODO Replace these checks with a check for (pin < 64)
#define PI_GPIO_MASK (0xFFFFFFC0)

#define PI_GPIO_MASK (0xFFFFFFC0)

// Handy defines

// wiringPi modes

#define WPI_MODE_PINS 0
#define WPI_MODE_GPIO 1
#define WPI_MODE_GPIO_SYS 2
#define WPI_MODE_PHYS 3
#define WPI_MODE_PIFACE 4
#define WPI_MODE_UNINITIALISED -1
#define WPI_MODE_PINS 0 // Virtual pin numbers 0 through 16
#define WPI_MODE_GPIO 1 // Broadcom GPIO pin numbers
#define WPI_MODE_GPIO_SYS 2 // Broadcom GPIO pin numbers, but uses /sys/class/gpio (slower)
#define WPI_MODE_PHYS 3 // Raspberry Pi pysical pins
#define WPI_MODE_PIFACE 4 // UNUSED
#define WPI_MODE_UNINITIALISED -1

// Pin modes
#define INPUT 0
#define OUTPUT 1
#define PWM_OUTPUT 2
#define GPIO_CLOCK 3
#define SOFT_PWM_OUTPUT 4
#define SOFT_TONE_OUTPUT 5
#define PWM_TONE_OUTPUT 6
#define LOW 0
#define HIGH 1
#define INPUT 0
#define OUTPUT 1
#define PWM_OUTPUT 2
#define GPIO_CLOCK 3
#define SOFT_PWM_OUTPUT 4
#define SOFT_TONE_OUTPUT 5
#define PWM_TONE_OUTPUT 6
// Pin levels
#define LOW 0
#define HIGH 1

// Pull up/down/none

#define PUD_OFF 0
#define PUD_DOWN 1
#define PUD_UP 2
#define PUD_OFF 0
#define PUD_DOWN 1
#define PUD_UP 2

// PWM

#define PWM_MODE_MS 0
#define PWM_MODE_BAL 1
#define PWM_MODE_MS 0
#define PWM_MODE_BAL 1

// Interrupt levels

#define INT_EDGE_SETUP 0
#define INT_EDGE_FALLING 1
#define INT_EDGE_RISING 2
#define INT_EDGE_BOTH 3
#define INT_EDGE_SETUP 0
#define INT_EDGE_FALLING 1
#define INT_EDGE_RISING 2
#define INT_EDGE_BOTH 3

// Pi model types and version numbers
// Intended for the GPIO program Use at your own risk.
// Intended for the GPIO program
// Use at your own risk
// https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes

#define PI_MODEL_A 0
#define PI_MODEL_B 1
#define PI_MODEL_AP 2
#define PI_MODEL_BP 3
#define PI_MODEL_2 4
#define PI_ALPHA 5
#define PI_MODEL_CM 6
#define PI_MODEL_07 7
#define PI_MODEL_3B 8
#define PI_MODEL_ZERO 9
#define PI_MODEL_CM3 10
#define PI_MODEL_ZERO_W 12
#define PI_MODEL_3BP 13
#define PI_MODEL_3AP 14
#define PI_MODEL_CM3P 16
#define PI_MODEL_4B 17
#define PI_MODEL_ZERO_2W 18
#define PI_MODEL_400 19
#define PI_MODEL_CM4 20

#define PI_VERSION_1 0
#define PI_VERSION_1_1 1
#define PI_VERSION_1_2 2
#define PI_VERSION_2 3

#define PI_MAKER_SONY 0
#define PI_MAKER_EGOMAN 1
#define PI_MAKER_EMBEST 2
#define PI_MAKER_SONYJAPAN 3
#define PI_MAKER_EMBEST4 4
#define PI_MAKER_STADIUM 5

extern const char *piModelNames [21] ;
extern const char *piRevisionNames [21] ;
extern const char *piMakerNames [16] ;
extern const int piMemorySize [ 8] ;


// Intended for the GPIO program Use at your own risk.
// Format (bits): FMMM'CCCC'PPPP'TTTTTTTT'RRRR

// F bit (New flag)
#define PI_FLAG_OLD 0 // old-style revision
#define PI_FLAG_NEW 1 // new-style revision

// MMM bits (Memory size)
#define PI_MEM_256M 0
#define PI_MEM_512M 1
#define PI_MEM_1G 2
#define PI_MEM_2G 3
#define PI_MEM_4G 4
#define PI_MEM_8G 5

// CCCC bits (Manufacturer)
#define PI_MAKER_SONY 0 // Sony UK
#define PI_MAKER_EGOMAN 1
#define PI_MAKER_EMBEST 2
#define PI_MAKER_SONYJAPAN 3
#define PI_MAKER_EMBEST4 4
#define PI_MAKER_STADIUM 5

// PPPP bits (Processor)
#define PI_PROC_BCM2835 0
#define PI_PROC_BCM2836 1
#define PI_PROC_BCM2837 2
#define PI_PROC_BCM2711 3

// TTTTTTTT bits (Type)
#define PI_MODEL_A 0x00
#define PI_MODEL_B 0x01
#define PI_MODEL_AP 0x02
#define PI_MODEL_BP 0x03
#define PI_MODEL_2B 0x04
#define PI_ALPHA 0x05
#define PI_MODEL_CM1 0x06
// 0x07
#define PI_MODEL_3B 0x08
#define PI_MODEL_ZERO 0x09
#define PI_MODEL_CM3 0x0A
// 0x0B
#define PI_MODEL_ZERO_W 0x0C
#define PI_MODEL_3BP 0x0D
#define PI_MODEL_3AP 0x0E
// 0x0F
#define PI_MODEL_CM3P 0x10
#define PI_MODEL_4B 0x11
#define PI_MODEL_ZERO_2W 0x12
#define PI_MODEL_400 0x13
#define PI_MODEL_CM4 0x14

// RRRR bits (Revision)
#define PI_VERSION_1 0
#define PI_VERSION_1_1 1
#define PI_VERSION_1_2 2
#define PI_VERSION_2 3
#define PI_VERSION_1_4 4


extern const char *piModelNames [21];
extern const char *piRevisionNames [ 5];
extern const char *piMakerNames [16];
extern const char *piProcessorNames[ 5];
extern const int piMemorySize [ 8];


// Intended for the GPIO program
// Use at your own risk.

// Threads

#define PI_THREAD(X) void *X (UNU void *dummy)
#define PI_THREAD(X) void *X (UNU void *dummy)

// Failure modes

#define WPI_FATAL (1==1)
#define WPI_ALMOST (1==2)
#define WPI_FATAL true
#define WPI_ALMOST false


// 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
// 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....

// This describes additional device nodes in the extended wiringPi
// 2.0 scheme of things. It's a simple linked list.
struct wiringPiNodeStruct
{
int pinBase ;
int pinMax ;

int fd ; // Node specific
unsigned int data0 ; // ditto
unsigned int data1 ; // ditto
unsigned int data2 ; // ditto
unsigned int data3 ; // ditto

void (*pinMode) (struct wiringPiNodeStruct *node, int pin, int mode) ;
void (*pullUpDnControl) (struct wiringPiNodeStruct *node, int pin, int mode) ;
int (*digitalRead) (struct wiringPiNodeStruct *node, int pin) ;
//unsigned int (*digitalRead8) (struct wiringPiNodeStruct *node, int pin) ;
void (*digitalWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;
// void (*digitalWrite8) (struct wiringPiNodeStruct *node, int pin, int value) ;
void (*pwmWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;
int (*analogRead) (struct wiringPiNodeStruct *node, int pin) ;
void (*analogWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;

struct wiringPiNodeStruct *next ;
} ;

extern struct wiringPiNodeStruct *wiringPiNodes ;
int pinBase;
int pinMax;

// Export variables for the hardware pointers
int fd; // Node specific
unsigned int data0; // ditto
unsigned int data1; // ditto
unsigned int data2; // ditto
unsigned int data3; // ditto

extern volatile unsigned int *_wiringPiGpio ;
extern volatile unsigned int *_wiringPiPwm ;
extern volatile unsigned int *_wiringPiClk ;
extern volatile unsigned int *_wiringPiPads ;
extern volatile unsigned int *_wiringPiTimer ;
extern volatile unsigned int *_wiringPiTimerIrqRaw ;
void (*pinMode) (struct wiringPiNodeStruct *node, int pin, int mode);
void (*pullUpDnControl) (struct wiringPiNodeStruct *node, int pin, int mode);
int (*digitalRead) (struct wiringPiNodeStruct *node, int pin);
void (*digitalWrite) (struct wiringPiNodeStruct *node, int pin, int value);
void (*pwmWrite) (struct wiringPiNodeStruct *node, int pin, int value);
int (*analogRead) (struct wiringPiNodeStruct *node, int pin);
void (*analogWrite) (struct wiringPiNodeStruct *node, int pin, int value);

struct wiringPiNodeStruct *next;
};

extern struct wiringPiNodeStruct *wiringPiNodes;

// Export variables for the hardware pointers
extern volatile unsigned int *_wiringPiGpio;
extern volatile unsigned int *_wiringPiPwm;
extern volatile unsigned int *_wiringPiClk;
extern volatile unsigned int *_wiringPiPads;
extern volatile unsigned int *_wiringPiTimer;
extern volatile unsigned int *_wiringPiTimerIrqRaw;

// Function prototypes
// c++ wrappers thanks to a comment by Nick Lott
// (and others on the Raspberry Pi forums)

// Function prototypes
// c++ wrappers thanks to a comment by Nick Lott
// (and others on the Raspberry Pi forums)
#ifdef __cplusplus
extern "C" {
#endif
@@ -193,81 +203,72 @@ extern "C" {
// Data

// Internal

extern int wiringPiFailure (int fatal, const char *message, ...) ;
extern int wiringPiFailure (int fatal, const char *message, ...);

// Core wiringPi functions

extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ;
extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ;

extern void wiringPiVersion (int *major, int *minor) ;
extern int wiringPiSetup (void) ;
extern int wiringPiSetupSys (void) ;
extern int wiringPiSetupGpio (void) ;
extern int wiringPiSetupPhys (void) ;

extern void pinModeAlt (int pin, int mode) ;
extern void pinMode (int pin, int mode) ;
extern void pullUpDnControl (int pin, int pud) ;
extern int digitalRead (int pin) ;
extern void digitalWrite (int pin, int value) ;
extern unsigned int digitalRead8 (int pin) ;
extern void digitalWrite8 (int pin, int value) ;
extern void pwmWrite (int pin, int value) ;
extern int analogRead (int pin) ;
extern void analogWrite (int pin, int value) ;
extern struct wiringPiNodeStruct *wiringPiFindNode (int pin);
extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins);

extern void wiringPiVersion (int *major, int *minor);
extern int wiringPiSetup (void);
extern int wiringPiSetupSys (void);
extern int wiringPiSetupGpio (void);
extern int wiringPiSetupPhys (void);

extern void pinModeAlt (int pin, int mode);
extern void pinMode (int pin, int mode);
extern void pullUpDnControl (int pin, int pud);
extern int digitalRead (int pin);
extern void digitalWrite (int pin, int value);
extern unsigned int digitalRead8 (int pin);
extern void digitalWrite8 (int pin, int value);
extern void pwmWrite (int pin, int value);
extern int analogRead (int pin);
extern void analogWrite (int pin, int value);

// PiFace specifics
// (Deprecated)

extern int wiringPiSetupPiFace (void) ;
extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
// (Deprecated)
extern int wiringPiSetupPiFace (void);
extern int wiringPiSetupPiFaceForGpioProg (void); // Don't use this - for gpio program only

// On-Board Raspberry Pi hardware specific stuff

extern int piGpioLayout (void) ;
extern int piBoardRev (void) ; // Deprecated
extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ;
extern int wpiPinToGpio (int wpiPin) ;
extern int physPinToGpio (int physPin) ;
extern void setPadDrive (int group, int value) ;
extern int getAlt (int pin) ;
extern void pwmToneWrite (int pin, int freq) ;
extern void pwmSetMode (int mode) ;
extern void pwmSetRange (unsigned int range) ;
extern void pwmSetClock (int divisor) ;
extern void gpioClockSet (int pin, int freq) ;
extern unsigned int digitalReadByte (void) ;
extern unsigned int digitalReadByte2 (void) ;
extern void digitalWriteByte (int value) ;
extern void digitalWriteByte2 (int value) ;
extern int piGpioLayout (void);
extern void piBoardId (int *model, int *proc, int *rev, int *mem, int *maker, int *overVolted);
extern int wpiPinToGpio (int wpiPin);
extern int physPinToGpio (int physPin);
extern void setPadDrive (int group, int value);
extern int getAlt (int pin);
extern void pwmToneWrite (int pin, int freq);
extern void pwmSetMode (int mode);
extern void pwmSetRange (unsigned int range);
extern void pwmSetClock (int divisor);
extern void gpioClockSet (int pin, int freq);
extern unsigned int digitalReadByte (void);
extern unsigned int digitalReadByte2 (void);
extern void digitalWriteByte (int value);
extern void digitalWriteByte2 (int value);

// Interrupts
// (Also Pi hardware specific)

extern int waitForInterrupt (int pin, int mS) ;
extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
// (Also Pi hardware specific)
extern int waitForInterrupt (int pin, int mS);
extern int wiringPiISR (int pin, int mode, void (*function)(void));

// Threads

extern int piThreadCreate (void *(*fn)(void *)) ;
extern void piLock (int key) ;
extern void piUnlock (int key) ;
extern int piThreadCreate (void *(*fn)(void *));
extern void piLock (int key);
extern void piUnlock (int key);

// Schedulling priority

extern int piHiPri (const int pri) ;
extern int piHiPri (const int pri);

// Extras from arduino land

extern void delay (unsigned int howLong) ;
extern void delayMicroseconds (unsigned int howLong) ;
extern unsigned int millis (void) ;
extern unsigned int micros (void) ;
extern void delay (unsigned int howLong); // milliseconds
extern void delayMicroseconds (unsigned int howLong);
extern unsigned int millis (void);
extern unsigned int micros (void);

#ifdef __cplusplus
}
#endif

#endif
#endif // __WIRING_PI_H__

+ 0
- 0
wiringPi/wiringPiSPI.c Целия файл


Зареждане…
Отказ
Запис