From 1aed7f7c9d9e9dcc4f3b0a88a589d78be3777090 Mon Sep 17 00:00:00 2001 From: fanoush Date: Thu, 26 Nov 2020 15:57:05 +0100 Subject: [PATCH] Add support for Pi 400 and CM4 --- gpio/readall.c | 6 ++++-- wiringPi/wiringPi.c | 7 +++++-- wiringPi/wiringPi.h | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gpio/readall.c b/gpio/readall.c index 2d745a4..f0ad40d 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -311,6 +311,8 @@ static void plus2header (int model) printf (" +-----+-----+---------+------+---+---Pi 3A+-+---+------+---------+-----+-----+\n") ; else if (model == PI_MODEL_4B) printf (" +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+\n") ; + else if (model == PI_MODEL_400) + printf (" +-----+-----+---------+------+---+---Pi 400-+---+------+---------+-----+-----+\n") ; else printf (" +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+\n") ; } @@ -358,10 +360,10 @@ void doReadall (void) (model == PI_MODEL_2) || (model == PI_MODEL_3AP) || (model == PI_MODEL_3B) || (model == PI_MODEL_3BP) || - (model == PI_MODEL_4B) || + (model == PI_MODEL_4B) || (model == PI_MODEL_400) || (model == PI_MODEL_ZERO) || (model == PI_MODEL_ZERO_W)) piPlusReadall (model) ; - else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || ((model == PI_MODEL_CM3P))) + else if ((model == PI_MODEL_CM) || (model == PI_MODEL_CM3) || (model == PI_MODEL_CM3P) || (model == PI_MODEL_CM4)) allReadall () ; else printf ("Oops - unable to determine board type... model: %d\n", model) ; diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index c3b9d8b..59e1baf 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -219,7 +219,7 @@ volatile unsigned int *_wiringPiTimerIrqRaw ; static volatile unsigned int piGpioBase = 0 ; -const char *piModelNames [20] = +const char *piModelNames [21] = { "Model A", // 0 "Model B", // 1 @@ -240,7 +240,8 @@ const char *piModelNames [20] = "CM3+", // 16 "Pi 4B", // 17 "Unknown18", // 18 - "Unknown19", // 19 + "Pi 400", // 19 + "CM4", // 20 } ; const char *piRevisionNames [16] = @@ -2312,6 +2313,8 @@ int wiringPiSetup (void) break ; case PI_MODEL_4B: + case PI_MODEL_400: + case PI_MODEL_CM4: piGpioBase = GPIO_PERI_BASE_2711 ; piGpioPupOffset = GPPUPPDN0 ; break ; diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h index ecce383..fc0d497 100644 --- a/wiringPi/wiringPi.h +++ b/wiringPi/wiringPi.h @@ -103,6 +103,8 @@ #define PI_MODEL_3AP 14 #define PI_MODEL_CM3P 16 #define PI_MODEL_4B 17 +#define PI_MODEL_400 19 +#define PI_MODEL_CM4 20 #define PI_VERSION_1 0 #define PI_VERSION_1_1 1 @@ -114,7 +116,7 @@ #define PI_MAKER_EMBEST 2 #define PI_MAKER_UNKNOWN 3 -extern const char *piModelNames [20] ; +extern const char *piModelNames [21] ; extern const char *piRevisionNames [16] ; extern const char *piMakerNames [16] ; extern const int piMemorySize [ 8] ;