chiark / gitweb /
Updating gpio manual page
authorGordon Henderson <gordon@drogon.net>
Tue, 2 Oct 2012 13:32:12 +0000 (14:32 +0100)
committerGordon Henderson <gordon@drogon.net>
Tue, 2 Oct 2012 13:32:12 +0000 (14:32 +0100)
examples/Makefile
gpio/Makefile
gpio/gpio.1
gpio/gpio.c
wiringPi/Makefile
wiringPi/lcd.c
wiringPi/lcd.h
wiringPi/wiringPi.c

index 450e0dcd9253805e1fc9fbd18606441f832dfd49..16bf7e2fa6e408000d7a6ebea20523fcd1e30186 100644 (file)
@@ -39,7 +39,12 @@ SRC  =       test1.c test2.c speed.c lcd.c wfi.c piface.c gertboard.c nes.c delayTest.c
 
 OBJ    =       test1.o test2.o speed.o lcd.o wfi.o piface.o gertboard.o nes.o delayTest.o softPwm.o
 
-all:           test1 test2 speed lcd wfi piface gertboard nes softPwm
+BINS   =       test1 test2 speed lcd wfi piface gertboard nes delayTest softPwm
+
+all:   
+       @cat README.TXT
+       @echo "    $(BINS)" | fmt
+       @echo ""
 
 test1: test1.o
        @echo [link]
@@ -77,7 +82,6 @@ softPwm:      softPwm.o
        @echo [link]
        $(CC) -o $@ softPwm.o $(LDFLAGS) $(LIBS) -lm -lpthread
 
-
 delayTest:     delayTest.o
        @echo [link]
        $(CC) -o $@ delayTest.o $(LDFLAGS) $(LIBS)
index a92dd5f930150d70ac36f22a183f99bb4ca8ddee..cd56e5ec3f388f83ca1b85261ac2e8c101822d65 100644 (file)
@@ -41,7 +41,7 @@ OBJ   =       gpio.o
 
 all:           gpio
 
-gpio:  gpio.o /usr/local/lib/libwiringPi.a
+gpio:  gpio.o /usr/local/lib/libwiringPi.a /usr/local/lib/libwiringPi.so.1.0
        @echo [LD]
        @$(CC) -o $@ gpio.o $(LDFLAGS) $(LIBS)
        
@@ -60,11 +60,14 @@ depend:
        makedepend -Y $(SRC)
 
 install:
-       cp gpio /usr/local/bin
-       chown root.root /usr/local/bin/gpio
-       chmod 4755 /usr/local/bin/gpio
-       mkdir -p /usr/local/man/man1
-       cp gpio.1 /usr/local/man/man1
+       @echo -n "Installing... "
+       @cp gpio /usr/local/bin
+       @chown root.root /usr/local/bin/gpio
+       @chmod 4755 /usr/local/bin/gpio
+       @mkdir -p /usr/local/man/man1
+       @cp gpio.1 /usr/local/man/man1
+       @echo "Done."
+       
 
 uninstall:
        rm -f /usr/local/bin/gpio
index bc8e36e10e5b06873429173477bf44deba836088..ba0183f63c61a04fccd180f8894719ef2655c797 100644 (file)
@@ -48,9 +48,9 @@ channel value
 .SH DESCRIPTION
 
 .B GPIO
-is a swiss army knofe of a command line tool to allow the user easy
+is a swiss army knife of a command line tool to allow the user easy
 access to the GPIO pins on the Raspberry Pi and the SPI A/D and D/A
-convertors on the Gertboard. It's designed for simple testing and
+converters on the Gertboard. It's designed for simple testing and
 diagnostic purposes, but can be used in shell scripts for general if
 somewhat slow control of the GPIO pins.
 
@@ -122,7 +122,7 @@ the direction to input and set the edge interrupt method to \fInone\fR,
 above and note that \fBBCM_GPIO\fR pin number is used not not wiringPi pin
 numbering.
 
-Like the export commands abovem ownership is set to that of the 
+Like the export commands above, ownership is set to that of the 
 calling user, allowing subsequent access from user programs without
 requiring root/sudo.
 
@@ -155,7 +155,7 @@ the associated /dev/ entries so that the current user has access to them.
 .B gbr
 channel
 
