chiark / gitweb /
Slight change to the gpio program to fix SPI buffer size when loading
authorGordon Henderson <projects@drogon.net>
Thu, 7 Feb 2013 21:53:49 +0000 (21:53 +0000)
committerGordon Henderson <projects@drogon.net>
Thu, 7 Feb 2013 21:53:49 +0000 (21:53 +0000)
the module.
Typo in gpio man page
Bug fixed in board revision detection (which would never happen
anyway, however)

People
gpio/gpio.1
gpio/gpio.c
wiringPi/wiringPi.c
wiringPi/wiringPiISR.c [deleted file]

diff --git a/People b/People
index f5645be1c3b48f1698e8827d399b005c868c638f..8be8b6d2e5c18b4c744366cc3a725b0604353e3e 100644 (file)
--- a/People
+++ b/People
@@ -22,3 +22,6 @@ Arno Wagner
 
 CHARLES Thibaut:
   A small issue in softTone
+
+Xian Stannard
+  Fixing some typos in the man page!
index ec54f13faa6ea3b72ef3898d59fca96eacff4d6c..ec65519a9004b4b4cbba51cb7bf6513e285623c5 100644 (file)
@@ -182,7 +182,7 @@ close as the Pi can manage) The default speed is 100Kb/sec.
 
 .TP
 .B load spi [buffer size in KB]
-This loads the the spi drivers into the kernel and changes the permissions
+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. Optionally it will set the SPI buffer size to that supplied. The
 default is 4KB.
index 8d61957d07e5757c8ba8f7b3ad362f91eb4f07f9..e71e432f310ac06ff9c5479621fc6c5948795e22 100644 (file)
@@ -42,7 +42,7 @@ extern int wiringPiDebug ;
 #  define      FALSE   (1==2)
 #endif
 
-#define        VERSION "1.11"
+#define        VERSION "1.12"
 
 static int wpMode ;
 
@@ -152,7 +152,7 @@ static void doLoad (int argc, char *argv [])
     file1  = "/dev/spidev0.0" ;
     file2  = "/dev/spidev0.1" ;
     if (argc == 4)
-      sprintf (args1, " bufsize=%d", atoi (argv [3]) * 1024) ;
+      sprintf (args1, " bufsiz=%d", atoi (argv [3]) * 1024) ;
     else if (argc > 4)
       _doLoadUsage (argv) ;
   }
index 12b1af11ef0ecefc489dc59fb97f7f53a18543ee..a68ae33e0565cbd9e39bb36b373b2315d31c703b 100644 (file)
@@ -475,9 +475,11 @@ int wpiPinToGpio (int wpiPin)
  *     0001 - Not used
  *     0002 - Rev 1
  *     0003 - Rev 1
- *     0004 - Rev 2
- *     0005 - Rev 2 (but error)
+ *     0004 - Rev 2 (Early reports?
+ *     0005 - Rev 2 (but error?)
  *     0006 - Rev 2
+ *     0008 - Rev 2 - Model A
+ *     000e - Rev 2 + 512MB
  *     000f - Rev 2 + 512MB
  *
  *     A small thorn is the olde style overvolting - that will add in
@@ -502,13 +504,11 @@ int piBoardRev (void)
   char *c, lastChar ;
   static int  boardRev = -1 ;
 
-// No point checking twice...
-
-  if (boardRev != -1)
+  if (boardRev != -1)  // No point checking twice
     return boardRev ;
 
   if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
-    return -1 ;
+    piBoardRevOops ("Unable to open /proc/cpuinfo") ;
 
   while (fgets (line, 120, cpuFd) != NULL)
     if (strncmp (line, "Revision", 8) == 0)
@@ -516,10 +516,11 @@ int piBoardRev (void)
 
   fclose (cpuFd) ;
 
-  if (line == NULL)
+  if (strncmp (line, "Revision", 8) != 0)
     piBoardRevOops ("No \"Revision\" line") ;
 
-  line [strlen (line) - 1] = 0 ; // Chomp LF
+  for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
+    *c = 0 ;
   
   if (wiringPiDebug)
     printf ("piboardRev: Revision string: %s\n", line) ;
diff --git a/wiringPi/wiringPiISR.c b/wiringPi/wiringPiISR.c
deleted file mode 100644 (file)
index 9e847cc..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * wiringPiISR.c:
- *     Simplified Interrupt Service Routine handling
- *     Copyright (c) 2013 Gordon Henderson
- ***********************************************************************
- * This file is part of wiringPi:
- *     https://projects.drogon.net/raspberry-pi/wiringpi/
- *
- *    wiringPi is free software: you can redistribute it and/or modify
- *    it under the terms of the GNU Lesser General Public License as
- *    published by the Free Software Foundation, either version 3 of the
- *    License, or (at your option) any later version.
- *
- *    wiringPi is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with wiringPi.
- *    If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
-#include "wiringPi.h"
-
-
-
-static void (*isrFunctions [64])(void) ;
-static int    isrFds       [64] ;
-
-/*
- * interruptHandler:
- *     This is a thread and gets started to wait for the interrupt we're
- *     hoping to catch. It will call the user-function when the interrupt
- *     fires.
- *********************************************************************************
- */
-
-static void *interruptHandler (void *arg)
-{
-  int pin = *(int *)arg ;
-
-  (void)piHiPri (55) ;
-
-  for (;;)
-  {
-    if (waitForInterrupt (pin, -1) > 0)
-      isrFunctions [pin] () ;
-  }
-
-  return NULL ;
-}
-
-/*
- * wiringPiISR:
- *     Take the details and create an interrupt handler that will do a call-
- *     back to the user supplied function.
- *********************************************************************************
- */
-
-int wiringPiISR (int pin, int mode, void (*function)(void))
-{
-  pthread_t threadId ;
-  char command [64] ;
-
-  pin &= 63 ;
-
-  if (wiringPiMode == WPI_MODE_UNINITIALISED)
-  {
-    fprintf (stderr, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ;
-    exit (EXIT_FAILURE) ;
-  }
-  else if (wiringPiMode == WPI_MODE_PINS)
-    pin = pinToGpio [pin] ;
-
-
-  isrFunctions [pin] = function ;
-
-// Now export the pin and set the right edge
-
-  if (mode != INT_EDGE_SETUP)
-  {
-    /**/ if (mode == INT_EDGE_FALLING)
-      modes = "falling" ;
-    else if (mode == INT_EDGE_RISING)
-      modes = "rising" ;
-    else
-      modes = "both" ;
-
-    sprintf (command, "/usr/local/bin/gpio edge %d %s", pin, modes) ;
-    system (command) ;
-  }
-
-  sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ;
-  if ((isrFds [pin] = open (fName, O_RDWR)) < 0)
-    return -1 ;
-
-  {
-    fprintf ("std
-
-  pthread_create (&threadId, NULL, interruptHandler, &pin) ;
-}
-
-