Przeglądaj źródła

Fixing a few issues - makefile goofs.

Also adding in the stuff for /dev/gpiomem with warnings
and information in the gpio manual page (who reads that
though!)
pull/62/head
Gordon Henderson 9 lat temu
rodzic
commit
d79506694d
9 zmienionych plików z 80 dodań i 11 usunięć
  1. +1
    -1
      VERSION
  2. +1
    -1
      debian-template/wiringPi/DEBIAN/control
  3. +2
    -2
      examples/Makefile
  4. +14
    -3
      examples/max31855.c
  5. +1
    -1
      gpio/Makefile
  6. +13
    -1
      gpio/gpio.1
  7. +3
    -0
      gpio/gpio.c
  8. +1
    -1
      gpio/version.h
  9. +44
    -1
      wiringPi/wiringPi.c

+ 1
- 1
VERSION Wyświetl plik

@@ -1 +1 @@
2.28
2.29

+ 1
- 1
debian-template/wiringPi/DEBIAN/control Wyświetl plik

@@ -1,5 +1,5 @@
Package: wiringpi
Version: 2.28
Version: 2.29
Section: libraries
Priority: optional
Architecture: armhf


+ 2
- 2
examples/Makefile Wyświetl plik

@@ -45,7 +45,7 @@ SRC = blink.c blink8.c blink12.c \
lcd.c lcd-adafruit.c clock.c \
nes.c \
softPwm.c softTone.c \
delayTest.c serialRead.c serialTest.c okLed.c ds1302.c \
delayTest.c serialRead.c serialTestc okLed.c ds1302.c \
lowPower.c \
max31855.c \
rht03.c
@@ -151,7 +151,7 @@ ds1302: ds1302.o

max31855: max31855.o
$Q echo [link]
$Q $(CC) -o $@ max31855.c.o $(LDFLAGS) $(LDLIBS)
$Q $(CC) -o $@ max31855.o $(LDFLAGS) $(LDLIBS)

.c.o:
$Q echo [CC] $<


+ 14
- 3
examples/max31855.c Wyświetl plik

@@ -33,7 +33,7 @@

int main (int argc, char *argv [])
{
int i ;
int i = 0 ;

wiringPiSetup () ;
max31855Setup (200, 0) ;
@@ -41,9 +41,20 @@ int main (int argc, char *argv [])

for (;;)
{
printf ("%6d, %6d, %6d, %6d ::::", analogRead (200), analogRead (201), analogRead (202), analogRead (203)) ;
printf ("%6d, %6d, %6d, %6d\n", analogRead (400), analogRead (401), analogRead (402), analogRead (403)) ;
if (i == 0)
{
printf ("+------+------+------+------++------+------+------+------+\n") ;
printf ("| Raw | Err | C | F || Raw | Err | C | F |\n") ;
printf ("+------+------+------+------++------+------+------+------+\n") ;
}

printf ("| %4d | %4d | %4d | %4d |", analogRead (200), analogRead (201), analogRead (202), analogRead (203)) ;
printf ("| %4d | %4d | %4d | %4d |\n", analogRead (400), analogRead (401), analogRead (402), analogRead (403)) ;
delay (500) ;

if (++i == 10)
i = 0 ;

}

}

+ 1
- 1
gpio/Makefile Wyświetl plik

@@ -37,7 +37,7 @@ INCLUDE = -I$(DESTDIR)$(PREFIX)/include
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe

LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lwiringPi -lwiringPiDev -lpthread -lm
LIBS = -lwiringPi -lwiringPiDev -lpthread

# May not need to alter anything below this line
###############################################################################


+ 13
- 1
gpio/gpio.1 Wyświetl plik

@@ -260,7 +260,7 @@ raspi-config program to load/unload the I2C device at boot time.
This loads the spi drivers into the kernel and changes the permissions
on the associated /dev/ entries so that the current user has access to
them. It used to have the ability to change the buffer size from the
default of 4096 bytes to an arbitary value, however for some time the
default of 4096 bytes to an arbitrary value, however for some time the
Pi Foundation have compiled the SPI device driver into the kernel and
this has fixed the buffer size. The way to change it now is to edit
the /boot/cmdline.txt file and add on spdev.bufsiz=8192 to set it to
@@ -321,6 +321,18 @@ When using the \fIexport\fR, \fIedge\fR or \fIunexport\fR commands, the
pin numbers are \fBalways\fR native BCM_GPIO numbers and never wiringPi
pin numbers.

