Sync with changes from wiringpi_2.50.orig.tar.gz

Sourced from http://archive.ubuntu.com/ubuntu/pool/universe/w/wiringpi/wiringpi_2.50.orig.tar.gz
This commit is contained in:
Steve Baker 2019-12-14 13:42:07 +13:00
parent 093e0a17a4
commit 03204c3807
6 changed files with 37 additions and 21 deletions

View File

@ -1 +1 @@
2.46 2.50

View File

@ -303,10 +303,12 @@ static void plus2header (int model)
printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_2) else if (model == PI_MODEL_2)
printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_3) else if (model == PI_MODEL_3B)
printf (" +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+\n") ; printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_3P) else if (model == PI_MODEL_3BP)
printf (" +-----+-----+---------+------+---+---Pi 3+--+---+------+---------+-----+-----+\n") ; printf (" +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+\n") ;
else if (model == PI_MODEL_3AP)
printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n") ;
else else
printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ;
} }
@ -352,10 +354,11 @@ void doReadall (void)
abReadall (model, rev) ; abReadall (model, rev) ;
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) ||
(model == PI_MODEL_2) || (model == PI_MODEL_2) ||
(model == PI_MODEL_3) || (model == PI_MODEL_3P) || (model == PI_MODEL_3AP) ||
(model == PI_MODEL_3B) || (model == PI_MODEL_3BP) ||
(model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W))
piPlusReadall (model) ; piPlusReadall (model) ;
else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3)) else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || ((model == PI_MODEL_CM3P)))
allReadall () ; allReadall () ;
else else
printf ("Oops - unable to determine board type... model: %d\n", model) ; printf ("Oops - unable to determine board type... model: %d\n", model) ;

View File

@ -1,3 +1,3 @@
#define VERSION "2.46" #define VERSION "2.50"
#define VERSION_MAJOR 2 #define VERSION_MAJOR 2
#define VERSION_MINOR 46 #define VERSION_MINOR 50

View File

@ -218,7 +218,7 @@ volatile unsigned int *_wiringPiTimerIrqRaw ;
static volatile unsigned int piGpioBase = 0 ; static volatile unsigned int piGpioBase = 0 ;
const char *piModelNames [16] = const char *piModelNames [20] =
{ {
"Model A", // 0 "Model A", // 0
"Model B", // 1 "Model B", // 1
@ -233,9 +233,13 @@ const char *piModelNames [16] =
"CM3", // 10 "CM3", // 10
"Unknown11", // 11 "Unknown11", // 11
"Pi Zero-W", // 12 "Pi Zero-W", // 12
"Pi 3+", // 13 "Pi 3B+", // 13
"Unknown14", // 14 "Pi 3A+", // 14
"Unknown15", // 15 "Unknown15", // 15
"CM3+", // 16
"Unknown17", // 17
"Unknown18", // 18
"Unknown19", // 19
} ; } ;
const char *piRevisionNames [16] = const char *piRevisionNames [16] =
@ -2239,7 +2243,7 @@ int wiringPiSetup (void)
piBoardId (&model, &rev, &mem, &maker, &overVolted) ; piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3)) if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P))
wiringPiMode = WPI_MODE_GPIO ; wiringPiMode = WPI_MODE_GPIO ;
else else
wiringPiMode = WPI_MODE_PINS ; wiringPiMode = WPI_MODE_PINS ;

View File

@ -95,11 +95,13 @@
#define PI_ALPHA 5 #define PI_ALPHA 5
#define PI_MODEL_CM 6 #define PI_MODEL_CM 6
#define PI_MODEL_07 7 #define PI_MODEL_07 7
#define PI_MODEL_3 8 #define PI_MODEL_3B 8
#define PI_MODEL_ZERO 9 #define PI_MODEL_ZERO 9
#define PI_MODEL_CM3 10 #define PI_MODEL_CM3 10
#define PI_MODEL_ZERO_W 12 #define PI_MODEL_ZERO_W 12
#define PI_MODEL_3P 13 #define PI_MODEL_3BP 13
#define PI_MODEL_3AP 14
#define PI_MODEL_CM3P 16
#define PI_VERSION_1 0 #define PI_VERSION_1 0
#define PI_VERSION_1_1 1 #define PI_VERSION_1_1 1
@ -111,7 +113,7 @@
#define PI_MAKER_EMBEST 2 #define PI_MAKER_EMBEST 2
#define PI_MAKER_UNKNOWN 3 #define PI_MAKER_UNKNOWN 3
extern const char *piModelNames [16] ; extern const char *piModelNames [20] ;
extern const char *piRevisionNames [16] ; extern const char *piRevisionNames [16] ;
extern const char *piMakerNames [16] ; extern const char *piMakerNames [16] ;
extern const int piMemorySize [ 8] ; extern const int piMemorySize [ 8] ;

View File

@ -23,7 +23,9 @@
*/ */
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -39,8 +41,8 @@
// The SPI bus parameters // The SPI bus parameters
// Variables as they need to be passed as pointers later on // Variables as they need to be passed as pointers later on
static const char *spiDev0 = "/dev/spidev0.0" ; //static const char *spiDev0 = "/dev/spidev0.0" ;
static const char *spiDev1 = "/dev/spidev0.1" ; //static const char *spiDev1 = "/dev/spidev0.1" ;
static const uint8_t spiBPW = 8 ; static const uint8_t spiBPW = 8 ;
static const uint16_t spiDelay = 0 ; static const uint16_t spiDelay = 0 ;
@ -100,11 +102,16 @@ int wiringPiSPIDataRW (int channel, unsigned char *data, int len)
int wiringPiSPISetupMode (int channel, int speed, int mode) int wiringPiSPISetupMode (int channel, int speed, int mode)
{ {
int fd ; int fd ;
char spiDev [32] ;
mode &= 3 ; // Mode is 0, 1, 2 or 3 mode &= 3 ; // Mode is 0, 1, 2 or 3
channel &= 1 ; // Channel is 0 or 1
if ((fd = open (channel == 0 ? spiDev0 : spiDev1, O_RDWR)) < 0) // Channel can be anything - lets hope for the best
// channel &= 1 ; // Channel is 0 or 1
snprintf (spiDev, 31, "/dev/spidev0.%d", channel) ;
if ((fd = open (spiDev, O_RDWR)) < 0)
return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ;
spiSpeeds [channel] = speed ; spiSpeeds [channel] = speed ;