diff --git a/VERSION b/VERSION index 4bdd32f..2a43146 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.40 +2.42 diff --git a/build b/build index 070ea3f..7dc074c 100755 --- a/build +++ b/build @@ -160,13 +160,13 @@ fi $sudo make install check_make_ok - echo - echo "wiringPi Daemon" - cd ../wiringPiD - make -j5 - check_make_ok - $sudo make install - check_make_ok +# echo +# echo "wiringPi Daemon" +# cd ../wiringPiD +# make -j5 +# check_make_ok +# $sudo make install +# check_make_ok # echo # echo "Examples" diff --git a/debian-template/wiringPi/DEBIAN/control b/debian-template/wiringPi/DEBIAN/control index 75cedfa..73359aa 100644 --- a/debian-template/wiringPi/DEBIAN/control +++ b/debian-template/wiringPi/DEBIAN/control @@ -1,5 +1,5 @@ Package: wiringpi -Version: 2.40 +Version: 2.42 Section: libraries Priority: optional Architecture: armhf diff --git a/examples/Makefile b/examples/Makefile index 4725d85..6d87885 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -33,7 +33,7 @@ INCLUDE = -I/usr/local/include CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe LDFLAGS = -L/usr/local/lib -LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt # Should not alter anything below this line ############################################################################### diff --git a/gpio/readall.c b/gpio/readall.c index aec6de6..18f836f 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -299,6 +299,8 @@ static void plus2header (int model) printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ; else if (model == PI_MODEL_ZERO) printf (" +-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+\n") ; + else if (model == PI_MODEL_ZERO_W) + printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; else if (model == PI_MODEL_2) printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; else if (model == PI_MODEL_3) @@ -346,7 +348,7 @@ void doReadall (void) /**/ 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_3) || (model == PI_MODEL_ZERO)) + else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || (model == PI_MODEL_2) || (model == PI_MODEL_3) || (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) piPlusReadall (model) ; else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3)) allReadall () ; diff --git a/version.h b/version.h index 2c359b6..b556f91 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ -#define VERSION "2.40" +#define VERSION "2.42" #define VERSION_MAJOR 2 -#define VERSION_MINOR 40 +#define VERSION_MINOR 42 diff --git a/wiringPi/Makefile b/wiringPi/Makefile index 0a1283f..e1868b9 100644 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -41,7 +41,7 @@ INCLUDE = -I. DEFS = -D_GNU_SOURCE CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC -LIBS = -lm -lpthread -lrt +LIBS = -lm -lpthread -lrt -lcrypt ############################################################################### diff --git a/wiringPi/rht03.c b/wiringPi/rht03.c index 9fa5702..1129cfd 100644 --- a/wiringPi/rht03.c +++ b/wiringPi/rht03.c @@ -22,22 +22,147 @@ *********************************************************************** */ -//#include -//#include -//#include - -//#include -//#include +#include +#include #include -//#include #include -//#include #include "wiringPi.h" -#include "../devLib/maxdetect.h" - #include "rht03.h" +/* + * maxDetectLowHighWait: + * Wait for a transition from low to high on the bus + ********************************************************************************* + */ + +static int maxDetectLowHighWait (const int pin) +{ + struct timeval now, timeOut, timeUp ; + +// If already high then wait for pin to go low + + gettimeofday (&now, NULL) ; + timerclear (&timeOut) ; + timeOut.tv_usec = 1000 ; + timeradd (&now, &timeOut, &timeUp) ; + + while (digitalRead (pin) == HIGH) + { + gettimeofday (&now, NULL) ; + if (timercmp (&now, &timeUp, >)) + return FALSE ; + } + +// Wait for it to go HIGH + + gettimeofday (&now, NULL) ; + timerclear (&timeOut) ; + timeOut.tv_usec = 1000 ; + timeradd (&now, &timeOut, &timeUp) ; + + while (digitalRead (pin) == LOW) + { + gettimeofday (&now, NULL) ; + if (timercmp (&now, &timeUp, >)) + return FALSE ; + } + + return TRUE ; +} + + +/* + * maxDetectClockByte: + * Read in a single byte from the MaxDetect bus + ********************************************************************************* + */ + +static unsigned int maxDetectClockByte (const int pin) +{ + unsigned int byte = 0 ; + int bit ; + + for (bit = 0 ; bit < 8 ; ++bit) + { + if (!maxDetectLowHighWait (pin)) + return 0 ; + +// bit starting now - we need to time it. + + delayMicroseconds (30) ; + byte <<= 1 ; + if (digitalRead (pin) == HIGH) // It's a 1 + byte |= 1 ; + } + + return byte ; +} + + +/* + * maxDetectRead: + * Read in and return the 4 data bytes from the MaxDetect sensor. + * Return TRUE/FALSE depending on the checksum validity + ********************************************************************************* + */ + +static int maxDetectRead (const int pin, unsigned char buffer [4]) +{ + int i ; + unsigned int checksum ; + unsigned char localBuf [5] ; + struct timeval now, then, took ; + +// See how long we took + + gettimeofday (&then, NULL) ; + +// Wake up the RHT03 by pulling the data line low, then high +// Low for 10mS, high for 40uS. + + pinMode (pin, OUTPUT) ; + digitalWrite (pin, 0) ; delay (10) ; + digitalWrite (pin, 1) ; delayMicroseconds (40) ; + pinMode (pin, INPUT) ; + +// Now wait for sensor to pull pin low + + if (!maxDetectLowHighWait (pin)) + return FALSE ; + +// and read in 5 bytes (40 bits) + + for (i = 0 ; i < 5 ; ++i) + localBuf [i] = maxDetectClockByte (pin) ; + + checksum = 0 ; + for (i = 0 ; i < 4 ; ++i) + { + buffer [i] = localBuf [i] ; + checksum += localBuf [i] ; + } + checksum &= 0xFF ; + +// See how long we took + + gettimeofday (&now, NULL) ; + timersub (&now, &then, &took) ; + +// Total time to do this should be: +// 10mS + 40µS - reset +// + 80µS + 80µS - sensor doing its low -> high thing +// + 40 * (50µS + 27µS (0) or 70µS (1) ) +// = 15010µS +// so if we take more than that, we've had a scheduling interruption and the +// reading is probably bogus. + + if ((took.tv_sec != 0) || (took.tv_usec > 16000)) + return FALSE ; + + return checksum == localBuf [4] ; +} + /* * myReadRHT03: @@ -76,6 +201,7 @@ static int myReadRHT03 (const int pin, int *temp, int *rh) return TRUE ; } + /* * myAnalogRead: ********************************************************************************* diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index e018100..a8f5963 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -222,7 +222,7 @@ const char *piModelNames [16] = "Pi Zero", // 09 "CM3", // 10 "Unknown11", // 11 - "Unknown12", // 12 + "Pi Zero-W", // 12 "Unknown13", // 13 "Unknown14", // 14 "Unknown15", // 15 diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h index 0788bf2..f601f13 100644 --- a/wiringPi/wiringPi.h +++ b/wiringPi/wiringPi.h @@ -98,6 +98,7 @@ #define PI_MODEL_3 8 #define PI_MODEL_ZERO 9 #define PI_MODEL_CM3 10 +#define PI_MODEL_ZERO_W 12 #define PI_VERSION_1 0 #define PI_VERSION_1_1 1 diff --git a/wiringPiD/wiringpid b/wiringPiD/wiringpid index 529e286..b21232e 100755 Binary files a/wiringPiD/wiringpid and b/wiringPiD/wiringpid differ