Преглед изворни кода

Added a fix to include -lcrypt for people who can't do it themselves.

Added gpio readall support for the Pi 0W.
pull/62/head
Gordon Henderson пре 7 година
родитељ
комит
e8da87fbac
11 измењених фајлова са 154 додато и 25 уклоњено
  1. +1
    -1
      VERSION
  2. +7
    -7
      build
  3. +1
    -1
      debian-template/wiringPi/DEBIAN/control
  4. +1
    -1
      examples/Makefile
  5. +3
    -1
      gpio/readall.c
  6. +2
    -2
      version.h
  7. +1
    -1
      wiringPi/Makefile
  8. +136
    -10
      wiringPi/rht03.c
  9. +1
    -1
      wiringPi/wiringPi.c
  10. +1
    -0
      wiringPi/wiringPi.h
  11. BIN
      wiringPiD/wiringpid

+ 1
- 1
VERSION Прегледај датотеку

@@ -1 +1 @@
2.40
2.42

+ 7
- 7
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"


+ 1
- 1
debian-template/wiringPi/DEBIAN/control Прегледај датотеку

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


+ 1
- 1
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
###############################################################################


+ 3
- 1
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 () ;


+ 2
- 2
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

+ 1
- 1
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

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



+ 136
- 10
wiringPi/rht03.c Прегледај датотеку

@@ -22,22 +22,147 @@
***********************************************************************
*/

//#include <sys/types.h>
//#include <sys/stat.h>
//#include <fcntl.h>

//#include <unistd.h>
//#include <stdint.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdio.h>
//#include <string.h>
#include <time.h>
//#include <ctype.h>

#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:
*********************************************************************************


+ 1
- 1
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


+ 1
- 0
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


BIN
wiringPiD/wiringpid Прегледај датотеку


Loading…
Откажи
Сачувај