Browse Source

Slight change to the gpio program to fix SPI buffer size when loading

the module.
Typo in gpio man page
Bug fixed in board revision detection (which would never happen
anyway, however)
pull/22/head
Gordon Henderson 11 years ago
parent
commit
98bcb20d93
5 changed files with 15 additions and 120 deletions
  1. +3
    -0
      People
  2. +1
    -1
      gpio/gpio.1
  3. +2
    -2
      gpio/gpio.c
  4. +9
    -8
      wiringPi/wiringPi.c
  5. +0
    -109
      wiringPi/wiringPiISR.c

+ 3
- 0
People View File

@@ -22,3 +22,6 @@ Arno Wagner

CHARLES Thibaut:
A small issue in softTone

Xian Stannard
Fixing some typos in the man page!

+ 1
- 1
gpio/gpio.1 View 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.


+ 2
- 2
gpio/gpio.c View 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) ;
}


+ 9
- 8
wiringPi/wiringPi.c View 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) ;


+ 0
- 109
wiringPi/wiringPiISR.c View File

@@ -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) ;
}



Loading…
Cancel
Save