-This reads the analog to digital convertor on the Gertboard on the given
+This reads the analog to digital converter on the Gertboard on the given
 channel. The board jumpers need to be in-place to do this operation.
 
 .TP
@@ -163,7 +163,7 @@ channel. The board jumpers need to be in-place to do this operation.
 channel value
 
 This writes the supplied value to the output channel on the Gertboards
-SPI digital to analogue convertor.
+SPI digital to analogue converter.
 The board jumpers need to be in-place to do this operation.
 
 
@@ -171,26 +171,30 @@ The board jumpers need to be in-place to do this operation.
 
 .PP
 .TS
-r r l.
-WiringPi       GPIO    Function
+r r l.
+WiringPi       GPIO-r1 GPIO-r2 Function
 _
-0      17
-1      18      (PWM)
-2      21
-3      22
-4      23
-5      24
-6      25
-7      4
-8      0       SDA0
-9      1       SCL0
-10     8       SPI CE0
-11     7       SPI CE1
-12     10      SPI MOSI
-13     9       SPI MISO
-14     11      SPI SCLK
-15     14      TxD
-16     15      RxD
+0      17      17
+1      18      18      (PWM)
+2      21      27
+3      22      22
+4      23      23
+5      24      24
+6      25      25
+7      4       4
+8      0       2       I2C: SDA0
+9      1       3       I2C: SCL0
+10     8       8       SPI: CE0
+11     7       7       SPI: CE1
+12     10      10      SPI: MOSI
+13     9       9       SPI: MISO
+14     11      11      SPI: SCLK
+15     14      14      TxD
+16     15      16      RxD
+17     -       28
+18     -       29
+19     -       30
+20     -       31
 .TE
 
 .SH FILES
index 8b15eea113a5bd27a22814dbc73bf431741df2d6..b3534c8fd2010bfcb7c13a383bb670c8ec793269 100644 (file)
@@ -40,7 +40,7 @@
 #  define      FALSE   (1==2)
 #endif
 
-#define        VERSION "1.2"
+#define        VERSION "1.3"
 
 static int wpMode ;
 
@@ -753,7 +753,7 @@ int main (int argc, char *argv [])
 
   if (argc == 1)
   {
-    fprintf (stderr, "%s: %s\n", argv [0], usage) ;
+    fprintf (stderr, "%s\n", usage) ;
     return 1 ;
   }
 
@@ -769,6 +769,8 @@ int main (int argc, char *argv [])
     printf ("Copyright (c) 2012 Gordon Henderson\n") ;
     printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
     printf ("For details type: %s -warranty\n", argv [0]) ;
+    printf ("\n") ;
+    printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ;
     return 0 ;
   }
 
@@ -807,9 +809,8 @@ int main (int argc, char *argv [])
   else if (strcasecmp (argv [1], "unexportall") == 0)  { doUnexportall (argc, argv) ;  return 0 ; }
   else if (strcasecmp (argv [1], "unexport"   ) == 0)  { doUnexport    (argc, argv) ;  return 0 ; }
 
-// Check for drive or load commands:
+// Check for load command:
 
-  if (strcasecmp (argv [1], "drive") == 0)     { doPadDrive (argc, argv) ; return 0 ; }
   if (strcasecmp (argv [1], "load" ) == 0)     { doLoad     (argc, argv) ; return 0 ; }
 
 // Gertboard commands
@@ -861,14 +862,15 @@ int main (int argc, char *argv [])
     wpMode = WPI_MODE_PINS ;
   }
 
-// Check for PWM operations
+// Check for PWM or Pad Drive operations
 
   if (wpMode != WPI_MODE_PIFACE)
   {
-    if (strcasecmp (argv [1], "pwm-bal") == 0) { doPwmMode  (PWM_MODE_BAL) ; return 0 ; }
-    if (strcasecmp (argv [1], "pwm-ms")  == 0) { doPwmMode  (PWM_MODE_MS) ;  return 0 ; }
-    if (strcasecmp (argv [1], "pwmr")    == 0) { doPwmRange (argc, argv) ;   return 0 ; }
-    if (strcasecmp (argv [1], "pwmc")    == 0) { doPwmClock (argc, argv) ;   return 0 ; }
+    if (strcasecmp (argv [1], "pwm-bal") == 0) { doPwmMode  (PWM_MODE_BAL) ;   return 0 ; }
+    if (strcasecmp (argv [1], "pwm-ms")  == 0) { doPwmMode  (PWM_MODE_MS) ;    return 0 ; }
+    if (strcasecmp (argv [1], "pwmr")    == 0) { doPwmRange (argc, argv) ;     return 0 ; }
+    if (strcasecmp (argv [1], "pwmc")    == 0) { doPwmClock (argc, argv) ;     return 0 ; }
+    if (strcasecmp (argv [1], "drive")   == 0) { doPadDrive (argc, argv) ;     return 0 ; }
   }
 
 // Check for wiring commands
