@@ -1 +1 @@ | |||||
3.8 | |||||
3.10 |
@@ -65,7 +65,7 @@ void drawClockHands (void) | |||||
struct tm *now ; | struct tm *now ; | ||||
double angle, p, x0, y0, x1, y1 ; | double angle, p, x0, y0, x1, y1 ; | ||||
int h24, h, m, s ; | int h24, h, m, s ; | ||||
char text [20] ; | |||||
char text [40] ; | |||||
time (&t) ; | time (&t) ; | ||||
now = localtime (&t) ; | now = localtime (&t) ; | ||||
@@ -37,7 +37,7 @@ int main() | |||||
int t ; | int t ; | ||||
int max, min ; | int max, min ; | ||||
int del ; | int del ; | ||||
int underRuns, overRuns, exactRuns, bogusRuns, total ; | |||||
int underRuns, overRuns, exactRuns, total ; | |||||
int descheds ; | int descheds ; | ||||
@@ -93,7 +93,7 @@ int main (void) | |||||
// character device ABI | // character device ABI | ||||
printf ("\ncharacter device ABI method: (%8d iterations)\n", SLOW_COUNT) ; | printf ("\ncharacter device ABI method: (%8d iterations)\n", SLOW_COUNT) ; | ||||
wiringPiSetupGpioDevice () ; | |||||
wiringPiSetupGpioDevice (WPI_PIN_BCM) ; | |||||
pinMode (17, OUTPUT) ; | pinMode (17, OUTPUT) ; | ||||
speedTest (17, SLOW_COUNT) ; | speedTest (17, SLOW_COUNT) ; | ||||
@@ -4,7 +4,7 @@ | |||||
# A swiss-army knige of GPIO shenanigans. | # A swiss-army knige of GPIO shenanigans. | ||||
# https://github.com/wiringPi/wiringPi | # https://github.com/wiringPi/wiringPi | ||||
# | # | ||||
# Copyright (c) 2012-2016 Gordon Henderson | |||||
# Copyright (c) 2012-2024 Gordon Henderson and contributors | |||||
################################################################################# | ################################################################################# | ||||
# This file is part of wiringPi: | # This file is part of wiringPi: | ||||
# A "wiring" library for the Raspberry Pi | # A "wiring" library for the Raspberry Pi | ||||
@@ -75,7 +75,7 @@ install: gpio | |||||
$Q mkdir -p $(DESTDIR)$(PREFIX)/bin | $Q mkdir -p $(DESTDIR)$(PREFIX)/bin | ||||
$Q cp gpio $(DESTDIR)$(PREFIX)/bin | $Q cp gpio $(DESTDIR)$(PREFIX)/bin | ||||
ifneq ($(WIRINGPI_SUID),0) | ifneq ($(WIRINGPI_SUID),0) | ||||
$Q chown root.root $(DESTDIR)$(PREFIX)/bin/gpio | |||||
$Q chown root:root $(DESTDIR)$(PREFIX)/bin/gpio | |||||
$Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio | $Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio | ||||
endif | endif | ||||
$Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 | $Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 | ||||
@@ -75,8 +75,9 @@ static void doReadallExternal (void) | |||||
********************************************************************************* | ********************************************************************************* | ||||
*/ | */ | ||||
#define MAX_ALTS 11 | |||||
static const char unknown_alt[] = " - "; | static const char unknown_alt[] = " - "; | ||||
static const char *alts [] = | |||||
static const char *alts [MAX_ALTS+1] = | |||||
{ | { | ||||
"IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3", "ALT6", "ALT7", "ALT8", "ALT9" | "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3", "ALT6", "ALT7", "ALT8", "ALT9" | ||||
} ; | } ; | ||||
@@ -84,7 +85,7 @@ static const char *alts [] = | |||||
static const char* GetAltString(int alt) { | static const char* GetAltString(int alt) { | ||||
if (alt>=0 && alt<=11) { | |||||
if (alt>=0 && alt<=MAX_ALTS) { | |||||
return alts[alt]; | return alts[alt]; | ||||
} | } | ||||
@@ -1,3 +1,3 @@ | |||||
#define VERSION "3.8" | |||||
#define VERSION "3.10" | |||||
#define VERSION_MAJOR 3 | #define VERSION_MAJOR 3 | ||||
#define VERSION_MINOR 8 | |||||
#define VERSION_MINOR 10 |
@@ -1658,19 +1658,62 @@ void pinEnableED01Pi (int pin) | |||||
} | } | ||||
#endif | #endif | ||||
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length)) | |||||
const char DEV_GPIO_PI[] ="/dev/gpiochip0"; | |||||
const char DEV_GPIO_PI5[]="/dev/gpiochip4"; | |||||
int OpenAndCheckGpioChip(int GPIONo, const char* label, const unsigned int lines) { | |||||
char szGPIOChip[30]; | |||||
sprintf(szGPIOChip, "/dev/gpiochip%d", GPIONo); | |||||
int Fd = open(szGPIOChip, O_RDWR); | |||||
if (Fd < 0) { | |||||
fprintf(stderr, "wiringPi: ERROR: %s open ret=%d\n", szGPIOChip, Fd); | |||||
return Fd; | |||||
} else { | |||||
if (wiringPiDebug) { | |||||
printf("wiringPi: Open chip %s succeded, fd=%d\n", szGPIOChip, Fd) ; | |||||
} | |||||
struct gpiochip_info chipinfo; | |||||
ZeroMemory(&chipinfo, sizeof(chipinfo)); | |||||
int ret = ioctl(Fd, GPIO_GET_CHIPINFO_IOCTL, &chipinfo); | |||||
if (0==ret) { | |||||
if (wiringPiDebug) { | |||||
printf("%s: name=%s, label=%s, lines=%u\n", szGPIOChip, chipinfo.name, chipinfo.label, chipinfo.lines) ; | |||||
} | |||||
int chipOK = 1; | |||||
if (label[0]!='\0' && NULL==strstr(chipinfo.label, label)) { | |||||
chipOK = 0; | |||||
} | |||||
if (lines>0 && chipinfo.lines!=lines) { | |||||
chipOK = 0; | |||||
} | |||||
if (chipOK) { | |||||
if (wiringPiDebug) { | |||||
printf("%s: valid, fd=%d\n", szGPIOChip, Fd); | |||||
} | |||||
} else { | |||||
if (wiringPiDebug) { | |||||
printf("%s: invalid, search for '%s' with %u lines!\n", szGPIOChip, label, lines) ; | |||||
} | |||||
close(Fd); | |||||
return -1; // invalid chip | |||||
} | |||||
} | |||||
} | |||||
return Fd; | |||||
} | |||||
int wiringPiGpioDeviceGetFd() { | int wiringPiGpioDeviceGetFd() { | ||||
if (chipFd<0) { | if (chipFd<0) { | ||||
piBoard(); | piBoard(); | ||||
const char* gpiochip = PI_MODEL_5 == RaspberryPiModel ? DEV_GPIO_PI5 : DEV_GPIO_PI; | |||||
chipFd = open(gpiochip, O_RDWR); | |||||
if (chipFd < 0) { | |||||
fprintf(stderr, "wiringPi: ERROR: %s open ret=%d\n", gpiochip, chipFd); | |||||
} else if (wiringPiDebug) { | |||||
printf ("wiringPi: Open chip %s succeded, fd=%d\n", gpiochip, chipFd) ; | |||||
if (PI_MODEL_5 == RaspberryPiModel) { | |||||
chipFd = OpenAndCheckGpioChip(0, "rp1", 54); // /dev/gpiochip0 @ Pi5 since Kernel 6.6.47 | |||||
if (chipFd<0) { | |||||
chipFd = OpenAndCheckGpioChip(4, "rp1", 54); // /dev/gpiochip4 @ Pi5 with older kernel | |||||
} | |||||
} else { | |||||
// not all Pis have same number of lines: Pi0, Pi1, Pi3, 54 lines, Pi4, 58 lines (CM ?), see #280, so this check is disabled | |||||
chipFd = OpenAndCheckGpioChip(0, "bcm", 0); | |||||
} | } | ||||
} | } | ||||
return chipFd; | return chipFd; | ||||
@@ -3,7 +3,7 @@ | |||||
# The wiringPiD utility: | # The wiringPiD utility: | ||||
# https://github.com/wiringPi/wiringPi | # https://github.com/wiringPi/wiringPi | ||||
# | # | ||||
# Copyright (c) 2012-2017 Gordon Henderson | |||||
# Copyright (c) 2012-2024 Gordon Henderson and contributors | |||||
################################################################################# | ################################################################################# | ||||
# This file is part of wiringPi: | # This file is part of wiringPi: | ||||
# A "wiring" library for the Raspberry Pi | # A "wiring" library for the Raspberry Pi | ||||
@@ -70,7 +70,7 @@ install: wiringpid | |||||
$Q echo "[Install]" | $Q echo "[Install]" | ||||
$Q mkdir -p $(DESTDIR)$(PREFIX)/sbin | $Q mkdir -p $(DESTDIR)$(PREFIX)/sbin | ||||
$Q cp wiringpid $(DESTDIR)$(PREFIX)/sbin | $Q cp wiringpid $(DESTDIR)$(PREFIX)/sbin | ||||
$Q chown root.root $(DESTDIR)$(PREFIX)/sbin/wiringpid | |||||
$Q chown root:root $(DESTDIR)$(PREFIX)/sbin/wiringpid | |||||
# $Q mkdir -p $(DESTDIR)$(PREFIX)/man/man8 | # $Q mkdir -p $(DESTDIR)$(PREFIX)/man/man8 | ||||
# $Q cp gpio.1 $(DESTDIR)$(PREFIX)/man/man8 | # $Q cp gpio.1 $(DESTDIR)$(PREFIX)/man/man8 | ||||