浏览代码

Merge pull request #284 from WiringPi/develop

Develop
master
mstroh76 2 个月前
committed by GitHub
父节点
当前提交
a0b52b3a40
找不到此签名对应的密钥 GPG 密钥 ID: B5690EEEBB952194
共有 9 个文件被更改,包括 64 次插入20 次删除
  1. +1
    -1
      VERSION
  2. +1
    -1
      examples/clock.c
  3. +1
    -1
      examples/delayTest.c
  4. +1
    -1
      examples/speed.c
  5. +2
    -2
      gpio/Makefile
  6. +3
    -2
      gpio/readall.c
  7. +2
    -2
      version.h
  8. +51
    -8
      wiringPi/wiringPi.c
  9. +2
    -2
      wiringPiD/Makefile

+ 1
- 1
VERSION 查看文件

@@ -1 +1 @@
3.8
3.10

+ 1
- 1
examples/clock.c 查看文件

@@ -65,7 +65,7 @@ void drawClockHands (void)
struct tm *now ;
double angle, p, x0, y0, x1, y1 ;
int h24, h, m, s ;
char text [20] ;
char text [40] ;

time (&t) ;
now = localtime (&t) ;


+ 1
- 1
examples/delayTest.c 查看文件

@@ -37,7 +37,7 @@ int main()
int t ;
int max, min ;
int del ;
int underRuns, overRuns, exactRuns, bogusRuns, total ;
int underRuns, overRuns, exactRuns, total ;
int descheds ;




+ 1
- 1
examples/speed.c 查看文件

@@ -93,7 +93,7 @@ int main (void)
// character device ABI

printf ("\ncharacter device ABI method: (%8d iterations)\n", SLOW_COUNT) ;
wiringPiSetupGpioDevice () ;
wiringPiSetupGpioDevice (WPI_PIN_BCM) ;
pinMode (17, OUTPUT) ;
speedTest (17, SLOW_COUNT) ;



+ 2
- 2
gpio/Makefile 查看文件

@@ -4,7 +4,7 @@
# A swiss-army knige of GPIO shenanigans.
# 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:
# A "wiring" library for the Raspberry Pi
@@ -75,7 +75,7 @@ install: gpio
$Q mkdir -p $(DESTDIR)$(PREFIX)/bin
$Q cp gpio $(DESTDIR)$(PREFIX)/bin
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
endif
$Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1


+ 3
- 2
gpio/readall.c 查看文件

@@ -75,8 +75,9 @@ static void doReadallExternal (void)
*********************************************************************************
*/

#define MAX_ALTS 11
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"
} ;
@@ -84,7 +85,7 @@ static const char *alts [] =

static const char* GetAltString(int alt) {

if (alt>=0 && alt<=11) {
if (alt>=0 && alt<=MAX_ALTS) {
return alts[alt];
}



+ 2
- 2
version.h 查看文件

@@ -1,3 +1,3 @@
#define VERSION "3.8"
#define VERSION "3.10"
#define VERSION_MAJOR 3
#define VERSION_MINOR 8
#define VERSION_MINOR 10

+ 51
- 8
wiringPi/wiringPi.c 查看文件

@@ -1658,19 +1658,62 @@ void pinEnableED01Pi (int pin)
}
#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() {
if (chipFd<0) {
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;


+ 2
- 2
wiringPiD/Makefile 查看文件

@@ -3,7 +3,7 @@
# The wiringPiD utility:
# 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:
# A "wiring" library for the Raspberry Pi
@@ -70,7 +70,7 @@ install: wiringpid
$Q echo "[Install]"
$Q mkdir -p $(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 cp gpio.1 $(DESTDIR)$(PREFIX)/man/man8


正在加载...
取消
保存