Browse Source

Updated wiringPi for the new Pi Zero.

Also affects the Pi v2 which also uses the new Revision
encoding scheme (It was slightly bodged before) This ought
to be relatively future proof, but who knows.

Fixed a minor thing in the examples Makefile
(not that anyone bothers to use it, judging by the emails I get )-:
pull/62/head
Gordon Henderson 9 years ago
parent
commit
bb6f08487c
7 changed files with 289 additions and 173 deletions
  1. +1
    -1
      VERSION
  2. +1
    -1
      debian-template/wiringPi/DEBIAN/control
  3. +1
    -1
      examples/Makefile
  4. +55
    -44
      gpio/gpio.c
  5. +1
    -1
      gpio/version.h
  6. +212
    -105
      wiringPi/wiringPi.c
  7. +18
    -20
      wiringPi/wiringPi.h

+ 1
- 1
VERSION View File

@@ -1 +1 @@
2.29
2.30

+ 1
- 1
debian-template/wiringPi/DEBIAN/control View File

@@ -1,5 +1,5 @@
Package: wiringpi
Version: 2.29
Version: 2.30
Section: libraries
Priority: optional
Architecture: armhf


+ 1
- 1
examples/Makefile View 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 serialTestc okLed.c ds1302.c \
delayTest.c serialRead.c serialTest.c okLed.c ds1302.c \
lowPower.c \
max31855.c \
rht03.c


+ 55
- 44
gpio/gpio.c View File

@@ -1149,6 +1149,56 @@ static void doPwmClock (int argc, char *argv [])


/*
* doVersion:
* Handle the ever more complicated version command
*********************************************************************************
*/

static void doVersion (char *argv [])
{
int model, rev, mem, maker, warranty ;
struct stat statBuf ;

printf ("gpio version: %s\n", VERSION) ;
printf ("Copyright (c) 2012-2015 Gordon Henderson\n") ;
printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
printf ("For details type: %s -warranty\n", argv [0]) ;
printf ("\n") ;
piBoardId (&model, &rev, &mem, &maker, &warranty) ;

/*************
if (model == PI_MODEL_UNKNOWN)
{
printf ("Your Raspberry Pi has an unknown model type. Please report this to\n") ;
printf (" projects@drogon.net\n") ;
printf ("with a copy of your /proc/cpuinfo if possible\n") ;
}
else
***************/

{
printf ("Raspberry Pi Details:\n") ;
printf (" Type: %s, Revision: %s, Memory: %dMB, Maker: %s %s\n",
piModelNames [model], piRevisionNames [rev], piMemorySize [mem], piMakerNames [maker], warranty ? "[Out of Warranty]" : "") ;

// Check for device tree

if (stat ("/proc/device-tree", &statBuf) == 0) // We're on a devtree system ...
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") ;
}
}