As of kernels 4.1.7, a user-level GPIO access mechanism is available,
however wiringPi will not use this by default - because at this time
there appears to be issues when trying to program the PWM or clock output
hardware. If you can live without PWM or GPIO clocks and you want to use
the GPIO from a non-root program, then you need to make sure that the
module \fIbcm2835_gpiomem\fR is loaded at boot time. This should happen
automatically when you enable the device tree in raspi-config. You may
also need some additional information in /etc/udev/rules.d/ to change the
mode and ownership of the /dev/gpiomem file. Finally, you need to set
the environment variable \fIWIRINGPI_GPIOMEM\fR. This will go-away
in future releases once the /dev/gpiomem interface is fully operational.

.SH "SEE ALSO"

.LP


+ 3
- 0
gpio/gpio.c Wyświetl plik

@@ -1223,7 +1223,10 @@ int main (int argc, char *argv [])
printf (" Device tree is enabled.\n") ;

if (stat ("/dev/gpiomem", &statBuf) == 0) // User level GPIO is GO
{
printf (" This Raspberry Pi supports user-level GPIO access.\n") ;
printf (" -> See the man-page for more details\n") ;
}
else
printf (" * Root or sudo required for GPIO access.\n") ;


+ 1
- 1
gpio/version.h Wyświetl plik

@@ -1 +1 @@
#define VERSION "2.28"
#define VERSION "2.29"

+ 44
- 1
wiringPi/wiringPi.c Wyświetl plik

@@ -84,6 +84,7 @@

#define ENV_DEBUG "WIRINGPI_DEBUG"
#define ENV_CODES "WIRINGPI_CODES"
#define ENV_GPIOMEM "WIRINGPI_GPIOMEM"


// Mask for the bottom 64 pins which belong to the Raspberry Pi
@@ -253,6 +254,10 @@ static pthread_mutex_t pinMutex ;
int wiringPiDebug = FALSE ;
int wiringPiReturnCodes = FALSE ;

// Use /dev/gpiomem ?

int wiringPiTryGpioMem = FALSE ;

// sysFds:
// Map a file descriptor from the /sys/class/gpio/gpioX/value

@@ -913,6 +918,9 @@ void setPadDrive (int group, int value)

if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

if ((group < 0) || (group > 2))
return ;

@@ -986,6 +994,9 @@ void pwmSetRange (unsigned int range)
{
if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

*(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ;
*(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ;
}
@@ -1007,6 +1018,9 @@ void pwmSetClock (int divisor)

if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

if (wiringPiDebug)
printf ("Setting to: %d. Current: 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;

@@ -1059,6 +1073,9 @@ void gpioClockSet (int pin, int freq)
else if (wiringPiMode != WPI_MODE_GPIO)
return ;
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

divi = 19200000 / freq ;
divr = 19200000 % freq ;
divf = (int)((double)divr * 4096.0 / 19200000.0) ;
@@ -1231,11 +1248,17 @@ void pinMode (int pin, int mode)
softToneCreate (origPin) ;
else if (mode == PWM_TONE_OUTPUT)
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

pinMode (origPin, PWM_OUTPUT) ; // Call myself to enable PWM mode
pwmSetMode (PWM_MODE_MS) ;
}
else if (mode == PWM_OUTPUT)
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

if ((alt = gpioToPwmALT [pin]) == 0) // Not a hardware capable PWM pin
return ;

@@ -1250,6 +1273,9 @@ void pinMode (int pin, int mode)
}
else if (mode == GPIO_CLOCK)
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

if ((alt = gpioToGpClkALT0 [pin]) == 0) // Not a GPIO_CLOCK pin
return ;

@@ -1404,6 +1430,9 @@ void pwmWrite (int pin, int value)

if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
{
if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

/**/ if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio [pin] ;
else if (wiringPiMode == WPI_MODE_PHYS)
@@ -1470,6 +1499,9 @@ void pwmToneWrite (int pin, int freq)
{
int range ;

if (RASPBERRY_PI_PERI_BASE == 0) // Ignore for now
return ;

if (freq == 0)
pwmWrite (pin, 0) ; // Off
else
@@ -1838,8 +1870,15 @@ int wiringPiSetup (void)
if (getenv (ENV_CODES) != NULL)
wiringPiReturnCodes = TRUE ;

if (getenv (ENV_GPIOMEM) != NULL)
wiringPiTryGpioMem = TRUE ;

if (wiringPiDebug)
{
printf ("wiringPi: wiringPiSetup called\n") ;
if (wiringPiTryGpioMem)
printf ("wiringPi: Using /dev/gpiomem\n") ;
}

boardRev = piBoardRev () ;

@@ -1863,8 +1902,12 @@ int wiringPiSetup (void)

// See if /dev/gpiomem exists and we can open it...

if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) >= 0)
if (wiringPiTryGpioMem)
{
if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/gpiomem: %s\n", strerror (errno)) ;
RASPBERRY_PI_PERI_BASE = 0 ;
}

// ... otherwise fall back to the original /dev/mem which requires root level access



Ładowanie…
Anuluj
Zapisz