Lots of changes here. Added new I2C test code, a new serialTest program,
and developed the new ISR - Interrupt Service Routine handler - much easier than the old waitForInterrupt code! Minor tweaks to the gpio program to recognise the environment variable WIRINGPI_DEBUG too, and removed the printing of the errors from the main wiringPi setup routines (and added some new ones!)
This commit is contained in:
24
gpio/gpio.c
24
gpio/gpio.c
@@ -35,12 +35,14 @@
|
||||
#include <wiringPi.h>
|
||||
#include <gertboard.h>
|
||||
|
||||
extern int wiringPiDebug ;
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE (1==1)
|
||||
# define FALSE (1==2)
|
||||
#endif
|
||||
|
||||
#define VERSION "1.5"
|
||||
#define VERSION "1.6"
|
||||
|
||||
static int wpMode ;
|
||||
|
||||
@@ -127,7 +129,7 @@ static int moduleLoaded (char *modName)
|
||||
|
||||
static void _doLoadUsage (char *argv [])
|
||||
{
|
||||
fprintf (stderr, "Usage: %s load <spi/i2c>\n", argv [0]) ;
|
||||
fprintf (stderr, "Usage: %s load <spi/i2c> [bufferSize in KB for spi]\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
@@ -136,16 +138,24 @@ static void doLoad (int argc, char *argv [])
|
||||
char *module1, *module2 ;
|
||||
char cmd [80] ;
|
||||
char *file1, *file2 ;
|
||||
char spiBuf [32] ;
|
||||
|
||||
if (argc != 3)
|
||||
if (argc < 3)
|
||||
_doLoadUsage (argv) ;
|
||||
|
||||
spiBuf [0] = 0 ;
|
||||
|
||||
/**/ if (strcasecmp (argv [2], "spi") == 0)
|
||||
{
|
||||
module1 = "spidev" ;
|
||||
module2 = "spi_bcm2708" ;
|
||||
file1 = "/dev/spidev0.0" ;
|
||||
file2 = "/dev/spidev0.1" ;
|
||||
if (argc == 4)
|
||||
sprintf (spiBuf, " bufsize=%d", atoi (argv [3]) * 1024) ;
|
||||
else if (argc > 4)
|
||||
_doLoadUsage (argv) ;
|
||||
|
||||
}
|
||||
else if (strcasecmp (argv [2], "i2c") == 0)
|
||||
{
|
||||
@@ -159,7 +169,7 @@ static void doLoad (int argc, char *argv [])
|
||||
|
||||
if (!moduleLoaded (module1))
|
||||
{
|
||||
sprintf (cmd, "modprobe %s", module1) ;
|
||||
sprintf (cmd, "modprobe %s%s", module1, spiBuf) ;
|
||||
system (cmd) ;
|
||||
}
|
||||
|
||||
@@ -848,6 +858,12 @@ int main (int argc, char *argv [])
|
||||
{
|
||||
int i ;
|
||||
|
||||
if (getenv ("WIRINGPI_DEBUG") != NULL)
|
||||
{
|
||||
printf ("gpio: wiringPi debug mode enabled\n") ;
|
||||
wiringPiDebug = TRUE ;
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
fprintf (stderr, "%s\n", usage) ;
|
||||
|
||||
Reference in New Issue
Block a user