/*
* main:
* Start here
*********************************************************************************
@@ -1157,9 +1207,6 @@ static void doPwmClock (int argc, char *argv [])
int main (int argc, char *argv [])
{
int i ;
int model, rev, mem, maker, overVolted ;
struct stat statBuf ;


if (getenv ("WIRINGPI_DEBUG") != NULL)
{
@@ -1181,56 +1228,20 @@ int main (int argc, char *argv [])
return 0 ;
}

// Sort of a special:

if (strcmp (argv [1], "-R") == 0)
{
printf ("%d\n", piBoardRev ()) ;
return 0 ;
}

// Version & Warranty
// Wish I could remember why I have both -R and -V ...

if (strcmp (argv [1], "-V") == 0)
if ((strcmp (argv [1], "-R") == 0) || (strcmp (argv [1], "-V") == 0))
{
printf ("%d\n", piBoardRev ()) ;
return 0 ;
}

// Version and information

if (strcmp (argv [1], "-v") == 0)
{
printf ("gpio version: %s\n", VERSION) ;
printf ("Copyright (c) 2012-2015 Gordon Henderson\n") ;
printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
printf ("For details type: %s -warranty\n", argv [0]) ;
printf ("\n") ;
piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
if (model == PI_MODEL_UNKNOWN)
{
printf ("Your Raspberry Pi has an unknown model type. Please report this to\n") ;
printf (" projects@drogon.net\n") ;
printf ("with a copy of your /proc/cpuinfo if possible\n") ;
}
else
{
printf ("Raspberry Pi Details:\n") ;
printf (" Type: %s, Revision: %s, Memory: %dMB, Maker: %s %s\n",
piModelNames [model], piRevisionNames [rev], mem, piMakerNames [maker], overVolted ? "[OV]" : "") ;

// Check for device tree

if (stat ("/proc/device-tree", &statBuf) == 0) // We're on a devtree system ...
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") ;
}
doVersion (argv) ;
return 0 ;
}



+ 1
- 1
gpio/version.h View File

@@ -1 +1 @@
#define VERSION "2.29"
#define VERSION "2.30"

+ 212
- 105
wiringPi/wiringPi.c View File

@@ -209,35 +209,77 @@ static volatile uint32_t *timerIrqRaw ;

static int piModel2 = FALSE ;

const char *piModelNames [7] =
const char *piModelNames [16] =
{
"Unknown",
"Model A",
"Model B",
"Model B+",
"Compute Module",
"Model A+",
"Model 2", // Quad Core
"Model A", // 0
"Model B", // 1
"Model A+", // 2
"Model B+", // 3
"Pi 2", // 4
"Alpha", // 5
"CM", // 6
"Unknown07", // 07
"Unknown08", // 08
"Pi Zero", // 09
"Unknown10", // 10
"Unknown11", // 11
"Unknown12", // 12
"Unknown13", // 13
"Unknown14", // 14
"Unknown15", // 15
} ;

const char *piRevisionNames [5] =
const char *piRevisionNames [16] =
{
"Unknown",
"1",
"1.1",
"1.2",
"2",
"00",
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12",
"13",
"14",
"15",
} ;

const char *piMakerNames [5] =
const char *piMakerNames [16] =
{
"Unknown",
"Egoman",
"Sony",
"Qusda",
"MBest",
"Sony", // 0
"Egoman", // 1
"Embest", // 2
"Unknown", // 3
"Embest", // 4
"Unknown05", // 5
"Unknown06", // 6
"Unknown07", // 7
"Unknown08", // 8
"Unknown09", // 9
"Unknown10", // 10
"Unknown11", // 11
"Unknown12", // 12
"Unknown13", // 13
"Unknown14", // 14
"Unknown15", // 15
} ;

const int piMemorySize [8] =
{
256, // 0
512, // 1
1024, // 2
0, // 3
0, // 4
0, // 5
0, // 6
0, // 7
} ;

// Time for easy calculations

@@ -612,43 +654,20 @@ int wiringPiFailure (int fatal, const char *message, ...)
/*
* piBoardRev:
* Return a number representing the hardware revision of the board.
* This is not strictly the board revision but is used to check the
* layout of the GPIO connector - and there are 2 types that we are
* really interested in here. The very earliest Pi's and the
* ones that came after that which switched some pins ....
*
* Revision 1 really means the early Model B's.
* Revision 1 really means the early Model A and B's.
* Revision 2 is everything else - it covers the B, B+ and CM.
* ... and the Pi 2 - which is a B+ ++ ...
* ... and the Pi 0 - which is an A+ ...
*
* Seems there are some boards with 0000 in them (mistake in manufacture)
* So the distinction between boards that I can see is:
* 0000 - Error
* 0001 - Not used
* 0002 - Model B, Rev 1, 256MB, Egoman
* 0003 - Model B, Rev 1.1, 256MB, Egoman, Fuses/D14 removed.
* 0004 - Model B, Rev 2, 256MB, Sony
* 0005 - Model B, Rev 2, 256MB, Qisda
* 0006 - Model B, Rev 2, 256MB, Egoman
* 0007 - Model A, Rev 2, 256MB, Egoman
* 0008 - Model A, Rev 2, 256MB, Sony
* 0009 - Model A, Rev 2, 256MB, Qisda
* 000d - Model B, Rev 2, 512MB, Egoman
* 000e - Model B, Rev 2, 512MB, Sony
* 000f - Model B, Rev 2, 512MB, Qisda
* 0010 - Model B+, Rev 1.2, 512MB, Sony
* 0011 - Pi CM, Rev 1.2, 512MB, Sony
* 0012 - Model A+ Rev 1.2, 256MB, Sony
* 0014 - Pi CM, Rev 1.1, 512MB, Sony (Actual Revision might be different)
* 0015 - Model A+ Rev 1.1, 256MB, Sony
*
* For the Pi 2:
* 0010 - Model 2, Rev 1.1, Quad Core, 1GB, Sony
*
* A small thorn is the olde style overvolting - that will add in
* 1000000
*
* The Pi compute module has an revision of 0011 - since we only check the
* last digit, then it's 1, therefore it'll default to not 2 or 3 for a
* Rev 1, so will appear as a Rev 2. This is fine for the most part, but
* we'll properly detect the Compute Module later and adjust accordingly.
* And the next rev of the CN is 0014 ...
* The main difference between the revision 1 and 2 system that I use here
* is the mapping of the GPIO pins. From revision 2, the Pi Foundation changed
* 3 GPIO pins on the (original) 26-way header - BCM_GPIO 22 was dropped and
* replaced with 27, and 0 + 1 - I2C bus 0 was changed to 2 + 3; I2C bus 1.
*
*********************************************************************************
*/
@@ -675,22 +694,28 @@ int piBoardRev (void)
if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
piBoardRevOops ("Unable to open /proc/cpuinfo") ;

