From 2abcabc4f7e4ed42df66ea650179f6904acf7208 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Sat, 8 Jun 2024 20:04:18 +0200 Subject: [PATCH] #254 remove pins and wiringpid, fix compile error --- CMakeLists.txt | 4 ++-- wiringPi/wiringPi.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b20eb36..90b4d64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,6 @@ project(WiringPiLib) # Include subdirectories add_subdirectory(devLib) add_subdirectory(gpio) -add_subdirectory(pins) +#add_subdirectory(pins) add_subdirectory(wiringPi) -add_subdirectory(wiringPiD) +#add_subdirectory(wiringPiD) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 22d2010..5cdd18f 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -1966,10 +1966,14 @@ int digitalRead (int pin) } if (PI_MODEL_5 == RaspberryPiModel) { - switch(gpio[2*pin] & RP1_STATUS_LEVEL_MASK) { - default: // 11 or 00 not allowed, give LOW! - case RP1_STATUS_LEVEL_LOW: return LOW ; - case RP1_STATUS_LEVEL_HIGH: return HIGH ; + const unsigned int status = gpio[2*pin] & RP1_STATUS_LEVEL_MASK; + if (RP1_STATUS_LEVEL_LOW==status) { + return LOW; + } else if (RP1_STATUS_LEVEL_HIGH==status) { + return HIGH; + } else { // 11 or 00 not allowed, give LOW! + fprintf(stderr, "digitalRead: invalid status %u\n", status); + return LOW; } } else { if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)