index dc189cda2c9dad55d87c3192170e2cd839474f81..2d7967f109761e993f493e0ce211b9d38de6eedc 100644 (file)
 #    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
 #################################################################################
 
+DYN_VERS_MAJ=1
+DYN_VERS_MIN=0
 
-TARGET=libwiringPi.a
+STATIC=libwiringPi.a
+DYNAMIC=libwiringPi.so.$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
 
 #DEBUG = -g -O0
-DEBUG  = -O3
+DEBUG  = -O2
 CC     = gcc
 INCLUDE        = -I.
-CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
+CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe -fPIC
 
 LIBS    =
 
@@ -45,20 +48,25 @@ OBJ =       wiringPi.o wiringPiFace.o wiringSerial.o wiringShift.o  \
                piNes.o                                                 \
                lcd.o piHiPri.o piThread.o softPwm.o wiringPiSPI.o
 
-all:           $(TARGET)
+all:           $(STATIC) $(DYNAMIC)
 
-$(TARGET):     $(OBJ)
-       @echo [AR] $(OBJ)
-       @ar rcs $(TARGET) $(OBJ)
-       @ranlib $(TARGET)
-       @size   $(TARGET)
+$(STATIC):     $(OBJ)
+       @echo [STATIC]
+       @ar rcs $(STATIC) $(OBJ)
+       @ranlib $(STATIC)
+
+#      @size   $(STATIC)
+
+$(DYNAMIC):    $(OBJ)
+       @echo [DYNAMIC]
+       @gcc -shared -Wl,-soname,libwiringPi.so.1 -o libwiringPi.so.1.0 -lpthread $(OBJ)
 
 .c.o:
        @echo [CC] $<
        @$(CC) -c $(CFLAGS) $< -o $@
 
 clean:
-       rm -f $(OBJ) $(TARGET) *~ core tags Makefile.bak
+       rm -f $(OBJ) *~ core tags Makefile.bak libwiringPi.*
 
 tags:  $(SRC)
        @echo [ctags]
@@ -69,27 +77,34 @@ depend:
 
 install:       $(TARGET)
        @echo [install]
-       install -m 0755 -d /usr/local/lib
-       install -m 0755 -d /usr/local/include
-       install -m 0644 wiringPi.h      /usr/local/include
-       install -m 0644 wiringSerial.h  /usr/local/include
-       install -m 0644 wiringShift.h   /usr/local/include
-       install -m 0644 gertboard.h     /usr/local/include
-       install -m 0644 piNes.h         /usr/local/include
-       install -m 0644 softPwm.h       /usr/local/include
-       install -m 0644 lcd.h           /usr/local/include
-       install -m 0644 wiringPiSPI.h   /usr/local/include
-       install -m 0644 libwiringPi.a   /usr/local/lib
+       @install -m 0755 -d /usr/local/lib
+       @install -m 0755 -d /usr/local/include
+       @install -m 0644 wiringPi.h     /usr/local/include
+       @install -m 0644 wiringSerial.h /usr/local/include
+       @install -m 0644 wiringShift.h  /usr/local/include
+       @install -m 0644 gertboard.h    /usr/local/include
+       @install -m 0644 piNes.h                /usr/local/include
+       @install -m 0644 softPwm.h      /usr/local/include
+       @install -m 0644 lcd.h          /usr/local/include
+       @install -m 0644 wiringPiSPI.h  /usr/local/include
+       @install -m 0644 libwiringPi.a  /usr/local/lib
+       @install        -m 0755 libwiringPi.so.1.0 /usr/local/lib
+       @ln -sf /usr/local/lib/libwiringPi.so.1.0 /usr/local/lib/libwiringPi.so
+       @ln -sf /usr/local/lib/libwiringPi.so.1.0 /usr/local/lib/libwiringPi.so.1
+       @ldconfig
 
 uninstall:
        @echo [uninstall]