// Start by looking for the Architecture, then we can look for a B2 revision....
// Start by looking for the Architecture to make sure we're really running
// on a Pi. I'm getting fed-up with people whinging at me because
// they can't get it to work on weirdFruitPi boards...

while (fgets (line, 120, cpuFd) != NULL)
if (strncmp (line, "Hardware", 8) == 0)
break ;

if (strncmp (line, "Hardware", 8) != 0)
piBoardRevOops ("No \"Hardware\" line") ;
piBoardRevOops ("No hardware line") ;

if (wiringPiDebug)
printf ("piboardRev: Hardware: %s\n", line) ;

// See if it's BCM2708 or BCM2709

if (strstr (line, "BCM2709") != NULL)
if (strstr (line, "BCM2709") != NULL) // Pi v2 - no point doing anything more at this point
{
piModel2 = TRUE ;
fclose (cpuFd) ;
return boardRev = 2 ;
}
else if (strstr (line, "BCM2708") == NULL)
{
fprintf (stderr, "Unable to determine hardware version. I see: %s,\n", line) ;
@@ -702,10 +727,12 @@ int piBoardRev (void)
exit (EXIT_FAILURE) ;
}

// Now do the rest of it as before
// Now do the rest of it as before - we just need to see if it's an older
// Rev 1 as anything else is rev 2.

rewind (cpuFd) ;
// Isolate the Revision line

rewind (cpuFd) ;
while (fgets (line, 120, cpuFd) != NULL)
if (strncmp (line, "Revision", 8) == 0)
break ;
@@ -723,28 +750,43 @@ int piBoardRev (void)
if (wiringPiDebug)
printf ("piboardRev: Revision string: %s\n", line) ;

// Scan to first digit
// Scan to the first character of the revision number

for (c = line ; *c ; ++c)
if (isdigit (*c))
if (*c == ':')
break ;

if (!isdigit (*c))
piBoardRevOops ("No numeric revision string") ;
if (*c != ':')
piBoardRevOops ("Bogus \"Revision\" line (no colon)") ;

// Chomp spaces

++c ;
while (isspace (*c))
++c ;

if (!isxdigit (*c))
piBoardRevOops ("Bogus \"Revision\" line (no hex digit at start of revision)") ;

// Make sure its long enough

if (strlen (c) < 4)
piBoardRevOops ("Bogus \"Revision\" line (too small)") ;
piBoardRevOops ("Bogus revision line (too small)") ;
// If you have overvolted the Pi, then it appears that the revision
// has 100000 added to it!
// The actual condition for it being set is:
// (force_turbo || current_limit_override || temp_limit>85) && over_voltage>0


// This test is not correct for the new encoding scheme, so we'll remove it here as
// we don't really need it at this point.

/********************
if (wiringPiDebug)
if (strlen (c) != 4)
printf ("piboardRev: This Pi has/is (force_turbo || current_limit_override || temp_limit>85) && over_voltage>0\n") ;
*******************/

// Isolate last 4 characters:

@@ -767,12 +809,49 @@ int piBoardRev (void)

