From 03204c3807e660e81209284c7f8e426e04077fb7 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Sat, 14 Dec 2019 13:42:07 +1300 Subject: [PATCH] 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 --- VERSION | 2 +- gpio/readall.c | 17 ++++++++++------- version.h | 4 ++-- wiringPi/wiringPi.c | 12 ++++++++---- wiringPi/wiringPi.h | 8 +++++--- wiringPi/wiringPiSPI.c | 15 +++++++++++---- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/VERSION b/VERSION index e72716a..f02fc20 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.46 +2.50 diff --git a/gpio/readall.c b/gpio/readall.c index 9396c6d..097755a 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -303,10 +303,12 @@ static void plus2header (int model) printf (" +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+\n") ; else if (model == PI_MODEL_2) printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ; - else if (model == PI_MODEL_3) - printf (" +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+\n") ; - else if (model == PI_MODEL_3P) - printf (" +-----+-----+---------+------+---+---Pi 3+--+---+------+---------+-----+-----+\n") ; + else if (model == PI_MODEL_3B) + printf (" +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+\n") ; + else if (model == PI_MODEL_3BP) + printf (" +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+\n") ; + else if (model == PI_MODEL_3AP) + printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n") ; else printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; } @@ -351,11 +353,12 @@ 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_3P) || + (model == PI_MODEL_2) || + (model == PI_MODEL_3AP) || + (model == PI_MODEL_3B) || (model == PI_MODEL_3BP) || (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) 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 () ; else printf ("Oops - unable to determine board type... model: %d\n", model) ; diff --git a/version.h b/version.h index 242c62b..07e50ef 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ -#define VERSION "2.46" +#define VERSION "2.50" #define VERSION_MAJOR 2 -#define VERSION_MINOR 46 +#define VERSION_MINOR 50 diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 586b148..3db6866 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -218,7 +218,7 @@ volatile unsigned int *_wiringPiTimerIrqRaw ; static volatile unsigned int piGpioBase = 0 ; -const char *piModelNames [16] = +const char *piModelNames [20] = { "Model A", // 0 "Model B", // 1 @@ -233,9 +233,13 @@ const char *piModelNames [16] = "CM3", // 10 "Unknown11", // 11 "Pi Zero-W", // 12 - "Pi 3+", // 13 - "Unknown14", // 14 + "Pi 3B+", // 13 + "Pi 3A+", // 14 "Unknown15", // 15 + "CM3+", // 16 + "Unknown17", // 17 + "Unknown18", // 18 + "Unknown19", // 19 } ; const char *piRevisionNames [16] = @@ -2239,7 +2243,7 @@ int wiringPiSetup (void) 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 ; else wiringPiMode = WPI_MODE_PINS ; diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h index ae5d647..0ff0c92 100644 --- a/wiringPi/wiringPi.h +++ b/wiringPi/wiringPi.h @@ -95,11 +95,13 @@ #define PI_ALPHA 5 #define PI_MODEL_CM 6 #define PI_MODEL_07 7 -#define PI_MODEL_3 8 +#define PI_MODEL_3B 8 #define PI_MODEL_ZERO 9 #define PI_MODEL_CM3 10 #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_1 1 @@ -111,7 +113,7 @@ #define PI_MAKER_EMBEST 2 #define PI_MAKER_UNKNOWN 3 -extern const char *piModelNames [16] ; +extern const char *piModelNames [20] ; extern const char *piRevisionNames [16] ; extern const char *piMakerNames [16] ; extern const int piMemorySize [ 8] ; diff --git a/wiringPi/wiringPiSPI.c b/wiringPi/wiringPiSPI.c index 022b99f..749c8fe 100644 --- a/wiringPi/wiringPiSPI.c +++ b/wiringPi/wiringPiSPI.c @@ -23,7 +23,9 @@ */ +#include #include +#include #include #include #include @@ -39,8 +41,8 @@ // The SPI bus parameters // Variables as they need to be passed as pointers later on -static const char *spiDev0 = "/dev/spidev0.0" ; -static const char *spiDev1 = "/dev/spidev0.1" ; +//static const char *spiDev0 = "/dev/spidev0.0" ; +//static const char *spiDev1 = "/dev/spidev0.1" ; static const uint8_t spiBPW = 8 ; 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 fd ; + char spiDev [32] ; 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)) ; spiSpeeds [channel] = speed ;