Updates to the build process
Moved the extensions into wiringPi from gpio and made it more general purpose more so that RTB and anything else can dymanically add devices into wiringPi. Changes to GPIO to updates for the SPI and I2C module loads Added gpio unload for SPI and I2C. Added a new way to setup SPI - by passing the mode in. Support for the new Pi2 thing too
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# A swiss-army knige of GPIO shenanigans.
|
||||
# https://projects.drogon.net/wiring-pi
|
||||
#
|
||||
# Copyright (c) 2012-2013 Gordon Henderson
|
||||
# Copyright (c) 2012-2015 Gordon Henderson
|
||||
#################################################################################
|
||||
# This file is part of wiringPi:
|
||||
# Wiring Compatable library for the Raspberry Pi
|
||||
@@ -38,7 +38,7 @@ LIBS = -lwiringPi -lwiringPiDev -lpthread -lm
|
||||
# May not need to alter anything below this line
|
||||
###############################################################################
|
||||
|
||||
SRC = gpio.c extensions.c readall.c pins.c
|
||||
SRC = gpio.c readall.c pins.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
@@ -82,6 +82,3 @@ depend:
|
||||
makedepend -Y $(SRC)
|
||||
|
||||
# DO NOT DELETE
|
||||
|
||||
gpio.o: extensions.h
|
||||
extensions.o: extensions.h
|
||||
|
||||
@@ -1,700 +0,0 @@
|
||||
/*
|
||||
* extensions.c:
|
||||
* Part of the GPIO program to test, peek, poke and otherwise
|
||||
* noodle with the GPIO hardware on the Raspberry Pi.
|
||||
* Copyright (c) 2012-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 <stdint.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include <mcp23008.h>
|
||||
#include <mcp23016.h>
|
||||
#include <mcp23017.h>
|
||||
#include <mcp23s08.h>
|
||||
#include <mcp23s17.h>
|
||||
#include <sr595.h>
|
||||
#include <pcf8591.h>
|
||||
#include <pcf8574.h>
|
||||
#include <max31855.h>
|
||||
#include <max5322.h>
|
||||
#include <mcp3002.h>
|
||||
#include <mcp3004.h>
|
||||
#include <mcp4802.h>
|
||||
#include <mcp3422.h>
|
||||
#include <sn3218.h>
|
||||
#include <drcSerial.h>
|
||||
|
||||
#include "extensions.h"
|
||||
|
||||
extern int wiringPiDebug ;
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE (1==1)
|
||||
# define FALSE (1==2)
|
||||
#endif
|
||||
|
||||
// Local structure to hold details
|
||||
|
||||
struct extensionFunctionStruct
|
||||
{
|
||||
const char *name ;
|
||||
int (*function)(char *progName, int pinBase, char *params) ;
|
||||
} ;
|
||||
|
||||
|
||||
/*
|
||||
* extractInt:
|
||||
* Check & return an integer at the given location (prefixed by a :)
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static char *extractInt (char *progName, char *p, int *num)
|
||||
{
|
||||
if (*p != ':')
|
||||
{
|
||||
fprintf (stderr, "%s: colon expected\n", progName) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
++p ;
|
||||
|
||||
if (!isdigit (*p))
|
||||
{
|
||||
fprintf (stderr, "%s: digit expected\n", progName) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
*num = strtol (p, NULL, 0) ;
|
||||
while (isdigit (*p))
|
||||
++p ;
|
||||
|
||||
return p ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* extractStr:
|
||||
* Check & return a string at the given location (prefixed by a :)
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static char *extractStr (char *progName, char *p, char **str)
|
||||
{
|
||||
char *q, *r ;
|
||||
|
||||
if (*p != ':')
|
||||
{
|
||||
fprintf (stderr, "%s: colon expected\n", progName) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
++p ;
|
||||
|
||||
if (!isprint (*p))
|
||||
{
|
||||
fprintf (stderr, "%s: character expected\n", progName) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
q = p ;
|
||||
while ((*q != 0) && (*q != ':'))
|
||||
++q ;
|
||||
|
||||
*str = r = calloc (q - p + 2, 1) ; // Zeros it
|
||||
|
||||
while (p != q)
|
||||
*r++ = *p++ ;
|
||||
|
||||
return p ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp23008:
|
||||
* MCP23008 - 8-bit I2C GPIO expansion chip
|
||||
* mcp23002:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp23008 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp23008Setup (pinBase, i2c) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp23016:
|
||||
* MCP230016- 16-bit I2C GPIO expansion chip
|
||||
* mcp23016:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp23016 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp23016Setup (pinBase, i2c) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp23017:
|
||||
* MCP230017- 16-bit I2C GPIO expansion chip
|
||||
* mcp23017:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp23017 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp23017Setup (pinBase, i2c) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp23s08:
|
||||
* MCP23s08 - 8-bit SPI GPIO expansion chip
|
||||
* mcp23s08:base:spi:port
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp23s08 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi, port ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &port)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((port < 0) || (port > 7))
|
||||
{
|
||||
fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp23s08Setup (pinBase, spi, port) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp23s17:
|
||||
* MCP23s17 - 16-bit SPI GPIO expansion chip
|
||||
* mcp23s17:base:spi:port
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp23s17 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi, port ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &port)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((port < 0) || (port > 7))
|
||||
{
|
||||
fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp23s17Setup (pinBase, spi, port) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionSr595:
|
||||
* Shift Register 74x595
|
||||
* sr595:base:pins:data:clock:latch
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionSr595 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int pins, data, clock, latch ;
|
||||
|
||||
// Extract pins
|
||||
|
||||
if ((params = extractInt (progName, params, &pins)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((pins < 8) || (pins > 32))
|
||||
{
|
||||
fprintf (stderr, "%s: pin count (%d) out of range - 8-32 expected.\n", progName, pins) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &data)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((params = extractInt (progName, params, &clock)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((params = extractInt (progName, params, &latch)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
sr595Setup (pinBase, pins, data, clock, latch) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionPcf8574:
|
||||
* Digital IO (Crude!)
|
||||
* pcf8574:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionPcf8574 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
pcf8574Setup (pinBase, i2c) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionPcf8591:
|
||||
* Analog IO
|
||||
* pcf8591:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionPcf8591 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
pcf8591Setup (pinBase, i2c) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMax31855:
|
||||
* Analog IO
|
||||
* max31855:base:spiChan
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMax31855 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
max31855Setup (pinBase, spi) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp3002:
|
||||
* Analog IO
|
||||
* mcp3002:base:spiChan
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp3002 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp3002Setup (pinBase, spi) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp3004:
|
||||
* Analog IO
|
||||
* mcp3004:base:spiChan
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp3004 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp3004Setup (pinBase, spi) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMax5322:
|
||||
* Analog O
|
||||
* max5322:base:spiChan
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMax5322 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
max5322Setup (pinBase, spi) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp4802:
|
||||
* Analog IO
|
||||
* mcp4802:base:spiChan
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp4802 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int spi ;
|
||||
|
||||
if ((params = extractInt (progName, params, &spi)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((spi < 0) || (spi > 1))
|
||||
{
|
||||
fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp4802Setup (pinBase, spi) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionSn3218:
|
||||
* Analog Output (LED Driver)
|
||||
* sn3218:base
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionSn3218 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
sn3218Setup (pinBase) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doExtensionMcp3422:
|
||||
* Analog IO
|
||||
* mcp3422:base:i2cAddr
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionMcp3422 (char *progName, int pinBase, char *params)
|
||||
{
|
||||
int i2c, sampleRate, gain ;
|
||||
|
||||
if ((params = extractInt (progName, params, &i2c)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((i2c < 0x03) || (i2c > 0x77))
|
||||
{
|
||||
fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &sampleRate)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((sampleRate < 0) || (sampleRate > 3))
|
||||
{
|
||||
fprintf (stderr, "%s: sample rate (%d) out of range\n", progName, sampleRate) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &gain)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((gain < 0) || (gain > 3))
|
||||
{
|
||||
fprintf (stderr, "%s: gain (%d) out of range\n", progName, gain) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
mcp3422Setup (pinBase, i2c, sampleRate, gain) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
* doExtensionDrcS:
|
||||
* Interface to a DRC Serial system
|
||||
* drcs:base:pins:serialPort:baud
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static int doExtensionDrcS (char *progName, int pinBase, char *params)
|
||||
{
|
||||
char *port ;
|
||||
int pins, baud ;
|
||||
|
||||
if ((params = extractInt (progName, params, &pins)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((pins < 1) || (pins > 100))
|
||||
{
|
||||
fprintf (stderr, "%s: pins (%d) out of range (2-100)\n", progName, pins) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractStr (progName, params, &port)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if (strlen (port) == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: serial port device name required\n", progName) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if ((params = extractInt (progName, params, &baud)) == NULL)
|
||||
return FALSE ;
|
||||
|
||||
if ((baud < 1) || (baud > 4000000))
|
||||
{
|
||||
fprintf (stderr, "%s: baud rate (%d) out of range\n", progName, baud) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
drcSetupSerial (pinBase, pins, port, baud) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Function list
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
struct extensionFunctionStruct extensionFunctions [] =
|
||||
{
|
||||
{ "mcp23008", &doExtensionMcp23008 },
|
||||
{ "mcp23016", &doExtensionMcp23016 },
|
||||
{ "mcp23017", &doExtensionMcp23017 },
|
||||
{ "mcp23s08", &doExtensionMcp23s08 },
|
||||
{ "mcp23s17", &doExtensionMcp23s17 },
|
||||
{ "sr595", &doExtensionSr595 },
|
||||
{ "pcf8574", &doExtensionPcf8574 },
|
||||
{ "pcf8591", &doExtensionPcf8591 },
|
||||
{ "mcp3002", &doExtensionMcp3002 },
|
||||
{ "mcp3004", &doExtensionMcp3004 },
|
||||
{ "mcp4802", &doExtensionMcp4802 },
|
||||
{ "mcp3422", &doExtensionMcp3422 },
|
||||
{ "max31855", &doExtensionMax31855 },
|
||||
{ "max5322", &doExtensionMax5322 },
|
||||
{ "sn3218", &doExtensionSn3218 },
|
||||
{ "drcs", &doExtensionDrcS },
|
||||
{ NULL, NULL },
|
||||
} ;
|
||||
|
||||
|
||||
/*
|
||||
* doExtension:
|
||||
* Load in a wiringPi extension
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
int doExtension (char *progName, char *extensionData)
|
||||
{
|
||||
char *p ;
|
||||
char *extension = extensionData ;
|
||||
struct extensionFunctionStruct *extensionFn ;
|
||||
int pinBase = 0 ;
|
||||
|
||||
// Get the extension extension name by finding the first colon
|
||||
|
||||
p = extension ;
|
||||
while (*p != ':')
|
||||
{
|
||||
if (!*p) // ran out of characters
|
||||
{
|
||||
fprintf (stderr, "%s: extension name not terminated by a colon\n", progName) ;
|
||||
return FALSE ;
|
||||
}
|
||||
++p ;
|
||||
}
|
||||
|
||||
*p++ = 0 ;
|
||||
|
||||
if (!isdigit (*p))
|
||||
{
|
||||
fprintf (stderr, "%s: pinBase number expected after extension name\n", progName) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
while (isdigit (*p))
|
||||
{
|
||||
if (pinBase > 1000000000)
|
||||
{
|
||||
fprintf (stderr, "%s: pinBase too large\n", progName) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
pinBase = pinBase * 10 + (*p - '0') ;
|
||||
++p ;
|
||||
}
|
||||
|
||||
if (pinBase < 64)
|
||||
{
|
||||
fprintf (stderr, "%s: pinBase (%d) too small. Minimum is 64.\n", progName, pinBase) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
// Search for extensions:
|
||||
|
||||
for (extensionFn = extensionFunctions ; extensionFn->name != NULL ; ++extensionFn)
|
||||
{
|
||||
if (strcmp (extensionFn->name, extension) == 0)
|
||||
return extensionFn->function (progName, pinBase, p) ;
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s: extension %s not found\n", progName, extension) ;
|
||||
return FALSE ;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* extensions.h:
|
||||
* Part of the GPIO program to test, peek, poke and otherwise
|
||||
* noodle with the GPIO hardware on the Raspberry Pi.
|
||||
* Copyright (c) 2012-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/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
extern int doExtension (char *progName, char *extensionData) ;
|
||||
79
gpio/gpio.1
79
gpio/gpio.1
@@ -1,4 +1,4 @@
|
||||
.TH "GPIO" "March 2013" "Command-Line access to Raspberry Pi's GPIO"
|
||||
.TH "GPIO" "January 2015" "Command-Line access to Raspberry Pi's GPIO"
|
||||
|
||||
.SH NAME
|
||||
gpio \- Command-line access to Raspberry Pi's GPIO
|
||||
@@ -21,7 +21,7 @@ gpio \- Command-line access to Raspberry Pi's GPIO
|
||||
.B ...
|
||||
.PP
|
||||
.B gpio
|
||||
.B readall/reset
|
||||
.B readall
|
||||
.PP
|
||||
.B gpio
|
||||
.B unexportall/exports
|
||||
@@ -156,16 +156,6 @@ The readall command is usable with an extension module (via the -x parameter),
|
||||
but it's unable to determine pin modes or states, so will perform both a
|
||||
digital and analog read on each pin in-turn.
|
||||
|
||||
.TP
|
||||
.B reset
|
||||
Resets the GPIO - As much as it's possible to do. All pins are set to
|
||||
input mode and all the internal pull-up/down resistors are disconnected
|
||||
(tristate mode).
|
||||
|
||||
The reset command is usable with an extension module (via the -x parameter),
|
||||
but it's limited to turning the pin into input mode (if applicable) and
|
||||
removing any pull up/down resistor.
|
||||
|
||||
.TP
|
||||
.B pwm <pin> <value>
|
||||
Write a PWM value (0-1023) to the given pin. The pin needs to be put
|
||||
@@ -182,6 +172,8 @@ Set a pin into \fIinput\fR, \fIoutput\fR or \fIpwm\fR mode. Can also
|
||||
use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal
|
||||
pull-up, pull-down or tristate (off) controls.
|
||||
|
||||
The ALT modes can also be set using \fIalt0\fR, \fIalt1\fR, ... \fIalt5\fR.
|
||||
|
||||
.TP
|
||||
.B unexportall
|
||||
Un-Export all the GPIO pins in the /sys/class/gpio directory.
|
||||
@@ -257,12 +249,30 @@ on the associated /dev/ entries so that the current user has access to
|
||||
them. Optionally it will set the I2C baudrate to that supplied in Kb/sec
|
||||
(or as close as the Pi can manage) The default speed is 100Kb/sec.
|
||||
|
||||
Note that on a Pi with a recent 3.18 kernel with the device-tree structure
|
||||
enable, the load may fail until you add:
|
||||
|
||||
.I dtparam=i2c=on
|
||||
|
||||
into \fB/boot/config.txt\fR to allow user use of the I2C bus.
|
||||
|
||||
.TP
|
||||
.B load spi [buffer size in KB]
|
||||
.B load spi
|
||||
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.
|
||||
them. It used to have the ability to change the buffer size from the
|
||||
default of 4096 bytes to an arbitary value, however for some time the
|
||||
Pi Foundation have compiled the SPI device driver into the kernel and
|
||||
this has fixed the buffer size. The way to change it now is to edit
|
||||
the /boot/cmdline.txt file and add on spdev.bufsiz=8192 to set it to
|
||||
e.g. 8192 bytes then reboot.
|
||||
|
||||
Note that on a Pi with a recent 3.18 kernel with the device-tree structure
|
||||
enable, the load may fail until you add:
|
||||
|
||||
.I dtparam=spi=on
|
||||
|
||||
into \fB/boot/config.txt\fR to allow user use of the I2C bus.
|
||||
|
||||
.TP
|
||||
.B gbr
|
||||
@@ -280,41 +290,12 @@ SPI digital to analogue converter.
|
||||
The board jumpers need to be in-place to do this operation.
|
||||
|
||||
|
||||
.SH "WiringPi vs. BCM_GPIO Pin numbering"
|
||||
.SH "WiringPi vs. BCM_GPIO Pin numbering vs. Physical pin numbering"
|
||||
|
||||
.PP
|
||||
.TS
|
||||
c c c c l.
|
||||
WiringPi GPIO-r1 GPIO-r2 P1-Phys Function
|
||||
_
|
||||
0 17 17 11
|
||||
1 18 18 12 (PWM)
|
||||
2 21 27 13
|
||||
3 22 22 15
|
||||
4 23 23 16
|
||||
5 24 24 18
|
||||
6 25 25 22
|
||||
7 4 4 7
|
||||
8 0 2 3 I2C: SDA0
|
||||
9 1 3 5 I2C: SCL0
|
||||
10 8 8 24 SPI: CE0
|
||||
11 7 7 26 SPI: CE1
|
||||
12 10 10 19 SPI: MOSI
|
||||
13 9 9 21 SPI: MISO
|
||||
14 11 11 23 SPI: SCLK
|
||||
15 14 14 8 TxD
|
||||
16 15 16 10 RxD
|
||||
17 - 28
|
||||
18 - 29
|
||||
19 - 30
|
||||
20 - 31
|
||||
.TE
|
||||
|
||||
Note that "r1" and "r2" above refers to the board revision. Normally
|
||||
wiringPi detects the correct board revision with use for it's own
|
||||
numbering scheme, but if you are using a Revision 2 board with some
|
||||
of the pins which change numbers between revisions you will need
|
||||
to alter your software.
|
||||
The quickest way to get a list of the pin differences is to run the command
|
||||
.TP
|
||||
gpio readall
|
||||
|
||||
.SH FILES
|
||||
|
||||
@@ -361,7 +342,7 @@ Please report bugs to <projects@drogon.net>
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
Copyright (c) 2012-2013 Gordon Henderson
|
||||
Copyright (c) 2012-2015 Gordon Henderson
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
144
gpio/gpio.c
144
gpio/gpio.c
@@ -2,7 +2,7 @@
|
||||
* gpio.c:
|
||||
* Swiss-Army-Knife, Set-UID command-line interface to the Raspberry
|
||||
* Pi's GPIO.
|
||||
* Copyright (c) 2012-2014 Gordon Henderson
|
||||
* Copyright (c) 2012-2015 Gordon Henderson
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
@@ -35,11 +35,11 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <wiringPi.h>
|
||||
#include <wpiExtensions.h>
|
||||
|
||||
#include <gertboard.h>
|
||||
#include <piFace.h>
|
||||
|
||||
#include "extensions.h"
|
||||
|
||||
extern int wiringPiDebug ;
|
||||
|
||||
@@ -53,7 +53,7 @@ extern void doPins (void) ;
|
||||
# define FALSE (1==2)
|
||||
#endif
|
||||
|
||||
#define VERSION "2.22"
|
||||
#define VERSION "2.23"
|
||||
#define PI_USB_POWER_CONTROL 38
|
||||
#define I2CDETECT "/usr/sbin/i2cdetect"
|
||||
|
||||
@@ -73,6 +73,7 @@ char *usage = "Usage: gpio -v\n"
|
||||
" gpio pwmr <range> \n"
|
||||
" gpio pwmc <divider> \n"
|
||||
" gpio load spi/i2c\n"
|
||||
" gpio unload spi/i2c\n"
|
||||
" gpio i2cd/i2cdetect\n"
|
||||
" gpio usbp high/low\n"
|
||||
" gpio gbr <channel>\n"
|
||||
@@ -115,12 +116,9 @@ static void changeOwner (char *cmd, char *file)
|
||||
if (chown (file, uid, gid) != 0)
|
||||
{
|
||||
if (errno == ENOENT) // Warn that it's not there
|
||||
fprintf (stderr, "%s: Warning: File not present: %s\n", cmd, file) ;
|
||||
fprintf (stderr, "%s: Warning (not an error): File not present: %s\n", cmd, file) ;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Unable to change ownership of %s: %s\n", cmd, file, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
}
|
||||
fprintf (stderr, "%s: Warning (not an error): Unable to change ownership of %s: %s\n", cmd, file, strerror (errno)) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +165,7 @@ static int moduleLoaded (char *modName)
|
||||
|
||||
static void _doLoadUsage (char *argv [])
|
||||
{
|
||||
fprintf (stderr, "Usage: %s load <spi/i2c> [SPI bufferSize in KB | I2C baudrate in Kb/sec]\n", argv [0]) ;
|
||||
fprintf (stderr, "Usage: %s load <spi/i2c> [I2C baudrate in Kb/sec]\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
@@ -190,7 +188,10 @@ static void doLoad (int argc, char *argv [])
|
||||
file1 = "/dev/spidev0.0" ;
|
||||
file2 = "/dev/spidev0.1" ;
|
||||
if (argc == 4)
|
||||
sprintf (args1, " bufsiz=%d", atoi (argv [3]) * 1024) ;
|
||||
{
|
||||
fprintf (stderr, "%s: Unable to set the buffer size now. Load aborted. Please see the man page.\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
else if (argc > 4)
|
||||
_doLoadUsage (argv) ;
|
||||
}
|
||||
@@ -210,13 +211,13 @@ static void doLoad (int argc, char *argv [])
|
||||
|
||||
if (!moduleLoaded (module1))
|
||||
{
|
||||
sprintf (cmd, "modprobe %s%s", module1, args1) ;
|
||||
sprintf (cmd, "/sbin/modprobe %s%s", module1, args1) ;
|
||||
system (cmd) ;
|
||||
}
|
||||
|
||||
if (!moduleLoaded (module2))
|
||||
{
|
||||
sprintf (cmd, "modprobe %s%s", module2, args2) ;
|
||||
sprintf (cmd, "/sbin/modprobe %s%s", module2, args2) ;
|
||||
system (cmd) ;
|
||||
}
|
||||
|
||||
@@ -233,6 +234,53 @@ static void doLoad (int argc, char *argv [])
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doUnLoad:
|
||||
* Un-Load either the spi or i2c modules and change device ownerships, etc.
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static void _doUnLoadUsage (char *argv [])
|
||||
{
|
||||
fprintf (stderr, "Usage: %s unload <spi/i2c>\n", argv [0]) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
static void doUnLoad (int argc, char *argv [])
|
||||
{
|
||||
char *module1, *module2 ;
|
||||
char cmd [80] ;
|
||||
|
||||
if (argc != 3)
|
||||
_doUnLoadUsage (argv) ;
|
||||
|
||||
/**/ if (strcasecmp (argv [2], "spi") == 0)
|
||||
{
|
||||
module1 = "spidev" ;
|
||||
module2 = "spi_bcm2708" ;
|
||||
}
|
||||
else if (strcasecmp (argv [2], "i2c") == 0)
|
||||
{
|
||||
module1 = "i2c_dev" ;
|
||||
module2 = "i2c_bcm2708" ;
|
||||
}
|
||||
else
|
||||
_doUnLoadUsage (argv) ;
|
||||
|
||||
if (moduleLoaded (module1))
|
||||
{
|
||||
sprintf (cmd, "/sbin/rmmod %s", module1) ;
|
||||
system (cmd) ;
|
||||
}
|
||||
|
||||
if (moduleLoaded (module2))
|
||||
{
|
||||
sprintf (cmd, "/sbin/rmmod %s", module2) ;
|
||||
system (cmd) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doI2Cdetect:
|
||||
* Run the i2cdetect command with the right runes for this Pi revision
|
||||
@@ -586,24 +634,6 @@ void doUnexportall (char *progName)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doResetExternal:
|
||||
* Load readallExternal, we try to do this with an external device.
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static void doResetExternal (void)
|
||||
{
|
||||
int pin ;
|
||||
|
||||
for (pin = wiringPiNodes->pinBase ; pin <= wiringPiNodes->pinMax ; ++pin)
|
||||
{
|
||||
pinMode (pin, INPUT) ;
|
||||
pullUpDnControl (pin, PUD_OFF) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doReset:
|
||||
* Reset the GPIO pins - as much as we can do
|
||||
@@ -612,45 +642,9 @@ static void doResetExternal (void)
|
||||
|
||||
static void doReset (char *progName)
|
||||
{
|
||||
int model, rev, mem, maker, overVolted ;
|
||||
int pin, endPin ;
|
||||
|
||||
printf ("GPIO Reset is dangerous!\n") ;
|
||||
printf (" - Do Not rely on this to do anything sensible!\n") ;
|
||||
|
||||
if (wiringPiNodes != NULL) // External
|
||||
{
|
||||
doResetExternal () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
|
||||
|
||||
/**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B))
|
||||
endPin = 16 ;
|
||||
else if (model == PI_MODEL_BP)
|
||||
endPin = 39 ;
|
||||
else if (model == PI_MODEL_CM)
|
||||
{
|
||||
printf (" - Don't know how to reset a comput module:\n") ;
|
||||
printf (" Write a shell-script to reset the pins to the state you need.\n") ;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("Oops - unable to determine board type... model: %d\n", model) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
for (pin = 0 ; pin <= endPin ; ++pin)
|
||||
{
|
||||
if (wpiPinToGpio (pin) == -1)
|
||||
continue ;
|
||||
|
||||
digitalWrite (pin, LOW) ;
|
||||
pinMode (pin, INPUT) ;
|
||||
pullUpDnControl (pin, PUD_OFF) ;
|
||||
}
|
||||
printf ("GPIO Reset is dangerous and has been removed from the gpio command.\n") ;
|
||||
printf (" - Please write a shell-script to reset the GPIO pins into the state\n") ;
|
||||
printf (" that you need them in for your applications.\n") ;
|
||||
}
|
||||
|
||||
|
||||
@@ -686,9 +680,6 @@ void doMode (int argc, char *argv [])
|
||||
else if (strcasecmp (mode, "down") == 0) pullUpDnControl (pin, PUD_DOWN) ;
|
||||
else if (strcasecmp (mode, "tri") == 0) pullUpDnControl (pin, PUD_OFF) ;
|
||||
else if (strcasecmp (mode, "off") == 0) pullUpDnControl (pin, PUD_OFF) ;
|
||||
|
||||
// Undocumented
|
||||
|
||||
else if (strcasecmp (mode, "alt0") == 0) pinModeAlt (pin, 0b100) ;
|
||||
else if (strcasecmp (mode, "alt1") == 0) pinModeAlt (pin, 0b101) ;
|
||||
else if (strcasecmp (mode, "alt2") == 0) pinModeAlt (pin, 0b110) ;
|
||||
@@ -1183,7 +1174,7 @@ int main (int argc, char *argv [])
|
||||
if (strcmp (argv [1], "-v") == 0)
|
||||
{
|
||||
printf ("gpio version: %s\n", VERSION) ;
|
||||
printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
|
||||
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") ;
|
||||
@@ -1206,7 +1197,7 @@ int main (int argc, char *argv [])
|
||||
if (strcasecmp (argv [1], "-warranty") == 0)
|
||||
{
|
||||
printf ("gpio version: %s\n", VERSION) ;
|
||||
printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
|
||||
printf ("Copyright (c) 2012-2015 Gordon Henderson\n") ;
|
||||
printf ("\n") ;
|
||||
printf (" This program is free software; you can redistribute it and/or modify\n") ;
|
||||
printf (" it under the terms of the GNU Leser General Public License as published\n") ;
|
||||
@@ -1240,7 +1231,8 @@ int main (int argc, char *argv [])
|
||||
|
||||
// Check for load command:
|
||||
|
||||
if (strcasecmp (argv [1], "load" ) == 0) { doLoad (argc, argv) ; return 0 ; }
|
||||
if (strcasecmp (argv [1], "load" ) == 0) { doLoad (argc, argv) ; return 0 ; }
|
||||
if (strcasecmp (argv [1], "unload" ) == 0) { doUnLoad (argc, argv) ; return 0 ; }
|
||||
|
||||
// Gertboard commands
|
||||
|
||||
@@ -1301,7 +1293,7 @@ int main (int argc, char *argv [])
|
||||
exit (EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
if (!doExtension (argv [0], argv [2])) // Prints its own error messages
|
||||
if (!loadWPiExtension (argv [0], argv [2], TRUE)) // Prints its own error messages
|
||||
exit (EXIT_FAILURE) ;
|
||||
|
||||
for (i = 3 ; i < argc ; ++i)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* pins.c:
|
||||
* Just display a handy Pi pinnout diagram.
|
||||
* Copyright (c) 2012-2013 Gordon Henderson
|
||||
* Copyright (c) 2012-2015 Gordon Henderson
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
|
||||
16
gpio/pintest
16
gpio/pintest
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# pintest
|
||||
# Test the Pi's GPIO port
|
||||
# Copyright (c) 2013 Gordon Henderson
|
||||
# Copyright (c) 2013-2015 Gordon Henderson
|
||||
#################################################################################
|
||||
# This file is part of wiringPi:
|
||||
# Wiring Compatable library for the Raspberry Pi
|
||||
@@ -104,13 +104,11 @@ testPins()
|
||||
|
||||
intro()
|
||||
{
|
||||
revision=`gpio -V`
|
||||
cat <<EOF
|
||||
PinTest
|
||||
=======
|
||||
|
||||
This is a simple utility to test the GPIO pins on your revision $revision
|
||||
Raspberry Pi.
|
||||
This is a simple utility to test the GPIO pins on your Raspberry Pi.
|
||||
|
||||
NOTE: All GPIO peripherals must be removed to perform this test. This
|
||||
includes serial, I2C and SPI connections. You may get incorrect results
|
||||
@@ -123,6 +121,9 @@ the output drivers.
|
||||
You will need to reboot your Pi after this test if you wish to use the
|
||||
serial port as it will be left in GPIO mode rather than serial mode.
|
||||
|
||||
This test only tests the original pins present on the Rev A and B. It
|
||||
does not test the extra pins on the Revision A2, B2 nor the A+ or B+
|
||||
|
||||
Please make sure everything is removed and press the ENTER key to continue,
|
||||
EOF
|
||||
|
||||
@@ -136,7 +137,6 @@ EOF
|
||||
|
||||
intro
|
||||
gpio unexportall
|
||||
gpio reset
|
||||
|
||||
errs=0
|
||||
totErrs=0
|
||||
@@ -147,12 +147,6 @@ echo ""
|
||||
|
||||
testPins 0 7 "The main 8 GPIO pins"
|
||||
|
||||
# P5 pins, if a rev 2:
|
||||
|
||||
if [ $revision = 2 ]; then
|
||||
testPins 17 20 "The 4 pins on the P5 connector"
|
||||
fi
|
||||
|
||||
# SPI
|
||||
|
||||
testPins 10 14 "The 5 SPI pins"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* readall.c:
|
||||
* The readall functions - getting a bit big, so split them out.
|
||||
* Copyright (c) 2012-2013 Gordon Henderson
|
||||
* Copyright (c) 2012-2015 Gordon Henderson
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
@@ -283,14 +283,22 @@ void abReadall (int model, int rev)
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
static void plus2header (int model)
|
||||
{
|
||||
/**/ if (model == PI_MODEL_AP)
|
||||
printf (" +-----+-----+---------+------+---+--A Plus--+---+------+---------+-----+-----+\n") ;
|
||||
else if (model == PI_MODEL_BP)
|
||||
printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ;
|
||||
else
|
||||
printf (" +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n") ;
|
||||
}
|
||||
|
||||
|
||||
void piPlusReadall (int model)
|
||||
{
|
||||
int pin ;
|
||||
|
||||
if (model == PI_MODEL_AP)
|
||||
printf (" +-----+-----+---------+------+---+--A Plus--+---+------+---------+-----+-----+\n") ;
|
||||
else
|
||||
printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ;
|
||||
plus2header (model) ;
|
||||
|
||||
printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ;
|
||||
printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ;
|
||||
@@ -299,10 +307,7 @@ void piPlusReadall (int model)
|
||||
printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ;
|
||||
printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ;
|
||||
|
||||
if (model == PI_MODEL_AP)
|
||||
printf (" +-----+-----+---------+------+---+--A Plus--+---+------+---------+-----+-----+\n") ;
|
||||
else
|
||||
printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ;
|
||||
plus2header (model) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +325,7 @@ void doReadall (void)
|
||||
|
||||
/**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B))
|
||||
abReadall (model, rev) ;
|
||||
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP))
|
||||
else if ((model == PI_MODEL_BP) || (model == PI_MODEL_AP) || (model == PI_MODEL_2))
|
||||
piPlusReadall (model) ;
|
||||
else if (model == PI_MODEL_CM)
|
||||
cmReadall () ;
|
||||
|
||||
Reference in New Issue
Block a user