/*
* piBoardId:
* Do more digging into the board revision string as above, but return
* as much details as we can.
* Return the real details of the board we have.
*
* This is undocumented and really only intended for the GPIO command.
* Use at your own risk!
*
* for Pi v2:
* Seems there are some boards with 0000 in them (mistake in manufacture)
* So the distinction between boards that I can see is:
*
* 0000 - Error
* 0001 - Not used
*
* Original Pi boards:
* 0002 - Model B, Rev 1, 256MB, Egoman
* 0003 - Model B, Rev 1.1, 256MB, Egoman, Fuses/D14 removed.
*
* Newer Pi's with remapped GPIO:
* 0004 - Model B, Rev 2, 256MB, Sony
* 0005 - Model B, Rev 2, 256MB, Qisda
* 0006 - Model B, Rev 2, 256MB, Egoman
* 0007 - Model A, Rev 2, 256MB, Egoman
* 0008 - Model A, Rev 2, 256MB, Sony
* 0009 - Model A, Rev 2, 256MB, Qisda
* 000d - Model B, Rev 2, 512MB, Egoman (Red Pi, Blue Pi?)
* 000e - Model B, Rev 2, 512MB, Sony
* 000f - Model B, Rev 2, 512MB, Qisda
* 0010 - Model B+, Rev 1.2, 512MB, Sony
* 0011 - Pi CM, Rev 1.2, 512MB, Sony
* 0012 - Model A+ Rev 1.2, 256MB, Sony
* 0014 - Pi CM, Rev 1.1, 512MB, Sony (Actual Revision might be different)
* 0015 - Model A+ Rev 1.1, 256MB, Sony
*
* A small thorn is the olde style overvolting - that will add in
* 1000000
*
* The Pi compute module has an revision of 0011 or 0014 - since we only
* check the last digit, then it's 1, therefore it'll default to not 2 or
* 3 for a Rev 1, so will appear as a Rev 2. This is fine for the most part, but
* we'll properly detect the Compute Module later and adjust accordingly.
*
* And then things changed with the introduction of the v2...
*
* For Pi v2 and subsequent models - e.g. the Zero:
*
* [USER:8] [NEW:1] [MEMSIZE:3] [MANUFACTURER:4] [PROCESSOR:4] [TYPE:8] [REV:4]
* NEW 23: will be 1 for the new scheme, 0 for the old scheme
* MEMSIZE 20: 0=256M 1=512M 2=1G
@@ -783,11 +862,13 @@ int piBoardRev (void)
*********************************************************************************
*/

void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)
void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
{
FILE *cpuFd ;
char line [120] ;
char *c ;
unsigned int revision ;
int bRev, bType, bProc, bMfg, bMem, bWarranty ;

// Will deal with the properly later on - for now, lets just get it going...
// unsigned int modelNum ;
@@ -814,33 +895,59 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)
if (wiringPiDebug)
printf ("piboardId: Revision string: %s\n", line) ;

if (piModel2)
{
// Need to work out if it's using the new or old encoding scheme:

// Scan to the colon
// Scan to the first character of the revision number

for (c = line ; *c ; ++c)
if (*c == ':')
break ;
for (c = line ; *c ; ++c)
if (*c == ':')
break ;

if (*c != ':')
piBoardRevOops ("Bogus \"Revision\" line (no colon)") ;
if (*c != ':')
piBoardRevOops ("Bogus \"Revision\" line (no colon)") ;

// modelNum = (unsigned int)strtol (++c, NULL, 16) ; // Hex number with no leading 0x
// Chomp spaces

++c ;
while (isspace (*c))
++c ;

if (!isxdigit (*c))
piBoardRevOops ("Bogus \"Revision\" line (no hex digit at start of revision)") ;

revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x

// Check for new way:

if ((revision & (1 << 23)) != 0) // New way
{
if (wiringPiDebug)
printf ("piBoardId: New Way: revision is: 0x%08X\n", revision) ;

bRev = (revision & (0x0F << 0)) >> 0 ;
bType = (revision & (0xFF << 4)) >> 4 ;
bProc = (revision & (0x0F << 12)) >> 12 ; // Not used for now.
bMfg = (revision & (0x0F << 16)) >> 16 ;
bMem = (revision & (0x07 << 20)) >> 20 ;
bWarranty = (revision & (0x03 << 24)) != 0 ;
*model = PI_MODEL_2 ;
*rev = PI_VERSION_1_1 ;
*mem = 1024 ;
*maker = PI_MAKER_SONY ;
*model = bType ;
*rev = bRev ;
*mem = bMem ;
*maker = bMfg ;
*warranty = bWarranty ;

if (wiringPiDebug)
printf ("piboardId: rev: %d, type: %d, proc: %d, mfg: %d, mem: %d, warranty: %d\n",
bRev, bType, bProc, bMfg, bMem, bWarranty) ;
}
else
else // Old way
{
if (wiringPiDebug)
printf ("piBoardId: Old Way: revision is: %s\n", c) ;

// Scan to first digit

for (c = line ; *c ; ++c)
if (isdigit (*c))
break ;
if (!isdigit (*c))
piBoardRevOops ("Bogus \"Revision\" line (no digit at start of revision)") ;

// Make sure its long enough

@@ -849,7 +956,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)

// If longer than 4, we'll assume it's been overvolted

*overVolted = strlen (c) > 4 ;
*warranty = strlen (c) > 4 ;
// Extract last 4 characters:

@@ -857,23 +964,23 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)

