chiark / gitweb /
Fixing a few issues - makefile goofs.
authorGordon Henderson <projects@drogon.net>
Wed, 30 Sep 2015 15:11:42 +0000 (16:11 +0100)
committerGordon Henderson <projects@drogon.net>
Wed, 30 Sep 2015 15:11:42 +0000 (16:11 +0100)
Also adding in the stuff for /dev/gpiomem with warnings
and information in the gpio manual page (who reads that
though!)

VERSION
debian-template/wiringPi/DEBIAN/control
examples/Makefile
examples/max31855.c
gpio/Makefile
gpio/gpio.1
gpio/gpio.c
gpio/version.h
wiringPi/wiringPi.c

diff --git a/VERSION b/VERSION
index 410158ac6db4cffce76ff93122ccd007fb6e74a9..072e651358f916e70f590870b4c74880ac696de6 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.28
+2.29
index 9def8c5c955d01f38ae95885e5af9ca03b2c0125..3b15a242fd6f0394f2cdeb15c9eeefe1297cbb65 100644 (file)
@@ -1,5 +1,5 @@
 Package: wiringpi
-Version: 2.28
+Version: 2.29
 Section: libraries
 Priority: optional
 Architecture: armhf
index 04bcaecacf2832f8e1d5a9575c175e3883121ae1..e6b9b71b86e7af2b52bf439e9f75d2f21d35cb31 100644 (file)
@@ -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] $<
index 2060a5592cfb9e9d102c9648f5297c55bb11d07b..36b3cf60d6835226654ccd950b39cc3ca36c86c7 100644 (file)
@@ -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 ;
+
   }
 
 }
index e998d8464be8b089af20e6c0179ffc74f6e7293f..7dcd090a3d6954f938e5e2251e0ae3dfe93e4215 100644 (file)
@@ -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
 ###############################################################################
index 673ebbe2c8db2c2d215fee702db2fd4ec223825f..e5fe181e7d94a2e2a1167d74c80fb4434ce1f3a6 100644 (file)
@@ -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
index 5c87a7e16ee09545945f2e9615b6d4fd18ae5c7b..4eef19d6ced5f947d8e86bb73b17c0005e84a974 100644 (file)
@@ -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") ;
       
index 704c10dfbd35e6267bf8e2d1f08e3af4404f724e..ac094927eb62b299652918f0397d635f36b46b8b 100644 (file)
@@ -1 +1 @@
-#define VERSION "2.28"
+#define VERSION "2.29"
index 7c899ea5c276316e4f4c0d2b78bb31815557369b..32e5100c48cba2bfade613d10be8b6ee1a0893b8 100644 (file)
@@ -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