-       rm -f /usr/local/include/lcd.h
-       rm -f /usr/local/include/lpiNes.h
-       rm -f /usr/local/include/gertboard.h
-       rm -f /usr/local/include/wiringShift.h
-       rm -f /usr/local/include/wiringSerial.h
-       rm -f /usr/local/include/wiringPi.h
-       rm -f /usr/local/lib/libwiringPi.a
+       @rm -f /usr/local/include/wiringPi.h
+       @rm -f /usr/local/include/wiringSerial.h
+       @rm -f /usr/local/include/wiringShift.h
+       @rm -f /usr/local/include/gertboard.h
+       @rm -f /usr/local/include/piNes.h
+       @rm -f /usr/local/include/softPwm.h
+       @rm -f /usr/local/include/lcd.h
+       @rm -f /usr/local/include/wiringPiSPI.h
+       @rm -f /usr/local/lib/libwiringPi.*
+       @ldconfig
 
 
 # DO NOT DELETE
@@ -98,8 +113,10 @@ wiringPi.o: wiringPi.h
 wiringPiFace.o: wiringPi.h
 wiringSerial.o: wiringSerial.h
 wiringShift.o: wiringPi.h wiringShift.h
-gertboard.o: gertboard.h
+gertboard.o: wiringPiSPI.h gertboard.h
 piNes.o: wiringPi.h piNes.h
 lcd.o: wiringPi.h lcd.h
 piHiPri.o: wiringPi.h
 piThread.o: wiringPi.h
+softPwm.o: wiringPi.h softPwm.h
+wiringPiSPI.o: wiringPiSPI.h
index 6826a604bb7bcf77395b7619b276063c6f6f5eae..aa58cab1c83e4ff21ff9bd102916e41638777be8 100644 (file)
@@ -75,7 +75,10 @@ struct lcdDataStruct *lcds [MAX_LCDS] ;
 
 static void strobe (struct lcdDataStruct *lcd)
 {
-  digitalWrite (lcd->strbPin, 1) ; delayMicroseconds  (1) ;
+
+// Note timing changes for new version of delayMicroseconds ()
+
+  digitalWrite (lcd->strbPin, 1) ; delayMicroseconds (50) ;
   digitalWrite (lcd->strbPin, 0) ; delayMicroseconds (50) ;
 }
 
index d4c724c0a757db0a2db881fb278fffbb10b81dc8..ecd1d25bee72918405783edebcd8feab0c4771c4 100644 (file)
 
 #define        MAX_LCDS        8
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void lcdHome     (int fd) ;
 extern void lcdClear    (int fd) ;
 extern void lcdPosition (int fd, int x, int y) ;
@@ -33,10 +37,6 @@ extern void lcdPutchar  (int fd, uint8_t data) ;
 extern void lcdPuts     (int fd, char *string) ;
 extern void lcdPrintf   (int fd, char *message, ...) ;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 extern int  lcdInit (int rows, int cols, int bits, int rs, int strb,
        int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) ;
 
index b572dde12be7e97ac70003e1cce3e74d4bd0a326..ad6208236d5a927a24adff97d42b5dd9fa11a791 100644 (file)
@@ -427,6 +427,7 @@ int piBoardRev (void)
       }
 
   fclose (cpuFd) ;
+
   if (r == -1)
   {
     fprintf (stderr, "piBoardRev: Unable to determine board revision from /proc/cpuinfo\n") ;
@@ -449,9 +450,11 @@ int piBoardRev (void)
     boardRev = 2 ;
   else
   {
-    fprintf (stderr, "piBoardRev: Unable to determine board revision from %d\n", r) ;
-    errno = 0 ;
-    return -1 ;
+    fprintf (stderr, "WARNING: wiringPi: Unable to determine board revision from \"%d\"\n", r) ;
+    fprintf (stderr, " -> You may want to check:\n") ;
+    fprintf (stderr, " -> http://www.raspberrypi.org/phpBB3/viewtopic.php?p=184410#p184410\n") ;
+    fprintf (stderr, " -> Assuming a Rev 1 board\n") ;
+    boardRev = 1 ;
   }
 
   if (wiringPiDebug)