// Fill out the replys as appropriate

/**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0005") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_QISDA ; }
else if (strcmp (c, "0006") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0007") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0008") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; ; }
else if (strcmp (c, "0009") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_QISDA ; }
else if (strcmp (c, "000d") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "000e") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "000f") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0010") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0011") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0012") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0013") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_MBEST ; }
else if (strcmp (c, "0014") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0015") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 256 ; *maker = PI_MAKER_SONY ; }
/**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0005") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_UNKNOWN ; }
else if (strcmp (c, "0006") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0007") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0008") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; ; }
else if (strcmp (c, "0009") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 0 ; *maker = PI_MAKER_UNKNOWN ; }
else if (strcmp (c, "000d") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "000e") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "000f") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0010") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0011") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0012") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_2 ; *mem = 0 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0013") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0014") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_2 ; *mem = 1 ; *maker = PI_MAKER_SONY ; }
else if (strcmp (c, "0015") == 0) { *model = PI_MODEL_AP ; *rev = PI_VERSION_1_1 ; *mem = 0 ; *maker = PI_MAKER_SONY ; }
else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; }
}
}


+ 18
- 20
wiringPi/wiringPi.h View File

@@ -26,8 +26,7 @@

// Handy defines

// Deprecated
#define NUM_PINS 17
// wiringPi modes

#define WPI_MODE_PINS 0
#define WPI_MODE_GPIO 1
@@ -70,29 +69,28 @@
// Pi model types and version numbers
// Intended for the GPIO program Use at your own risk.

#define PI_MODEL_UNKNOWN 0
#define PI_MODEL_A 1
#define PI_MODEL_B 2
#define PI_MODEL_A 0
#define PI_MODEL_B 1
#define PI_MODEL_AP 2
#define PI_MODEL_BP 3
#define PI_MODEL_CM 4
#define PI_MODEL_AP 5
#define PI_MODEL_2 6
#define PI_MODEL_2 4
#define PI_ALPHA 5
#define PI_MODEL_CM 6

#define PI_VERSION_UNKNOWN 0
#define PI_VERSION_1 1
#define PI_VERSION_1_1 2
#define PI_VERSION_1_2 3
#define PI_VERSION_2 4
#define PI_VERSION_1 0
#define PI_VERSION_1_1 1
#define PI_VERSION_1_2 2
#define PI_VERSION_2 3

#define PI_MAKER_UNKNOWN 0
#define PI_MAKER_SONY 0
#define PI_MAKER_EGOMAN 1
#define PI_MAKER_SONY 2
#define PI_MAKER_QISDA 3
#define PI_MAKER_MBEST 4
#define PI_MAKER_MBEST 2
#define PI_MAKER_UNKNOWN 3

extern const char *piModelNames [7] ;
extern const char *piRevisionNames [5] ;
extern const char *piMakerNames [5] ;
extern const char *piModelNames [16] ;
extern const char *piRevisionNames [16] ;
extern const char *piMakerNames [16] ;
extern const int piMemorySize [ 8] ;


// Intended for the GPIO program Use at your own risk.


Loading…
Cancel
Save