Просмотр исходного кода

Pushing to 2.39 as I have have not done the last one rightly...

pull/62/head
Gordon Henderson 7 лет назад
Родитель
Сommit
e687f3f2c6
16 измененных файлов: 122 добавлений и 68 удалений
  1. +1
    -1
      VERSION
  2. +2
    -2
      debian-template/wiringPi/DEBIAN/control
  3. +1
    -1
      gpio/Makefile
  4. +20
    -10
      gpio/gpio.c
  5. +1
    -1
      gpio/pins.c
  6. +2
    -2
      gpio/readall.c
  7. +0
    -1
      gpio/version.h
  8. +7
    -3
      newVersion
  9. +2
    -2
      version.h
  10. +4
    -2
      wiringPi/Makefile
  11. +1
    -1
      wiringPi/htu21d.c
  12. +1
    -1
      wiringPi/pcf8591.c
  13. +56
    -24
      wiringPi/wiringPi.c
  14. +19
    -12
      wiringPi/wiringPi.h
  15. +1
    -0
      wiringPi/wiringSerial.c
  16. +4
    -5
      wiringPi/wpiExtensions.c

+ 1
- 1
VERSION Просмотреть файл

@@ -1 +1 @@
2.36
2.39

+ 2
- 2
debian-template/wiringPi/DEBIAN/control Просмотреть файл

@@ -1,5 +1,5 @@
Package: wiringpi
Version: 2.36
Version: 2.38
Section: libraries
Priority: optional
Architecture: armhf
@@ -7,4 +7,4 @@ Depends: libc6
Maintainer: Gordon Henderson <projects@drogon.net>
Description: The wiringPi libraries, headers and gpio command
Libraries to allow GPIO access on a Raspberry Pi from C and C++
programs as well as from the command-line
and BASIC programs as well as from the command-line

+ 1
- 1
gpio/Makefile Просмотреть файл

@@ -100,4 +100,4 @@ depend:

# DO NOT DELETE

gpio.o: version.h
gpio.o: ../version.h

+ 20
- 10
gpio/gpio.c Просмотреть файл

@@ -2,7 +2,7 @@
* gpio.c:
* Swiss-Army-Knife, Set-UID command-line interface to the Raspberry
* Pi's GPIO.
* Copyright (c) 2012-2015 Gordon Henderson
* Copyright (c) 2012-2017 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -40,7 +40,7 @@
#include <gertboard.h>
#include <piFace.h>

#include "version.h"
#include "../version.h"

extern int wiringPiDebug ;

@@ -64,7 +64,9 @@ int wpMode ;

char *usage = "Usage: gpio -v\n"
" gpio -h\n"
" gpio [-g|-1] [-x extension:params] ...\n"
" gpio [-g|-1] ...\n"
" gpio [-d] ...\n"
" [-x extension:params] [[ -x ...]] ...\n"
" gpio [-p] <read/write/wb> ...\n"
" gpio <read/write/aread/awritewb/pwm/clock/mode> ...\n"
" gpio <toggle/blink> <pin>\n"
@@ -357,7 +359,7 @@ static void doUnLoad (int argc, char *argv [])
*********************************************************************************
*/

static void doI2Cdetect (int argc, char *argv [])
static void doI2Cdetect (UNU int argc, char *argv [])
{
int port = piGpioLayout () == 1 ? 0 : 1 ;
char *c, *command ;
@@ -388,7 +390,7 @@ static void doI2Cdetect (int argc, char *argv [])
*********************************************************************************
*/

static void doExports (int argc, char *argv [])
static void doExports (UNU int argc, UNU char *argv [])
{
int fd ;
int i, l, first ;
@@ -714,7 +716,7 @@ void doUnexportall (char *progName)
*********************************************************************************
*/

static void doReset (char *progName)
static void doReset (UNU char *progName)
{
printf ("GPIO Reset is dangerous and has been removed from the gpio command.\n") ;
printf (" - Please write a shell-script to reset the GPIO pins into the state\n") ;
@@ -1264,8 +1266,11 @@ static void doVersion (char *argv [])
char name [80] ;
FILE *fd ;

printf ("gpio version: %s\n", VERSION) ;
printf ("Copyright (c) 2012-2015 Gordon Henderson\n") ;
int vMaj, vMin ;

wiringPiVersion (&vMaj, &vMin) ;
printf ("gpio version: %d.%d\n", vMaj, vMin) ;
printf ("Copyright (c) 2012-2017 Gordon Henderson\n") ;
printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
printf ("For details type: %s -warranty\n", argv [0]) ;
printf ("\n") ;
@@ -1347,7 +1352,7 @@ int main (int argc, char *argv [])
if (strcasecmp (argv [1], "-warranty") == 0)
{
printf ("gpio version: %s\n", VERSION) ;
printf ("Copyright (c) 2012-2015 Gordon Henderson\n") ;
printf ("Copyright (c) 2012-2017 Gordon Henderson\n") ;
printf ("\n") ;
printf (" This program is free software; you can redistribute it and/or modify\n") ;
printf (" it under the terms of the GNU Leser General Public License as published\n") ;
@@ -1447,8 +1452,11 @@ int main (int argc, char *argv [])
}

// Check for -x argument to load in a new extension
// -x extension:base:args
// Can load many modules, but unless daemon mode we can only send one
// command at a time.

if (strcasecmp (argv [1], "-x") == 0)
while (strcasecmp (argv [1], "-x") == 0)
{
if (argc < 3)
{
@@ -1459,6 +1467,8 @@ int main (int argc, char *argv [])
if (!loadWPiExtension (argv [0], argv [2], TRUE)) // Prints its own error messages
exit (EXIT_FAILURE) ;

// Shift args down by 2

for (i = 3 ; i < argc ; ++i)
argv [i - 2] = argv [i] ;
argc -= 2 ;


+ 1
- 1
gpio/pins.c Просмотреть файл

@@ -1,7 +1,7 @@
/*
* pins.c:
* Just display a handy Pi pinnout diagram.
* Copyright (c) 2012-2015 Gordon Henderson
* Copyright (c) 2012-2017 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/


+ 2
- 2
gpio/readall.c Просмотреть файл

@@ -1,7 +1,7 @@
/*
* readall.c:
* The readall functions - getting a bit big, so split them out.
* Copyright (c) 2012-2015 Gordon Henderson
* Copyright (c) 2012-2017 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -348,7 +348,7 @@ void doReadall (void)
abReadall (model, rev) ;
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || (model == PI_MODEL_2) || (model == PI_MODEL_3) || (model == PI_MODEL_ZERO))
piPlusReadall (model) ;
else if (model == PI_MODEL_CM)
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3))
allReadall () ;
else
printf ("Oops - unable to determine board type... model: %d\n", model) ;


+ 0
- 1
gpio/version.h Просмотреть файл

@@ -1 +0,0 @@
#define VERSION "2.36"

+ 7
- 3
newVersion Просмотреть файл

@@ -25,8 +25,12 @@

echo Updating to version: `cat VERSION`

rm -f gpio/version.h
echo "#define VERSION \"`cat VERSION`\"" > gpio/version.h
rm -f version.h
vMaj=`cut -d. -f1 VERSION`
vMin=`cut -d. -f2 VERSION`
echo "#define VERSION \"`cat VERSION`\"" > version.h
echo "#define VERSION_MAJOR $vMaj" >> version.h
echo "#define VERSION_MINOR $vMin" >> version.h

rm -f debian-template/wiringPi/DEBIAN/control
cat > debian-template/wiringPi/DEBIAN/control <<EOF
@@ -39,5 +43,5 @@ Depends: libc6
Maintainer: Gordon Henderson <projects@drogon.net>
Description: The wiringPi libraries, headers and gpio command
Libraries to allow GPIO access on a Raspberry Pi from C and C++
programs as well as from the command-line
and BASIC programs as well as from the command-line
EOF

+ 2
- 2
version.h Просмотреть файл

@@ -1,3 +1,3 @@
#define VERSION "2.36"
#define VERSION "2.38"
#define VERSION_MAJOR 2
#define VERSION_MINOR 36
#define VERSION_MINOR 38

+ 4
- 2
wiringPi/Makefile Просмотреть файл

@@ -140,7 +140,7 @@ depend:

# DO NOT DELETE

wiringPi.o: softPwm.h softTone.h wiringPi.h
wiringPi.o: softPwm.h softTone.h wiringPi.h ../version.h
wiringSerial.o: wiringSerial.h
wiringShift.o: wiringPi.h wiringShift.h
piHiPri.o: wiringPi.h
@@ -169,7 +169,9 @@ bmp180.o: wiringPi.h wiringPiI2C.h bmp180.h
htu21d.o: wiringPi.h wiringPiI2C.h htu21d.h
ds18b20.o: wiringPi.h ds18b20.h
drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h
pseudoPins.o: wiringPi.h pseudoPins.h
wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
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 bmp180.h htu21d.h ds18b20.h wpiExtensions.h
wpiExtensions.o: drcSerial.h pseudoPins.h bmp180.h htu21d.h ds18b20.h
wpiExtensions.o: wpiExtensions.h

+ 1
- 1
wiringPi/htu21d.c Просмотреть файл

@@ -38,7 +38,7 @@

#define I2C_ADDRESS 0x40

int checksum (uint8_t data [4])
int checksum (UNU uint8_t data [4])
{
return TRUE ;
}


+ 1
- 1
wiringPi/pcf8591.c Просмотреть файл

@@ -36,7 +36,7 @@
*********************************************************************************
*/

static void myAnalogWrite (struct wiringPiNodeStruct *node, int pin, int value)
static void myAnalogWrite (struct wiringPiNodeStruct *node, UNU int pin, int value)
{
unsigned char b [2] ;
b [0] = 0x40 ;


+ 56
- 24
wiringPi/wiringPi.c Просмотреть файл

@@ -1,7 +1,7 @@
/*
* wiringPi:
* Arduino look-a-like Wiring library for the Raspberry Pi
* Copyright (c) 2012-2015 Gordon Henderson
* Copyright (c) 2012-2017 Gordon Henderson
* Additional code for pwmSetClock by Chris Hall <chris@kchall.plus.com>
*
* Thanks to code samples from Gert Jan van Loo and the
@@ -75,6 +75,7 @@
#include "softTone.h"

#include "wiringPi.h"
#include "../version.h"

// Environment Variables

@@ -196,11 +197,6 @@ static volatile uint32_t *timer ;
static volatile uint32_t *timerIrqRaw ;
#endif

// GCC warning suppressor

#define UNU __attribute__((unused))


// Data for use with the boardId functions.
// The order of entries here to correspond with the PI_MODEL_X
// and PI_VERSION_X defines in wiringPi.h
@@ -226,7 +222,7 @@ const char *piModelNames [16] =
"Unknown07", // 07
"Pi 3", // 08
"Pi Zero", // 09
"Unknown10", // 10
"CM3", // 10
"Unknown11", // 11
"Unknown12", // 12
"Unknown13", // 13
@@ -804,20 +800,17 @@ int piGpioLayout (void)
return gpioLayout ;
}

/***
if (strstr (line, "BCM2709") != NULL) // Pi v2 - no point doing anything more at this point
{
piModel2 = TRUE ;
fclose (cpuFd) ;
return gpioLayout = 2 ;
}
else if (strstr (line, "BCM2708") == NULL)
{
}
***/
/*
* piBoardRev:
* Deprecated, but does the same as piGpioLayout
*********************************************************************************
*/

int piBoardRev (void)
{
return piGpioLayout () ;
}

// Now do the rest of it as before - we just need to see if it's an older
// Rev 1 as anything else is rev 2.


/*
@@ -963,7 +956,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
*warranty = bWarranty ;

if (wiringPiDebug)
printf ("piboardId: rev: %d, type: %d, proc: %d, mfg: %d, mem: %d, warranty: %d\n",
printf ("piBoardId: rev: %d, type: %d, proc: %d, mfg: %d, mem: %d, warranty: %d\n",
bRev, bType, bProc, bMfg, bMem, bWarranty) ;
}
else // Old way
@@ -1938,11 +1931,19 @@ int wiringPiISR (int pin, int mode, void (*function)(void))

static void initialiseEpoch (void)
{
#ifdef OLD_WAY
struct timeval tv ;

gettimeofday (&tv, NULL) ;
epochMilli = (uint64_t)tv.tv_sec * (uint64_t)1000 + (uint64_t)(tv.tv_usec / 1000) ;
epochMicro = (uint64_t)tv.tv_sec * (uint64_t)1000000 + (uint64_t)(tv.tv_usec) ;
#else
struct timespec ts ;

clock_gettime (CLOCK_MONOTONIC_RAW, &ts) ;
epochMilli = (uint64_t)ts.tv_sec * (uint64_t)1000 + (uint64_t)(ts.tv_nsec / 1000000L) ;
epochMicro = (uint64_t)ts.tv_sec * (uint64_t)1000000 + (uint64_t)(ts.tv_nsec / 1000L) ;
#endif
}


@@ -2016,17 +2017,27 @@ void delayMicroseconds (unsigned int howLong)
/*
* millis:
* Return a number of milliseconds as an unsigned int.
* Wraps at 49 days.
*********************************************************************************
*/

unsigned int millis (void)
{
struct timeval tv ;
uint64_t now ;

#ifdef OLD_WAY
struct timeval tv ;

gettimeofday (&tv, NULL) ;
now = (uint64_t)tv.tv_sec * (uint64_t)1000 + (uint64_t)(tv.tv_usec / 1000) ;

#else
struct timespec ts ;

clock_gettime (CLOCK_MONOTONIC_RAW, &ts) ;
now = (uint64_t)ts.tv_sec * (uint64_t)1000 + (uint64_t)(ts.tv_nsec / 1000000L) ;
#endif

return (uint32_t)(now - epochMilli) ;
}

@@ -2034,20 +2045,41 @@ unsigned int millis (void)
/*
* micros:
* Return a number of microseconds as an unsigned int.
* Wraps after 71 minutes.
*********************************************************************************
*/

unsigned int micros (void)
{
struct timeval tv ;
uint64_t now ;
#ifdef OLD_WAY
struct timeval tv ;

gettimeofday (&tv, NULL) ;
now = (uint64_t)tv.tv_sec * (uint64_t)1000000 + (uint64_t)tv.tv_usec ;
#else
struct timespec ts ;

clock_gettime (CLOCK_MONOTONIC_RAW, &ts) ;
now = (uint64_t)ts.tv_sec * (uint64_t)1000000 + (uint64_t)(ts.tv_nsec / 1000) ;
#endif


return (uint32_t)(now - epochMicro) ;
}

/*
* wiringPiVersion:
* Return our current version number
*********************************************************************************
*/

void wiringPiVersion (int *major, int *minor)
{
*major = VERSION_MAJOR ;
*minor = VERSION_MINOR ;
}


/*
* wiringPiSetup:
@@ -2092,7 +2124,7 @@ int wiringPiSetup (void)

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

if (model == PI_MODEL_CM)
if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3))
wiringPiMode = WPI_MODE_GPIO ;
else
wiringPiMode = WPI_MODE_PINS ;


+ 19
- 12
wiringPi/wiringPi.h Просмотреть файл

@@ -1,7 +1,7 @@
/*
* wiringPi.h:
* Arduino like Wiring library for the Raspberry Pi.
* Copyright (c) 2012-2016 Gordon Henderson
* Copyright (c) 2012-2017 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -32,6 +32,10 @@
# define FALSE (!TRUE)
#endif

// GCC warning suppressor

#define UNU __attribute__((unused))

// Handy defines

// wiringPi modes
@@ -77,16 +81,17 @@
// Pi model types and version numbers
// Intended for the GPIO program Use at your own risk.

#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_3 8
#define PI_MODEL_ZERO 9
#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_3 8
#define PI_MODEL_ZERO 9
#define PI_MODEL_CM3 10

#define PI_VERSION_1 0
#define PI_VERSION_1_1 1
@@ -108,7 +113,7 @@ extern const int piMemorySize [ 8] ;

// Threads

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

// Failure modes

@@ -168,6 +173,7 @@ extern int wiringPiFailure (int fatal, const char *message, ...) ;
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) ;
@@ -191,6 +197,7 @@ extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio
// 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) ;


+ 1
- 0
wiringPi/wiringSerial.c Просмотреть файл

@@ -60,6 +60,7 @@ int serialOpen (const char *device, const int baud)
case 1200: myBaud = B1200 ; break ;
case 1800: myBaud = B1800 ; break ;
case 2400: myBaud = B2400 ; break ;
case 4800: myBaud = B4800 ; break ;
case 9600: myBaud = B9600 ; break ;
case 19200: myBaud = B19200 ; break ;
case 38400: myBaud = B38400 ; break ;


+ 4
- 5
wiringPi/wpiExtensions.c Просмотреть файл

@@ -439,10 +439,9 @@ static int doExtensionPcf8591 (char *progName, int pinBase, char *params)
*********************************************************************************
*/

static int doExtensionPseudoPins (char *progName, int pinBase, char *params)
static int doExtensionPseudoPins (UNU char *progName, int pinBase, UNU char *params)
{
pseudoPinsSetup (pinBase) ;
printf ("pseudoPins: %d\n", pinBase) ;

return TRUE ;
}
@@ -455,7 +454,7 @@ printf ("pseudoPins: %d\n", pinBase) ;
*********************************************************************************
*/

static int doExtensionBmp180 (char *progName, int pinBase, char *params)
static int doExtensionBmp180 (UNU char *progName, int pinBase, UNU char *params)
{
bmp180Setup (pinBase) ;

@@ -470,7 +469,7 @@ static int doExtensionBmp180 (char *progName, int pinBase, char *params)
*********************************************************************************
*/

static int doExtensionHtu21d (char *progName, int pinBase, char *params)
static int doExtensionHtu21d (UNU char *progName, int pinBase, UNU char *params)
{
htu21dSetup (pinBase) ;

@@ -633,7 +632,7 @@ static int doExtensionMcp4802 (char *progName, int pinBase, char *params)
*********************************************************************************
*/

static int doExtensionSn3218 (char *progName, int pinBase, char *params)
static int doExtensionSn3218 (UNU char *progName, int pinBase, UNU char *params)
{
sn3218Setup (pinBase) ;
return TRUE ;


Загрузка…
Отмена
Сохранить