diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..081bcab
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build/
+__pycache__
diff --git a/README b/README
new file mode 100644
index 0000000..d3bb11b
--- /dev/null
+++ b/README
@@ -0,0 +1,58 @@
+
+WiringPi: An implementation of most of the Arduino Wiring
+ functions for the Raspberry Pi
+
+Prerequisites:
+ You must have python-dev and python-setuptools installed
+ If you manually rebuild the bindings with swig -python wiringpi.i
+ then cat wiringpi_class.py >> wiringpi.py to get the class-based wrapper
+
+Get/setup repo:
+ git clone https://github.com/WiringPi/WiringPi-Python.git
+ cd WiringPi-Python
+ git submodule update --init
+
+Build & install with:
+ sudo python setup.py install
+
+Class-based Usage:
+ import wiringpi
+ io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
+ io.pinMode(1,io.OUTPUT)
+ io.digitalWrite(1,io.HIGH)
+
+ GPIO with /sys/class/gpio (You must first export the interfaces):
+ import wiringpi
+ io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_SYS)
+ io.pinMode(1,io.OUTPUT)
+ io.digitalWrite(1,io.HIGH)
+
+ Serial:
+ serial = wiringpi.Serial('/dev/ttyAMA0',9600)
+ serial.puts("hello")
+ serial.close()
+
+Usage:
+ import wiringpi
+ wiringpi.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
+ OR
+ wiringpi.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
+ OR
+ wiringpi.wiringPiSetupGpio // For GPIO pin numbering
+
+ General IO:
+ wiringpi.pinMode(1,1) // Set pin 1 to output
+ wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1
+ wiringpi.digitalRead(1) // Read pin 1
+
+ Bit shifting:
+ wiringpi.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
+
+ Serial:
+ serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
+ wiringpi.serialPuts(serial,"hello")
+ wiringpi.serialClose(serial) // Pass in ID
+
+Full details at:
+ https://projects.drogon.net/raspberry-pi/wiringpi/
+
diff --git a/COPYING.LESSER b/WiringPi/COPYING.LESSER
similarity index 100%
rename from COPYING.LESSER
rename to WiringPi/COPYING.LESSER
diff --git a/INSTALL b/WiringPi/INSTALL
similarity index 100%
rename from INSTALL
rename to WiringPi/INSTALL
diff --git a/People b/WiringPi/People
similarity index 100%
rename from People
rename to WiringPi/People
diff --git a/wiringPi/README b/WiringPi/README
similarity index 100%
rename from wiringPi/README
rename to WiringPi/README
diff --git a/examples/COPYING.LESSER b/WiringPi/examples/COPYING.LESSER
similarity index 100%
rename from examples/COPYING.LESSER
rename to WiringPi/examples/COPYING.LESSER
diff --git a/examples/Makefile b/WiringPi/examples/Makefile
similarity index 95%
rename from examples/Makefile
rename to WiringPi/examples/Makefile
index defd510..b1ab319 100644
--- a/examples/Makefile
+++ b/WiringPi/examples/Makefile
@@ -38,7 +38,7 @@ LDLIBS = -lwiringPi -lpthread -lm
SRC = blink.c test1.c test2.c speed.c lcd.c wfi.c isr.c isr-osc.c \
piface.c gertboard.c nes.c \
pwm.c tone.c servo.c \
- delayTest.c serialRead.c serialTest.c okLed.c
+ delayTest.c serialRead.c serialTest.c okLed.c ds1302.c
OBJ = $(SRC:.c=.o)
@@ -123,6 +123,10 @@ servo: servo.o
@echo [link]
@$(CC) -o $@ servo.o $(LDFLAGS) $(LDLIBS)
+ds1302: ds1302.o
+ @echo [link]
+ @$(CC) -o $@ ds1302.o $(LDFLAGS) $(LDLIBS)
+
.c.o:
@echo [CC] $<
diff --git a/examples/README.TXT b/WiringPi/examples/README.TXT
similarity index 100%
rename from examples/README.TXT
rename to WiringPi/examples/README.TXT
diff --git a/examples/blink.c b/WiringPi/examples/blink.c
similarity index 100%
rename from examples/blink.c
rename to WiringPi/examples/blink.c
diff --git a/examples/blink.rtb b/WiringPi/examples/blink.rtb
similarity index 100%
rename from examples/blink.rtb
rename to WiringPi/examples/blink.rtb
diff --git a/examples/blink.sh b/WiringPi/examples/blink.sh
similarity index 100%
rename from examples/blink.sh
rename to WiringPi/examples/blink.sh
diff --git a/examples/delayTest.c b/WiringPi/examples/delayTest.c
similarity index 100%
rename from examples/delayTest.c
rename to WiringPi/examples/delayTest.c
diff --git a/WiringPi/examples/ds1302.c b/WiringPi/examples/ds1302.c
new file mode 100644
index 0000000..f1e9e20
--- /dev/null
+++ b/WiringPi/examples/ds1302.c
@@ -0,0 +1,238 @@
+/*
+ * ds1302.c:
+ * Real Time clock
+ *
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+// Register defines
+
+#define RTC_SECS 0
+#define RTC_MINS 1
+#define RTC_HOURS 2
+#define RTC_DATE 3
+#define RTC_MONTH 4
+#define RTC_DAY 5
+#define RTC_YEAR 6
+#define RTC_WP 7
+#define RTC_TC 8
+#define RTC_BM 31
+
+
+static unsigned int masks [] = { 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x07, 0xFF } ;
+
+
+/*
+ * bcdToD: dToBCD:
+ * BCD decode/encode
+ *********************************************************************************
+ */
+
+static int bcdToD (unsigned int byte, unsigned int mask)
+{
+ unsigned int b1, b2 ;
+ byte &= mask ;
+ b1 = byte & 0x0F ;
+ b2 = ((byte >> 4) & 0x0F) * 10 ;
+ return b1 + b2 ;
+}
+
+static unsigned int dToBcd (unsigned int byte)
+{
+ return ((byte / 10) << 4) + (byte % 10) ;
+}
+
+
+/*
+ * ramTest:
+ * Simple test of the 31 bytes of RAM inside the DS1302 chip
+ *********************************************************************************
+ */
+
+static int ramTestValues [] =
+ { 0x00, 0xFF, 0xAA, 0x55, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0xF0, 0x0F, -1 } ;
+
+static int ramTest (void)
+{
+ int addr ;
+ int got ;
+ int i = 0 ;
+ int errors = 0 ;
+ int testVal ;
+
+ printf ("DS1302 RAM TEST\n") ;
+
+ testVal = ramTestValues [i] ;
+
+ while (testVal != -1)
+ {
+ for (addr = 0 ; addr < 31 ; ++addr)
+ ds1302ramWrite (addr, testVal) ;
+
+ for (addr = 0 ; addr < 31 ; ++addr)
+ if ((got = ds1302ramRead (addr)) != testVal)
+ {
+ printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n",
+ addr, testVal, got) ;
+ ++errors ;
+ }
+ testVal = ramTestValues [++i] ;
+ }
+
+ for (addr = 0 ; addr < 31 ; ++addr)
+ ds1302ramWrite (addr, addr) ;
+
+ for (addr = 0 ; addr < 31 ; ++addr)
+ if ((got = ds1302ramRead (addr)) != addr)
+ {
+ printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n",
+ addr, addr, got) ;
+ ++errors ;
+ }
+
+ if (errors == 0)
+ printf ("-- DS1302 RAM TEST: OK\n") ;
+ else
+ printf ("-- DS1302 RAM TEST FAILURE. %d errors.\n", errors) ;
+
+ return 0 ;
+}
+
+/*
+ * setLinuxClock:
+ * Set the Linux clock from the hardware
+ *********************************************************************************
+ */
+
+static int setLinuxClock (void)
+{
+ char dateTime [20] ;
+ char command [64] ;
+ int clock [8] ;
+
+
+ printf ("Setting the Linux Clock from the DS1302... ") ; fflush (stdout) ;
+
+ ds1302clockRead (clock) ;
+
+// [MMDDhhmm[[CC]YY][.ss]]
+
+ sprintf (dateTime, "%02d%02d%02d%02d%02d%02d.%02d",
+ bcdToD (clock [RTC_MONTH], masks [RTC_MONTH]),
+ bcdToD (clock [RTC_DATE], masks [RTC_DATE]),
+ bcdToD (clock [RTC_HOURS], masks [RTC_HOURS]),
+ bcdToD (clock [RTC_MINS], masks [RTC_MINS]),
+ 20,
+ bcdToD (clock [RTC_YEAR], masks [RTC_YEAR]),
+ bcdToD (clock [RTC_SECS], masks [RTC_SECS])) ;
+
+ sprintf (command, "/bin/date %s", dateTime) ;
+ system (command) ;
+
+ return 0 ;
+}
+
+
+/*
+ * setDSclock:
+ * Set the DS1302 block from Linux time
+ *********************************************************************************
+ */
+
+static int setDSclock (void)
+{
+ struct tm t ;
+ time_t now ;
+ int clock [8] ;
+
+ printf ("Setting the clock in the DS1302 from Linux time... ") ;
+
+ now = time (NULL) ;
+ gmtime_r (&now, &t) ;
+
+ clock [ 0] = dToBcd (t.tm_sec) ; // seconds
+ clock [ 1] = dToBcd (t.tm_min) ; // mins
+ clock [ 2] = dToBcd (t.tm_hour) ; // hours
+ clock [ 3] = dToBcd (t.tm_mday) ; // date
+ clock [ 4] = dToBcd (t.tm_mon + 1) ; // months 0-11 --> 1-12
+ clock [ 5] = dToBcd (t.tm_wday + 1) ; // weekdays (sun 0)
+ clock [ 6] = dToBcd (t.tm_year - 100) ; // years
+ clock [ 7] = 0 ; // W-Protect off
+
+ ds1302clockWrite (clock) ;
+
+ printf ("OK\n") ;
+
+ return 0 ;
+}
+
+
+
+
+int main (int argc, char *argv [])
+{
+ int i ;
+ int clock [8] ;
+
+ wiringPiSetup () ;
+ ds1302setup (0, 1, 2) ;
+
+ if (argc == 2)
+ {
+ /**/ if (strcmp (argv [1], "-slc") == 0)
+ return setLinuxClock () ;
+ else if (strcmp (argv [1], "-sdsc") == 0)
+ return setDSclock () ;
+ else if (strcmp (argv [1], "-rtest") == 0)
+ return ramTest () ;
+ else
+ {
+ printf ("Usage: ds1302 [-slc | -sdsc | -rtest]\n") ;
+ return EXIT_FAILURE ;
+ }
+ }
+
+ for (i = 0 ;; ++i)
+ {
+ printf ("%5d: ", i) ;
+
+ ds1302clockRead (clock) ;
+ printf (" %2d:%02d:%02d",
+ bcdToD (clock [2], masks [2]), bcdToD (clock [1], masks [1]), bcdToD (clock [0], masks [0])) ;
+
+ printf (" %2d/%02d/%04d",
+ bcdToD (clock [3], masks [3]), bcdToD (clock [4], masks [4]), bcdToD (clock [6], masks [6]) + 2000) ;
+
+ printf ("\n") ;
+
+ delay (200) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/gertboard.c b/WiringPi/examples/gertboard.c
similarity index 100%
rename from examples/gertboard.c
rename to WiringPi/examples/gertboard.c
diff --git a/examples/gertboard.png b/WiringPi/examples/gertboard.png
similarity index 100%
rename from examples/gertboard.png
rename to WiringPi/examples/gertboard.png
diff --git a/examples/header.h b/WiringPi/examples/header.h
similarity index 100%
rename from examples/header.h
rename to WiringPi/examples/header.h
diff --git a/examples/isr-osc.c b/WiringPi/examples/isr-osc.c
similarity index 100%
rename from examples/isr-osc.c
rename to WiringPi/examples/isr-osc.c
diff --git a/examples/isr.c b/WiringPi/examples/isr.c
similarity index 100%
rename from examples/isr.c
rename to WiringPi/examples/isr.c
diff --git a/examples/lcd.c b/WiringPi/examples/lcd.c
similarity index 100%
rename from examples/lcd.c
rename to WiringPi/examples/lcd.c
diff --git a/examples/nes.c b/WiringPi/examples/nes.c
similarity index 100%
rename from examples/nes.c
rename to WiringPi/examples/nes.c
diff --git a/examples/okLed.c b/WiringPi/examples/okLed.c
similarity index 100%
rename from examples/okLed.c
rename to WiringPi/examples/okLed.c
diff --git a/examples/piface.c b/WiringPi/examples/piface.c
similarity index 82%
rename from examples/piface.c
rename to WiringPi/examples/piface.c
index 0f00960..c17cfb9 100644
--- a/examples/piface.c
+++ b/WiringPi/examples/piface.c
@@ -25,6 +25,7 @@
*/
#include
+#include
#include
#include
@@ -32,15 +33,17 @@
int outputs [4] = { 0,0,0,0 } ;
+#define PIFACE_BASE 200
+
void scanButton (int button)
{
- if (digitalRead (button) == LOW)
+ if (digitalRead (PIFACE_BASE + button) == LOW)
{
outputs [button] ^= 1 ;
- digitalWrite (button, outputs [button]) ;
+ digitalWrite (PIFACE_BASE + button, outputs [button]) ;
}
- while (digitalRead (button) == LOW)
+ while (digitalRead (PIFACE_BASE + button) == LOW)
delay (1) ;
}
@@ -50,16 +53,16 @@ int main (void)
int pin, button ;
printf ("Raspberry Pi wiringPiFace test program\n") ;
+ printf ("======================================\n") ;
- if (wiringPiSetupPiFace () == -1)
+ if (piFaceSetup (200) == -1)
exit (1) ;
// Enable internal pull-ups
- for (pin = 0 ; pin < 8 ; ++pin)
+ for (pin = PIFACE_BASE ; pin < (PIFACE_BASE + 8) ; ++pin)
pullUpDnControl (pin, PUD_UP) ;
-
for (;;)
{
for (button = 0 ; button < 4 ; ++button)
diff --git a/examples/pwm.c b/WiringPi/examples/pwm.c
similarity index 100%
rename from examples/pwm.c
rename to WiringPi/examples/pwm.c
diff --git a/examples/serialRead.c b/WiringPi/examples/serialRead.c
similarity index 100%
rename from examples/serialRead.c
rename to WiringPi/examples/serialRead.c
diff --git a/examples/serialTest.c b/WiringPi/examples/serialTest.c
similarity index 100%
rename from examples/serialTest.c
rename to WiringPi/examples/serialTest.c
diff --git a/examples/servo.c b/WiringPi/examples/servo.c
similarity index 100%
rename from examples/servo.c
rename to WiringPi/examples/servo.c
diff --git a/examples/speed.c b/WiringPi/examples/speed.c
similarity index 100%
rename from examples/speed.c
rename to WiringPi/examples/speed.c
diff --git a/examples/test1.c b/WiringPi/examples/test1.c
similarity index 100%
rename from examples/test1.c
rename to WiringPi/examples/test1.c
diff --git a/examples/test2.c b/WiringPi/examples/test2.c
similarity index 100%
rename from examples/test2.c
rename to WiringPi/examples/test2.c
diff --git a/examples/tone.c b/WiringPi/examples/tone.c
similarity index 100%
rename from examples/tone.c
rename to WiringPi/examples/tone.c
diff --git a/examples/wfi.c b/WiringPi/examples/wfi.c
similarity index 100%
rename from examples/wfi.c
rename to WiringPi/examples/wfi.c
diff --git a/gpio/COPYING.LESSER b/WiringPi/gpio/COPYING.LESSER
similarity index 100%
rename from gpio/COPYING.LESSER
rename to WiringPi/gpio/COPYING.LESSER
diff --git a/gpio/Makefile b/WiringPi/gpio/Makefile
similarity index 100%
rename from gpio/Makefile
rename to WiringPi/gpio/Makefile
diff --git a/gpio/gpio.1 b/WiringPi/gpio/gpio.1
similarity index 90%
rename from gpio/gpio.1
rename to WiringPi/gpio/gpio.1
index ec65519..3703dfa 100644
--- a/gpio/gpio.1
+++ b/WiringPi/gpio/gpio.1
@@ -8,8 +8,8 @@ gpio \- Command-line access to Raspberry Pi and PiFace GPIO
.B \-v
.PP
.B gpio
-.B [ \-g ]
-.B read/write/wb/pwm/clock/mode ...
+.B [ \-g | \-1 ]
+.B read/write/aread/awrite/wb/pwm/clock/mode ...
.PP
.B gpio
.B [ \-p ]
@@ -17,7 +17,7 @@ gpio \- Command-line access to Raspberry Pi and PiFace GPIO
.B ...
.PP
.B gpio
-.B readall
+.B readall/reset
.PP
.B gpio
.B unexportall/exports
@@ -73,12 +73,21 @@ Output the current version including the board revision of the Raspberry Pi.
.TP
.B \-g
Use the BCM_GPIO pins numbers rather than wiringPi pin numbers.
-\fINOTE:\fR The BCM_GPIO pin numbers are always used with the
+\fINote:\fR The BCM_GPIO pin numbers are always used with the
export and edge commands.
+.TP
+.B \-1
+Use the physical pin numbers rather than wiringPi pin numbers.
+\fINote:\fR that this applies to the P1 connector only. It is not possible to
+use pins on the Revision 2 P5 connector this way, and as with \-g the
+BCM_GPIO pin numbers are always used with the export and edge commands.
+
.TP
.B \-p
-Use the PiFace interface board and its corresponding pin numbers.
+Use the PiFace interface board and its corresponding pin numbers. The PiFace
+will always appear at pin number 200 in the gpio command. You can assign any
+pin numbers you like in your own programs though.
.TP
.B read
@@ -102,6 +111,11 @@ Output a table of all GPIO pins values. The values represent the actual values r
if the pin is in input mode, or the last value written if the pin is in output
mode.
+.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).
+
.TP
.B pwm
Write a PWM value (0-1023) to the given pin. The pin needs to be put
diff --git a/gpio/gpio.c b/WiringPi/gpio/gpio.c
similarity index 68%
rename from gpio/gpio.c
rename to WiringPi/gpio/gpio.c
index e71e432..3a74605 100644
--- a/gpio/gpio.c
+++ b/WiringPi/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 Gordon Henderson
+ * Copyright (c) 2012-2013 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -33,7 +34,14 @@
#include
#include
+
#include
+#include
+#include
+#include
+#include
+#include
+#include
extern int wiringPiDebug ;
@@ -42,16 +50,17 @@ extern int wiringPiDebug ;
# define FALSE (1==2)
#endif
-#define VERSION "1.12"
+#define VERSION "2.00"
static int wpMode ;
char *usage = "Usage: gpio -v\n"
" gpio -h\n"
- " gpio [-g] ...\n"
+ " gpio [-g|-1] [-x module:params] ...\n"
" gpio [-p] ...\n"
- " gpio readall\n"
- " gpio unexportall/exports ...\n"
+ " gpio ...\n"
+ " gpio readall/reset\n"
+ " gpio unexportall/exports\n"
" gpio export/edge/unexport ...\n"
" gpio drive \n"
" gpio pwm-bal/pwm-ms \n"
@@ -61,6 +70,193 @@ char *usage = "Usage: gpio -v\n"
" gpio gbr \n"
" gpio gbw " ; // No trailing newline needed here.
+struct moduleFunctionStruct
+{
+ const char *name ;
+ int (*function)(char *progName, int pinBase, char *params) ;
+} ;
+
+static int doModuleMcp23008 (char *progName, int pinBase, char *params)
+{
+ int i2c ;
+
+// Extract the I2C address:
+
+ if (*params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ i2c = strtol (params, NULL, 0) ;
+ 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 ;
+}
+
+static int doModuleMcp23017 (char *progName, int pinBase, char *params)
+{
+ int i2c ;
+
+// Extract the I2C address:
+
+ if (*params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ i2c = strtol (params, NULL, 0) ;
+ 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 ;
+}
+
+static int doModuleMcp23s08 (char *progName, int pinBase, char *params)
+{
+ int spi, port ;
+
+// Extract the SPI address:
+
+ if (*params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ spi = *params - '0' ;
+ if ((spi < 0) || (spi > 1))
+ {
+ fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ;
+ return FALSE ;
+ }
+
+// Extract the port:
+
+ if (*++params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after SPI address\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after SPI address\n", progName) ;
+ return FALSE ;
+ }
+
+ port = strtol (params, NULL, 0) ;
+ 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 ;
+}
+
+static int doModuleMcp23s17 (char *progName, int pinBase, char *params)
+{
+ int spi, port ;
+
+// Extract the SPI address:
+
+ if (*params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ;
+ return FALSE ;
+ }
+
+ spi = *params - '0' ;
+ if ((spi < 0) || (spi > 1))
+ {
+ fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ;
+ return FALSE ;
+ }
+
+// Extract the port:
+
+ if (*++params != ':')
+ {
+ fprintf (stderr, "%s: colon expected after SPI address\n", progName) ;
+ return FALSE ;
+ }
+
+ ++params ;
+ if (!isdigit (*params))
+ {
+ fprintf (stderr, "%s: digit expected after SPI address\n", progName) ;
+ return FALSE ;
+ }
+
+ port = strtol (params, NULL, 0) ;
+ 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 ;
+}
+
+
+struct moduleFunctionStruct moduleFunctions [] =
+{
+ { "mcp23008", &doModuleMcp23008 },
+ { "mcp23017", &doModuleMcp23017 },
+ { "mcp23s08", &doModuleMcp23s08 },
+ { "mcp23s17", &doModuleMcp23s17 },
+ { NULL, NULL },
+} ;
+
+
+
+
/*
* changeOwner:
@@ -215,27 +411,39 @@ static char *alts [] =
"IN ", "OUT ", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3"
} ;
+static int wpiToPhys [64] =
+{
+ 11, 12, 13, 15, 16, 18, 22, 7, // 0...7
+ 3, 5, // 8...9
+ 24, 26, 19, 21, 23, // 10..14
+ 8, 10, // 15..16
+ 3, 4, 5, 6, // 17..20
+ 0,0,0,0,0,0,0,0,0,0,0, // 20..31
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 32..47
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 47..63
+} ;
+
static void doReadall (void)
{
int pin ;
- printf ("+----------+------+--------+------+-------+\n") ;
- printf ("| wiringPi | GPIO | Name | Mode | Value |\n") ;
- printf ("+----------+------+--------+------+-------+\n") ;
+ printf ("+----------+-Rev%d-+------+--------+------+-------+\n", piBoardRev ()) ;
+ printf ("| wiringPi | GPIO | Phys | Name | Mode | Value |\n") ;
+ printf ("+----------+------+------+--------+------+-------+\n") ;
for (pin = 0 ; pin < 64 ; ++pin)
{
if (wpiPinToGpio (pin) == -1)
continue ;
- printf ("| %6d | %3d | %s | %s | %s |\n",
- pin, wpiPinToGpio (pin),
+ printf ("| %6d | %3d | %3d | %s | %s | %s |\n",
+ pin, wpiPinToGpio (pin), wpiToPhys [pin],
pinNames [pin],
alts [getAlt (pin)],
digitalRead (pin) == HIGH ? "High" : "Low ") ;
}
- printf ("+----------+------+--------+------+-------+\n") ;
+ printf ("+----------+------+------+--------+------+-------+\n") ;
}
@@ -499,7 +707,7 @@ void doUnexport (int argc, char *argv [])
*********************************************************************************
*/
-void doUnexportall (int argc, char *argv [])
+void doUnexportall (char *progName)
{
FILE *fd ;
int pin ;
@@ -508,7 +716,7 @@ void doUnexportall (int argc, char *argv [])
{
if ((fd = fopen ("/sys/class/gpio/unexport", "w")) == NULL)
{
- fprintf (stderr, "%s: Unable to open GPIO export interface\n", argv [0]) ;
+ fprintf (stderr, "%s: Unable to open GPIO export interface\n", progName) ;
exit (1) ;
}
fprintf (fd, "%d\n", pin) ;
@@ -517,6 +725,30 @@ void doUnexportall (int argc, char *argv [])
}
+/*
+ * doReset:
+ * Reset the GPIO pins - as much as we can do
+ *********************************************************************************
+ */
+
+static void doReset (char *progName)
+{
+ int pin ;
+
+ doUnexportall (progName) ;
+
+ for (pin = 0 ; pin < 64 ; ++pin)
+ {
+ if (wpiPinToGpio (pin) == -1)
+ continue ;
+
+ digitalWrite (pin, LOW) ;
+ pinMode (pin, INPUT) ;
+ pullUpDnControl (pin, PUD_OFF) ;
+ }
+}
+
+
/*
* doMode:
* gpio mode pin mode ...
@@ -536,9 +768,6 @@ void doMode (int argc, char *argv [])
pin = atoi (argv [2]) ;
- if ((wpMode == WPI_MODE_PINS) && ((pin < 0) || (pin >= NUM_PINS)))
- return ;
-
mode = argv [3] ;
/**/ if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ;
@@ -623,13 +852,13 @@ static void doGbw (int argc, char *argv [])
exit (1) ;
}
- if (gertboardSPISetup () == -1)
+ if (gertboardAnalogSetup (64) < 0)
{
fprintf (stderr, "Unable to initialise the Gertboard SPI interface: %s\n", strerror (errno)) ;
exit (1) ;
}
- gertboardAnalogWrite (channel, value) ;
+ analogWrite (64 + channel, value) ;
}
@@ -658,17 +887,16 @@ static void doGbr (int argc, char *argv [])
exit (1) ;
}
- if (gertboardSPISetup () == -1)
+ if (gertboardAnalogSetup (64) < 0)
{
fprintf (stderr, "Unable to initialise the Gertboard SPI interface: %s\n", strerror (errno)) ;
exit (1) ;
}
- printf ("%d\n",gertboardAnalogRead (channel)) ;
+ printf ("%d\n", analogRead (64 + channel)) ;
}
-
/*
* doWrite:
* gpio write pin value
@@ -687,9 +915,6 @@ static void doWrite (int argc, char *argv [])
pin = atoi (argv [2]) ;
- if ((wpMode == WPI_MODE_PINS) && ((pin < 0) || (pin >= NUM_PINS)))
- return ;
-
/**/ if ((strcasecmp (argv [3], "up") == 0) || (strcasecmp (argv [3], "on") == 0))
val = 1 ;
else if ((strcasecmp (argv [3], "down") == 0) || (strcasecmp (argv [3], "off") == 0))
@@ -703,6 +928,31 @@ static void doWrite (int argc, char *argv [])
digitalWrite (pin, HIGH) ;
}
+
+/*
+ * doAwriterite:
+ * gpio awrite pin value
+ *********************************************************************************
+ */
+
+static void doAwrite (int argc, char *argv [])
+{
+ int pin, val ;
+
+ if (argc != 4)
+ {
+ fprintf (stderr, "Usage: %s awrite pin value\n", argv [0]) ;
+ exit (1) ;
+ }
+
+ pin = atoi (argv [2]) ;
+
+ val = atoi (argv [3]) ;
+
+ analogWrite (pin, val) ;
+}
+
+
/*
* doWriteByte:
* gpio write value
@@ -743,13 +993,31 @@ void doRead (int argc, char *argv [])
pin = atoi (argv [2]) ;
- if ((wpMode == WPI_MODE_PINS) && ((pin < 0) || (pin >= NUM_PINS)))
+ val = digitalRead (pin) ;
+
+ printf ("%s\n", val == 0 ? "0" : "1") ;
+}
+
+
+/*
+ * doAread:
+ * Read an analog pin and return the value
+ *********************************************************************************
+ */
+
+void doAread (int argc, char *argv [])
+{
+ int pin, val ;
+
+ if (argc != 3)
{
- printf ("0\n") ;
- return ;
+ fprintf (stderr, "Usage: %s aread pin\n", argv [0]) ;
+ exit (1) ;
}
- val = digitalRead (pin) ;
+ pin = atoi (argv [2]) ;
+
+ val = analogRead (pin) ;
printf ("%s\n", val == 0 ? "0" : "1") ;
}
@@ -773,9 +1041,6 @@ void doClock (int argc, char *argv [])
pin = atoi (argv [2]) ;
- if ((wpMode == WPI_MODE_PINS) && ((pin < 0) || (pin >= NUM_PINS)))
- return ;
-
freq = atoi (argv [3]) ;
gpioClockSet (pin, freq) ;
@@ -800,9 +1065,6 @@ void doPwm (int argc, char *argv [])
pin = atoi (argv [2]) ;
- if ((wpMode == WPI_MODE_PINS) && ((pin < 0) || (pin >= NUM_PINS)))
- return ;
-
val = atoi (argv [3]) ;
pwmWrite (pin, val) ;
@@ -863,6 +1125,72 @@ static void doPwmClock (int argc, char *argv [])
}
+/*
+ * doModule:
+ * Load in a wiringPi extension module
+ *********************************************************************************
+ */
+
+static int doModule (char *progName, char *moduleData)
+{
+ char *p ;
+ char *module = moduleData ;
+ struct moduleFunctionStruct *modFn ;
+ int pinBase = 0 ;
+
+// Get the module name by finding the first :
+
+ p = module ;
+ while (*p != ':')
+ {
+ if (!*p) // ran out of characters
+ {
+ fprintf (stderr, "%s: module name not terminated by a colon\n", progName) ;
+ return FALSE ;
+ }
+ ++p ;
+ }
+
+ *p++ = 0 ;
+
+ if (!isdigit (*p))
+ {
+ fprintf (stderr, "%s: pinBase number expected after module 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 modules:
+
+ for (modFn = moduleFunctions ; modFn->name != NULL ; ++modFn)
+ {
+ if (strcmp (modFn->name, module) == 0)
+ return modFn->function (progName, pinBase, p) ;
+ }
+
+ fprintf (stderr, "%s: module %s not found\n", progName, module) ;
+ return FALSE ;
+}
+
+
+
/*
* main:
* Start here
@@ -894,7 +1222,7 @@ int main (int argc, char *argv [])
if (strcasecmp (argv [1], "-v") == 0)
{
printf ("gpio version: %s\n", VERSION) ;
- printf ("Copyright (c) 2012 Gordon Henderson\n") ;
+ printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ;
printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
printf ("For details type: %s -warranty\n", argv [0]) ;
printf ("\n") ;
@@ -905,7 +1233,7 @@ int main (int argc, char *argv [])
if (strcasecmp (argv [1], "-warranty") == 0)
{
printf ("gpio version: %s\n", VERSION) ;
- printf ("Copyright (c) 2012 Gordon Henderson\n") ;
+ printf ("Copyright (c) 2012-2013 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") ;
@@ -934,8 +1262,8 @@ int main (int argc, char *argv [])
/**/ if (strcasecmp (argv [1], "exports" ) == 0) { doExports (argc, argv) ; return 0 ; }
else if (strcasecmp (argv [1], "export" ) == 0) { doExport (argc, argv) ; return 0 ; }
else if (strcasecmp (argv [1], "edge" ) == 0) { doEdge (argc, argv) ; return 0 ; }
- else if (strcasecmp (argv [1], "unexportall") == 0) { doUnexportall (argc, argv) ; return 0 ; }
else if (strcasecmp (argv [1], "unexport" ) == 0) { doUnexport (argc, argv) ; return 0 ; }
+ else if (strcasecmp (argv [1], "unexportall") == 0) { doUnexportall (argv [0]) ; return 0 ; }
// Check for load command:
@@ -948,13 +1276,9 @@ int main (int argc, char *argv [])
// Check for -g argument
- if (strcasecmp (argv [1], "-g") == 0)
+ /**/ if (strcasecmp (argv [1], "-g") == 0)
{
- if (wiringPiSetupGpio () == -1)
- {
- fprintf (stderr, "%s: Unable to initialise GPIO mode.\n", argv [0]) ;
- exit (1) ;
- }
+ wiringPiSetupGpio () ;
for (i = 2 ; i < argc ; ++i)
argv [i - 1] = argv [i] ;
@@ -962,15 +1286,23 @@ int main (int argc, char *argv [])
wpMode = WPI_MODE_GPIO ;
}
+// Check for -1 argument
+
+ else if (strcasecmp (argv [1], "-1") == 0)
+ {
+ wiringPiSetupPhys () ;
+
+ for (i = 2 ; i < argc ; ++i)
+ argv [i - 1] = argv [i] ;
+ --argc ;
+ wpMode = WPI_MODE_PHYS ;
+ }
+
// Check for -p argument for PiFace
else if (strcasecmp (argv [1], "-p") == 0)
{
- if (wiringPiSetupPiFaceForGpioProg () == -1)
- {
- fprintf (stderr, "%s: Unable to initialise PiFace.\n", argv [0]) ;
- exit (1) ;
- }
+ piFaceSetup (200) ;
for (i = 2 ; i < argc ; ++i)
argv [i - 1] = argv [i] ;
@@ -982,38 +1314,58 @@ int main (int argc, char *argv [])
else
{
- if (wiringPiSetup () == -1)
- {
- fprintf (stderr, "%s: Unable to initialise wiringPi mode\n", argv [0]) ;
- exit (1) ;
- }
+ wiringPiSetup () ;
wpMode = WPI_MODE_PINS ;
}
-// Check for PWM or Pad Drive operations
+// Check for -x argument to load in a new module
- if (wpMode != WPI_MODE_PIFACE)
+ if (strcasecmp (argv [1], "-x") == 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 ; }
+ if (argc < 3)
+ {
+ fprintf (stderr, "%s: -x missing module specification.\n", argv [0]) ;
+ exit (EXIT_FAILURE) ;
+ }
+
+ if (!doModule (argv [0], argv [2])) // Prints its own error messages
+ exit (EXIT_FAILURE) ;
+
+ for (i = 3 ; i < argc ; ++i)
+ argv [i - 2] = argv [i] ;
+ argc -= 2 ;
}
-// Check for wiring commands
+ if (argc <= 1)
+ {
+ fprintf (stderr, "%s: no command given\n", argv [0]) ;
+ exit (EXIT_FAILURE) ;
+ }
- /**/ if (strcasecmp (argv [1], "readall" ) == 0) doReadall () ;
- else if (strcasecmp (argv [1], "read" ) == 0) doRead (argc, argv) ;
- else if (strcasecmp (argv [1], "write") == 0) doWrite (argc, argv) ;
- else if (strcasecmp (argv [1], "wb") == 0) doWriteByte (argc, argv) ;
- else if (strcasecmp (argv [1], "pwm" ) == 0) doPwm (argc, argv) ;
- else if (strcasecmp (argv [1], "clock") == 0) doClock (argc, argv) ;
- else if (strcasecmp (argv [1], "mode" ) == 0) doMode (argc, argv) ;
+// Core wiringPi functions
+
+ /**/ if (strcasecmp (argv [1], "mode" ) == 0) doMode (argc, argv) ;
+ else if (strcasecmp (argv [1], "read" ) == 0) doRead (argc, argv) ;
+ else if (strcasecmp (argv [1], "write" ) == 0) doWrite (argc, argv) ;
+ else if (strcasecmp (argv [1], "pwm" ) == 0) doPwm (argc, argv) ;
+ else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite (argc, argv) ;
+ else if (strcasecmp (argv [1], "aread" ) == 0) doAread (argc, argv) ;
+
+// Pi Specifics
+
+ else if (strcasecmp (argv [1], "pwm-bal") == 0) doPwmMode (PWM_MODE_BAL) ;
+ else if (strcasecmp (argv [1], "pwm-ms" ) == 0) doPwmMode (PWM_MODE_MS) ;
+ else if (strcasecmp (argv [1], "pwmr" ) == 0) doPwmRange (argc, argv) ;
+ else if (strcasecmp (argv [1], "pwmc" ) == 0) doPwmClock (argc, argv) ;
+ else if (strcasecmp (argv [1], "drive" ) == 0) doPadDrive (argc, argv) ;
+ else if (strcasecmp (argv [1], "readall") == 0) doReadall () ;
+ else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ;
+ else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ;
+ else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ;
else
{
fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
- exit (1) ;
+ exit (EXIT_FAILURE) ;
}
return 0 ;
}
diff --git a/gpio/test.sh b/WiringPi/gpio/test.sh
similarity index 100%
rename from gpio/test.sh
rename to WiringPi/gpio/test.sh
diff --git a/WiringPi/pins/Makefile b/WiringPi/pins/Makefile
new file mode 100644
index 0000000..5e200c2
--- /dev/null
+++ b/WiringPi/pins/Makefile
@@ -0,0 +1,18 @@
+
+SRC = pins.tex
+
+
+all: ${SRC}
+ @echo Generating DVI
+ @latex pins.tex
+
+pins.dvi: pins.tex
+ @latex pins.tex
+
+pdf: pins.dvi
+ @dvipdf pins.dvi
+
+
+.PHONEY: clean
+clean:
+ @rm -f *.dvi *.aux *.log *.ps *.toc *.bak *~
diff --git a/WiringPi/pins/pins.pdf b/WiringPi/pins/pins.pdf
new file mode 100644
index 0000000..bd9629d
Binary files /dev/null and b/WiringPi/pins/pins.pdf differ
diff --git a/WiringPi/pins/pins.tex b/WiringPi/pins/pins.tex
new file mode 100644
index 0000000..c3753e9
--- /dev/null
+++ b/WiringPi/pins/pins.tex
@@ -0,0 +1,116 @@
+\documentclass[12pt,a4paper]{article}
+\parskip 1ex
+\parindent 0em
+\thispagestyle{empty}
+\pagestyle{plain}
+\pagenumbering{arabic}
+\setlength{\topmargin}{0pt}
+\setlength{\headheight}{0pt}
+\setlength{\headsep}{0pt}
+\setlength{\topskip}{0pt}
+\setlength{\textheight}{240mm}
+\setlength{\footskip}{5ex}
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{160mm}
+\usepackage[dvips]{graphics,color}
+\usepackage{helvet}
+\renewcommand{\familydefault}{\sfdefault}
+\begin{document}
+\begin{sffamily}
+\definecolor{rtb-black}{rgb} {0.0, 0.0, 0.0}
+\definecolor{rtb-navy}{rgb} {0.0, 0.0, 0.5}
+\definecolor{rtb-green}{rgb} {0.0, 0.5, 0.0}
+\definecolor{rtb-teal}{rgb} {0.0, 0.5, 0.5}
+\definecolor{rtb-maroon}{rgb} {0.5, 0.0, 0.0}
+\definecolor{rtb-purple}{rgb} {0.5, 0.0, 0.5}
+\definecolor{rtb-olive}{rgb} {0.5, 0.5, 0.0}
+\definecolor{rtb-silver}{rgb} {0.7, 0.7, 0.7}
+\definecolor{rtb-grey}{rgb} {0.5, 0.5, 0.5}
+\definecolor{rtb-blue}{rgb} {0.0, 0.0, 1.0}
+\definecolor{rtb-lime}{rgb} {0.0, 1.0, 0.0}
+\definecolor{rtb-aqua}{rgb} {0.0, 1.0, 1.0}
+\definecolor{rtb-red}{rgb} {1.0, 0.0, 0.0}
+\definecolor{rtb-fuchsia}{rgb}{1.0, 0.0, 1.0}
+\definecolor{rtb-yellow}{rgb} {1.0, 1.0, 0.0}
+\definecolor{rtb-white}{rgb} {1.0, 1.0, 1.0}
+
+\begin{center}
+\bfseries{WiringPi: GPIO Pin Numbering Tables}\\
+\tt{http://wiringpi.com/}
+\end{center}
+
+\begin{center}
+\begin{tabular}{|c|c|c||p{8mm}|p{8mm}||c|c|c|c|}
+\hline
+\multicolumn{8}{|c|}{\bfseries{P1: The Main GPIO connector}}\\
+\hline
+\hline
+WiringPi Pin & BCM GPIO & Name & \multicolumn{2}{|c||}{Header} & Name & BCM GPIO & WiringPi Pin\\
+\hline
+\hline
+ & & \textcolor{rtb-red}{3.3v} & \raggedleft{1} & 2 & \textcolor{rtb-maroon}{5v} & & \\
+\hline
+8 & Rv1:0 - Rv2:2 & \textcolor{rtb-aqua}{SDA} & \raggedleft{3} & 4 & \textcolor{rtb-maroon}{5v} & & \\
+\hline
+9 & Rv1:1 - Rv2:3 & \textcolor{rtb-aqua}{SCL} & \raggedleft{5} & 6 & \textcolor{rtb-black}{0v} & & \\
+\hline
+7 & 4 & \textcolor{rtb-green}{GPIO7} & \raggedleft{7} & 8 & \textcolor{rtb-yellow}{TxD} & 14 & 15\\
+\hline
+ & & \textcolor{rtb-black}{0v} & \raggedleft{9} & 10 & \textcolor{rtb-yellow}{RxD} & 15 & 16\\
+\hline
+0 & 17 & \textcolor{rtb-green}{GPIO0} & \raggedleft{11} & 12 & \textcolor{rtb-green}{GPIO1} & 18 & 1\\
+\hline
+2 & Rv1:21 - Rv2:27 & \textcolor{rtb-green}{GPIO2} & \raggedleft{13} & 14 & \textcolor{rtb-black}{0v} & & \\
+\hline
+3 & 22 & \textcolor{rtb-green}{GPIO3} & \raggedleft{15} & 16 & \textcolor{rtb-green}{GPIO4} & 23 & 4\\
+\hline
+ & & \textcolor{rtb-red}{3.3v} & \raggedleft{17} & 18 & \textcolor{rtb-green}{GPIO5} & 24 & 5\\
+\hline
+12 & 10 & \textcolor{rtb-teal}{MOSI} & \raggedleft{19} & 20 & \textcolor{rtb-black}{0v} & & \\
+\hline
+13 & 9 & \textcolor{rtb-teal}{MISO} & \raggedleft{21} & 22 & \textcolor{rtb-green}{GPIO6} & 25 & 6\\
+\hline
+14 & 11 & \textcolor{rtb-teal}{SCLK} & \raggedleft{23} & 24 & \textcolor{rtb-teal}{CE0} & 8 & 10\\
+\hline
+ & & \textcolor{rtb-black}{0v} & \raggedleft{25} & 26 & \textcolor{rtb-teal}{CE1} & 7 & 11\\
+\hline
+\hline
+WiringPi Pin & BCM GPIO & Name & \multicolumn{2}{|c||}{Header} & Name & BCM GPIO & WiringPi Pin\\
+\hline
+\end{tabular}
+\end{center}
+
+Note the differences between Revision 1 and Revision 2 Raspberry
+Pi's. The Revision 2 is readily identifiable by the presence of the 2
+mounting holes.
+
+The revision 2 Raspberry Pi has an additional GPIO connector, P5, which is next to the main P1 GPIO
+connector:
+
+\begin{center}
+\begin{tabular}{|c|c|c||p{8mm}|p{8mm}||c|c|c|c|}
+\hline
+\multicolumn{8}{|c|}{\bfseries{P5: Secondary GPIO connector (Rev. 2 Pi only)}}\\
+\hline
+\hline
+WiringPi Pin & BCM GPIO & Name & \multicolumn{2}{|c||}{Header} & Name & BCM GPIO & WiringPi Pin\\
+\hline
+\hline
+ & & \textcolor{rtb-maroon}{5v} & \raggedleft{1} & 2 & \textcolor{rtb-red}{3.3v} & & \\
+\hline
+17 & 28 & \textcolor{rtb-green}{GPIO8} & \raggedleft{3} & 4 & \textcolor{rtb-green}{GPIO9} & 29 & 18 \\
+\hline
+19 & 30 & \textcolor{rtb-green}{GPIO10} & \raggedleft{5} & 6 & \textcolor{rtb-green}{GPIO11} & 31 & 20 \\
+\hline
+ & & \textcolor{rtb-black}{0v} & \raggedleft{7} & 8 & \textcolor{rtb-black}{0v} & & \\
+\hline
+\hline
+WiringPi Pin & BCM GPIO & Name & \multicolumn{2}{|c||}{Header} & Name & BCM GPIO & WiringPi Pin\\
+\hline
+\end{tabular}
+\end{center}
+
+
+\end{sffamily}
+\end{document}
diff --git a/wiringPi/Makefile b/WiringPi/wiringPi/Makefile
similarity index 69%
rename from wiringPi/Makefile
rename to WiringPi/wiringPi/Makefile
index c6a4555..eaf250e 100644
--- a/wiringPi/Makefile
+++ b/WiringPi/wiringPi/Makefile
@@ -21,7 +21,7 @@
# along with wiringPi. If not, see .
#################################################################################
-DYN_VERS_MAJ=1
+DYN_VERS_MAJ=2
DYN_VERS_MIN=0
VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
@@ -42,19 +42,18 @@ LIBS =
# Should not alter anything below this line
###############################################################################
-SRC = wiringPi.c wiringPiFace.c wiringSerial.c wiringShift.c \
- gertboard.c \
- piNes.c \
- lcd.c piHiPri.c piThread.c \
- wiringPiSPI.c \
- softPwm.c softServo.c softTone.c
-
-SRC_I2C = wiringPiI2C.c
+SRC = wiringPi.c \
+ wiringSerial.c wiringShift.c \
+ piHiPri.c piThread.c \
+ wiringPiSPI.c wiringPiI2C.c \
+ softPwm.c softTone.c \
+ mcp23s08.c mcp23008.c \
+ mcp23s17.c mcp23017.c sr595.c \
+ piFace.c gertboard.c \
+ piNes.c ds1302.c lcd.c
OBJ = $(SRC:.c=.o)
-OBJ_I2C = $(SRC_I2C:.c=.o)
-
all: $(DYNAMIC)
static: $(STATIC)
@@ -67,11 +66,7 @@ $(STATIC): $(OBJ)
$(DYNAMIC): $(OBJ)
@echo "[Link (Dynamic)]"
- @$(CC) -shared -Wl,-soname,libwiringPi.so.1 -o libwiringPi.so.1.0 -lpthread $(OBJ)
-
-i2c: $(OBJ) $(OBJ_I2C)
- @echo "[Link (Dynamic + I2C)]"
- @$(CC) -shared -Wl,-soname,libwiringPi.so.1 -o libwiringPi.so.1.0 -lpthread $(OBJ) $(OBJ_I2C)
+ @$(CC) -shared -Wl,-soname,libwiringPi.so -o libwiringPi.so.$(VERSION) -lpthread $(OBJ)
.c.o:
@echo [Compile] $<
@@ -95,16 +90,21 @@ install: $(DYNAMIC)
@install -m 0644 wiringSerial.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 wiringShift.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 gertboard.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 piFace.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 piNes.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 ds1302.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 softPwm.h $(DESTDIR)$(PREFIX)/include
- @install -m 0644 softServo.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 softTone.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 lcd.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 wiringPiSPI.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 wiringPiI2C.h $(DESTDIR)$(PREFIX)/include
- @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib
- @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
- @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so.1
+ @install -m 0644 mcp23008.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 mcp23017.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 mcp23s08.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 mcp23s17.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 sr595.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
+ @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
@ldconfig
.PHONEY: install-static
@@ -119,13 +119,19 @@ uninstall:
@rm -f $(DESTDIR)$(PREFIX)/include/wiringSerial.h
@rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h
@rm -f $(DESTDIR)$(PREFIX)/include/gertboard.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/piFace.h
@rm -f $(DESTDIR)$(PREFIX)/include/piNes.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/ds1302.h
@rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h
- @rm -f $(DESTDIR)$(PREFIX)/include/softServo.h
@rm -f $(DESTDIR)$(PREFIX)/include/softTone.h
@rm -f $(DESTDIR)$(PREFIX)/include/lcd.h
@rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h
@rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/sr595.h
@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.*
@ldconfig
@@ -137,16 +143,21 @@ depend:
# DO NOT DELETE
wiringPi.o: wiringPi.h
-wiringPiFace.o: wiringPi.h
wiringSerial.o: wiringSerial.h
wiringShift.o: wiringPi.h wiringShift.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
wiringPiSPI.o: wiringPiSPI.h
+wiringPiI2C.o: wiringPi.h wiringPiI2C.h
softPwm.o: wiringPi.h softPwm.h
-softServo.o: wiringPi.h softServo.h
softTone.o: wiringPi.h softTone.h
-wiringPiI2C.o: wiringPi.h wiringPiI2C.h
+mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
+mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
+mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
+mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
+sr595.o: wiringPi.h sr595.h
+piFace.o: wiringPi.h wiringPiSPI.h piFace.h mcp23x0817.h
+gertboard.o: wiringPi.h wiringPiSPI.h gertboard.h
+piNes.o: wiringPi.h piNes.h
+ds1302.o: wiringPi.h ds1302.h
+lcd.o: wiringPi.h lcd.h
diff --git a/WiringPi/wiringPi/ds1302.c b/WiringPi/wiringPi/ds1302.c
new file mode 100644
index 0000000..ce5da29
--- /dev/null
+++ b/WiringPi/wiringPi/ds1302.c
@@ -0,0 +1,239 @@
+/*
+ * ds1302.c:
+ * Real Time clock
+ *
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+#include
+#include
+
+#include "wiringPi.h"
+#include "ds1302.h"
+
+// Register defines
+
+#define RTC_SECS 0
+#define RTC_MINS 1
+#define RTC_HOURS 2
+#define RTC_DATE 3
+#define RTC_MONTH 4
+#define RTC_DAY 5
+#define RTC_YEAR 6
+#define RTC_WP 7
+#define RTC_TC 8
+#define RTC_BM 31
+
+
+// Locals
+
+static int dPin, cPin, sPin ;
+
+/*
+ * dsShiftIn:
+ * Shift a number in from the chip, LSB first. Note that the data is
+ * sampled on the trailing edge of the last clock, so it's valid immediately.
+ *********************************************************************************
+ */
+
+unsigned int dsShiftIn (void)
+{
+ uint8_t value = 0 ;
+ int i ;
+
+ pinMode (dPin, INPUT) ; delayMicroseconds (1) ;
+
+ for (i = 0 ; i < 8 ; ++i)
+ {
+ value |= (digitalRead (dPin) << i) ;
+ digitalWrite (cPin, HIGH) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, LOW) ; delayMicroseconds (1) ;
+ }
+
+ return value;
+}
+
+
+/*
+ * dsShiftOut:
+ * A normal LSB-first shift-out, just slowed down a bit - the Pi is
+ * a bit faster than the chip can handle.
+ *********************************************************************************
+ */
+
+void dsShiftOut (unsigned int data)
+{
+ int i ;
+
+ pinMode (dPin, OUTPUT) ;
+
+ for (i = 0 ; i < 8 ; ++i)
+ {
+ digitalWrite (dPin, data & (1 << i)) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, HIGH) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, LOW) ; delayMicroseconds (1) ;
+ }
+}
+
+
+/*
+ * ds1302regRead: ds1302regWrite:
+ * Read/Write a value to an RTC Register or RAM location on the chip
+ *********************************************************************************
+ */
+
+static unsigned int ds1302regRead (int reg)
+{
+ unsigned int data ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+ dsShiftOut (reg) ;
+ data = dsShiftIn () ;
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+
+ return data ;
+}
+
+static void ds1302regWrite (int reg, unsigned int data)
+{
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+ dsShiftOut (reg) ;
+ dsShiftOut (data) ;
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302rtcWrite: ds1302rtcRead:
+ * Writes/Reads the data to/from the RTC register
+ *********************************************************************************
+ */
+
+unsigned int ds1302rtcRead (int reg)
+{
+ return ds1302regRead (0x81 | ((reg & 0x1F) << 1)) ;
+}
+
+void ds1302rtcWrite (int reg, unsigned int data)
+{
+ ds1302regWrite (0x80 | ((reg & 0x1F) << 1), data) ;
+}
+
+
+/*
+ * ds1302ramWrite: ds1302ramRead:
+ * Writes/Reads the data to/from the RTC register
+ *********************************************************************************
+ */
+
+unsigned int ds1302ramRead (int addr)
+{
+ return ds1302regRead (0xC1 | ((addr & 0x1F) << 1)) ;
+}
+
+void ds1302ramWrite (int addr, unsigned int data)
+{
+ ds1302regWrite ( 0xC0 | ((addr & 0x1F) << 1), data) ;
+}
+
+/*
+ * ds1302clockRead:
+ * Read all 8 bytes of the clock in a single operation
+ *********************************************************************************
+ */
+
+void ds1302clockRead (int clockData [8])
+{
+ int i ;
+ unsigned int regVal = 0x81 | ((RTC_BM & 0x1F) << 1) ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+
+ dsShiftOut (regVal) ;
+ for (i = 0 ; i < 8 ; ++i)
+ clockData [i] = dsShiftIn () ;
+
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302clockWrite:
+ * Write all 8 bytes of the clock in a single operation
+ *********************************************************************************
+ */
+
+void ds1302clockWrite (int clockData [8])
+{
+ int i ;
+ unsigned int regVal = 0x80 | ((RTC_BM & 0x1F) << 1) ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+
+ dsShiftOut (regVal) ;
+ for (i = 0 ; i < 8 ; ++i)
+ dsShiftOut (clockData [i]) ;
+
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302trickleCharge:
+ * Set the bits on the trickle charger.
+ * Probably best left alone...
+ *********************************************************************************
+ */
+
+void ds1302trickleCharge (int diodes, int resistors)
+{
+ if (diodes + resistors == 0)
+ ds1302rtcWrite (RTC_TC, 0x5C) ; // Disabled
+ else
+ ds1302rtcWrite (RTC_TC, 0xA0 | ((diodes & 3) << 2) | (resistors & 3)) ;
+}
+
+
+
+
+/*
+ * ds1302setup:
+ * Initialise the chip & remember the pins we're using
+ *********************************************************************************
+ */
+
+void ds1302setup (int clockPin, int dataPin, int csPin)
+{
+ dPin = dataPin ;
+ cPin = clockPin ;
+ sPin = csPin ;
+
+ digitalWrite (dPin, LOW) ;
+ digitalWrite (cPin, LOW) ;
+ digitalWrite (sPin, LOW) ;
+
+ pinMode (dPin, OUTPUT) ;
+ pinMode (cPin, OUTPUT) ;
+ pinMode (sPin, OUTPUT) ;
+
+ ds1302rtcWrite (RTC_WP, 0) ; // Remove write-protect
+}
diff --git a/WiringPi/wiringPi/ds1302.h b/WiringPi/wiringPi/ds1302.h
new file mode 100644
index 0000000..8449a9b
--- /dev/null
+++ b/WiringPi/wiringPi/ds1302.h
@@ -0,0 +1,44 @@
+/*
+ * ds1302.h:
+ * Real Time clock
+ *
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern unsigned int ds1302rtcRead (int reg) ;
+extern void ds1302rtcWrite (int reg, unsigned int data) ;
+
+extern unsigned int ds1302ramRead (int addr) ;
+extern void ds1302ramWrite (int addr, unsigned int data) ;
+
+extern void ds1302clockRead (int clockData [8]) ;
+extern void ds1302clockWrite (int clockData [8]) ;
+
+extern void ds1302trickleCharge (int diodes, int resistors) ;
+
+extern void ds1302setup (int clockPin, int dataPin, int csPin) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/wiringPi/gertboard.c b/WiringPi/wiringPi/gertboard.c
similarity index 71%
rename from wiringPi/gertboard.c
rename to WiringPi/wiringPi/gertboard.c
index a8795d3..87dbe41 100644
--- a/wiringPi/gertboard.c
+++ b/WiringPi/wiringPi/gertboard.c
@@ -38,16 +38,17 @@
#include
#include
+#include "wiringPi.h"
#include "wiringPiSPI.h"
#include "gertboard.h"
// The A-D convertor won't run at more than 1MHz @ 3.3v
-#define SPI_ADC_SPEED 1000000
-#define SPI_DAC_SPEED 1000000
-#define SPI_A2D 0
-#define SPI_D2A 1
+#define SPI_ADC_SPEED 1000000
+#define SPI_DAC_SPEED 1000000
+#define SPI_A2D 0
+#define SPI_D2A 1
/*
@@ -120,3 +121,46 @@ int gertboardSPISetup (void)
return 0 ;
}
+
+
+/*
+ * New wiringPi node extension methods.
+ *********************************************************************************
+ */
+
+int gbWiringPiAnalogRead (struct wiringPiNodeStruct *node, int chan)
+{
+ chan -= node->pinBase ;
+ return gertboardAnalogRead (chan) ;
+}
+
+void gbWiringPiAnalogWrite (struct wiringPiNodeStruct *node, int chan, int value)
+{
+ chan -= node->pinBase ;
+ gertboardAnalogWrite (chan, value) ;
+}
+
+
+/*
+ * gertboardAnalogSetup:
+ * Create a new wiringPi device node for the analog devices on the
+ * Gertboard. We create one node with 2 pins - each pin being read
+ * and write - although the operations actually go to different
+ * hardware devices.
+ *********************************************************************************
+ */
+
+int gertboardAnalogSetup (int pinBase)
+{
+ struct wiringPiNodeStruct *node ;
+ int x ;
+
+ if (( x = gertboardSPISetup ()) != 0)
+ return x;
+
+ node = wiringPiNewNode (pinBase, 2) ;
+ node->analogRead = gbWiringPiAnalogRead ;
+ node->analogWrite = gbWiringPiAnalogWrite ;
+
+ return 0 ;
+}
diff --git a/wiringPi/gertboard.h b/WiringPi/wiringPi/gertboard.h
similarity index 96%
rename from wiringPi/gertboard.h
rename to WiringPi/wiringPi/gertboard.h
index 98fd1e7..e96300f 100644
--- a/wiringPi/gertboard.h
+++ b/WiringPi/wiringPi/gertboard.h
@@ -33,6 +33,7 @@ extern "C" {
extern void gertboardAnalogWrite (int chan, int value) ;
extern int gertboardAnalogRead (int chan) ;
extern int gertboardSPISetup (void) ;
+extern int gertboardAnalogSetup (int pinBase) ;
#ifdef __cplusplus
}
diff --git a/wiringPi/lcd.c b/WiringPi/wiringPi/lcd.c
similarity index 100%
rename from wiringPi/lcd.c
rename to WiringPi/wiringPi/lcd.c
diff --git a/wiringPi/lcd.h b/WiringPi/wiringPi/lcd.h
similarity index 100%
rename from wiringPi/lcd.h
rename to WiringPi/wiringPi/lcd.h
diff --git a/WiringPi/wiringPi/mcp23008.c b/WiringPi/wiringPi/mcp23008.c
new file mode 100644
index 0000000..c518c14
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23008.c
@@ -0,0 +1,155 @@
+/*
+ * mcp23008.c:
+ * Extend wiringPi with the MCP 23008 I2C GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiI2C.h"
+#include "mcp23x0817.h"
+
+#include "mcp23008.h"
+
+
+/*
+ * myPinMode:
+ *********************************************************************************
+ */
+
+static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, ddr ;
+
+ pin -= node->pinBase ;
+ ddr = MCP23x08_IODIR ;
+ mask = 1 << pin ;
+ old = wiringPiI2CReadReg8 (node->fd, ddr) ;
+
+ if (mode == OUTPUT)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ wiringPiI2CWriteReg8 (node->fd, ddr, old) ;
+}
+
+
+/*
+ * myPullUpDnControl:
+ *********************************************************************************
+ */
+
+static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, pud ;
+
+ pin -= node->pinBase ;
+ pud = MCP23x08_GPPU ;
+ mask = 1 << pin ;
+
+ old = wiringPiI2CReadReg8 (node->fd, pud) ;
+
+ if (mode == PUD_UP)
+ old |= mask ;
+ else
+ old &= (~mask) ;
+
+ wiringPiI2CWriteReg8 (node->fd, pud, old) ;
+}
+
+
+/*
+ * myDigitalWrite:
+ *********************************************************************************
+ */
+
+static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ int bit, old ;
+
+ pin -= node->pinBase ;
+ bit = 1 << (pin & 7) ;
+
+ old = node->data2 ;
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ wiringPiI2CWriteReg8 (node->fd, MCP23x08_GPIO, old) ;
+ node->data2 = old ;
+}
+
+
+/*
+ * myDigitalRead:
+ *********************************************************************************
+ */
+
+static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
+{
+ int mask, value, gpio ;
+
+ pin -= node->pinBase ;
+ gpio = MCP23x08_GPIO ;
+ mask = 1 << pin ;
+
+ value = wiringPiI2CReadReg8 (node->fd, gpio) ;
+
+ if ((value & mask) == 0)
+ return LOW ;
+ else
+ return HIGH ;
+}
+
+
+/*
+ * mcp23008Setup:
+ * Create a new instance of an MCP23008 I2C GPIO interface. We know it
+ * has 16 pins, so all we need to know here is the I2C address and the
+ * user-defined pin base.
+ *********************************************************************************
+ */
+
+int mcp23008Setup (int pinBase, int i2cAddress)
+{
+ int fd ;
+ struct wiringPiNodeStruct *node ;
+
+ if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
+ return fd ;
+
+ wiringPiI2CWriteReg8 (fd, MCP23x08_IOCON, IOCON_INIT) ;
+
+ node = wiringPiNewNode (pinBase, 16) ;
+
+ node->fd = fd ;
+ node->pinMode = myPinMode ;
+ node->pullUpDnControl = myPullUpDnControl ;
+ node->digitalRead = myDigitalRead ;
+ node->digitalWrite = myDigitalWrite ;
+ node->data2 = wiringPiI2CReadReg8 (fd, MCP23x08_OLAT) ;
+
+ return 0 ;
+}
diff --git a/WiringPi/wiringPi/mcp23008.h b/WiringPi/wiringPi/mcp23008.h
new file mode 100644
index 0000000..0aa21dc
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23008.h
@@ -0,0 +1,33 @@
+/*
+ * 23008.h:
+ * Extend wiringPi with the MCP 23008 I2C GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int mcp23008Setup (int pinBase, int i2cAddress) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/WiringPi/wiringPi/mcp23017.c b/WiringPi/wiringPi/mcp23017.c
new file mode 100644
index 0000000..cf6593e
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23017.c
@@ -0,0 +1,195 @@
+/*
+ * mcp23017.c:
+ * Extend wiringPi with the MCP 23017 I2C GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiI2C.h"
+#include "mcp23x0817.h"
+
+#include "mcp23017.h"
+
+
+/*
+ * myPinMode:
+ *********************************************************************************
+ */
+
+static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, ddr ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ ddr = MCP23x17_IODIRA ;
+ else
+ {
+ ddr = MCP23x17_IODIRB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ old = wiringPiI2CReadReg8 (node->fd, ddr) ;
+
+ if (mode == OUTPUT)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ wiringPiI2CWriteReg8 (node->fd, ddr, old) ;
+}
+
+
+/*
+ * myPullUpDnControl:
+ *********************************************************************************
+ */
+
+static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, pud ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ pud = MCP23x17_GPPUA ;
+ else
+ {
+ pud = MCP23x17_GPPUB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ old = wiringPiI2CReadReg8 (node->fd, pud) ;
+
+ if (mode == PUD_UP)
+ old |= mask ;
+ else
+ old &= (~mask) ;
+
+ wiringPiI2CWriteReg8 (node->fd, pud, old) ;
+}
+
+
+/*
+ * myDigitalWrite:
+ *********************************************************************************
+ */
+
+static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ int bit, old ;
+
+ pin -= node->pinBase ; // Pin now 0-15
+
+ bit = 1 << (pin & 7) ;
+
+ if (pin < 8) // Bank A
+ {
+ old = node->data2 ;
+
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ wiringPiI2CWriteReg8 (node->fd, MCP23x17_GPIOA, old) ;
+ node->data2 = old ;
+ }
+ else // Bank B
+ {
+ old = node->data3 ;
+
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ wiringPiI2CWriteReg8 (node->fd, MCP23x17_GPIOB, old) ;
+ node->data3 = old ;
+ }
+}
+
+
+/*
+ * myDigitalRead:
+ *********************************************************************************
+ */
+
+static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
+{
+ int mask, value, gpio ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ gpio = MCP23x17_GPIOA ;
+ else
+ {
+ gpio = MCP23x17_GPIOB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ value = wiringPiI2CReadReg8 (node->fd, gpio) ;
+
+ if ((value & mask) == 0)
+ return LOW ;
+ else
+ return HIGH ;
+}
+
+
+/*
+ * mcp23017Setup:
+ * Create a new instance of an MCP23017 I2C GPIO interface. We know it
+ * has 16 pins, so all we need to know here is the I2C address and the
+ * user-defined pin base.
+ *********************************************************************************
+ */
+
+int mcp23017Setup (int pinBase, int i2cAddress)
+{
+ int fd ;
+ struct wiringPiNodeStruct *node ;
+
+ if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
+ return fd ;
+
+ wiringPiI2CWriteReg8 (fd, MCP23x17_IOCON, IOCON_INIT) ;
+
+ node = wiringPiNewNode (pinBase, 16) ;
+
+ node->fd = fd ;
+ node->pinMode = myPinMode ;
+ node->pullUpDnControl = myPullUpDnControl ;
+ node->digitalRead = myDigitalRead ;
+ node->digitalWrite = myDigitalWrite ;
+ node->data2 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATA) ;
+ node->data3 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATB) ;
+
+ return 0 ;
+}
diff --git a/WiringPi/wiringPi/mcp23017.h b/WiringPi/wiringPi/mcp23017.h
new file mode 100644
index 0000000..3d0e42c
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23017.h
@@ -0,0 +1,33 @@
+/*
+ * 23017.h:
+ * Extend wiringPi with the MCP 23017 I2C GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int mcp23017Setup (int pinBase, int i2cAddress) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/WiringPi/wiringPi/mcp23s08.c b/WiringPi/wiringPi/mcp23s08.c
new file mode 100644
index 0000000..391e9e1
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23s08.c
@@ -0,0 +1,195 @@
+/*
+ * mcp23s08.c:
+ * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiSPI.h"
+#include "mcp23x0817.h"
+
+#include "mcp23s08.h"
+
+#define MCP_SPEED 4000000
+
+
+
+/*
+ * writeByte:
+ * Write a byte to a register on the MCP23s08 on the SPI bus.
+ *********************************************************************************
+ */
+
+static void writeByte (uint8_t spiPort, uint8_t devId, uint8_t reg, uint8_t data)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_WRITE | ((devId & 7) << 1) ;
+ spiData [1] = reg ;
+ spiData [2] = data ;
+
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
+}
+
+/*
+ * readByte:
+ * Read a byte from a register on the MCP23s08 on the SPI bus.
+ *********************************************************************************
+ */
+
+static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_READ | ((devId & 7) << 1) ;
+ spiData [1] = reg ;
+
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
+
+ return spiData [2] ;
+}
+
+
+/*
+ * myPinMode:
+ *********************************************************************************
+ */
+
+static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, ddr ;
+
+ pin -= node->pinBase ;
+ ddr = MCP23x08_IODIR ;
+ mask = 1 << pin ;
+ old = readByte (node->data0, node->data1, ddr) ;
+
+ if (mode == OUTPUT)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ writeByte (node->data0, node->data1, ddr, old) ;
+}
+
+
+/*
+ * myPullUpDnControl:
+ *********************************************************************************
+ */
+
+static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, pud ;
+
+ pin -= node->pinBase ;
+ pud = MCP23x08_GPPU ;
+ mask = 1 << pin ;
+
+ old = readByte (node->data0, node->data1, pud) ;
+
+ if (mode == PUD_UP)
+ old |= mask ;
+ else
+ old &= (~mask) ;
+
+ writeByte (node->data0, node->data1, pud, old) ;
+}
+
+
+/*
+ * myDigitalWrite:
+ *********************************************************************************
+ */
+
+static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ int bit, old ;
+
+ pin -= node->pinBase ;
+ bit = 1 << pin ;
+
+ old = node->data2 ;
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ writeByte (node->data0, node->data1, MCP23x08_GPIO, old) ;
+ node->data2 = old ;
+}
+
+
+/*
+ * myDigitalRead:
+ *********************************************************************************
+ */
+
+static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
+{
+ int mask, value, gpio ;
+
+ pin -= node->pinBase ;
+ gpio = MCP23x08_GPIO ;
+ mask = 1 << pin ;
+
+ value = readByte (node->data0, node->data1, gpio) ;
+
+ if ((value & mask) == 0)
+ return LOW ;
+ else
+ return HIGH ;
+}
+
+
+/*
+ * mcp23s08Setup:
+ * Create a new instance of an MCP23s08 SPI GPIO interface. We know it
+ * has 16 pins, so all we need to know here is the SPI address and the
+ * user-defined pin base.
+ *********************************************************************************
+ */
+
+int mcp23s08Setup (int pinBase, int spiPort, int devId)
+{
+ int x ;
+ struct wiringPiNodeStruct *node ;
+
+ if ((x = wiringPiSPISetup (spiPort, MCP_SPEED)) < 0)
+ return x ;
+
+ writeByte (spiPort, devId, MCP23x08_IOCON, IOCON_INIT) ;
+
+ node = wiringPiNewNode (pinBase, 16) ;
+
+ node->data0 = spiPort ;
+ node->data1 = devId ;
+ node->pinMode = myPinMode ;
+ node->pullUpDnControl = myPullUpDnControl ;
+ node->digitalRead = myDigitalRead ;
+ node->digitalWrite = myDigitalWrite ;
+ node->data2 = readByte (spiPort, devId, MCP23x08_OLAT) ;
+
+ return 0 ;
+}
diff --git a/wiringPi/wiringPiI2C.h b/WiringPi/wiringPi/mcp23s08.h
similarity index 70%
rename from wiringPi/wiringPiI2C.h
rename to WiringPi/wiringPi/mcp23s08.h
index 6710ff4..3c2b22f 100644
--- a/wiringPi/wiringPiI2C.h
+++ b/WiringPi/wiringPi/mcp23s08.h
@@ -1,6 +1,6 @@
/*
- * wiringPiI2C.h:
- * Simplified I2C access routines
+ * 23s08.h:
+ * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip
* Copyright (c) 2013 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
@@ -26,15 +26,7 @@
extern "C" {
#endif
-extern int wiringPiI2CRead (int fd) ;
-extern int wiringPiI2CReadReg8 (int fd, int reg) ;
-extern int wiringPiI2CReadReg16 (int fd, int reg) ;
-
-extern int wiringPiI2CWrite (int fd, int data) ;
-extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;
-extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;
-
-int wiringPiI2CSetup (int devId) ;
+extern int mcp23s08Setup (int pinBase, int spiPort, int devId) ;
#ifdef __cplusplus
}
diff --git a/WiringPi/wiringPi/mcp23s17.c b/WiringPi/wiringPi/mcp23s17.c
new file mode 100644
index 0000000..b20ea71
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23s17.c
@@ -0,0 +1,236 @@
+/*
+ * mcp23s17.c:
+ * Extend wiringPi with the MCP 23s17 SPI GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiSPI.h"
+#include "mcp23x0817.h"
+
+#include "mcp23s17.h"
+
+#define MCP_SPEED 4000000
+
+
+
+/*
+ * writeByte:
+ * Write a byte to a register on the MCP23s17 on the SPI bus.
+ *********************************************************************************
+ */
+
+static void writeByte (uint8_t spiPort, uint8_t devId, uint8_t reg, uint8_t data)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_WRITE | ((devId & 7) << 1) ;
+ spiData [1] = reg ;
+ spiData [2] = data ;
+
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
+}
+
+/*
+ * readByte:
+ * Read a byte from a register on the MCP23s17 on the SPI bus.
+ *********************************************************************************
+ */
+
+static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_READ | ((devId & 7) << 1) ;
+ spiData [1] = reg ;
+
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
+
+ return spiData [2] ;
+}
+
+
+/*
+ * myPinMode:
+ *********************************************************************************
+ */
+
+static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, ddr ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ ddr = MCP23x17_IODIRA ;
+ else
+ {
+ ddr = MCP23x17_IODIRB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ old = readByte (node->data0, node->data1, ddr) ;
+
+ if (mode == OUTPUT)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ writeByte (node->data0, node->data1, ddr, old) ;
+}
+
+
+/*
+ * myPullUpDnControl:
+ *********************************************************************************
+ */
+
+static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
+{
+ int mask, old, pud ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ pud = MCP23x17_GPPUA ;
+ else
+ {
+ pud = MCP23x17_GPPUB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ old = readByte (node->data0, node->data1, pud) ;
+
+ if (mode == PUD_UP)
+ old |= mask ;
+ else
+ old &= (~mask) ;
+
+ writeByte (node->data0, node->data1, pud, old) ;
+}
+
+
+/*
+ * myDigitalWrite:
+ *********************************************************************************
+ */
+
+static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ int bit, old ;
+
+ pin -= node->pinBase ; // Pin now 0-15
+
+ bit = 1 << (pin & 7) ;
+
+ if (pin < 8) // Bank A
+ {
+ old = node->data2 ;
+
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ writeByte (node->data0, node->data1, MCP23x17_GPIOA, old) ;
+ node->data2 = old ;
+ }
+ else // Bank B
+ {
+ old = node->data3 ;
+
+ if (value == LOW)
+ old &= (~bit) ;
+ else
+ old |= bit ;
+
+ writeByte (node->data0, node->data1, MCP23x17_GPIOB, old) ;
+ node->data3 = old ;
+ }
+}
+
+
+/*
+ * myDigitalRead:
+ *********************************************************************************
+ */
+
+static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
+{
+ int mask, value, gpio ;
+
+ pin -= node->pinBase ;
+
+ if (pin < 8) // Bank A
+ gpio = MCP23x17_GPIOA ;
+ else
+ {
+ gpio = MCP23x17_GPIOB ;
+ pin &= 0x07 ;
+ }
+
+ mask = 1 << pin ;
+ value = readByte (node->data0, node->data1, gpio) ;
+
+ if ((value & mask) == 0)
+ return LOW ;
+ else
+ return HIGH ;
+}
+
+
+/*
+ * mcp23s17Setup:
+ * Create a new instance of an MCP23s17 SPI GPIO interface. We know it
+ * has 16 pins, so all we need to know here is the SPI address and the
+ * user-defined pin base.
+ *********************************************************************************
+ */
+
+int mcp23s17Setup (int pinBase, int spiPort, int devId)
+{
+ int x ;
+ struct wiringPiNodeStruct *node ;
+
+ if ((x = wiringPiSPISetup (spiPort, MCP_SPEED)) < 0)
+ return x ;
+
+ writeByte (spiPort, devId, MCP23x17_IOCON, IOCON_INIT | IOCON_HAEN) ;
+ writeByte (spiPort, devId, MCP23x17_IOCONB, IOCON_INIT | IOCON_HAEN) ;
+
+ node = wiringPiNewNode (pinBase, 16) ;
+
+ node->data0 = spiPort ;
+ node->data1 = devId ;
+ node->pinMode = myPinMode ;
+ node->pullUpDnControl = myPullUpDnControl ;
+ node->digitalRead = myDigitalRead ;
+ node->digitalWrite = myDigitalWrite ;
+ node->data2 = readByte (spiPort, devId, MCP23x17_OLATA) ;
+ node->data3 = readByte (spiPort, devId, MCP23x17_OLATB) ;
+
+ return 0 ;
+}
diff --git a/WiringPi/wiringPi/mcp23s17.h b/WiringPi/wiringPi/mcp23s17.h
new file mode 100644
index 0000000..3b2a808
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23s17.h
@@ -0,0 +1,33 @@
+/*
+ * 23s17.h:
+ * Extend wiringPi with the MCP 23s17 SPI GPIO expander chip
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/WiringPi/wiringPi/mcp23x08.h b/WiringPi/wiringPi/mcp23x08.h
new file mode 100644
index 0000000..c4e6b27
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23x08.h
@@ -0,0 +1,73 @@
+/*
+ * mcp23x17:
+ * Copyright (c) 2012-2013 Gordon Henderson
+ *
+ * Header file for code using the MCP23x17 GPIO expander chip.
+ * This comes in 2 flavours: MCP23017 which has an I2C interface,
+ * an the MXP23S17 which has an SPI interface.
+ ***********************************************************************
+ * 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 .
+ ***********************************************************************
+ */
+
+
+// MCP23x17 Registers
+
+#define IODIRA 0x00
+#define IPOLA 0x02
+#define GPINTENA 0x04
+#define DEFVALA 0x06
+#define INTCONA 0x08
+#define IOCON 0x0A
+#define GPPUA 0x0C
+#define INTFA 0x0E
+#define INTCAPA 0x10
+#define GPIOA 0x12
+#define OLATA 0x14
+
+#define IODIRB 0x01
+#define IPOLB 0x03
+#define GPINTENB 0x05
+#define DEFVALB 0x07
+#define INTCONB 0x09
+#define IOCONB 0x0B
+#define GPPUB 0x0D
+#define INTFB 0x0F
+#define INTCAPB 0x11
+#define GPIOB 0x13
+#define OLATB 0x15
+
+// Bits in the IOCON register
+
+#define IOCON_UNUSED 0x01
+#define IOCON_INTPOL 0x02
+#define IOCON_ODR 0x04
+#define IOCON_HAEN 0x08
+#define IOCON_DISSLW 0x10
+#define IOCON_SEQOP 0x20
+#define IOCON_MIRROR 0x40
+#define IOCON_BANK_MODE 0x80
+
+// Default initialisation mode
+
+#define IOCON_INIT (IOCON_SEQOP)
+
+// SPI Command codes
+
+#define CMD_WRITE 0x40
+#define CMD_READ 0x41
diff --git a/WiringPi/wiringPi/mcp23x0817.h b/WiringPi/wiringPi/mcp23x0817.h
new file mode 100644
index 0000000..58bc038
--- /dev/null
+++ b/WiringPi/wiringPi/mcp23x0817.h
@@ -0,0 +1,87 @@
+/*
+ * mcp23xxx:
+ * Copyright (c) 2012-2013 Gordon Henderson
+ *
+ * Header file for code using the MCP23x08 and 17 GPIO expander
+ * chips.
+ * This comes in 2 flavours: MCP230xx (08/17) which has an I2C
+ * interface, and the MXP23Sxx (08/17) which has an SPI interface.
+ ***********************************************************************
+ * 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 .
+ ***********************************************************************
+ */
+
+// MCP23x08 Registers
+
+#define MCP23x08_IODIR 0x00
+#define MCP23x08_IPOL 0x01
+#define MCP23x08_GPINTEN 0x02
+#define MCP23x08_DEFVAL 0x03
+#define MCP23x08_INTCON 0x04
+#define MCP23x08_IOCON 0x05
+#define MCP23x08_GPPU 0x06
+#define MCP23x08_INTF 0x07
+#define MCP23x08_INTCAP 0x08
+#define MCP23x08_GPIO 0x09
+#define MCP23x08_OLAT 0x0A
+
+// MCP23x17 Registers
+
+#define MCP23x17_IODIRA 0x00
+#define MCP23x17_IPOLA 0x02
+#define MCP23x17_GPINTENA 0x04
+#define MCP23x17_DEFVALA 0x06
+#define MCP23x17_INTCONA 0x08
+#define MCP23x17_IOCON 0x0A
+#define MCP23x17_GPPUA 0x0C
+#define MCP23x17_INTFA 0x0E
+#define MCP23x17_INTCAPA 0x10
+#define MCP23x17_GPIOA 0x12
+#define MCP23x17_OLATA 0x14
+
+#define MCP23x17_IODIRB 0x01
+#define MCP23x17_IPOLB 0x03
+#define MCP23x17_GPINTENB 0x05
+#define MCP23x17_DEFVALB 0x07
+#define MCP23x17_INTCONB 0x09
+#define MCP23x17_IOCONB 0x0B
+#define MCP23x17_GPPUB 0x0D
+#define MCP23x17_INTFB 0x0F
+#define MCP23x17_INTCAPB 0x11
+#define MCP23x17_GPIOB 0x13
+#define MCP23x17_OLATB 0x15
+
+// Bits in the IOCON register
+
+#define IOCON_UNUSED 0x01
+#define IOCON_INTPOL 0x02
+#define IOCON_ODR 0x04
+#define IOCON_HAEN 0x08
+#define IOCON_DISSLW 0x10
+#define IOCON_SEQOP 0x20
+#define IOCON_MIRROR 0x40
+#define IOCON_BANK_MODE 0x80
+
+// Default initialisation mode
+
+#define IOCON_INIT (IOCON_SEQOP)
+
+// SPI Command codes
+
+#define CMD_WRITE 0x40
+#define CMD_READ 0x41
diff --git a/WiringPi/wiringPi/piFace.c b/WiringPi/wiringPi/piFace.c
new file mode 100644
index 0000000..c09c41d
--- /dev/null
+++ b/WiringPi/wiringPi/piFace.c
@@ -0,0 +1,179 @@
+/*
+ * piFace.:
+ * Arduino compatable (ish) Wiring library for the Raspberry Pi
+ * Copyright (c) 2012-2013 Gordon Henderson
+ *
+ * This file to interface with the PiFace peripheral device which
+ * has an MCP23S17 GPIO device connected via the SPI bus.
+ ***********************************************************************
+ * 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 .
+ ***********************************************************************
+ */
+
+
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiSPI.h"
+
+#include "piFace.h"
+
+#define PIFACE_SPEED 4000000
+#define PIFACE_DEVNO 0
+
+#include "mcp23x0817.h"
+
+
+/*
+ * writeByte:
+ * Write a byte to a register on the MCP23S17 on the SPI bus.
+ *********************************************************************************
+ */
+
+static void writeByte (uint8_t reg, uint8_t data)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_WRITE ;
+ spiData [1] = reg ;
+ spiData [2] = data ;
+
+ wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ;
+}
+
+/*
+ * readByte:
+ * Read a byte from a register on the MCP23S17 on the SPI bus.
+ *********************************************************************************
+ */
+
+static uint8_t readByte (uint8_t reg)
+{
+ uint8_t spiData [4] ;
+
+ spiData [0] = CMD_READ ;
+ spiData [1] = reg ;
+
+ wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ;
+
+ return spiData [2] ;
+}
+
+
+/*
+ * digitalWrite:
+ * Perform the digitalWrite function on the PiFace board
+ *********************************************************************************
+ */
+
+void digitalWritePiFace (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ uint8_t mask, old ;
+
+ pin -= node->pinBase ;
+ mask = 1 << pin ;
+ old = readByte (MCP23x17_GPIOA) ;
+
+ if (value == 0)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ writeByte (MCP23x17_GPIOA, old) ;
+}
+
+
+/*
+ * digitalReadPiFace:
+ * Perform the digitalRead function on the PiFace board
+ *********************************************************************************
+ */
+
+int digitalReadPiFace (struct wiringPiNodeStruct *node, int pin)
+{
+ uint8_t mask, reg ;
+
+ pin -= node->pinBase ;
+ mask = 1 << (pin & 7) ;
+
+ if (pin < 8)
+ reg = MCP23x17_GPIOB ; // Input regsiter
+ else
+ reg = MCP23x17_OLATA ; // Output latch regsiter
+
+ if ((readByte (reg) & mask) != 0)
+ return HIGH ;
+ else
+ return LOW ;
+}
+
+
+/*
+ * pullUpDnControlPiFace:
+ * Perform the pullUpDnControl function on the PiFace board
+ *********************************************************************************
+ */
+
+void pullUpDnControlPiFace (struct wiringPiNodeStruct *node, int pin, int pud)
+{
+ uint8_t mask, old ;
+
+ pin -= node->pinBase ;
+ mask = 1 << pin ;
+ old = readByte (MCP23x17_GPPUB) ;
+
+ if (pud == 0)
+ old &= (~mask) ;
+ else
+ old |= mask ;
+
+ writeByte (MCP23x17_GPPUB, old) ;
+}
+
+
+/*
+ * piFaceSetup
+ * Setup the SPI interface and initialise the MCP23S17 chip
+ * We create one node with 16 pins - each if the first 8 pins being read
+ * and write - although the operations actually go to different
+ * hardware ports. The top 8 let you read the state of the output register.
+ *********************************************************************************
+ */
+
+int piFaceSetup (int pinBase)
+{
+ int x ;
+ struct wiringPiNodeStruct *node ;
+
+ if ((x = wiringPiSPISetup (PIFACE_DEVNO, PIFACE_SPEED)) < 0)
+ return x ;
+
+// Setup the MCP23S17
+
+ writeByte (MCP23x17_IOCON, IOCON_INIT) ;
+ writeByte (MCP23x17_IODIRA, 0x00) ; // Port A -> Outputs
+ writeByte (MCP23x17_IODIRB, 0xFF) ; // Port B -> Inputs
+
+ node = wiringPiNewNode (pinBase, 16) ;
+ node->digitalRead = digitalReadPiFace ;
+ node->digitalWrite = digitalWritePiFace ;
+ node->pullUpDnControl = pullUpDnControlPiFace ;
+
+ return 0 ;
+}
diff --git a/WiringPi/wiringPi/piFace.h b/WiringPi/wiringPi/piFace.h
new file mode 100644
index 0000000..d012f5c
--- /dev/null
+++ b/WiringPi/wiringPi/piFace.h
@@ -0,0 +1,32 @@
+/*
+ * piFace.h:
+ * Control the PiFace Interface board for 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int piFaceSetup (int pinBase) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/wiringPi/piHiPri.c b/WiringPi/wiringPi/piHiPri.c
similarity index 100%
rename from wiringPi/piHiPri.c
rename to WiringPi/wiringPi/piHiPri.c
diff --git a/wiringPi/piNes.c b/WiringPi/wiringPi/piNes.c
similarity index 100%
rename from wiringPi/piNes.c
rename to WiringPi/wiringPi/piNes.c
diff --git a/wiringPi/piNes.h b/WiringPi/wiringPi/piNes.h
similarity index 100%
rename from wiringPi/piNes.h
rename to WiringPi/wiringPi/piNes.h
diff --git a/wiringPi/piThread.c b/WiringPi/wiringPi/piThread.c
similarity index 100%
rename from wiringPi/piThread.c
rename to WiringPi/wiringPi/piThread.c
diff --git a/wiringPi/softPwm.c b/WiringPi/wiringPi/softPwm.c
similarity index 100%
rename from wiringPi/softPwm.c
rename to WiringPi/wiringPi/softPwm.c
diff --git a/wiringPi/softPwm.h b/WiringPi/wiringPi/softPwm.h
similarity index 100%
rename from wiringPi/softPwm.h
rename to WiringPi/wiringPi/softPwm.h
diff --git a/wiringPi/softServo.c b/WiringPi/wiringPi/softServo.c
similarity index 100%
rename from wiringPi/softServo.c
rename to WiringPi/wiringPi/softServo.c
diff --git a/wiringPi/softServo.h b/WiringPi/wiringPi/softServo.h
similarity index 100%
rename from wiringPi/softServo.h
rename to WiringPi/wiringPi/softServo.h
diff --git a/wiringPi/softTone.c b/WiringPi/wiringPi/softTone.c
similarity index 88%
rename from wiringPi/softTone.c
rename to WiringPi/wiringPi/softTone.c
index 8463627..b4a89f8 100644
--- a/wiringPi/softTone.c
+++ b/WiringPi/wiringPi/softTone.c
@@ -36,7 +36,7 @@
#define PULSE_TIME 100
-static int frewqs [MAX_PINS] ;
+static int freqs [MAX_PINS] ;
static int newPin = -1 ;
@@ -49,7 +49,7 @@ static int newPin = -1 ;
static PI_THREAD (softToneThread)
{
- int pin, frewq, halfPeriod ;
+ int pin, freq, halfPeriod ;
pin = newPin ;
newPin = -1 ;
@@ -58,12 +58,12 @@ static PI_THREAD (softToneThread)
for (;;)
{
- frewq = frewqs [pin] ;
- if (frewq == 0)
+ freq = freqs [pin] ;
+ if (freq == 0)
delay (1) ;
else
{
- halfPeriod = 500000 / frewq ;
+ halfPeriod = 500000 / freq ;
digitalWrite (pin, HIGH) ;
delayMicroseconds (halfPeriod) ;
@@ -83,16 +83,16 @@ static PI_THREAD (softToneThread)
*********************************************************************************
*/
-void softToneWrite (int pin, int frewq)
+void softToneWrite (int pin, int freq)
{
pin &= 63 ;
- /**/ if (frewq < 0)
- frewq = 0 ;
- else if (frewq > 5000) // Max 5KHz
- frewq = 5000 ;
+ /**/ if (freq < 0)
+ freq = 0 ;
+ else if (freq > 5000) // Max 5KHz
+ freq = 5000 ;
- frewqs [pin] = frewq ;
+ freqs [pin] = freq ;
}
@@ -109,7 +109,7 @@ int softToneCreate (int pin)
pinMode (pin, OUTPUT) ;
digitalWrite (pin, LOW) ;
- frewqs [pin] = 0 ;
+ freqs [pin] = 0 ;
newPin = pin ;
res = piThreadCreate (softToneThread) ;
diff --git a/wiringPi/softTone.h b/WiringPi/wiringPi/softTone.h
similarity index 96%
rename from wiringPi/softTone.h
rename to WiringPi/wiringPi/softTone.h
index 80c64fe..d8b4e54 100644
--- a/wiringPi/softTone.h
+++ b/WiringPi/wiringPi/softTone.h
@@ -31,7 +31,7 @@ extern "C" {
#endif
extern int softToneCreate (int pin) ;
-extern void softToneWrite (int pin, int frewq) ;
+extern void softToneWrite (int pin, int freq) ;
#ifdef __cplusplus
}
diff --git a/WiringPi/wiringPi/sr595.c b/WiringPi/wiringPi/sr595.c
new file mode 100644
index 0000000..e71ff58
--- /dev/null
+++ b/WiringPi/wiringPi/sr595.c
@@ -0,0 +1,108 @@
+/*
+ * sr595.c:
+ * Extend wiringPi with the 74x595 shift register as a GPIO
+ * expander chip.
+ * Note that the code can cope with a number of 595's
+ * daisy-chained together - up to 4 for now as we're storing
+ * the output "register" in a single unsigned int.
+ *
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+
+#include "wiringPi.h"
+
+#include "sr595.h"
+
+
+/*
+ * myDigitalWrite:
+ *********************************************************************************
+ */
+
+static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
+{
+ unsigned int mask ;
+ int dataPin, clockPin, latchPin ;
+ int bit, bits, output ;
+
+ pin -= node->pinBase ; // Normalise pin number
+ bits = node->pinMax - node->pinBase + 1 ; // ie. number of clock pulses
+ dataPin = node->data0 ;
+ clockPin = node->data1 ;
+ latchPin = node->data2 ;
+ output = node->data3 ;
+
+ mask = 1 << pin ;
+
+ if (value == LOW)
+ output &= (~mask) ;
+ else
+ output |= mask ;
+
+ node->data3 = output ;
+
+// A low -> high latch transition copies the latch to the output pins
+
+ digitalWrite (latchPin, LOW) ; delayMicroseconds (1) ;
+ for (bit = bits - 1 ; bit >= 0 ; --bit)
+ {
+ digitalWrite (dataPin, output & (1 << bit)) ;
+
+ digitalWrite (clockPin, HIGH) ; delayMicroseconds (1) ;
+ digitalWrite (clockPin, LOW) ; delayMicroseconds (1) ;
+ }
+ digitalWrite (latchPin, HIGH) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * sr595Setup:
+ * Create a new instance of a 74x595 shift register GPIO expander.
+ *********************************************************************************
+ */
+
+int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin)
+{
+ struct wiringPiNodeStruct *node ;
+
+ node = wiringPiNewNode (pinBase, numPins) ;
+
+ node->data0 = dataPin ;
+ node->data1 = clockPin ;
+ node->data2 = latchPin ;
+ node->data3 = 0 ; // Output register
+ node->digitalWrite = myDigitalWrite ;
+
+// Initialise the underlying hardware
+
+ digitalWrite (dataPin, LOW) ;
+ digitalWrite (clockPin, LOW) ;
+ digitalWrite (latchPin, HIGH) ;
+
+ pinMode (dataPin, OUTPUT) ;
+ pinMode (clockPin, OUTPUT) ;
+ pinMode (latchPin, OUTPUT) ;
+
+ return 0 ;
+}
diff --git a/WiringPi/wiringPi/sr595.h b/WiringPi/wiringPi/sr595.h
new file mode 100644
index 0000000..708671f
--- /dev/null
+++ b/WiringPi/wiringPi/sr595.h
@@ -0,0 +1,33 @@
+/*
+ * sr595.h:
+ * Extend wiringPi with the 74x595 shift registers.
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/wiringPi/wiringPi.c b/WiringPi/wiringPi/wiringPi.c
similarity index 66%
rename from wiringPi/wiringPi.c
rename to WiringPi/wiringPi/wiringPi.c
index a68ae33..59a3392 100644
--- a/wiringPi/wiringPi.c
+++ b/WiringPi/wiringPi/wiringPi.c
@@ -53,6 +53,7 @@
#include
+#include
#include
#include
#include
@@ -71,28 +72,24 @@
#include "wiringPi.h"
-// Function stubs
-
-void (*pinMode) (int pin, int mode) ;
-int (*getAlt) (int pin) ;
-void (*pullUpDnControl) (int pin, int pud) ;
-void (*digitalWrite) (int pin, int value) ;
-void (*digitalWriteByte) (int value) ;
-void (*pwmWrite) (int pin, int value) ;
-void (*gpioClockSet) (int pin, int value) ;
-void (*setPadDrive) (int group, int value) ;
-int (*digitalRead) (int pin) ;
-int (*waitForInterrupt) (int pin, int mS) ;
-void (*pwmSetMode) (int mode) ;
-void (*pwmSetRange) (unsigned int range) ;
-void (*pwmSetClock) (int divisor) ;
-
-
#ifndef TRUE
#define TRUE (1==1)
#define FALSE (1==2)
#endif
+// Environment Variables
+
+#define ENV_DEBUG "WIRINGPI_DEBUG"
+#define ENV_CODES "WIRINGPI_CODES"
+
+
+// Mask for the bottom 64 pins which belong to the Raspberry Pi
+// The others are available for the other devices
+
+#define PI_GPIO_MASK (0xFFFFFFC0)
+
+static struct wiringPiNodeStruct *wiringPiNodes = NULL ;
+
// BCM Magic
#define BCM_PASSWORD 0x5A000000
@@ -192,8 +189,11 @@ static volatile uint32_t *gpio ;
static volatile uint32_t *pwm ;
static volatile uint32_t *clk ;
static volatile uint32_t *pads ;
+
+#ifdef USE_TIMER
static volatile uint32_t *timer ;
static volatile uint32_t *timerIrqRaw ;
+#endif
// Time for easy calculations
@@ -203,9 +203,10 @@ static uint64_t epochMilli, epochMicro ;
static int wiringPiMode = WPI_MODE_UNINITIALISED ;
-// Debugging
+// Debugging & Return codes
int wiringPiDebug = FALSE ;
+int wiringPiCodes = FALSE ;
// sysFds:
// Map a file descriptor from the /sys/class/gpio/gpioX/value
@@ -223,17 +224,17 @@ static void (*isrFunctions [64])(void) ;
// pinToGpio:
// Take a Wiring pin (0 through X) and re-map it to the BCM_GPIO pin
-// Cope for 2 different board revieions here
+// Cope for 2 different board revisions here.
static int *pinToGpio ;
static int pinToGpioR1 [64] =
{
- 17, 18, 21, 22, 23, 24, 25, 4, // From the Original Wiki - GPIO 0 through 7
- 0, 1, // I2C - SDA0, SCL0
- 8, 7, // SPI - CE1, CE0
- 10, 9, 11, // SPI - MOSI, MISO, SCLK
- 14, 15, // UART - Tx, Rx
+ 17, 18, 21, 22, 23, 24, 25, 4, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
+ 0, 1, // I2C - SDA0, SCL0 wpi 8 - 9
+ 8, 7, // SPI - CE1, CE0 wpi 10 - 11
+ 10, 9, 11, // SPI - MOSI, MISO, SCLK wpi 12 - 14
+ 14, 15, // UART - Tx, Rx wpi 15 - 16
// Padding:
@@ -259,8 +260,65 @@ static int pinToGpioR2 [64] =
} ;
+// physToGpio:
+// Take a physical pin (1 through 26) and re-map it to the BCM_GPIO pin
+// Cope for 2 different board revisions here.
+
+static int *physToGpio ;
+
+static int physToGpioR1 [64] =
+{
+ -1, // 0
+ -1, -1, // 1, 2
+ 0, -1,
+ 1, -1,
+ 4, 14,
+ -1, 15,
+ 17, 18,
+ 21, -1,
+ 22, 23,
+ -1, 24,
+ 10, -1,
+ 9, 25,
+ 11, 8,
+ -1, 7, // 25, 26
+
+// Padding:
+
+ -1, -1, -1, -1, -1, // ... 31
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
+} ;
+
+static int physToGpioR2 [64] =
+{
+ -1, // 0
+ -1, -1, // 1, 2
+ 2, -1,
+ 3, -1,
+ 4, 14,
+ -1, 15,
+ 17, 18,
+ 27, -1,
+ 22, 23,
+ -1, 24,
+ 10, -1,
+ 9, 25,
+ 11, 8,
+ -1, 7, // 25, 26
+
+// Padding:
+
+ -1, -1, -1, -1, -1, // ... 31
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
+} ;
+
+
// gpioToGPFSEL:
-// Map a BCM_GPIO pin to it's control port. (GPFSEL 0-5)
+// Map a BCM_GPIO pin to it's Function Selection
+// control port. (GPFSEL 0-5)
+// Groups of 10 - 3 bits per Function - 30 bits per port
static uint8_t gpioToGPFSEL [] =
{
@@ -295,7 +353,6 @@ static uint8_t gpioToGPSET [] =
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
} ;
-
// gpioToGPCLR:
// (Word) offset to the GPIO Clear registers for each GPIO pin
@@ -376,6 +433,7 @@ static uint8_t gpioToPwmALT [] =
0, 0, 0, 0, 0, 0, 0, 0, // 56 -> 63
} ;
+
// gpioToPwmPort
// The port value to put a GPIO pin into PWM mode
@@ -395,7 +453,7 @@ static uint8_t gpioToPwmPort [] =
// gpioToGpClkALT:
// ALT value to put a GPIO pin into GP Clock mode.
// On the Pi we can really only use BCM_GPIO_4 and BCM_GPIO_21
-// for clocks 0 and 1 respectivey, however I'll include the full
+// for clocks 0 and 1 respectively, however I'll include the full
// list for completeness - maybe one day...
#define GPIO_CLOCK_SOURCE 1
@@ -449,16 +507,24 @@ static uint8_t gpioToClkDiv [] =
/*
- * wpiPinToGpio:
- * Translate a wiringPi Pin number to native GPIO pin number.
- * (We don't use this here, prefering to just do the lookup directly,
- * but it's been requested!)
+ * wiringPiFailure:
+ * Fail. Or not.
*********************************************************************************
*/
-int wpiPinToGpio (int wpiPin)
+int wiringPiFailure (char *message, ...)
{
- return pinToGpio [wpiPin & 63] ;
+ va_list argp ;
+ char buffer [1024] ;
+
+ va_start (argp, message) ;
+ vsnprintf (buffer, 1023, message, argp) ;
+ va_end (argp) ;
+
+ fprintf (stderr,"%s", buffer) ;
+ exit (EXIT_FAILURE) ;
+
+ return 0 ;
}
@@ -556,6 +622,58 @@ int piBoardRev (void)
}
+/*
+ * wpiPinToGpio:
+ * Translate a wiringPi Pin number to native GPIO pin number.
+ * Provided for external support.
+ *********************************************************************************
+ */
+
+int wpiPinToGpio (int wpiPin)
+{
+ return pinToGpio [wpiPin & 63] ;
+}
+
+
+/*
+ * physPinToGpio:
+ * Translate a physical Pin number to native GPIO pin number.
+ * Provided for external support.
+ *********************************************************************************
+ */
+
+int physPinToGpio (int physPin)
+{
+ return physToGpio [physPin & 63] ;
+}
+
+
+/*
+ * setPadDrive:
+ * Set the PAD driver value
+ *********************************************************************************
+ */
+
+void setPadDrive (int group, int value)
+{
+ uint32_t wrVal ;
+
+ if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO))
+ {
+ if ((group < 0) || (group > 2))
+ return ;
+
+ wrVal = BCM_PASSWORD | 0x18 | (value & 7) ;
+ *(pads + group + 11) = wrVal ;
+
+ if (wiringPiDebug)
+ {
+ printf ("setPadDrive: Group: %d, value: %d (%08X)\n", group, value, wrVal) ;
+ printf ("Read : %08X\n", *(pads + group + 11)) ;
+ }
+ }
+}
+
/*
* getAlt:
@@ -564,12 +682,19 @@ int piBoardRev (void)
*********************************************************************************
*/
-int getAltGpio (int pin)
+int getAlt (int pin)
{
int fSel, shift, alt ;
pin &= 63 ;
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return 0 ;
+
fSel = gpioToGPFSEL [pin] ;
shift = gpioToShift [pin] ;
@@ -578,70 +703,66 @@ int getAltGpio (int pin)
return alt ;
}
-int getAltWPi (int pin)
-{
- return getAltGpio (pinToGpio [pin & 63]) ;
-}
-
-int getAltSys (int pin)
-{
- return 0 ;
-}
-
/*
- * pwmControl:
- * Allow the user to control some of the PWM functions
+ * pwmSetMode:
+ * Select the native "balanced" mode, or standard mark:space mode
*********************************************************************************
*/
-void pwmSetModeWPi (int mode)
+void pwmSetMode (int mode)
{
- if (mode == PWM_MODE_MS)
- *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE | PWM0_MS_MODE | PWM1_MS_MODE ;
- else
- *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE ;
+ if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS))
+ {
+ if (mode == PWM_MODE_MS)
+ *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE | PWM0_MS_MODE | PWM1_MS_MODE ;
+ else
+ *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE ;
+ }
}
-void pwmSetModeSys (int mode)
-{
- return ;
-}
+/*
+ * pwmSetRange:
+ * Set the PWM range register. We set both range registers to the same
+ * value. If you want different in your own code, then write your own.
+ *********************************************************************************
+ */
-void pwmSetRangeWPi (unsigned int range)
+void pwmSetRange (unsigned int range)
{
- *(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ;
- *(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ;
+ if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS))
+ {
+ *(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ;
+ *(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ;
+ }
}
-void pwmSetRangeSys (unsigned int range)
-{
- return ;
-}
/*
- * pwmSetClockWPi:
+ * pwmSetClock:
* Set/Change the PWM clock. Originally my code, but changed
* (for the better!) by Chris Hall,
* after further study of the manual and testing with a 'scope
*********************************************************************************
*/
-void pwmSetClockWPi (int divisor)
+void pwmSetClock (int divisor)
{
uint32_t pwm_control ;
divisor &= 4095 ;
- if (wiringPiDebug)
- printf ("Setting to: %d. Current: 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;
+ if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS))
+ {
+ if (wiringPiDebug)
+ printf ("Setting to: %d. Current: 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;
- pwm_control = *(pwm + PWM_CONTROL) ; // preserve PWM_CONTROL
+ pwm_control = *(pwm + PWM_CONTROL) ; // preserve PWM_CONTROL
// We need to stop PWM prior to stopping PWM clock in MS mode otherwise BUSY
// stays high.
- *(pwm + PWM_CONTROL) = 0 ; // Stop PWM
+ *(pwm + PWM_CONTROL) = 0 ; // Stop PWM
// Stop PWM clock before changing divisor. The delay after this does need to
// this big (95uS occasionally fails, 100uS OK), it's almost as though the BUSY
@@ -649,226 +770,251 @@ void pwmSetClockWPi (int divisor)
// adjusted the clock sometimes switches to very slow, once slow further DIV
// adjustments do nothing and it's difficult to get out of this mode.
- *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x01 ; // Stop PWM Clock
- delayMicroseconds (110) ; // prevents clock going sloooow
+ *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x01 ; // Stop PWM Clock
+ delayMicroseconds (110) ; // prevents clock going sloooow
- while ((*(clk + PWMCLK_CNTL) & 0x80) != 0) // Wait for clock to be !BUSY
- delayMicroseconds (1) ;
+ while ((*(clk + PWMCLK_CNTL) & 0x80) != 0) // Wait for clock to be !BUSY
+ delayMicroseconds (1) ;
- *(clk + PWMCLK_DIV) = BCM_PASSWORD | (divisor << 12) ;
+ *(clk + PWMCLK_DIV) = BCM_PASSWORD | (divisor << 12) ;
- *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x11 ; // Start PWM clock
- *(pwm + PWM_CONTROL) = pwm_control ; // restore PWM_CONTROL
+ *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x11 ; // Start PWM clock
+ *(pwm + PWM_CONTROL) = pwm_control ; // restore PWM_CONTROL
- if (wiringPiDebug)
- printf ("Set to: %d. Now : 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;
-}
-
-void pwmSetClockSys (int divisor)
-{
- return ;
+ if (wiringPiDebug)
+ printf ("Set to: %d. Now : 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;
+ }
}
-#ifdef notYetReady
/*
- * pinED01:
- * pinED10:
- * Enables edge-detect mode on a pin - from a 0 to a 1 or 1 to 0
- * Pin must already be in input mode with appropriate pull up/downs set.
+ * gpioClockSet:
+ * Set the freuency on a GPIO clock pin
*********************************************************************************
*/
-void pinEnableED01Pi (int pin)
+void gpioClockSet (int pin, int freq)
{
- pin = pinToGpio [pin & 63] ;
-}
-#endif
+ int divi, divr, divf ;
+ pin &= 63 ;
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return ;
+
+ divi = 19200000 / freq ;
+ divr = 19200000 % freq ;
+ divf = (int)((double)divr * 4096.0 / 19200000.0) ;
-/*
- * digitalWrite:
- * Set an output bit
- *********************************************************************************
- */
+ if (divi > 4095)
+ divi = 4095 ;
-void digitalWriteWPi (int pin, int value)
-{
- pin = pinToGpio [pin & 63] ;
+ *(clk + gpioToClkCon [pin]) = BCM_PASSWORD | GPIO_CLOCK_SOURCE ; // Stop GPIO Clock
+ while ((*(clk + gpioToClkCon [pin]) & 0x80) != 0) // ... and wait
+ ;
- if (value == LOW)
- *(gpio + gpioToGPCLR [pin]) = 1 << (pin & 31) ;
- else
- *(gpio + gpioToGPSET [pin]) = 1 << (pin & 31) ;
+ *(clk + gpioToClkDiv [pin]) = BCM_PASSWORD | (divi << 12) | divf ; // Set dividers
+ *(clk + gpioToClkCon [pin]) = BCM_PASSWORD | 0x10 | GPIO_CLOCK_SOURCE ; // Start Clock
}
-void digitalWriteGpio (int pin, int value)
-{
- pin &= 63 ;
- if (value == LOW)
- *(gpio + gpioToGPCLR [pin]) = 1 << (pin & 31) ;
- else
- *(gpio + gpioToGPSET [pin]) = 1 << (pin & 31) ;
-}
+/*
+ * wiringPiFindNode:
+ * Locate our device node
+ *********************************************************************************
+ */
-void digitalWriteSys (int pin, int value)
+static struct wiringPiNodeStruct *wiringPiFindNode (int pin)
{
- pin &= 63 ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- if (sysFds [pin] != -1)
- {
- if (value == LOW)
- write (sysFds [pin], "0\n", 2) ;
+ while (node != NULL)
+ if ((pin >= node->pinBase) && (pin <= node->pinMax))
+ return node ;
else
- write (sysFds [pin], "1\n", 2) ;
- }
+ node = node->next ;
+
+ return NULL ;
}
/*
- * digitalWriteByte:
- * Write an 8-bit byte to the first 8 GPIO pins - try to do it as
- * fast as possible.
- * However it still needs 2 operations to set the bits, so any external
- * hardware must not rely on seeing a change as there will be a change
- * to set the outputs bits to zero, then another change to set the 1's
+ * wiringPiNewNode:
+ * Create a new GPIO node into the wiringPi handling system
*********************************************************************************
*/
-void digitalWriteByteGpio (int value)
+static void pinModeDummy (struct wiringPiNodeStruct *node, int pin, int mode) { return ; }
+static void pullUpDnControlDummy (struct wiringPiNodeStruct *node, int pin, int pud) { return ; }
+static int digitalReadDummy (struct wiringPiNodeStruct *node, int pin) { return LOW ; }
+static void digitalWriteDummy (struct wiringPiNodeStruct *node, int pin, int value) { return ; }
+static void pwmWriteDummy (struct wiringPiNodeStruct *node, int pin, int value) { return ; }
+static int analogReadDummy (struct wiringPiNodeStruct *node, int pin) { return 0 ; }
+static void analogWriteDummy (struct wiringPiNodeStruct *node, int pin, int value) { return ; }
+
+struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins)
{
- uint32_t pinSet = 0 ;
- uint32_t pinClr = 0 ;
- int mask = 1 ;
- int pin ;
+ int pin ;
+ struct wiringPiNodeStruct *node ;
- for (pin = 0 ; pin < 8 ; ++pin)
- {
- if ((value & mask) == 0)
- pinClr |= (1 << pinToGpio [pin]) ;
- else
- pinSet |= (1 << pinToGpio [pin]) ;
+// Minimum pin base is 64
- mask <<= 1 ;
- }
+ if (pinBase < 64)
+ (void)wiringPiFailure ("wiringPiNewNode: pinBase of %d is < 64\n", pinBase) ;
- *(gpio + gpioToGPCLR [0]) = pinClr ;
- *(gpio + gpioToGPSET [0]) = pinSet ;
-}
+// Check all pins in-case there is overlap:
-void digitalWriteByteSys (int value)
-{
- int mask = 1 ;
- int pin ;
+ for (pin = pinBase ; pin < (pinBase + numPins) ; ++pin)
+ if (wiringPiFindNode (pin) != NULL)
+ (void)wiringPiFailure ("wiringPiNewNode: Pin %d overlaps with existing definition\n", pin) ;
- for (pin = 0 ; pin < 8 ; ++pin)
- {
- digitalWriteSys (pinToGpio [pin], value & mask) ;
- mask <<= 1 ;
- }
+ node = calloc (sizeof (struct wiringPiNodeStruct), 1) ; // calloc zeros
+ if (node == NULL)
+ (void)wiringPiFailure ("wiringPiNewNode: Unable to allocate memory: %s\n", strerror (errno)) ;
+
+ node->pinBase = pinBase ;
+ node->pinMax = pinBase + numPins - 1 ;
+ node->pinMode = pinModeDummy ;
+ node->pullUpDnControl = pullUpDnControlDummy ;
+ node->digitalRead = digitalReadDummy ;
+ node->digitalWrite = digitalWriteDummy ;
+ node->pwmWrite = pwmWriteDummy ;
+ node->analogRead = analogReadDummy ;
+ node->analogWrite = analogWriteDummy ;
+ node->next = wiringPiNodes ;
+ wiringPiNodes = node ;
+
+ return node ;
}
+#ifdef notYetReady
/*
- * pwmWrite:
- * Set an output PWM value
+ * pinED01:
+ * pinED10:
+ * Enables edge-detect mode on a pin - from a 0 to a 1 or 1 to 0
+ * Pin must already be in input mode with appropriate pull up/downs set.
*********************************************************************************
*/
-void pwmWriteGpio (int pin, int value)
+void pinEnableED01Pi (int pin)
{
- int port ;
-
- pin = pin & 63 ;
- port = gpioToPwmPort [pin] ;
-
- *(pwm + port) = value ;
+ pin = pinToGpio [pin & 63] ;
}
+#endif
-void pwmWriteWPi (int pin, int value)
-{
- pwmWriteGpio (pinToGpio [pin & 63], value) ;
-}
-void pwmWriteSys (int pin, int value)
-{
- return ;
-}
+/*
+ *********************************************************************************
+ * Core Functions
+ *********************************************************************************
+ */
/*
- * gpioClockSet:
- * Set the freuency on a GPIO clock pin
+ * pinMode:
+ * Sets the mode of a pin to be input, output or PWM output
*********************************************************************************
*/
-void gpioClockSetGpio (int pin, int freq)
+void pinMode (int pin, int mode)
{
- int divi, divr, divf ;
+ int fSel, shift, alt ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- pin &= 63 ;
-
- divi = 19200000 / freq ;
- divr = 19200000 % freq ;
- divf = (int)((double)divr * 4096.0 / 19200000.0) ;
+ if ((pin & PI_GPIO_MASK) == 0) // On-board pin
+ {
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return ;
- if (divi > 4095)
- divi = 4095 ;
+ fSel = gpioToGPFSEL [pin] ;
+ shift = gpioToShift [pin] ;
- *(clk + gpioToClkCon [pin]) = BCM_PASSWORD | GPIO_CLOCK_SOURCE ; // Stop GPIO Clock
- while ((*(clk + gpioToClkCon [pin]) & 0x80) != 0) // ... and wait
- ;
+ /**/ if (mode == INPUT)
+ *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) ; // Sets bits to zero = input
+ else if (mode == OUTPUT)
+ *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (1 << shift) ;
+ else if (mode == PWM_OUTPUT)
+ {
+ if ((alt = gpioToPwmALT [pin]) == 0) // Not a PWM pin
+ return ;
- *(clk + gpioToClkDiv [pin]) = BCM_PASSWORD | (divi << 12) | divf ; // Set dividers
- *(clk + gpioToClkCon [pin]) = BCM_PASSWORD | 0x10 | GPIO_CLOCK_SOURCE ; // Start Clock
-}
+// Set pin to PWM mode
-void gpioClockSetWPi (int pin, int freq)
-{
- gpioClockSetGpio (pinToGpio [pin & 63], freq) ;
-}
+ *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
+ delayMicroseconds (110) ; // See comments in pwmSetClockWPi
-void gpioClockSetSys (int pin, int freq)
-{
- return ;
+ pwmSetMode (PWM_MODE_BAL) ; // Pi default mode
+ pwmSetRange (1024) ; // Default range of 1024
+ pwmSetClock (32) ; // 19.2 / 32 = 600KHz - Also starts the PWM
+ }
+ else if (mode == GPIO_CLOCK)
+ {
+ if ((alt = gpioToGpClkALT0 [pin]) == 0) // Not a GPIO_CLOCK pin
+ return ;
+
+// Set pin to GPIO_CLOCK mode and set the clock frequency to 100KHz
+
+ *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
+ delayMicroseconds (110) ;
+ gpioClockSet (pin, 100000) ;
+ }
+ }
+ else
+ {
+ if ((node = wiringPiFindNode (pin)) != NULL)
+ node->pinMode (node, pin, mode) ;
+ return ;
+ }
}
/*
- * setPadDrive:
- * Set the PAD driver value
+ * pullUpDownCtrl:
+ * Control the internal pull-up/down resistors on a GPIO pin
+ * The Arduino only has pull-ups and these are enabled by writing 1
+ * to a port when in input mode - this paradigm doesn't quite apply
+ * here though.
*********************************************************************************
*/
-void setPadDriveWPi (int group, int value)
+void pullUpDnControl (int pin, int pud)
{
- uint32_t wrVal ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- if ((group < 0) || (group > 2))
- return ;
+ if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
+ {
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return ;
- wrVal = BCM_PASSWORD | 0x18 | (value & 7) ;
- *(pads + group + 11) = wrVal ;
+ pud &= 3 ;
- if (wiringPiDebug)
+ *(gpio + GPPUD) = pud ; delayMicroseconds (5) ;
+ *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ;
+
+ *(gpio + GPPUD) = 0 ; delayMicroseconds (5) ;
+ *(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ;
+ }
+ else
{
- printf ("setPadDrive: Group: %d, value: %d (%08X)\n", group, value, wrVal) ;
- printf ("Read : %08X\n", *(pads + group + 11)) ;
+ if ((node = wiringPiFindNode (pin)) != NULL)
+ node->pullUpDnControl (node, pin, pud) ;
+ return ;
}
}
-void setPadDriveGpio (int group, int value)
-{
- setPadDriveWPi (group, value) ;
-}
-
-void setPadDriveSys (int group, int value)
-{
- return ;
-}
-
/*
* digitalRead:
@@ -876,134 +1022,200 @@ void setPadDriveSys (int group, int value)
*********************************************************************************
*/
-int digitalReadWPi (int pin)
+int digitalRead (int pin)
{
- pin = pinToGpio [pin & 63] ;
+ char c ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)
- return HIGH ;
+ if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
+ {
+ /**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode
+ {
+ if (sysFds [pin] == -1)
+ return LOW ;
+
+ lseek (sysFds [pin], 0L, SEEK_SET) ;
+ read (sysFds [pin], &c, 1) ;
+ return (c == '0') ? LOW : HIGH ;
+ }
+ else if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return LOW ;
+
+ if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)
+ return HIGH ;
+ else
+ return LOW ;
+ }
else
- return LOW ;
+ {
+ if ((node = wiringPiFindNode (pin)) == NULL)
+ return LOW ;
+ return node->digitalRead (node, pin) ;
+ }
}
-int digitalReadGpio (int pin)
-{
- pin &= 63 ;
- if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)
- return HIGH ;
- else
- return LOW ;
-}
+/*
+ * digitalWrite:
+ * Set an output bit
+ *********************************************************************************
+ */
-int digitalReadSys (int pin)
+void digitalWrite (int pin, int value)
{
- char c ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- pin &= 63 ;
-
- if (sysFds [pin] == -1)
- return 0 ;
+ if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
+ {
+ /**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode
+ {
+ if (sysFds [pin] != -1)
+ {
+ if (value == LOW)
+ write (sysFds [pin], "0\n", 2) ;
+ else
+ write (sysFds [pin], "1\n", 2) ;
+ }
+ }
+ else if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_GPIO)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return ;
- lseek (sysFds [pin], 0L, SEEK_SET) ;
- read (sysFds [pin], &c, 1) ;
- return (c == '0') ? 0 : 1 ;
+ if (value == LOW)
+ *(gpio + gpioToGPCLR [pin]) = 1 << (pin & 31) ;
+ else
+ *(gpio + gpioToGPSET [pin]) = 1 << (pin & 31) ;
+ }
+ else
+ {
+ if ((node = wiringPiFindNode (pin)) != NULL)
+ node->digitalWrite (node, pin, value) ;
+ }
}
/*
- * pullUpDownCtrl:
- * Control the internal pull-up/down resistors on a GPIO pin
- * The Arduino only has pull-ups and these are enabled by writing 1
- * to a port when in input mode - this paradigm doesn't quite apply
- * here though.
+ * pwmWrite:
+ * Set an output PWM value
*********************************************************************************
*/
-void pullUpDnControlGpio (int pin, int pud)
+void pwmWrite (int pin, int value)
{
- pin &= 63 ;
- pud &= 3 ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- *(gpio + GPPUD) = pud ; delayMicroseconds (5) ;
- *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ;
-
- *(gpio + GPPUD) = 0 ; delayMicroseconds (5) ;
- *(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ;
-}
+ if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
+ {
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+ else if (wiringPiMode != WPI_MODE_GPIO)
+ return ;
-void pullUpDnControlWPi (int pin, int pud)
-{
- pullUpDnControlGpio (pinToGpio [pin & 63], pud) ;
+ *(pwm + gpioToPwmPort [pin]) = value ;
+ }
+ else
+ {
+ if ((node = wiringPiFindNode (pin)) != NULL)
+ node->pwmWrite (node, pin, value) ;
+ }
}
-void pullUpDnControlSys (int pin, int pud)
+
+/*
+ * analogRead:
+ * Read the analog value of a given Pin.
+ * There is no on-board Pi analog hardware,
+ * so this needs to go to a new node.
+ *********************************************************************************
+ */
+
+int analogRead (int pin)
{
- return ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
+
+ if ((node = wiringPiFindNode (pin)) == NULL)
+ return 0 ;
+ else
+ return node->analogRead (node, pin) ;
}
/*
- * pinMode:
- * Sets the mode of a pin to be input, output or PWM output
+ * analogWrite:
+ * Write the analog value to the given Pin.
+ * There is no on-board Pi analog hardware,
+ * so this needs to go to a new node.
*********************************************************************************
*/
-void pinModeGpio (int pin, int mode)
+void analogWrite (int pin, int value)
{
-// register int barrier ;
+ struct wiringPiNodeStruct *node = wiringPiNodes ;
- int fSel, shift, alt ;
+ if ((node = wiringPiFindNode (pin)) == NULL)
+ return ;
- pin &= 63 ;
+ node->analogWrite (node, pin, value) ;
+}
- fSel = gpioToGPFSEL [pin] ;
- shift = gpioToShift [pin] ;
- /**/ if (mode == INPUT)
- *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) ; // Sets bits to zero = input
- else if (mode == OUTPUT)
- *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (1 << shift) ;
- else if (mode == PWM_OUTPUT)
- {
- if ((alt = gpioToPwmALT [pin]) == 0) // Not a PWM pin
- return ;
-// Set pin to PWM mode
+/*
+ * digitalWriteByte:
+ * Pi Specific
+ * Write an 8-bit byte to the first 8 GPIO pins - try to do it as
+ * fast as possible.
+ * However it still needs 2 operations to set the bits, so any external
+ * hardware must not rely on seeing a change as there will be a change
+ * to set the outputs bits to zero, then another change to set the 1's
+ *********************************************************************************
+ */
- *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
- delayMicroseconds (110) ; // See comments in pwmSetClockWPi
+void digitalWriteByte (int value)
+{
+ uint32_t pinSet = 0 ;
+ uint32_t pinClr = 0 ;
+ int mask = 1 ;
+ int pin ;
- pwmSetModeWPi (PWM_MODE_BAL) ; // Pi default mode
- pwmSetRangeWPi (1024) ; // Default range of 1024
- pwmSetClockWPi (32) ; // 19.2 / 32 = 600KHz - Also starts the PWM
+ /**/ if (wiringPiMode == WPI_MODE_GPIO_SYS)
+ {
+ for (pin = 0 ; pin < 8 ; ++pin)
+ {
+ digitalWrite (pin, value & mask) ;
+ mask <<= 1 ;
+ }
}
- else if (mode == GPIO_CLOCK)
+ else
{
- if ((alt = gpioToGpClkALT0 [pin]) == 0) // Not a GPIO_CLOCK pin
- return ;
+ for (pin = 0 ; pin < 8 ; ++pin)
+ {
+ if ((value & mask) == 0)
+ pinClr |= (1 << pinToGpio [pin]) ;
+ else
+ pinSet |= (1 << pinToGpio [pin]) ;
-// Set pin to GPIO_CLOCK mode and set the clock frequency to 100KHz
+ mask <<= 1 ;
+ }
- *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
- delayMicroseconds (110) ;
- gpioClockSetGpio (pin, 100000) ;
+ *(gpio + gpioToGPCLR [0]) = pinClr ;
+ *(gpio + gpioToGPSET [0]) = pinSet ;
}
}
-void pinModeWPi (int pin, int mode)
-{
- pinModeGpio (pinToGpio [pin & 63], mode) ;
-}
-
-void pinModeSys (int pin, int mode)
-{
- return ;
-}
-
/*
* waitForInterrupt:
+ * Pi Specific.
* Wait for Interrupt on a GPIO pin.
* This is actually done via the /sys/class/gpio interface regardless of
* the wiringPi access mode in-use. Maybe sometime it might get a better
@@ -1011,12 +1223,17 @@ void pinModeSys (int pin, int mode)
*********************************************************************************
*/
-int waitForInterruptSys (int pin, int mS)
+int waitForInterrupt (int pin, int mS)
{
int fd, x ;
uint8_t c ;
struct pollfd polls ;
+ /**/ if (wiringPiMode == WPI_MODE_PINS)
+ pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
+
if ((fd = sysFds [pin & 63]) == -1)
return -2 ;
@@ -1037,16 +1254,6 @@ int waitForInterruptSys (int pin, int mS)
return x ;
}
-int waitForInterruptWPi (int pin, int mS)
-{
- return waitForInterruptSys (pinToGpio [pin & 63], mS) ;
-}
-
-int waitForInterruptGpio (int pin, int mS)
-{
- return waitForInterruptSys (pin, mS) ;
-}
-
/*
* interruptHandler:
@@ -1063,7 +1270,7 @@ static void *interruptHandler (void *arg)
(void)piHiPri (55) ; // Only effective if we run as root
for (;;)
- if (waitForInterruptSys (myPin, -1) > 0)
+ if (waitForInterrupt (myPin, -1) > 0)
isrFunctions [myPin] () ;
return NULL ;
@@ -1072,6 +1279,7 @@ static void *interruptHandler (void *arg)
/*
* wiringPiISR:
+ * Pi Specific.
* Take the details and create an interrupt handler that will do a call-
* back to the user supplied function.
*********************************************************************************
@@ -1089,13 +1297,12 @@ int wiringPiISR (int pin, int mode, void (*function)(void))
pin &= 63 ;
- if (wiringPiMode == WPI_MODE_UNINITIALISED)
- {
- fprintf (stderr, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ;
- exit (EXIT_FAILURE) ;
- }
+ /**/ if (wiringPiMode == WPI_MODE_UNINITIALISED)
+ (void)wiringPiFailure ("wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ;
else if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio [pin] ;
+ else if (wiringPiMode == WPI_MODE_PHYS)
+ pin = physToGpio [pin] ;
// Now export the pin and set the right edge
// We're going to use the gpio program to do this, so it assumes
@@ -1152,7 +1359,7 @@ int wiringPiISR (int pin, int mode, void (*function)(void))
/*
* initialiseEpoch:
* Initialise our start-of-time variable to be the current unix
- * time in milliseconds.
+ * time in milliseconds and microseconds.
*********************************************************************************
*/
@@ -1165,9 +1372,10 @@ static void initialiseEpoch (void)
epochMicro = (uint64_t)tv.tv_sec * (uint64_t)1000000 + (uint64_t)(tv.tv_usec) ;
}
+
/*
* delay:
- * Wait for some number of milli seconds
+ * Wait for some number of milliseconds
*********************************************************************************
*/
@@ -1280,124 +1488,66 @@ int wiringPiSetup (void)
int fd ;
int boardRev ;
- if (geteuid () != 0)
- {
- fprintf (stderr, "wiringPi:\n Must be root to call wiringPiSetup().\n (Did you forget sudo?)\n") ;
- exit (EXIT_FAILURE) ;
- }
-
- if (getenv ("WIRINGPI_DEBUG") != NULL)
- {
- printf ("wiringPi: Debug mode enabled\n") ;
+ if (getenv (ENV_DEBUG) != NULL)
wiringPiDebug = TRUE ;
- }
+
+ if (getenv (ENV_CODES) != NULL)
+ wiringPiCodes = TRUE ;
+
+ if (geteuid () != 0)
+ (void)wiringPiFailure ("wiringPiSetup: Must be root. (Did you forget sudo?)\n") ;
if (wiringPiDebug)
printf ("wiringPi: wiringPiSetup called\n") ;
- pinMode = pinModeWPi ;
- getAlt = getAltWPi ;
- pullUpDnControl = pullUpDnControlWPi ;
- digitalWrite = digitalWriteWPi ;
- digitalWriteByte = digitalWriteByteGpio ; // Same code
- gpioClockSet = gpioClockSetWPi ;
- pwmWrite = pwmWriteWPi ;
- setPadDrive = setPadDriveWPi ;
- digitalRead = digitalReadWPi ;
- waitForInterrupt = waitForInterruptWPi ;
- pwmSetMode = pwmSetModeWPi ;
- pwmSetRange = pwmSetRangeWPi ;
- pwmSetClock = pwmSetClockWPi ;
-
boardRev = piBoardRev () ;
if (boardRev == 1)
- pinToGpio = pinToGpioR1 ;
+ {
+ pinToGpio = pinToGpioR1 ;
+ physToGpio = physToGpioR1 ;
+ }
else
- pinToGpio = pinToGpioR2 ;
+ {
+ pinToGpio = pinToGpioR2 ;
+ physToGpio = physToGpioR2 ;
+ }
// Open the master /dev/memory device
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
// GPIO:
gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_BASE) ;
if ((int32_t)gpio == -1)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: mmap failed: %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: mmap (GPIO) failed: %s\n", strerror (errno)) ;
// PWM
pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ;
if ((int32_t)pwm == -1)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: mmap failed (pwm): %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ;
// Clock control (needed for PWM)
clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, CLOCK_BASE) ;
if ((int32_t)clk == -1)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: mmap failed (clk): %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ;
// The drive pads
pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ;
if ((int32_t)pads == -1)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: mmap failed (pads): %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: mmap (PADS) failed: %s\n", strerror (errno)) ;
+#ifdef USE_TIMER
// The system timer
timer = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_TIMER) ;
if ((int32_t)timer == -1)
- {
- if (wiringPiDebug)
- {
- int serr = errno ;
- fprintf (stderr, "wiringPiSetup: mmap failed (timer): %s\n", strerror (errno)) ;
- errno = serr ;
- }
- return -1 ;
- }
+ (void)wiringPiFailure ("wiringPiSetup: mmap (TIMER) failed: %s\n", strerror (errno)) ;
// Set the timer to free-running, 1MHz.
// 0xF9 is 249, the timer divide is base clock / (divide+1)
@@ -1406,6 +1556,7 @@ int wiringPiSetup (void)
*(timer + TIMER_CONTROL) = 0x0000280 ;
*(timer + TIMER_PRE_DIV) = 0x00000F9 ;
timerIrqRaw = timer + TIMER_IRQ_RAW ;
+#endif
initialiseEpoch () ;
@@ -1426,40 +1577,39 @@ int wiringPiSetup (void)
int wiringPiSetupGpio (void)
{
- int x ;
-
- if (geteuid () != 0)
- {
- fprintf (stderr, "Must be root to call wiringPiSetupGpio(). (Did you forget sudo?)\n") ;
- exit (EXIT_FAILURE) ;
- }
-
- if ((x = wiringPiSetup ()) < 0)
- return x ;
+ (void)wiringPiSetup () ;
if (wiringPiDebug)
printf ("wiringPi: wiringPiSetupGpio called\n") ;
- pinMode = pinModeGpio ;
- getAlt = getAltGpio ;
- pullUpDnControl = pullUpDnControlGpio ;
- digitalWrite = digitalWriteGpio ;
- digitalWriteByte = digitalWriteByteGpio ;
- gpioClockSet = gpioClockSetGpio ;
- pwmWrite = pwmWriteGpio ;
- setPadDrive = setPadDriveGpio ;
- digitalRead = digitalReadGpio ;
- waitForInterrupt = waitForInterruptGpio ;
- pwmSetMode = pwmSetModeWPi ;
- pwmSetRange = pwmSetRangeWPi ;
- pwmSetClock = pwmSetClockWPi ;
-
wiringPiMode = WPI_MODE_GPIO ;
return 0 ;
}
+/*
+ * wiringPiSetupPhys:
+ * Must be called once at the start of your program execution.
+ *
+ * Phys setup: Initialises the system into Physical Pin mode and uses the
+ * memory mapped hardware directly.
+ *********************************************************************************
+ */
+
+int wiringPiSetupPhys (void)
+{
+ (void)wiringPiSetup () ;
+
+ if (wiringPiDebug)
+ printf ("wiringPi: wiringPiSetupPhys called\n") ;
+
+ wiringPiMode = WPI_MODE_PHYS ;
+
+ return 0 ;
+}
+
+
/*
* wiringPiSetupSys:
* Must be called once at the start of your program execution.
@@ -1475,32 +1625,27 @@ int wiringPiSetupSys (void)
int pin ;
char fName [128] ;
- if (getenv ("WIRINGPI_DEBUG") != NULL)
+ if (getenv (ENV_DEBUG) != NULL)
wiringPiDebug = TRUE ;
+ if (getenv (ENV_CODES) != NULL)
+ wiringPiCodes = TRUE ;
+
if (wiringPiDebug)
printf ("wiringPi: wiringPiSetupSys called\n") ;
- pinMode = pinModeSys ;
- getAlt = getAltSys ;
- pullUpDnControl = pullUpDnControlSys ;
- digitalWrite = digitalWriteSys ;
- digitalWriteByte = digitalWriteByteSys ;
- gpioClockSet = gpioClockSetSys ;
- pwmWrite = pwmWriteSys ;
- setPadDrive = setPadDriveSys ;
- digitalRead = digitalReadSys ;
- waitForInterrupt = waitForInterruptSys ;
- pwmSetMode = pwmSetModeSys ;
- pwmSetRange = pwmSetRangeSys ;
- pwmSetClock = pwmSetClockSys ;
-
boardRev = piBoardRev () ;
if (boardRev == 1)
- pinToGpio = pinToGpioR1 ;
+ {
+ pinToGpio = pinToGpioR1 ;
+ physToGpio = physToGpioR1 ;
+ }
else
- pinToGpio = pinToGpioR2 ;
+ {
+ pinToGpio = pinToGpioR2 ;
+ physToGpio = physToGpioR2 ;
+ }
// Open and scan the directory, looking for exported GPIOs, and pre-open
// the 'value' interface to speed things up for later
diff --git a/wiringPi/wiringPi.h b/WiringPi/wiringPi/wiringPi.h
similarity index 52%
rename from wiringPi/wiringPi.h
rename to WiringPi/wiringPi/wiringPi.h
index 18c6da5..2c0a72b 100644
--- a/wiringPi/wiringPi.h
+++ b/WiringPi/wiringPi/wiringPi.h
@@ -29,7 +29,8 @@
#define WPI_MODE_PINS 0
#define WPI_MODE_GPIO 1
#define WPI_MODE_GPIO_SYS 2
-#define WPI_MODE_PIFACE 3
+#define WPI_MODE_PHYS 3
+#define WPI_MODE_PIFACE 4
#define WPI_MODE_UNINITIALISED -1
// Pin modes
@@ -64,6 +65,36 @@
#define PI_THREAD(X) void *X (void *dummy)
+// wiringPiNodeStruct:
+// This describes additional device nodes in the extended wiringPi
+// 2.0 scheme of things.
+// It's a simple linked list for now, but will hopefully migrate to
+// a binary tree for efficiency reasons - but then again, the chances
+// of more than 1 or 2 devices being added are fairly slim, so who
+// knows....
+
+struct wiringPiNodeStruct
+{
+ int pinBase ;
+ int pinMax ;
+
+ int fd ; // Node specific
+ unsigned int data0 ; // ditto
+ unsigned int data1 ; // ditto
+ unsigned int data2 ; // ditto
+ unsigned int data3 ; // ditto
+
+ void (*pinMode) (struct wiringPiNodeStruct *node, int pin, int mode) ;
+ void (*pullUpDnControl) (struct wiringPiNodeStruct *node, int pin, int mode) ;
+ int (*digitalRead) (struct wiringPiNodeStruct *node, int pin) ;
+ void (*digitalWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;
+ void (*pwmWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;
+ int (*analogRead) (struct wiringPiNodeStruct *node, int pin) ;
+ void (*analogWrite) (struct wiringPiNodeStruct *node, int pin, int value) ;
+
+ struct wiringPiNodeStruct *next ;
+} ;
+
// Function prototypes
// c++ wrappers thanks to a comment by Nick Lott
@@ -73,47 +104,58 @@
extern "C" {
#endif
-// Basic wiringPi functions
+
+// Core wiringPi functions
+
+extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ;
extern int wiringPiSetup (void) ;
extern int wiringPiSetupSys (void) ;
extern int wiringPiSetupGpio (void) ;
-extern int wiringPiSetupPiFace (void) ;
+extern int wiringPiSetupPhys (void) ;
-extern int piBoardRev (void) ;
-extern int wpiPinToGpio (int wpiPin) ;
+extern void pinMode (int pin, int mode) ;
+extern void pullUpDnControl (int pin, int pud) ;
+extern int digitalRead (int pin) ;
+extern void digitalWrite (int pin, int value) ;
+extern void pwmWrite (int pin, int value) ;
+extern int analogRead (int pin) ;
+extern void analogWrite (int pin, int value) ;
+// PiFace specifics
+// (Deprecated)
+
+extern int wiringPiSetupPiFace (void) ;
extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
-extern void (*pinMode) (int pin, int mode) ;
-extern int (*getAlt) (int pin) ;
-extern void (*pullUpDnControl) (int pin, int pud) ;
-extern void (*digitalWrite) (int pin, int value) ;
-extern void (*digitalWriteByte) (int value) ;
-extern void (*gpioClockSet) (int pin, int freq) ;
-extern void (*pwmWrite) (int pin, int value) ;
-extern void (*setPadDrive) (int group, int value) ;
-extern int (*digitalRead) (int pin) ;
-extern void (*pwmSetMode) (int mode) ;
-extern void (*pwmSetRange) (unsigned int range) ;
-extern void (*pwmSetClock) (int divisor) ;
+// On-Board Raspberry Pi hardware specific stuff
+
+extern int piBoardRev (void) ;
+extern int wpiPinToGpio (int wpiPin) ;
+extern void setPadDrive (int group, int value) ;
+extern int getAlt (int pin) ;
+extern void digitalWriteByte (int value) ;
+extern void pwmSetMode (int mode) ;
+extern void pwmSetRange (unsigned int range) ;
+extern void pwmSetClock (int divisor) ;
+extern void gpioClockSet (int pin, int freq) ;
// Interrupts
+// (Also Pi hardware specific)
-extern int (*waitForInterrupt) (int pin, int mS) ;
+extern int waitForInterrupt (int pin, int mS) ;
extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
// Threads
-extern int piThreadCreate (void *(*fn)(void *)) ;
-extern void piLock (int key) ;
-extern void piUnlock (int key) ;
+extern int piThreadCreate (void *(*fn)(void *)) ;
+extern void piLock (int key) ;
+extern void piUnlock (int key) ;
// Schedulling priority
extern int piHiPri (int pri) ;
-
// Extras from arduino land
extern void delay (unsigned int howLong) ;
diff --git a/WiringPi/wiringPi/wiringPiI2C.c b/WiringPi/wiringPi/wiringPiI2C.c
new file mode 100644
index 0000000..dbc94b9
--- /dev/null
+++ b/WiringPi/wiringPi/wiringPiI2C.c
@@ -0,0 +1,227 @@
+/*
+ * wiringPiI2C.c:
+ * Simplified I2C access routines
+ * 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 .
+ ***********************************************************************
+ */
+
+/*
+ * Notes:
+ * The Linux I2C code is actually the same (almost) as the SMBus code.
+ * SMBus is System Management Bus - and in essentially I2C with some
+ * additional functionality added, and stricter controls on the electrical
+ * specifications, etc. however I2C does work well with it and the
+ * protocols work over both.
+ *
+ * I'm directly including the SMBus functions here as some Linux distros
+ * lack the correct header files, and also some header files are GPLv2
+ * rather than the LGPL that wiringPi is released under - presumably because
+ * originally no-one expected I2C/SMBus to be used outside the kernel -
+ * however enter the Raspberry Pi with people now taking directly to I2C
+ * devices without going via the kernel...
+ *
+ * This may ultimately reduce the flexibility of this code, but it won't be
+ * hard to maintain it and keep it current, should things change.
+ *
+ * Information here gained from: kernel/Documentation/i2c/dev-interface
+ * as well as other online resources.
+ *********************************************************************************
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include "wiringPi.h"
+#include "wiringPiI2C.h"
+
+// I2C definitions
+
+#define I2C_SLAVE 0x0703
+#define I2C_SMBUS 0x0720 /* SMBus-level access */
+
+#define I2C_SMBUS_READ 1
+#define I2C_SMBUS_WRITE 0
+
+// SMBus transaction types
+
+#define I2C_SMBUS_QUICK 0
+#define I2C_SMBUS_BYTE 1
+#define I2C_SMBUS_BYTE_DATA 2
+#define I2C_SMBUS_WORD_DATA 3
+#define I2C_SMBUS_PROC_CALL 4
+#define I2C_SMBUS_BLOCK_DATA 5
+#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
+#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
+#define I2C_SMBUS_I2C_BLOCK_DATA 8
+
+// SMBus messages
+
+#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
+#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
+
+// Structures used in the ioctl() calls
+
+union i2c_smbus_data
+{
+ uint8_t byte ;
+ uint16_t word ;
+ uint8_t block [I2C_SMBUS_BLOCK_MAX + 2] ; // block [0] is used for length + one more for PEC
+} ;
+
+struct i2c_smbus_ioctl_data
+{
+ char read_write ;
+ uint8_t command ;
+ int size ;
+ union i2c_smbus_data *data ;
+} ;
+
+static inline int i2c_smbus_access (int fd, char rw, uint8_t command, int size, union i2c_smbus_data *data)
+{
+ struct i2c_smbus_ioctl_data args ;
+
+ args.read_write = rw ;
+ args.command = command ;
+ args.size = size ;
+ args.data = data ;
+ return ioctl (fd, I2C_SMBUS, &args) ;
+}
+
+
+/*
+ * wiringPiI2CRead:
+ * Simple device read
+ *********************************************************************************
+ */
+
+int wiringPiI2CRead (int fd)
+{
+ union i2c_smbus_data data ;
+
+ if (i2c_smbus_access (fd, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data))
+ return -1 ;
+ else
+ return data.byte & 0xFF ;
+}
+
+
+/*
+ * wiringPiI2CReadReg8: wiringPiI2CReadReg16:
+ * Read an 8 or 16-bit value from a regsiter on the device
+ *********************************************************************************
+ */
+
+int wiringPiI2CReadReg8 (int fd, int reg)
+{
+ union i2c_smbus_data data;
+
+ if (i2c_smbus_access (fd, I2C_SMBUS_READ, reg, I2C_SMBUS_BYTE_DATA, &data))
+ return -1 ;
+ else
+ return data.byte & 0xFF ;
+}
+
+int wiringPiI2CReadReg16 (int fd, int reg)
+{
+ union i2c_smbus_data data;
+
+ if (i2c_smbus_access (fd, I2C_SMBUS_READ, reg, I2C_SMBUS_WORD_DATA, &data))
+ return -1 ;
+ else
+ return data.byte & 0xFF ;
+}
+
+
+/*
+ * wiringPiI2CWrite:
+ * Simple device write
+ *********************************************************************************
+ */
+
+int wiringPiI2CWrite (int fd, int data)
+{
+ return i2c_smbus_access (fd, I2C_SMBUS_WRITE, data, I2C_SMBUS_BYTE, NULL) ;
+}
+
+
+/*
+ * wiringPiI2CWriteReg8: wiringPiI2CWriteReg16:
+ * Write an 8 or 16-bit value to the given register
+ *********************************************************************************
+ */
+
+int wiringPiI2CWriteReg8 (int fd, int reg, int value)
+{
+ union i2c_smbus_data data ;
+
+ data.byte = value ;
+ return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_BYTE_DATA, &data) ;
+}
+
+int wiringPiI2CWriteReg16 (int fd, int reg, int value)
+{
+ union i2c_smbus_data data ;
+
+ data.word = value ;
+ return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, &data) ;
+}
+
+
+/*
+ * wiringPiI2CSetup:
+ * Open the I2C device, and regsiter the target device
+ *********************************************************************************
+ */
+
+int wiringPiI2CSetupInterface (char *device, int devId)
+{
+ int fd ;
+
+ if ((fd = open (device, O_RDWR)) < 0)
+ return -1 ;
+
+ if (ioctl (fd, I2C_SLAVE, devId) < 0)
+ return -1 ;
+
+ return fd ;
+}
+
+
+int wiringPiI2CSetup (int devId)
+{
+ int rev ;
+ char *device ;
+
+ if ((rev = piBoardRev ()) < 0)
+ {
+ fprintf (stderr, "wiringPiI2CSetup: Unable to determine Pi board revision\n") ;
+ exit (1) ;
+ }
+
+ if (rev == 1)
+ device = "/dev/i2c-0" ;
+ else
+ device = "/dev/i2c-1" ;
+
+ return wiringPiI2CSetupInterface (device, devId) ;
+}
diff --git a/WiringPi/wiringPi/wiringPiI2C.h b/WiringPi/wiringPi/wiringPiI2C.h
new file mode 100644
index 0000000..d1b5c01
--- /dev/null
+++ b/WiringPi/wiringPi/wiringPiI2C.h
@@ -0,0 +1,42 @@
+/*
+ * wiringPiI2C.h:
+ * Simplified I2C access routines
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int wiringPiI2CRead (int fd) ;
+extern int wiringPiI2CReadReg8 (int fd, int reg) ;
+extern int wiringPiI2CReadReg16 (int fd, int reg) ;
+
+extern int wiringPiI2CWrite (int fd, int data) ;
+extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;
+extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;
+
+extern int wiringPiI2CSetupInterface (char *device, int devId) ;
+extern int wiringPiI2CSetup (int devId) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/wiringPi/wiringPiSPI.c b/WiringPi/wiringPi/wiringPiSPI.c
similarity index 99%
rename from wiringPi/wiringPiSPI.c
rename to WiringPi/wiringPi/wiringPiSPI.c
index 4441498..4014bb7 100644
--- a/wiringPi/wiringPiSPI.c
+++ b/WiringPi/wiringPi/wiringPiSPI.c
@@ -28,6 +28,8 @@
#include
#include
+#include "wiringPi.h"
+
#include "wiringPiSPI.h"
diff --git a/wiringPi/wiringPiSPI.h b/WiringPi/wiringPi/wiringPiSPI.h
similarity index 100%
rename from wiringPi/wiringPiSPI.h
rename to WiringPi/wiringPi/wiringPiSPI.h
diff --git a/wiringPi/wiringSerial.c b/WiringPi/wiringPi/wiringSerial.c
similarity index 99%
rename from wiringPi/wiringSerial.c
rename to WiringPi/wiringPi/wiringSerial.c
index 28ec598..7035593 100644
--- a/wiringPi/wiringSerial.c
+++ b/WiringPi/wiringPi/wiringSerial.c
@@ -60,6 +60,7 @@ int serialOpen (char *device, int baud)
case 1200: myBaud = B1200 ; break ;
case 1800: myBaud = B1800 ; break ;
case 2400: myBaud = B2400 ; break ;
+ case 4800: myBaud = B4800 ; break ;
case 9600: myBaud = B9600 ; break ;
case 19200: myBaud = B19200 ; break ;
case 38400: myBaud = B38400 ; break ;
diff --git a/wiringPi/wiringSerial.h b/WiringPi/wiringPi/wiringSerial.h
similarity index 100%
rename from wiringPi/wiringSerial.h
rename to WiringPi/wiringPi/wiringSerial.h
diff --git a/wiringPi/wiringShift.c b/WiringPi/wiringPi/wiringShift.c
similarity index 99%
rename from wiringPi/wiringShift.c
rename to WiringPi/wiringPi/wiringShift.c
index b9b7a44..3df94e8 100644
--- a/wiringPi/wiringShift.c
+++ b/WiringPi/wiringPi/wiringShift.c
@@ -56,7 +56,6 @@ uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order)
return value;
}
-
/*
* shiftOut:
* Shift data out to a clocked source
diff --git a/wiringPi/wiringShift.h b/WiringPi/wiringPi/wiringShift.h
similarity index 88%
rename from wiringPi/wiringShift.h
rename to WiringPi/wiringPi/wiringShift.h
index a3f4581..419ade4 100644
--- a/wiringPi/wiringShift.h
+++ b/WiringPi/wiringPi/wiringShift.h
@@ -33,8 +33,8 @@
extern "C" {
#endif
-extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ;
-extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ;
+extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ;
+extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ;
#ifdef __cplusplus
}
diff --git a/_wiringpi.py b/_wiringpi.py
new file mode 100644
index 0000000..6e7d1f2
--- /dev/null
+++ b/_wiringpi.py
@@ -0,0 +1,277 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 2.0.7
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+
+
+
+from sys import version_info
+if version_info >= (2,6,0):
+ def swig_import_helper():
+ from os.path import dirname
+ import imp
+ fp = None
+ try:
+ fp, pathname, description = imp.find_module('__wiringpi', [dirname(__file__)])
+ except ImportError:
+ import __wiringpi
+ return __wiringpi
+ if fp is not None:
+ try:
+ _mod = imp.load_module('__wiringpi', fp, pathname, description)
+ finally:
+ fp.close()
+ return _mod
+ __wiringpi = swig_import_helper()
+ del swig_import_helper
+else:
+ import __wiringpi
+del version_info
+try:
+ _swig_property = property
+except NameError:
+ pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+ if (name == "thisown"): return self.this.own(value)
+ if (name == "this"):
+ if type(value).__name__ == 'SwigPyObject':
+ self.__dict__[name] = value
+ return
+ method = class_type.__swig_setmethods__.get(name,None)
+ if method: return method(self,value)
+ if (not static):
+ self.__dict__[name] = value
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+ return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+ if (name == "thisown"): return self.this.own()
+ method = class_type.__swig_getmethods__.get(name,None)
+ if method: return method(self)
+ raise AttributeError(name)
+
+def _swig_repr(self):
+ try: strthis = "proxy of " + self.this.__repr__()
+ except: strthis = ""
+ return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+ _object = object
+ _newclass = 1
+except AttributeError:
+ class _object : pass
+ _newclass = 0
+
+
+
+def wiringPiSetup():
+ return __wiringpi.wiringPiSetup()
+wiringPiSetup = __wiringpi.wiringPiSetup
+
+def wiringPiSetupSys():
+ return __wiringpi.wiringPiSetupSys()
+wiringPiSetupSys = __wiringpi.wiringPiSetupSys
+
+def wiringPiSetupGpio():
+ return __wiringpi.wiringPiSetupGpio()
+wiringPiSetupGpio = __wiringpi.wiringPiSetupGpio
+
+def piFaceSetup(*args):
+ return __wiringpi.piFaceSetup(*args)
+piFaceSetup = __wiringpi.piFaceSetup
+
+def piBoardRev():
+ return __wiringpi.piBoardRev()
+piBoardRev = __wiringpi.piBoardRev
+
+def wpiPinToGpio(*args):
+ return __wiringpi.wpiPinToGpio(*args)
+wpiPinToGpio = __wiringpi.wpiPinToGpio
+
+def pinMode(*args):
+ return __wiringpi.pinMode(*args)
+pinMode = __wiringpi.pinMode
+
+def getAlt(*args):
+ return __wiringpi.getAlt(*args)
+getAlt = __wiringpi.getAlt
+
+def pullUpDnControl(*args):
+ return __wiringpi.pullUpDnControl(*args)
+pullUpDnControl = __wiringpi.pullUpDnControl
+
+def digitalWrite(*args):
+ return __wiringpi.digitalWrite(*args)
+digitalWrite = __wiringpi.digitalWrite
+
+def digitalWriteByte(*args):
+ return __wiringpi.digitalWriteByte(*args)
+digitalWriteByte = __wiringpi.digitalWriteByte
+
+def gpioClockSet(*args):
+ return __wiringpi.gpioClockSet(*args)
+gpioClockSet = __wiringpi.gpioClockSet
+
+def pwmWrite(*args):
+ return __wiringpi.pwmWrite(*args)
+pwmWrite = __wiringpi.pwmWrite
+
+def setPadDrive(*args):
+ return __wiringpi.setPadDrive(*args)
+setPadDrive = __wiringpi.setPadDrive
+
+def digitalRead(*args):
+ return __wiringpi.digitalRead(*args)
+digitalRead = __wiringpi.digitalRead
+
+def pwmSetMode(*args):
+ return __wiringpi.pwmSetMode(*args)
+pwmSetMode = __wiringpi.pwmSetMode
+
+def pwmSetRange(*args):
+ return __wiringpi.pwmSetRange(*args)
+pwmSetRange = __wiringpi.pwmSetRange
+
+def pwmSetClock(*args):
+ return __wiringpi.pwmSetClock(*args)
+pwmSetClock = __wiringpi.pwmSetClock
+
+def wiringPiISR(*args):
+ return __wiringpi.wiringPiISR(*args)
+wiringPiISR = __wiringpi.wiringPiISR
+
+def piThreadCreate(*args):
+ return __wiringpi.piThreadCreate(*args)
+piThreadCreate = __wiringpi.piThreadCreate
+
+def piLock(*args):
+ return __wiringpi.piLock(*args)
+piLock = __wiringpi.piLock
+
+def piUnlock(*args):
+ return __wiringpi.piUnlock(*args)
+piUnlock = __wiringpi.piUnlock
+
+def delay(*args):
+ return __wiringpi.delay(*args)
+delay = __wiringpi.delay
+
+def delayMicroseconds(*args):
+ return __wiringpi.delayMicroseconds(*args)
+delayMicroseconds = __wiringpi.delayMicroseconds
+
+def millis():
+ return __wiringpi.millis()
+millis = __wiringpi.millis
+
+def micros():
+ return __wiringpi.micros()
+micros = __wiringpi.micros
+
+def serialOpen(*args):
+ return __wiringpi.serialOpen(*args)
+serialOpen = __wiringpi.serialOpen
+
+def serialClose(*args):
+ return __wiringpi.serialClose(*args)
+serialClose = __wiringpi.serialClose
+
+def serialFlush(*args):
+ return __wiringpi.serialFlush(*args)
+serialFlush = __wiringpi.serialFlush
+
+def serialPutchar(*args):
+ return __wiringpi.serialPutchar(*args)
+serialPutchar = __wiringpi.serialPutchar
+
+def serialPuts(*args):
+ return __wiringpi.serialPuts(*args)
+serialPuts = __wiringpi.serialPuts
+
+def serialPrintf(*args):
+ return __wiringpi.serialPrintf(*args)
+serialPrintf = __wiringpi.serialPrintf
+
+def serialDataAvail(*args):
+ return __wiringpi.serialDataAvail(*args)
+serialDataAvail = __wiringpi.serialDataAvail
+
+def serialGetchar(*args):
+ return __wiringpi.serialGetchar(*args)
+serialGetchar = __wiringpi.serialGetchar
+
+def shiftOut(*args):
+ return __wiringpi.shiftOut(*args)
+shiftOut = __wiringpi.shiftOut
+
+def shiftIn(*args):
+ return __wiringpi.shiftIn(*args)
+shiftIn = __wiringpi.shiftIn
+
+def wiringPiSPIGetFd(*args):
+ return __wiringpi.wiringPiSPIGetFd(*args)
+wiringPiSPIGetFd = __wiringpi.wiringPiSPIGetFd
+
+def wiringPiSPIDataRW(*args):
+ return __wiringpi.wiringPiSPIDataRW(*args)
+wiringPiSPIDataRW = __wiringpi.wiringPiSPIDataRW
+
+def wiringPiSPISetup(*args):
+ return __wiringpi.wiringPiSPISetup(*args)
+wiringPiSPISetup = __wiringpi.wiringPiSPISetup
+
+def wiringPiI2CRead(*args):
+ return __wiringpi.wiringPiI2CRead(*args)
+wiringPiI2CRead = __wiringpi.wiringPiI2CRead
+
+def wiringPiI2CReadReg8(*args):
+ return __wiringpi.wiringPiI2CReadReg8(*args)
+wiringPiI2CReadReg8 = __wiringpi.wiringPiI2CReadReg8
+
+def wiringPiI2CReadReg16(*args):
+ return __wiringpi.wiringPiI2CReadReg16(*args)
+wiringPiI2CReadReg16 = __wiringpi.wiringPiI2CReadReg16
+
+def wiringPiI2CWrite(*args):
+ return __wiringpi.wiringPiI2CWrite(*args)
+wiringPiI2CWrite = __wiringpi.wiringPiI2CWrite
+
+def wiringPiI2CWriteReg8(*args):
+ return __wiringpi.wiringPiI2CWriteReg8(*args)
+wiringPiI2CWriteReg8 = __wiringpi.wiringPiI2CWriteReg8
+
+def wiringPiI2CWriteReg16(*args):
+ return __wiringpi.wiringPiI2CWriteReg16(*args)
+wiringPiI2CWriteReg16 = __wiringpi.wiringPiI2CWriteReg16
+
+def softToneCreate(*args):
+ return __wiringpi.softToneCreate(*args)
+softToneCreate = __wiringpi.softToneCreate
+
+def softToneWrite(*args):
+ return __wiringpi.softToneWrite(*args)
+softToneWrite = __wiringpi.softToneWrite
+
+def softServoWrite(*args):
+ return __wiringpi.softServoWrite(*args)
+softServoWrite = __wiringpi.softServoWrite
+
+def softServoSetup(*args):
+ return __wiringpi.softServoSetup(*args)
+softServoSetup = __wiringpi.softServoSetup
+
+def softPwmCreate(*args):
+ return __wiringpi.softPwmCreate(*args)
+softPwmCreate = __wiringpi.softPwmCreate
+
+def softPwmWrite(*args):
+ return __wiringpi.softPwmWrite(*args)
+softPwmWrite = __wiringpi.softPwmWrite
+# This file is compatible with both classic and new-style classes.
+
+cvar = __wiringpi.cvar
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..8e7c275
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+from setuptools import setup, find_packages, Extension
+
+wiringpi_module = Extension(
+ '_wiringpi',
+ headers=[
+ 'WiringPi/wiringPi/ds1302.h',
+ 'WiringPi/wiringPi/gertboard.h',
+ 'WiringPi/wiringPi/lcd.h',
+ 'WiringPi/wiringPi/mcp23008.h',
+ 'WiringPi/wiringPi/mcp23017.h',
+ 'WiringPi/wiringPi/mcp23s08.h',
+ 'WiringPi/wiringPi/mcp23s17.h',
+ 'WiringPi/wiringPi/mcp23x0817.h',
+ 'WiringPi/wiringPi/mcp23x08.h',
+ 'WiringPi/wiringPi/piFace.h',
+ 'WiringPi/wiringPi/piNes.h',
+ 'WiringPi/wiringPi/softPwm.h',
+ 'WiringPi/wiringPi/softServo.h',
+ 'WiringPi/wiringPi/softTone.h',
+ 'WiringPi/wiringPi/sr595.h',
+ 'WiringPi/wiringPi/wiringPi.h',
+ 'WiringPi/wiringPi/wiringPiI2C.h',
+ 'WiringPi/wiringPi/wiringPiSPI.h',
+ 'WiringPi/wiringPi/wiringSerial.h',
+ 'WiringPi/wiringPi/wiringShift.h'
+ ],
+ sources=[
+ 'WiringPi/wiringPi/ds1302.c',
+ 'WiringPi/wiringPi/gertboard.c',
+ 'WiringPi/wiringPi/lcd.c',
+ 'WiringPi/wiringPi/mcp23008.c',
+ 'WiringPi/wiringPi/mcp23017.c',
+ 'WiringPi/wiringPi/mcp23s08.c',
+ 'WiringPi/wiringPi/mcp23s17.c',
+ 'WiringPi/wiringPi/piFace.c',
+ 'WiringPi/wiringPi/piHiPri.c',
+ 'WiringPi/wiringPi/piNes.c',
+ 'WiringPi/wiringPi/piThread.c',
+ 'WiringPi/wiringPi/softPwm.c',
+ 'WiringPi/wiringPi/softServo.c',
+ 'WiringPi/wiringPi/softTone.c',
+ 'WiringPi/wiringPi/sr595.c',
+ 'WiringPi/wiringPi/wiringPi.c',
+ 'WiringPi/wiringPi/wiringPiI2C.c',
+ 'WiringPi/wiringPi/wiringPiSPI.c',
+ 'WiringPi/wiringPi/wiringSerial.c',
+ 'WiringPi/wiringPi/wiringShift.c',
+ 'wiringpi_wrap.c'
+ ],
+)
+
+setup(
+ name = 'wiringpi',
+ version = '1.1.0',
+ author = "Philip Howard",
+ author_email = "phil@gadgetoid.com",
+ url = 'https://github.com/WiringPi/WiringPi-Python/',
+ description = """A python interface to WiringPi library which allows for
+ easily interfacing with the GPIO pins of the Raspberry Pi. Also supports
+ i2c and SPI""",
+ long_description=open('README').read(),
+ ext_modules = [wiringpi_module],
+ py_modules = ["wiringpi"],
+ install_requires=[],
+ headers=[
+ 'WiringPi/wiringPi/ds1302.h',
+ 'WiringPi/wiringPi/gertboard.h',
+ 'WiringPi/wiringPi/lcd.h',
+ 'WiringPi/wiringPi/mcp23008.h',
+ 'WiringPi/wiringPi/mcp23017.h',
+ 'WiringPi/wiringPi/mcp23s08.h',
+ 'WiringPi/wiringPi/mcp23s17.h',
+ 'WiringPi/wiringPi/mcp23x0817.h',
+ 'WiringPi/wiringPi/mcp23x08.h',
+ 'WiringPi/wiringPi/piFace.h',
+ 'WiringPi/wiringPi/piNes.h',
+ 'WiringPi/wiringPi/softPwm.h',
+ 'WiringPi/wiringPi/softServo.h',
+ 'WiringPi/wiringPi/softTone.h',
+ 'WiringPi/wiringPi/sr595.h',
+ 'WiringPi/wiringPi/wiringPi.h',
+ 'WiringPi/wiringPi/wiringPiI2C.h',
+ 'WiringPi/wiringPi/wiringPiSPI.h',
+ 'WiringPi/wiringPi/wiringSerial.h',
+ 'WiringPi/wiringPi/wiringShift.h'
+ ]
+)
diff --git a/wiringPi/COPYING.LESSER b/wiringPi/COPYING.LESSER
deleted file mode 100644
index 65c5ca8..0000000
--- a/wiringPi/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/wiringPi/wiringPiFace.c b/wiringPi/wiringPiFace.c
deleted file mode 100644
index ac3c6fa..0000000
--- a/wiringPi/wiringPiFace.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * wiringPiFace:
- * Arduino compatable (ish) Wiring library for the Raspberry Pi
- * Copyright (c) 2012 Gordon Henderson
- *
- * This file to interface with the PiFace peripheral device which
- * has an MCP23S17 GPIO device connected via the SPI bus.
- *
- ***********************************************************************
- * 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 .
- ***********************************************************************
- */
-
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "wiringPi.h"
-
-
-// The SPI bus parameters
-// Variables as they need to be passed as pointers later on
-
-static char *spiDevice = "/dev/spidev0.0" ;
-static uint8_t spiMode = 0 ;
-static uint8_t spiBPW = 8 ;
-static uint32_t spiSpeed = 5000000 ;
-static uint16_t spiDelay = 0;
-
-// Locals here to keep track of everything
-
-static int spiFd ;
-
-// The MCP23S17 doesn't have bit-set operations, so it's
-// cheaper to keep a copy here than to read/modify/write it
-
-uint8_t dataOutRegister = 0 ;
-uint8_t pudRegister = 0 ;
-
-// MCP23S17 Registers
-
-#define IOCON 0x0A
-
-#define IODIRA 0x00
-#define IPOLA 0x02
-#define GPINTENA 0x04
-#define DEFVALA 0x06
-#define INTCONA 0x08
-#define GPPUA 0x0C
-#define INTFA 0x0E
-#define INTCAPA 0x10
-#define GPIOA 0x12
-#define OLATA 0x14
-
-#define IODIRB 0x01
-#define IPOLB 0x03
-#define GPINTENB 0x05
-#define DEFVALB 0x07
-#define INTCONB 0x09
-#define GPPUB 0x0D
-#define INTFB 0x0F
-#define INTCAPB 0x11
-#define GPIOB 0x13
-#define OLATB 0x15
-
-// Bits in the IOCON register
-
-#define IOCON_BANK_MODE 0x80
-#define IOCON_MIRROR 0x40
-#define IOCON_SEQOP 0x20
-#define IOCON_DISSLW 0x10
-#define IOCON_HAEN 0x08
-#define IOCON_ODR 0x04
-#define IOCON_INTPOL 0x02
-#define IOCON_UNUSED 0x01
-
-// Default initialisation mode
-
-#define IOCON_INIT (IOCON_SEQOP)
-
-// Command codes
-
-#define CMD_WRITE 0x40
-#define CMD_READ 0x41
-
-
-/*
- * writeByte:
- * Write a byte to a register on the MCP23S17 on the SPI bus.
- * This is using the synchronous access mechanism.
- *********************************************************************************
- */
-
-static void writeByte (uint8_t reg, uint8_t data)
-{
- uint8_t spiBufTx [3] ;
- uint8_t spiBufRx [3] ;
- struct spi_ioc_transfer spi ;
-
- spiBufTx [0] = CMD_WRITE ;
- spiBufTx [1] = reg ;
- spiBufTx [2] = data ;
-
- spi.tx_buf = (unsigned long)spiBufTx ;
- spi.rx_buf = (unsigned long)spiBufRx ;
- spi.len = 3 ;
- spi.delay_usecs = spiDelay ;
- spi.speed_hz = spiSpeed ;
- spi.bits_per_word = spiBPW ;
-
- ioctl (spiFd, SPI_IOC_MESSAGE(1), &spi) ;
-}
-
-/*
- * readByte:
- * Read a byte from a register on the MCP23S17 on the SPI bus.
- * This is the synchronous access mechanism.
- * What appears to happen is that the data returned is at
- * the same offset as the number of bytes written to the device. So if we
- * write 2 bytes (e.g. command then register number), then the data returned
- * will by at the 3rd byte...
- *********************************************************************************
- */
-
-static uint8_t readByte (uint8_t reg)
-{
- uint8_t tx [4] ;
- uint8_t rx [4] ;
- struct spi_ioc_transfer spi ;
-
- tx [0] = CMD_READ ;
- tx [1] = reg ;
- tx [2] = 0 ;
-
- spi.tx_buf = (unsigned long)tx ;
- spi.rx_buf = (unsigned long)rx ;
- spi.len = 3 ;
- spi.delay_usecs = spiDelay ;
- spi.speed_hz = spiSpeed ;
- spi.bits_per_word = spiBPW ;
-
- ioctl (spiFd, SPI_IOC_MESSAGE(1), &spi) ;
-
- return rx [2] ;
-}
-
-
-/*
- * digitalWritePiFace:
- * Perform the digitalWrite function on the PiFace board
- *********************************************************************************
- */
-
-void digitalWritePiFace (int pin, int value)
-{
- uint8_t mask = 1 << pin ;
-
- if (value == 0)
- dataOutRegister &= (~mask) ;
- else
- dataOutRegister |= mask ;
-
- writeByte (GPIOA, dataOutRegister) ;
-}
-
-void digitalWriteBytePiFace (int value)
-{
- writeByte (GPIOA, value) ;
-}
-
-
-void digitalWritePiFaceSpecial (int pin, int value)
-{
- uint8_t mask = 1 << pin ;
- uint8_t old ;
-
- old = readByte (GPIOA) ;
-
- if (value == 0)
- old &= (~mask) ;
- else
- old |= mask ;
-
- writeByte (GPIOA, old) ;
-}
-
-
-/*
- * digitalReadPiFace:
- * Perform the digitalRead function on the PiFace board
- *********************************************************************************
- */
-
-int digitalReadPiFace (int pin)
-{
- uint8_t mask = 1 << pin ;
-
- if ((readByte (GPIOB) & mask) != 0)
- return HIGH ;
- else
- return LOW ;
-}
-
-
-/*
- * pullUpDnControlPiFace:
- * Perform the pullUpDnControl function on the PiFace board
- *********************************************************************************
- */
-
-void pullUpDnControlPiFace (int pin, int pud)
-{
- uint8_t mask = 1 << pin ;
-
- if (pud == PUD_UP)
- pudRegister |= mask ;
- else
- pudRegister &= (~mask) ;
-
- writeByte (GPPUB, pudRegister) ;
-
-}
-
-
-void pullUpDnControlPiFaceSpecial (int pin, int pud)
-{
- uint8_t mask = 1 << pin ;
- uint8_t old ;
-
- old = readByte (GPPUB) ;
-
- if (pud == PUD_UP)
- old |= mask ;
- else
- old &= (~mask) ;
-
- writeByte (GPPUB, old) ;
-
-}
-
-
-
-/*
- * Dummy functions that are not used in this mode
- *********************************************************************************
- */
-
-void pinModePiFace (int pin, int mode) {}
-void pwmWritePiFace (int pin, int value) {}
-int waitForInterruptPiFace (int pin, int mS) { return 0 ; }
-
-
-/*
- * wiringPiSetupPiFace
- * Setup the SPI interface and initialise the MCP23S17 chip
- *********************************************************************************
- */
-
-static int _wiringPiSetupPiFace (void)
-{
- if ((spiFd = open (spiDevice, O_RDWR)) < 0)
- return -1 ;
-
-// Set SPI parameters
-// Why are we doing a read after write?
-// I don't know - just blindliy copying an example elsewhere... -GH-
-
- if (ioctl (spiFd, SPI_IOC_WR_MODE, &spiMode) < 0)
- return -1 ;
-
- if (ioctl (spiFd, SPI_IOC_RD_MODE, &spiMode) < 0)
- return -1 ;
-
- if (ioctl (spiFd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0)
- return -1 ;
-
- if (ioctl (spiFd, SPI_IOC_RD_BITS_PER_WORD, &spiBPW) < 0)
- return -1 ;
-
- if (ioctl (spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &spiSpeed) < 0)
- return -1 ;
-
- if (ioctl (spiFd, SPI_IOC_RD_MAX_SPEED_HZ, &spiSpeed) < 0)
- return -1 ;
-
-// Setup the MCP23S17
-
- writeByte (IOCON, IOCON_INIT) ;
-
- writeByte (IODIRA, 0x00) ; // Port A -> Outputs
- writeByte (IODIRB, 0xFF) ; // Port B -> Inputs
-
- return 0 ;
-}
-
-
-int wiringPiSetupPiFace (void)
-{
- int x = _wiringPiSetupPiFace () ;
-
- if (x != 0)
- return x ;
-
- writeByte (GPIOA, 0x00) ; // Set all outptus off
- writeByte (GPPUB, 0x00) ; // Disable any pull-ups on port B
-
- pinMode = pinModePiFace ;
- pullUpDnControl = pullUpDnControlPiFace ;
- digitalWrite = digitalWritePiFace ;
- digitalWriteByte = digitalWriteBytePiFace ;
- pwmWrite = pwmWritePiFace ;
- digitalRead = digitalReadPiFace ;
- waitForInterrupt = waitForInterruptPiFace ;
-
- return 0 ;
-}
-
-
-/*
- * wiringPiSetupPiFaceForGpioProg:
- * Setup the SPI interface and initialise the MCP23S17 chip
- * Special version for the gpio program
- *********************************************************************************
- */
-
-
-int wiringPiSetupPiFaceForGpioProg (void)
-{
- int x = _wiringPiSetupPiFace () ;
-
- if (x != 0)
- return x ;
-
- pinMode = pinModePiFace ;
- pullUpDnControl = pullUpDnControlPiFaceSpecial ;
- digitalWrite = digitalWritePiFaceSpecial ;
- digitalWriteByte = digitalWriteBytePiFace ;
- pwmWrite = pwmWritePiFace ;
- digitalRead = digitalReadPiFace ;
- waitForInterrupt = waitForInterruptPiFace ;
-
- return 0 ;
-}
diff --git a/wiringPi/wiringPiI2C.c b/wiringPi/wiringPiI2C.c
deleted file mode 100644
index 93fe1d3..0000000
--- a/wiringPi/wiringPiI2C.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * wiringPiI2C.c:
- * Simplified I2C access routines
- * 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 .
- ***********************************************************************
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "wiringPi.h"
-#include "wiringPiI2C.h"
-
-
-/*
- * wiringPiI2CRead:
- * Simple device read
- *********************************************************************************
- */
-
-int wiringPiI2CRead (int fd)
-{
- return i2c_smbus_read_byte (fd) ;
-}
-
-
-/*
- * wiringPiI2CReadReg8: wiringPiI2CReadReg16:
- * Read an 8 or 16-bit value from a regsiter on the device
- *********************************************************************************
- */
-
-int wiringPiI2CReadReg8 (int fd, int reg)
-{
- return i2c_smbus_read_byte_data (fd, reg) ;
-}
-
-int wiringPiI2CReadReg16 (int fd, int reg)
-{
- return i2c_smbus_read_word_data (fd, reg) ;
-}
-
-
-/*
- * wiringPiI2CWrite:
- * Simple device write
- *********************************************************************************
- */
-
-int wiringPiI2CWrite (int fd, int data)
-{
- return i2c_smbus_write_byte (fd, data) ;
-}
-
-
-/*
- * wiringPiI2CWriteReg8: wiringPiI2CWriteReg16:
- * Write an 8 or 16-bit value to the given register
- *********************************************************************************
- */
-
-int wiringPiI2CWriteReg8 (int fd, int reg, int data)
-{
- return i2c_smbus_write_byte_data (fd, reg, data) ;
-}
-
-int wiringPiI2CWriteReg16 (int fd, int reg, int data)
-{
- return i2c_smbus_write_word_data (fd, reg, data) ;
-}
-
-
-/*
- * wiringPiI2CSetup:
- * Open the I2C device, and regsiter the target device
- *********************************************************************************
- */
-
-int wiringPiI2CSetup (int devId)
-{
- int rev, fd ;
- char *device ;
-
- if ((rev = piBoardRev ()) < 0)
- {
- fprintf (stderr, "wiringPiI2CSetup: Unable to determine Pi board revision\n") ;
- exit (1) ;
- }
-
- if (rev == 1)
- device = "/dev/i2c-0" ;
- else
- device = "/dev/i2c-1" ;
-
- if ((fd = open (device, O_RDWR)) < 0)
- return -1 ;
-
- if (ioctl (fd, I2C_SLAVE, devId) < 0)
- return -1 ;
-
- return fd ;
-}
diff --git a/wiringpi.i b/wiringpi.i
new file mode 100644
index 0000000..6d275eb
--- /dev/null
+++ b/wiringpi.i
@@ -0,0 +1,127 @@
+%module wiringpi
+
+%{
+#include "WiringPi/wiringPi/ds1302.h",
+#include "WiringPi/wiringPi/gertboard.h",
+#include "WiringPi/wiringPi/lcd.h",
+#include "WiringPi/wiringPi/mcp23008.h",
+#include "WiringPi/wiringPi/mcp23017.h",
+#include "WiringPi/wiringPi/mcp23s08.h",
+#include "WiringPi/wiringPi/mcp23s17.h",
+#include "WiringPi/wiringPi/mcp23x0817.h",
+#include "WiringPi/wiringPi/mcp23x08.h",
+#include "WiringPi/wiringPi/piFace.h",
+#include "WiringPi/wiringPi/piNes.h",
+#include "WiringPi/wiringPi/softPwm.h",
+#include "WiringPi/wiringPi/softServo.h",
+#include "WiringPi/wiringPi/softTone.h",
+#include "WiringPi/wiringPi/sr595.h",
+#include "WiringPi/wiringPi/wiringPi.h",
+#include "WiringPi/wiringPi/wiringPiI2C.h",
+#include "WiringPi/wiringPi/wiringPiSPI.h",
+#include "WiringPi/wiringPi/wiringSerial.h",
+#include "WiringPi/wiringPi/wiringShift.h"
+%}
+
+%apply unsigned char { uint8_t };
+
+extern int wiringPiSetup (void) ;
+extern int wiringPiSetupSys (void) ;
+extern int wiringPiSetupGpio (void) ;
+
+extern int piFaceSetup (int pinbase) ;
+
+extern int piBoardRev (void) ;
+extern int wpiPinToGpio (int wpiPin) ;
+
+extern void pinMode (int pin, int mode) ;
+extern int getAlt (int pin) ;
+extern void pullUpDnControl (int pin, int pud) ;
+extern void digitalWrite (int pin, int value) ;
+extern void digitalWriteByte (int value) ;
+extern void gpioClockSet (int pin, int freq) ;
+extern void pwmWrite (int pin, int value) ;
+extern void setPadDrive (int group, int value) ;
+extern int digitalRead (int pin) ;
+extern void pwmSetMode (int mode) ;
+extern void pwmSetRange (unsigned int range) ;
+extern void pwmSetClock (int divisor) ;
+
+// Interrupts
+
+extern int (*waitForInterrupt) (int pin, int mS) ;
+extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
+
+// Threads
+
+extern int piThreadCreate (void *(*fn)(void *)) ;
+extern void piLock (int key) ;
+extern void piUnlock (int key) ;
+
+// Extras from arduino land
+
+extern void delay (unsigned int howLong) ;
+extern void delayMicroseconds (unsigned int howLong) ;
+extern unsigned int millis (void) ;
+extern unsigned int micros (void) ;
+
+// WiringSerial
+
+extern int serialOpen (char *device, int baud) ;
+extern void serialClose (int fd) ;
+extern void serialFlush (int fd) ;
+extern void serialPutchar (int fd, unsigned char c) ;
+extern void serialPuts (int fd, char *s) ;
+extern void serialPrintf (int fd, char *message, ...) ;
+extern int serialDataAvail (int fd) ;
+extern int serialGetchar (int fd) ;
+
+// Shifting
+
+extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val);
+extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order);
+
+// Spi
+
+%typemap(in) (unsigned char *data, int len) {
+ $1 = (unsigned char *) PyString_AsString($input);
+ $2 = PyString_Size($input);
+};
+
+int wiringPiSPIGetFd (int channel) ;
+int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ;
+int wiringPiSPISetup (int channel, int speed) ;
+
+// i2c
+
+extern int wiringPiI2CRead (int fd) ;
+extern int wiringPiI2CReadReg8 (int fd, int reg) ;
+extern int wiringPiI2CReadReg16 (int fd, int reg) ;
+
+extern int wiringPiI2CWrite (int fd, int data) ;
+extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;
+extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;
+
+// Soft Tone
+
+extern int softToneCreate (int pin) ;
+extern void softToneWrite (int pin, int frewq) ;
+
+// Soft Servo
+
+extern void softServoWrite (int pin, int value) ;
+extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ;
+
+// Soft PWM
+
+extern int softPwmCreate (int pin, int value, int range) ;
+extern void softPwmWrite (int pin, int value) ;
+
+
+extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ;
+extern int mcp23017Setup (int pinBase, int i2cAddress) ;
+
+extern int mcp23s08Setup (int pinBase, int spiPort, int devId) ;
+extern int mcp23008Setup (int pinBase, int i2cAddress) ;
+
+extern int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ;
diff --git a/wiringpi.py b/wiringpi.py
new file mode 100644
index 0000000..0dc402c
--- /dev/null
+++ b/wiringpi.py
@@ -0,0 +1,297 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 2.0.7
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+
+
+
+from sys import version_info
+if version_info >= (2,6,0):
+ def swig_import_helper():
+ from os.path import dirname
+ import imp
+ fp = None
+ try:
+ fp, pathname, description = imp.find_module('_wiringpi', [dirname(__file__)])
+ except ImportError:
+ import _wiringpi
+ return _wiringpi
+ if fp is not None:
+ try:
+ _mod = imp.load_module('_wiringpi', fp, pathname, description)
+ finally:
+ fp.close()
+ return _mod
+ _wiringpi = swig_import_helper()
+ del swig_import_helper
+else:
+ import _wiringpi
+del version_info
+try:
+ _swig_property = property
+except NameError:
+ pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+ if (name == "thisown"): return self.this.own(value)
+ if (name == "this"):
+ if type(value).__name__ == 'SwigPyObject':
+ self.__dict__[name] = value
+ return
+ method = class_type.__swig_setmethods__.get(name,None)
+ if method: return method(self,value)
+ if (not static):
+ self.__dict__[name] = value
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+ return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+ if (name == "thisown"): return self.this.own()
+ method = class_type.__swig_getmethods__.get(name,None)
+ if method: return method(self)
+ raise AttributeError(name)
+
+def _swig_repr(self):
+ try: strthis = "proxy of " + self.this.__repr__()
+ except: strthis = ""
+ return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+ _object = object
+ _newclass = 1
+except AttributeError:
+ class _object : pass
+ _newclass = 0
+
+
+
+def wiringPiSetup():
+ return _wiringpi.wiringPiSetup()
+wiringPiSetup = _wiringpi.wiringPiSetup
+
+def wiringPiSetupSys():
+ return _wiringpi.wiringPiSetupSys()
+wiringPiSetupSys = _wiringpi.wiringPiSetupSys
+
+def wiringPiSetupGpio():
+ return _wiringpi.wiringPiSetupGpio()
+wiringPiSetupGpio = _wiringpi.wiringPiSetupGpio
+
+def piFaceSetup(*args):
+ return _wiringpi.piFaceSetup(*args)
+piFaceSetup = _wiringpi.piFaceSetup
+
+def piBoardRev():
+ return _wiringpi.piBoardRev()
+piBoardRev = _wiringpi.piBoardRev
+
+def wpiPinToGpio(*args):
+ return _wiringpi.wpiPinToGpio(*args)
+wpiPinToGpio = _wiringpi.wpiPinToGpio
+
+def pinMode(*args):
+ return _wiringpi.pinMode(*args)
+pinMode = _wiringpi.pinMode
+
+def getAlt(*args):
+ return _wiringpi.getAlt(*args)
+getAlt = _wiringpi.getAlt
+
+def pullUpDnControl(*args):
+ return _wiringpi.pullUpDnControl(*args)
+pullUpDnControl = _wiringpi.pullUpDnControl
+
+def digitalWrite(*args):
+ return _wiringpi.digitalWrite(*args)
+digitalWrite = _wiringpi.digitalWrite
+
+def digitalWriteByte(*args):
+ return _wiringpi.digitalWriteByte(*args)
+digitalWriteByte = _wiringpi.digitalWriteByte
+
+def gpioClockSet(*args):
+ return _wiringpi.gpioClockSet(*args)
+gpioClockSet = _wiringpi.gpioClockSet
+
+def pwmWrite(*args):
+ return _wiringpi.pwmWrite(*args)
+pwmWrite = _wiringpi.pwmWrite
+
+def setPadDrive(*args):
+ return _wiringpi.setPadDrive(*args)
+setPadDrive = _wiringpi.setPadDrive
+
+def digitalRead(*args):
+ return _wiringpi.digitalRead(*args)
+digitalRead = _wiringpi.digitalRead
+
+def pwmSetMode(*args):
+ return _wiringpi.pwmSetMode(*args)
+pwmSetMode = _wiringpi.pwmSetMode
+
+def pwmSetRange(*args):
+ return _wiringpi.pwmSetRange(*args)
+pwmSetRange = _wiringpi.pwmSetRange
+
+def pwmSetClock(*args):
+ return _wiringpi.pwmSetClock(*args)
+pwmSetClock = _wiringpi.pwmSetClock
+
+def wiringPiISR(*args):
+ return _wiringpi.wiringPiISR(*args)
+wiringPiISR = _wiringpi.wiringPiISR
+
+def piThreadCreate(*args):
+ return _wiringpi.piThreadCreate(*args)
+piThreadCreate = _wiringpi.piThreadCreate
+
+def piLock(*args):
+ return _wiringpi.piLock(*args)
+piLock = _wiringpi.piLock
+
+def piUnlock(*args):
+ return _wiringpi.piUnlock(*args)
+piUnlock = _wiringpi.piUnlock
+
+def delay(*args):
+ return _wiringpi.delay(*args)
+delay = _wiringpi.delay
+
+def delayMicroseconds(*args):
+ return _wiringpi.delayMicroseconds(*args)
+delayMicroseconds = _wiringpi.delayMicroseconds
+
+def millis():
+ return _wiringpi.millis()
+millis = _wiringpi.millis
+
+def micros():
+ return _wiringpi.micros()
+micros = _wiringpi.micros
+
+def serialOpen(*args):
+ return _wiringpi.serialOpen(*args)
+serialOpen = _wiringpi.serialOpen
+
+def serialClose(*args):
+ return _wiringpi.serialClose(*args)
+serialClose = _wiringpi.serialClose
+
+def serialFlush(*args):
+ return _wiringpi.serialFlush(*args)
+serialFlush = _wiringpi.serialFlush
+
+def serialPutchar(*args):
+ return _wiringpi.serialPutchar(*args)
+serialPutchar = _wiringpi.serialPutchar
+
+def serialPuts(*args):
+ return _wiringpi.serialPuts(*args)
+serialPuts = _wiringpi.serialPuts
+
+def serialPrintf(*args):
+ return _wiringpi.serialPrintf(*args)
+serialPrintf = _wiringpi.serialPrintf
+
+def serialDataAvail(*args):
+ return _wiringpi.serialDataAvail(*args)
+serialDataAvail = _wiringpi.serialDataAvail
+
+def serialGetchar(*args):
+ return _wiringpi.serialGetchar(*args)
+serialGetchar = _wiringpi.serialGetchar
+
+def shiftOut(*args):
+ return _wiringpi.shiftOut(*args)
+shiftOut = _wiringpi.shiftOut
+
+def shiftIn(*args):
+ return _wiringpi.shiftIn(*args)
+shiftIn = _wiringpi.shiftIn
+
+def wiringPiSPIGetFd(*args):
+ return _wiringpi.wiringPiSPIGetFd(*args)
+wiringPiSPIGetFd = _wiringpi.wiringPiSPIGetFd
+
+def wiringPiSPIDataRW(*args):
+ return _wiringpi.wiringPiSPIDataRW(*args)
+wiringPiSPIDataRW = _wiringpi.wiringPiSPIDataRW
+
+def wiringPiSPISetup(*args):
+ return _wiringpi.wiringPiSPISetup(*args)
+wiringPiSPISetup = _wiringpi.wiringPiSPISetup
+
+def wiringPiI2CRead(*args):
+ return _wiringpi.wiringPiI2CRead(*args)
+wiringPiI2CRead = _wiringpi.wiringPiI2CRead
+
+def wiringPiI2CReadReg8(*args):
+ return _wiringpi.wiringPiI2CReadReg8(*args)
+wiringPiI2CReadReg8 = _wiringpi.wiringPiI2CReadReg8
+
+def wiringPiI2CReadReg16(*args):
+ return _wiringpi.wiringPiI2CReadReg16(*args)
+wiringPiI2CReadReg16 = _wiringpi.wiringPiI2CReadReg16
+
+def wiringPiI2CWrite(*args):
+ return _wiringpi.wiringPiI2CWrite(*args)
+wiringPiI2CWrite = _wiringpi.wiringPiI2CWrite
+
+def wiringPiI2CWriteReg8(*args):
+ return _wiringpi.wiringPiI2CWriteReg8(*args)
+wiringPiI2CWriteReg8 = _wiringpi.wiringPiI2CWriteReg8
+
+def wiringPiI2CWriteReg16(*args):
+ return _wiringpi.wiringPiI2CWriteReg16(*args)
+wiringPiI2CWriteReg16 = _wiringpi.wiringPiI2CWriteReg16
+
+def softToneCreate(*args):
+ return _wiringpi.softToneCreate(*args)
+softToneCreate = _wiringpi.softToneCreate
+
+def softToneWrite(*args):
+ return _wiringpi.softToneWrite(*args)
+softToneWrite = _wiringpi.softToneWrite
+
+def softServoWrite(*args):
+ return _wiringpi.softServoWrite(*args)
+softServoWrite = _wiringpi.softServoWrite
+
+def softServoSetup(*args):
+ return _wiringpi.softServoSetup(*args)
+softServoSetup = _wiringpi.softServoSetup
+
+def softPwmCreate(*args):
+ return _wiringpi.softPwmCreate(*args)
+softPwmCreate = _wiringpi.softPwmCreate
+
+def softPwmWrite(*args):
+ return _wiringpi.softPwmWrite(*args)
+softPwmWrite = _wiringpi.softPwmWrite
+
+def mcp23s17Setup(*args):
+ return _wiringpi.mcp23s17Setup(*args)
+mcp23s17Setup = _wiringpi.mcp23s17Setup
+
+def mcp23017Setup(*args):
+ return _wiringpi.mcp23017Setup(*args)
+mcp23017Setup = _wiringpi.mcp23017Setup
+
+def mcp23s08Setup(*args):
+ return _wiringpi.mcp23s08Setup(*args)
+mcp23s08Setup = _wiringpi.mcp23s08Setup
+
+def mcp23008Setup(*args):
+ return _wiringpi.mcp23008Setup(*args)
+mcp23008Setup = _wiringpi.mcp23008Setup
+
+def sr595Setup(*args):
+ return _wiringpi.sr595Setup(*args)
+sr595Setup = _wiringpi.sr595Setup
+# This file is compatible with both classic and new-style classes.
+
+cvar = _wiringpi.cvar
+
diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c
new file mode 100644
index 0000000..4c572e7
--- /dev/null
+++ b/wiringpi_wrap.c
@@ -0,0 +1,5749 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.7
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
+
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Python.h has to appear first */
+#include
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic C API SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+ or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+ creating a static or dynamic library from the SWIG runtime code.
+ In 99.9% of the cases, SWIG just needs to declare them as 'static'.
+
+ But only do this if strictly necessary, ie, if you have problems
+ with your compiler or suchlike.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/* Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN 0x1
+
+
+/*
+ Flags/methods for returning states.
+
+ The SWIG conversion methods, as ConvertPtr, return an integer
+ that tells if the conversion was successful or not. And if not,
+ an error code can be returned (see swigerrors.swg for the codes).
+
+ Use the following macros/flags to set or process the returning
+ states.
+
+ In old versions of SWIG, code such as the following was usually written:
+
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+ // success code
+ } else {
+ //fail code
+ }
+
+ Now you can be more explicit:
+
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ } else {
+ // fail code
+ }
+
+ which is the same really, but now you can also do
+
+ Type *ptr;
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ if (SWIG_IsNewObj(res) {
+ ...
+ delete *ptr;
+ } else {
+ ...
+ }
+ } else {
+ // fail code
+ }
+
+ I.e., now SWIG_ConvertPtr can return new objects and you can
+ identify the case and take care of the deallocation. Of course that
+ also requires SWIG_ConvertPtr to return new result values, such as
+
+ int SWIG_ConvertPtr(obj, ptr,...) {
+ if () {
+ if () {
+ *ptr = ;
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = ;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
+ }
+
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+ SWIG errors code.
+
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+ allows to return the 'cast rank', for example, if you have this
+
+ int food(double)
+ int fooi(int);
+
+ and you call
+
+ food(1) // cast rank '1' (1 -> 1.0)
+ fooi(1) // cast rank '0'
+
+ just use the SWIG_AddCast()/SWIG_CheckState()
+*/
+
+#define SWIG_OK (0)
+#define SWIG_ERROR (-1)
+#define SWIG_IsOK(r) (r >= 0)
+#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ (SWIG_ERROR)
+#define SWIG_OLDOBJ (SWIG_OK)
+#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+# ifndef SWIG_TypeRank
+# define SWIG_TypeRank unsigned long
+# endif
+# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
+# define SWIG_MAXCASTRANK (2)
+# endif
+# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
+# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+}
+#else /* no cast-rank mode */
+# define SWIG_AddCast
+# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+ const char *name; /* mangled name of this type */
+ const char *str; /* human readable name of this type */
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
+ void *clientdata; /* language specific type data */
+ int owndata; /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
+ swig_converter_func converter; /* function to cast the void pointers */
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
+ struct swig_cast_info *prev; /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
+ size_t size; /* Number of types in this module */
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
+ swig_type_info **type_initial; /* Array of initially generated type structures */
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
+ void *clientdata; /* Language specific module data */
+} swig_module_info;
+
+/*
+ Compare two type names skipping the space characters, therefore
+ "char*" == "char *" and "Class" == "Class", etc.
+
+ Return 0 when the two name types are equivalent, as in
+ strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+ const char *f2, const char *l2) {
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+ }
+ return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+ Check type equivalence in a name list like ||...
+ Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ Check type equivalence in a name list like ||...
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCompare(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+
+/*
+ Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (strcmp(iter->type->name, c) == 0) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
+}
+
+/*
+ Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (iter->type == from) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
+}
+
+/*
+ Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/*
+ Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+ swig_type_info *lastty = ty;
+ if (!ty || !ty->dcast) return ty;
+ while (ty && (ty->dcast)) {
+ ty = (*ty->dcast)(ptr);
+ if (ty) lastty = ty;
+ }
+ return lastty;
+}
+
+/*
+ Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+ return ty->name;
+}
+
+/*
+ Return the pretty name associated with this type,
+ that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+ /* The "str" field contains the equivalent pretty names of the
+ type, separated by vertical-bar characters. We choose
+ to print the last name, as it is often (?) the most
+ specific. */
+ if (!type) return NULL;
+ if (type->str != NULL) {
+ const char *last_name = type->str;
+ const char *s;
+ for (s = type->str; *s; s++)
+ if (*s == '|') last_name = s+1;
+ return last_name;
+ }
+ else
+ return type->name;
+}
+
+/*
+ Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+ swig_cast_info *cast = ti->cast;
+ /* if (ti->clientdata == clientdata) return; */
+ ti->clientdata = clientdata;
+
+ while (cast) {
+ if (!cast->converter) {
+ swig_type_info *tc = cast->type;
+ if (!tc->clientdata) {
+ SWIG_TypeClientData(tc, clientdata);
+ }
+ }
+ cast = cast->next;
+ }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+ SWIG_TypeClientData(ti, clientdata);
+ ti->owndata = 1;
+}
+
+/*
+ Search for a swig_type_info structure only by mangled name
+ Search is a O(log #types)
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ swig_module_info *iter = start;
+ do {
+ if (iter->size) {
+ register size_t l = 0;
+ register size_t r = iter->size - 1;
+ do {
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ register size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ register int compare = strcmp(name, iname);
+ if (compare == 0) {
+ return iter->types[i];
+ } else if (compare < 0) {
+ if (i) {
+ r = i - 1;
+ } else {
+ break;
+ }
+ } else if (compare > 0) {
+ l = i + 1;
+ }
+ } else {
+ break; /* should never happen */
+ }
+ } while (l <= r);
+ }
+ iter = iter->next;
+ } while (iter != end);
+ return 0;
+}
+
+/*
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
+ It first searches the mangled names of the types, which is a O(log #types)
+ If a type is not found it then searches the human readable names, which is O(#types).
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ /* STEP 1: Search the name field using binary search */
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+ if (ret) {
+ return ret;
+ } else {
+ /* STEP 2: If the type hasn't been found, do a complete search
+ of the str field (the human readable name) */
+ swig_module_info *iter = start;
+ do {
+ register size_t i = 0;
+ for (; i < iter->size; ++i) {
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+ return iter->types[i];
+ }
+ iter = iter->next;
+ } while (iter != end);
+ }
+
+ /* neither found a match */
+ return 0;
+}
+
+/*
+ Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ register const unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register unsigned char uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+
+/*
+ Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register char d = *(c++);
+ register unsigned char uu;
+ if ((d >= '0') && (d <= '9'))
+ uu = ((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
+ *u = uu;
+ }
+ return c;
+}
+
+/*
+ Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+ char *r = buff;
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+ strcpy(r,name);
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ *ptr = (void *) 0;
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+ char *r = buff;
+ size_t lname = (name ? strlen(name) : 0);
+ if ((2*sz + 2 + lname) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,ptr,sz);
+ if (lname) {
+ strncpy(r,name,lname+1);
+ } else {
+ *r = 0;
+ }
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ memset(ptr,0,sz);
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Errors in SWIG */
+#define SWIG_UnknownError -1
+#define SWIG_IOError -2
+#define SWIG_RuntimeError -3
+#define SWIG_IndexError -4
+#define SWIG_TypeError -5
+#define SWIG_DivisionByZero -6
+#define SWIG_OverflowError -7
+#define SWIG_SyntaxError -8
+#define SWIG_ValueError -9
+#define SWIG_SystemError -10
+#define SWIG_AttributeError -11
+#define SWIG_MemoryError -12
+#define SWIG_NullReferenceError -13
+
+
+
+/* Compatibility macros for Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+
+#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
+#define PyInt_Check(x) PyLong_Check(x)
+#define PyInt_AsLong(x) PyLong_AsLong(x)
+#define PyInt_FromLong(x) PyLong_FromLong(x)
+#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
+#define PyString_Check(name) PyBytes_Check(name)
+#define PyString_FromString(x) PyUnicode_FromString(x)
+#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
+#define PyString_AsString(str) PyBytes_AsString(str)
+#define PyString_Size(str) PyBytes_Size(str)
+#define PyString_InternFromString(key) PyUnicode_InternFromString(key)
+#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
+#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
+#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
+
+#endif
+
+#ifndef Py_TYPE
+# define Py_TYPE(op) ((op)->ob_type)
+#endif
+
+/* SWIG APIs for compatibility of both Python 2 & 3 */
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_FromFormat PyUnicode_FromFormat
+#else
+# define SWIG_Python_str_FromFormat PyString_FromFormat
+#endif
+
+
+/* Warning: This function will allocate a new string in Python 3,
+ * so please call SWIG_Python_str_DelForPy3(x) to free the space.
+ */
+SWIGINTERN char*
+SWIG_Python_str_AsChar(PyObject *str)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ char *cstr;
+ char *newstr;
+ Py_ssize_t len;
+ str = PyUnicode_AsUTF8String(str);
+ PyBytes_AsStringAndSize(str, &cstr, &len);
+ newstr = (char *) malloc(len+1);
+ memcpy(newstr, cstr, len+1);
+ Py_XDECREF(str);
+ return newstr;
+#else
+ return PyString_AsString(str);
+#endif
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
+#else
+# define SWIG_Python_str_DelForPy3(x)
+#endif
+
+
+SWIGINTERN PyObject*
+SWIG_Python_str_FromChar(const char *c)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromString(c);
+#else
+ return PyString_FromString(c);
+#endif
+}
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+# define PyOS_snprintf _snprintf
+# else
+# define PyOS_snprintf snprintf
+# endif
+#endif
+
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
+
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+ va_list ap;
+ char buf[SWIG_PYBUFFER_SIZE * 2];
+ int res;
+ va_start(ap, fmt);
+ res = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
+
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+# define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+# define PyObject_GenericGetAttr 0
+# endif
+#endif
+
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+# define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
+
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
+
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+# define PySequence_Size PySequence_Length
+# endif
+#endif
+
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+ PyObject *result = ok ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
+}
+#endif
+
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+typedef inquiry lenfunc;
+typedef intargfunc ssizeargfunc;
+typedef intintargfunc ssizessizeargfunc;
+typedef intobjargproc ssizeobjargproc;
+typedef intintobjargproc ssizessizeobjargproc;
+typedef getreadbufferproc readbufferproc;
+typedef getwritebufferproc writebufferproc;
+typedef getsegcountproc segcountproc;
+typedef getcharbufferproc charbufferproc;
+static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
+{
+ long result = 0;
+ PyObject *i = PyNumber_Int(x);
+ if (i) {
+ result = PyInt_AsLong(i);
+ Py_DECREF(i);
+ }
+ return result;
+}
+#endif
+
+#if PY_VERSION_HEX < 0x02040000
+#define Py_VISIT(op) \
+ do { \
+ if (op) { \
+ int vret = visit((op), arg); \
+ if (vret) \
+ return vret; \
+ } \
+ } while (0)
+#endif
+
+#if PY_VERSION_HEX < 0x02030000
+typedef struct {
+ PyTypeObject type;
+ PyNumberMethods as_number;
+ PyMappingMethods as_mapping;
+ PySequenceMethods as_sequence;
+ PyBufferProcs as_buffer;
+ PyObject *name, *slots;
+} PyHeapTypeObject;
+#endif
+
+#if PY_VERSION_HEX < 0x02030000
+typedef destructor freefunc;
+#endif
+
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
+ (PY_MAJOR_VERSION > 3))
+# define SWIGPY_USE_CAPSULE
+# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
+
+#if PY_VERSION_HEX < 0x03020000
+#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
+#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+ PyObject* type = 0;
+ switch(code) {
+ case SWIG_MemoryError:
+ type = PyExc_MemoryError;
+ break;
+ case SWIG_IOError:
+ type = PyExc_IOError;
+ break;
+ case SWIG_RuntimeError:
+ type = PyExc_RuntimeError;
+ break;
+ case SWIG_IndexError:
+ type = PyExc_IndexError;
+ break;
+ case SWIG_TypeError:
+ type = PyExc_TypeError;
+ break;
+ case SWIG_DivisionByZero:
+ type = PyExc_ZeroDivisionError;
+ break;
+ case SWIG_OverflowError:
+ type = PyExc_OverflowError;
+ break;
+ case SWIG_SyntaxError:
+ type = PyExc_SyntaxError;
+ break;
+ case SWIG_ValueError:
+ type = PyExc_ValueError;
+ break;
+ case SWIG_SystemError:
+ type = PyExc_SystemError;
+ break;
+ case SWIG_AttributeError:
+ type = PyExc_AttributeError;
+ break;
+ default:
+ type = PyExc_RuntimeError;
+ }
+ return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+
+ if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ char *tmp;
+ PyObject *old_str = PyObject_Str(value);
+ PyErr_Clear();
+ Py_XINCREF(type);
+
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(old_str);
+ Py_DECREF(value);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, mesg);
+ }
+}
+
+#if defined(SWIG_PYTHON_NO_THREADS)
+# if defined(SWIG_PYTHON_THREADS)
+# undef SWIG_PYTHON_THREADS
+# endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+# define SWIG_PYTHON_USE_GIL
+# endif
+# endif
+# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+# ifndef SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# endif
+# ifdef __cplusplus /* C++ code */
+ class SWIG_Python_Thread_Block {
+ bool status;
+ PyGILState_STATE state;
+ public:
+ void end() { if (status) { PyGILState_Release(state); status = false;} }
+ SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+ ~SWIG_Python_Thread_Block() { end(); }
+ };
+ class SWIG_Python_Thread_Allow {
+ bool status;
+ PyThreadState *save;
+ public:
+ void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+ SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+ ~SWIG_Python_Thread_Allow() { end(); }
+ };
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
+# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
+# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
+# else /* C code */
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
+# endif
+# else /* Old thread way, not implemented, user must provide it */
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+# define SWIG_PYTHON_THREAD_END_ALLOW
+# endif
+# endif
+#else /* No thread support */
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# define SWIG_PYTHON_THREAD_END_ALLOW
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY 5
+
+/* Constant information structure */
+typedef struct swig_const_info {
+ int type;
+ char *name;
+ long lvalue;
+ double dvalue;
+ void *pvalue;
+ swig_type_info **ptype;
+} swig_const_info;
+
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyInstanceMethod_New() used in Python 3
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+#if PY_VERSION_HEX >= 0x03000000
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)
+{
+ return PyInstanceMethod_New(func);
+}
+#else
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
+{
+ return NULL;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+
+#ifdef SWIGPYTHON_BUILTIN
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
+#else
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
+#endif
+
+#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
+
+#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
+#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype int
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
+
+#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
+#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
+#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
+#define SWIG_fail goto fail
+
+
+/* Runtime API implementation */
+
+/* Error manipulation */
+
+SWIGINTERN void
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetObject(errtype, obj);
+ Py_DECREF(obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+SWIGINTERN void
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(errtype, msg);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
+
+/* Set a constant value */
+
+#if defined(SWIGPYTHON_BUILTIN)
+
+SWIGINTERN void
+SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
+ PyObject *s = PyString_InternFromString(key);
+ PyList_Append(seq, s);
+ Py_DECREF(s);
+}
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
+#if PY_VERSION_HEX < 0x02030000
+ PyDict_SetItemString(d, (char *)name, obj);
+#else
+ PyDict_SetItemString(d, name, obj);
+#endif
+ Py_DECREF(obj);
+ if (public_interface)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, name);
+}
+
+#else
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+#if PY_VERSION_HEX < 0x02030000
+ PyDict_SetItemString(d, (char *)name, obj);
+#else
+ PyDict_SetItemString(d, name, obj);
+#endif
+ Py_DECREF(obj);
+}
+
+#endif
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyList_Check(result)) {
+ PyObject *o2 = result;
+ result = PyList_New(1);
+ PyList_SetItem(result, 0, o2);
+ }
+ PyList_Append(result,obj);
+ Py_DECREF(obj);
+ }
+ return result;
+#else
+ PyObject* o2;
+ PyObject* o3;
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyTuple_Check(result)) {
+ o2 = result;
+ result = PyTuple_New(1);
+ PyTuple_SET_ITEM(result, 0, o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SET_ITEM(o3, 0, obj);
+ o2 = result;
+ result = PySequence_Concat(o2, o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+ return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+{
+ if (!args) {
+ if (!min && !max) {
+ return 1;
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
+ name, (min == max ? "" : "at least "), (int)min);
+ return 0;
+ }
+ }
+ if (!PyTuple_Check(args)) {
+ if (min <= 1 && max >= 1) {
+ register int i;
+ objs[0] = args;
+ for (i = 1; i < max; ++i) {
+ objs[i] = 0;
+ }
+ return 2;
+ }
+ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+ return 0;
+ } else {
+ register Py_ssize_t l = PyTuple_GET_SIZE(args);
+ if (l < min) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at least "), (int)min, (int)l);
+ return 0;
+ } else if (l > max) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at most "), (int)max, (int)l);
+ return 0;
+ } else {
+ register int i;
+ for (i = 0; i < l; ++i) {
+ objs[i] = PyTuple_GET_ITEM(args, i);
+ }
+ for (; l < max; ++l) {
+ objs[l] = 0;
+ }
+ return i + 1;
+ }
+ }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+ Helper for static pointer initialization for both C and C++ code, for example
+ static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var) var
+#else
+#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
+#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
+
+#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
+#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# ifndef SWIG_PYTHON_NO_BUILD_NONE
+# ifndef SWIG_PYTHON_BUILD_NONE
+# define SWIG_PYTHON_BUILD_NONE
+# endif
+# endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+# ifdef Py_None
+# undef Py_None
+# define Py_None SWIG_Py_None()
+# endif
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_Py_None(void)
+{
+ PyObject *none = Py_BuildValue((char*)"");
+ Py_DECREF(none);
+ return none;
+}
+SWIGRUNTIME PyObject *
+SWIG_Py_None(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+ return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Py_Void(void)
+{
+ PyObject *none = Py_None;
+ Py_INCREF(none);
+ return none;
+}
+
+/* SwigPyClientData */
+
+typedef struct {
+ PyObject *klass;
+ PyObject *newraw;
+ PyObject *newargs;
+ PyObject *destroy;
+ int delargs;
+ int implicitconv;
+ PyTypeObject *pytype;
+} SwigPyClientData;
+
+SWIGRUNTIMEINLINE int
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+ SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
+ return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+ SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
+ PyObject *klass = data ? data->klass : 0;
+ return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME SwigPyClientData *
+SwigPyClientData_New(PyObject* obj)
+{
+ if (!obj) {
+ return 0;
+ } else {
+ SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
+ /* the klass element */
+ data->klass = obj;
+ Py_INCREF(data->klass);
+ /* the newraw method and newargs arguments used to create a new raw instance */
+ if (PyClass_Check(obj)) {
+ data->newraw = 0;
+ data->newargs = obj;
+ Py_INCREF(obj);
+ } else {
+#if (PY_VERSION_HEX < 0x02020000)
+ data->newraw = 0;
+#else
+ data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+ if (data->newraw) {
+ Py_INCREF(data->newraw);
+ data->newargs = PyTuple_New(1);
+ PyTuple_SetItem(data->newargs, 0, obj);
+ } else {
+ data->newargs = obj;
+ }
+ Py_INCREF(data->newargs);
+ }
+ /* the destroy method, aka as the C++ delete method */
+ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ data->destroy = 0;
+ }
+ if (data->destroy) {
+ int flags;
+ Py_INCREF(data->destroy);
+ flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+ data->delargs = !(flags & (METH_O));
+#else
+ data->delargs = 0;
+#endif
+ } else {
+ data->delargs = 0;
+ }
+ data->implicitconv = 0;
+ data->pytype = 0;
+ return data;
+ }
+}
+
+SWIGRUNTIME void
+SwigPyClientData_Del(SwigPyClientData *data) {
+ Py_XDECREF(data->newraw);
+ Py_XDECREF(data->newargs);
+ Py_XDECREF(data->destroy);
+}
+
+/* =============== SwigPyObject =====================*/
+
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+#ifdef SWIGPYTHON_BUILTIN
+ PyObject *dict;
+#endif
+} SwigPyObject;
+
+SWIGRUNTIME PyObject *
+SwigPyObject_long(SwigPyObject *v)
+{
+ return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_format(const char* fmt, SwigPyObject *v)
+{
+ PyObject *res = NULL;
+ PyObject *args = PyTuple_New(1);
+ if (args) {
+ if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
+ PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
+ if (ofmt) {
+#if PY_VERSION_HEX >= 0x03000000
+ res = PyUnicode_Format(ofmt,args);
+#else
+ res = PyString_Format(ofmt,args);
+#endif
+ Py_DECREF(ofmt);
+ }
+ Py_DECREF(args);
+ }
+ }
+ return res;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_oct(SwigPyObject *v)
+{
+ return SwigPyObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_hex(SwigPyObject *v)
+{
+ return SwigPyObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+SwigPyObject_repr(SwigPyObject *v)
+#else
+SwigPyObject_repr(SwigPyObject *v, PyObject *args)
+#endif
+{
+ const char *name = SWIG_TypePrettyName(v->ty);
+ PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v);
+ if (v->next) {
+# ifdef METH_NOARGS
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
+# else
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
+# endif
+# if PY_VERSION_HEX >= 0x03000000
+ PyObject *joined = PyUnicode_Concat(repr, nrep);
+ Py_DecRef(repr);
+ Py_DecRef(nrep);
+ repr = joined;
+# else
+ PyString_ConcatAndDel(&repr,nrep);
+# endif
+ }
+ return repr;
+}
+
+SWIGRUNTIME int
+SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char *str;
+#ifdef METH_NOARGS
+ PyObject *repr = SwigPyObject_repr(v);
+#else
+ PyObject *repr = SwigPyObject_repr(v, NULL);
+#endif
+ if (repr) {
+ str = SWIG_Python_str_AsChar(repr);
+ fputs(str, fp);
+ SWIG_Python_str_DelForPy3(str);
+ Py_DECREF(repr);
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_str(SwigPyObject *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+ SWIG_Python_str_FromChar(result) : 0;
+}
+
+SWIGRUNTIME int
+SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
+{
+ void *i = v->ptr;
+ void *j = w->ptr;
+ return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+/* Added for Python 3.x, would it also be useful for Python 2.x? */
+SWIGRUNTIME PyObject*
+SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
+{
+ PyObject* res;
+ if( op != Py_EQ && op != Py_NE ) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+ res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
+ return res;
+}
+
+
+SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
+
+#ifdef SWIGPYTHON_BUILTIN
+static swig_type_info *SwigPyObject_stype = 0;
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+ SwigPyClientData *cd;
+ assert(SwigPyObject_stype);
+ cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+ assert(cd);
+ assert(cd->pytype);
+ return cd->pytype;
+}
+#else
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
+ return type;
+}
+#endif
+
+SWIGRUNTIMEINLINE int
+SwigPyObject_Check(PyObject *op) {
+#ifdef SWIGPYTHON_BUILTIN
+ PyTypeObject *target_tp = SwigPyObject_type();
+ if (PyType_IsSubtype(op->ob_type, target_tp))
+ return 1;
+ return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
+#else
+ return (Py_TYPE(op) == SwigPyObject_type())
+ || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
+#endif
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+SwigPyObject_dealloc(PyObject *v)
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ PyObject *next = sobj->next;
+ if (sobj->own == SWIG_POINTER_OWN) {
+ swig_type_info *ty = sobj->ty;
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+ PyObject *destroy = data ? data->destroy : 0;
+ if (destroy) {
+ /* destroy is always a VARARGS method */
+ PyObject *res;
+ if (data->delargs) {
+ /* we need to create a temporary object to carry the destroy operation */
+ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
+ res = SWIG_Python_CallFunctor(destroy, tmp);
+ Py_DECREF(tmp);
+ } else {
+ PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+ PyObject *mself = PyCFunction_GET_SELF(destroy);
+ res = ((*meth)(mself, v));
+ }
+ Py_XDECREF(res);
+ }
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
+ }
+#endif
+ }
+ Py_XDECREF(next);
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject*
+SwigPyObject_append(PyObject* v, PyObject* next)
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+#ifndef METH_O
+ PyObject *tmp = 0;
+ if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+ next = tmp;
+#endif
+ if (!SwigPyObject_Check(next)) {
+ return NULL;
+ }
+ sobj->next = next;
+ Py_INCREF(next);
+ return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_next(PyObject* v)
+#else
+SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ if (sobj->next) {
+ Py_INCREF(sobj->next);
+ return sobj->next;
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_disown(PyObject *v)
+#else
+SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ sobj->own = 0;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_acquire(PyObject *v)
+#else
+SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ sobj->own = SWIG_POINTER_OWN;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+SwigPyObject_own(PyObject *v, PyObject *args)
+{
+ PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+ if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#elif (PY_VERSION_HEX < 0x02050000)
+ if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
+#else
+ if (!PyArg_UnpackTuple(args, "own", 0, 1, &val))
+#endif
+ {
+ return NULL;
+ }
+ else
+ {
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+#ifdef METH_NOARGS
+ if (PyObject_IsTrue(val)) {
+ SwigPyObject_acquire(v);
+ } else {
+ SwigPyObject_disown(v);
+ }
+#else
+ if (PyObject_IsTrue(val)) {
+ SwigPyObject_acquire(v,args);
+ } else {
+ SwigPyObject_disown(v,args);
+ }
+#endif
+ }
+ return obj;
+ }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+SwigPyObject_getattr(SwigPyObject *sobj,char *name)
+{
+ return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_TypeOnce(void) {
+ static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+
+ static PyNumberMethods SwigPyObject_as_number = {
+ (binaryfunc)0, /*nb_add*/
+ (binaryfunc)0, /*nb_subtract*/
+ (binaryfunc)0, /*nb_multiply*/
+ /* nb_divide removed in Python 3 */
+#if PY_VERSION_HEX < 0x03000000
+ (binaryfunc)0, /*nb_divide*/
+#endif
+ (binaryfunc)0, /*nb_remainder*/
+ (binaryfunc)0, /*nb_divmod*/
+ (ternaryfunc)0,/*nb_power*/
+ (unaryfunc)0, /*nb_negative*/
+ (unaryfunc)0, /*nb_positive*/
+ (unaryfunc)0, /*nb_absolute*/
+ (inquiry)0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*nb_coerce*/
+#endif
+ (unaryfunc)SwigPyObject_long, /*nb_int*/
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_long, /*nb_long*/
+#else
+ 0, /*nb_reserved*/
+#endif
+ (unaryfunc)0, /*nb_float*/
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_oct, /*nb_oct*/
+ (unaryfunc)SwigPyObject_hex, /*nb_hex*/
+#endif
+#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
+#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+ };
+
+ static PyTypeObject swigpyobject_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ (char *)"SwigPyObject", /* tp_name */
+ sizeof(SwigPyObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyObject_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyObject_print, /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+ (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
+#else
+ (getattrfunc)0, /* tp_getattr */
+#endif
+ (setattrfunc)0, /* tp_setattr */
+#if PY_VERSION_HEX >= 0x03000000
+ 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+#else
+ (cmpfunc)SwigPyObject_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyObject_repr, /* tp_repr */
+ &SwigPyObject_as_number, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)SwigPyObject_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigobject_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ swigobject_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+ 0, /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ swigpyobject_type = tmp;
+ type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+ swigpyobject_type.ob_type = &PyType_Type;
+#else
+ if (PyType_Ready(&swigpyobject_type) < 0)
+ return NULL;
+#endif
+ }
+ return &swigpyobject_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
+{
+ SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
+ if (sobj) {
+ sobj->ptr = ptr;
+ sobj->ty = ty;
+ sobj->own = own;
+ sobj->next = 0;
+ }
+ return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+ PyObject_HEAD
+ void *pack;
+ swig_type_info *ty;
+ size_t size;
+} SwigPyPacked;
+
+SWIGRUNTIME int
+SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char result[SWIG_BUFFER_SIZE];
+ fputs("pack, v->size, 0, sizeof(result))) {
+ fputs("at ", fp);
+ fputs(result, fp);
+ }
+ fputs(v->ty->name,fp);
+ fputs(">", fp);
+ return 0;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_repr(SwigPyPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ return SWIG_Python_str_FromFormat("", result, v->ty->name);
+ } else {
+ return SWIG_Python_str_FromFormat("", v->ty->name);
+ }
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_str(SwigPyPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
+ } else {
+ return SWIG_Python_str_FromChar(v->ty->name);
+ }
+}
+
+SWIGRUNTIME int
+SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
+{
+ size_t i = v->size;
+ size_t j = w->size;
+ int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+ return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+SwigPyPacked_Check(PyObject *op) {
+ return ((op)->ob_type == SwigPyPacked_TypeOnce())
+ || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
+}
+
+SWIGRUNTIME void
+SwigPyPacked_dealloc(PyObject *v)
+{
+ if (SwigPyPacked_Check(v)) {
+ SwigPyPacked *sobj = (SwigPyPacked *) v;
+ free(sobj->pack);
+ }
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_TypeOnce(void) {
+ static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+ static PyTypeObject swigpypacked_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX>=0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ (char *)"SwigPyPacked", /* tp_name */
+ sizeof(SwigPyPacked), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyPacked_print, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+#if PY_VERSION_HEX>=0x03000000
+ 0, /* tp_reserved in 3.0.1 */
+#else
+ (cmpfunc)SwigPyPacked_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyPacked_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)SwigPyPacked_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigpacked_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+ 0, /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ swigpypacked_type = tmp;
+ type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+ swigpypacked_type.ob_type = &PyType_Type;
+#else
+ if (PyType_Ready(&swigpypacked_type) < 0)
+ return NULL;
+#endif
+ }
+ return &swigpypacked_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+ SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
+ if (sobj) {
+ void *pack = malloc(size);
+ if (pack) {
+ memcpy(pack, ptr, size);
+ sobj->pack = pack;
+ sobj->ty = ty;
+ sobj->size = size;
+ } else {
+ PyObject_DEL((PyObject *) sobj);
+ sobj = 0;
+ }
+ }
+ return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+ if (SwigPyPacked_Check(obj)) {
+ SwigPyPacked *sobj = (SwigPyPacked *)obj;
+ if (sobj->size != size) return 0;
+ memcpy(ptr, sobj->pack, size);
+ return sobj->ty;
+ } else {
+ return 0;
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+ return SWIG_Python_str_FromChar("this");
+}
+
+static PyObject *swig_this = NULL;
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+ if (swig_this == NULL)
+ swig_this = _SWIG_This();
+ return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+/* TODO: I don't know how to implement the fast getset in Python 3 right now */
+#if PY_VERSION_HEX>=0x03000000
+#define SWIG_PYTHON_SLOW_GETSET_THIS
+#endif
+
+SWIGRUNTIME SwigPyObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj)
+{
+ PyObject *obj;
+
+ if (SwigPyObject_Check(pyobj))
+ return (SwigPyObject *) pyobj;
+
+#ifdef SWIGPYTHON_BUILTIN
+ (void)obj;
+# ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ pyobj = PyWeakref_GET_OBJECT(pyobj);
+ if (pyobj && SwigPyObject_Check(pyobj))
+ return (SwigPyObject*) pyobj;
+ }
+# endif
+ return NULL;
+#else
+
+ obj = 0;
+
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+ if (PyInstance_Check(pyobj)) {
+ obj = _PyInstance_Lookup(pyobj, SWIG_This());
+ } else {
+ PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+ } else {
+#ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+ return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+ }
+#endif
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+ }
+ }
+#else
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+#endif
+ if (obj && !SwigPyObject_Check(obj)) {
+ /* a PyObject is called 'this', try to get the 'real this'
+ SwigPyObject from it */
+ return SWIG_Python_GetSwigThis(obj);
+ }
+ return (SwigPyObject *)obj;
+#endif
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+ if (own == SWIG_POINTER_OWN) {
+ SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (sobj) {
+ int oldown = sobj->own;
+ sobj->own = own;
+ return oldown;
+ }
+ }
+ return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+ int res;
+ SwigPyObject *sobj;
+
+ if (!obj)
+ return SWIG_ERROR;
+ if (obj == Py_None) {
+ if (ptr)
+ *ptr = 0;
+ return SWIG_OK;
+ }
+
+ res = SWIG_ERROR;
+
+ sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
+ while (sobj) {
+ void *vptr = sobj->ptr;
+ if (ty) {
+ swig_type_info *to = sobj->ty;
+ if (to == ty) {
+ /* no type cast needed */
+ if (ptr) *ptr = vptr;
+ break;
+ } else {
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) {
+ sobj = (SwigPyObject *)sobj->next;
+ } else {
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
+ break;
+ }
+ }
+ } else {
+ if (ptr) *ptr = vptr;
+ break;
+ }
+ }
+ if (sobj) {
+ if (own)
+ *own = *own | sobj->own;
+ if (flags & SWIG_POINTER_DISOWN) {
+ sobj->own = 0;
+ }
+ res = SWIG_OK;
+ } else {
+ if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+ if (data && !data->implicitconv) {
+ PyObject *klass = data->klass;
+ if (klass) {
+ PyObject *impconv;
+ data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+ impconv = SWIG_Python_CallFunctor(klass, obj);
+ data->implicitconv = 0;
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ impconv = 0;
+ }
+ if (impconv) {
+ SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
+ if (iobj) {
+ void *vptr;
+ res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+ if (SWIG_IsOK(res)) {
+ if (ptr) {
+ *ptr = vptr;
+ /* transfer the ownership to 'ptr' */
+ iobj->own = 0;
+ res = SWIG_AddCast(res);
+ res = SWIG_AddNewMask(res);
+ } else {
+ res = SWIG_AddCast(res);
+ }
+ }
+ }
+ Py_DECREF(impconv);
+ }
+ }
+ }
+ }
+ }
+ return res;
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+ if (!PyCFunction_Check(obj)) {
+ return SWIG_ConvertPtr(obj, ptr, ty, 0);
+ } else {
+ void *vptr = 0;
+
+ /* here we get the method pointer for callbacks */
+ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+ const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+ if (desc)
+ desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+ if (!desc)
+ return SWIG_ERROR;
+ if (ty) {
+ swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
+ } else {
+ *ptr = vptr;
+ }
+ return SWIG_OK;
+ }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+ Create a new instance object, without calling __init__, and set the
+ 'this' attribute.
+*/
+
+SWIGRUNTIME PyObject*
+SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+ PyObject *inst = 0;
+ PyObject *newraw = data->newraw;
+ if (newraw) {
+ inst = PyObject_Call(newraw, data->newargs, NULL);
+ if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ }
+ }
+#else
+ PyObject *key = SWIG_This();
+ PyObject_SetAttr(inst, key, swig_this);
+#endif
+ }
+ } else {
+#if PY_VERSION_HEX >= 0x03000000
+ inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
+ PyObject_SetAttr(inst, SWIG_This(), swig_this);
+ Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+#else
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+#endif
+ }
+ return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+ PyObject *inst;
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ return (PyObject *) inst;
+#else
+ PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+ if (inst == NULL) {
+ return NULL;
+ }
+ inst->in_class = (PyClassObject *)data->newargs;
+ Py_INCREF(inst->in_class);
+ inst->in_dict = PyDict_New();
+ if (inst->in_dict == NULL) {
+ Py_DECREF(inst);
+ return NULL;
+ }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+ inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+ PyObject_GC_Init(inst);
+#endif
+ PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+ return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ }
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+}
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+ PyObject *obj[2];
+ if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
+ return NULL;
+ } else {
+ SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ if (sthis) {
+ SwigPyObject_append((PyObject*) sthis, obj[1]);
+ } else {
+ SWIG_Python_SetSwigThis(obj[0], obj[1]);
+ }
+ return SWIG_Py_Void();
+ }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
+ SwigPyClientData *clientdata;
+ PyObject * robj;
+ int own;
+
+ if (!ptr)
+ return SWIG_Py_Void();
+
+ clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
+ own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ if (clientdata && clientdata->pytype) {
+ SwigPyObject *newobj;
+ if (flags & SWIG_BUILTIN_TP_INIT) {
+ newobj = (SwigPyObject*) self;
+ if (newobj->ptr) {
+ PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
+ while (newobj->next)
+ newobj = (SwigPyObject *) newobj->next;
+ newobj->next = next_self;
+ newobj = (SwigPyObject *)next_self;
+ }
+ } else {
+ newobj = PyObject_New(SwigPyObject, clientdata->pytype);
+ }
+ if (newobj) {
+ newobj->ptr = ptr;
+ newobj->ty = type;
+ newobj->own = own;
+ newobj->next = 0;
+#ifdef SWIGPYTHON_BUILTIN
+ newobj->dict = 0;
+#endif
+ return (PyObject*) newobj;
+ }
+ return SWIG_Py_Void();
+ }
+
+ assert(!(flags & SWIG_BUILTIN_TP_INIT));
+
+ robj = SwigPyObject_New(ptr, type, own);
+ if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+ PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+ if (inst) {
+ Py_DECREF(robj);
+ robj = inst;
+ }
+ }
+ return robj;
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+ return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ * Get type list
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void) {
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+# ifdef SWIGPY_USE_CAPSULE
+ type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
+# else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+# endif
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+ }
+#endif
+ }
+ return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0. The following function
+ is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+ PyObject *dict;
+ if (!PyModule_Check(m)) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs module as first arg");
+ return SWIG_ERROR;
+ }
+ if (!o) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs non-NULL value");
+ return SWIG_ERROR;
+ }
+
+ dict = PyModule_GetDict(m);
+ if (dict == NULL) {
+ /* Internal error -- modules must have a dict! */
+ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+ PyModule_GetName(m));
+ return SWIG_ERROR;
+ }
+ if (PyDict_SetItemString(dict, name, o))
+ return SWIG_ERROR;
+ Py_DECREF(o);
+ return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+#ifdef SWIGPY_USE_CAPSULE
+SWIG_Python_DestroyModule(PyObject *obj)
+#else
+SWIG_Python_DestroyModule(void *vptr)
+#endif
+{
+#ifdef SWIGPY_USE_CAPSULE
+ swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
+#else
+ swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
+ swig_type_info **types = swig_module->types;
+ size_t i;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+ SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+ if (data) SwigPyClientData_Del(data);
+ }
+ }
+ Py_DECREF(SWIG_This());
+ swig_this = NULL;
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+#if PY_VERSION_HEX >= 0x03000000
+ /* Add a dummy module object into sys.modules */
+ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
+#else
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
+#endif
+#ifdef SWIGPY_USE_CAPSULE
+ PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+ } else {
+ Py_XDECREF(pointer);
+ }
+#else
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+ } else {
+ Py_XDECREF(pointer);
+ }
+#endif
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+ static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+ return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+ PyObject *cache = SWIG_Python_TypeCache();
+ PyObject *key = SWIG_Python_str_FromChar(type);
+ PyObject *obj = PyDict_GetItem(cache, key);
+ swig_type_info *descriptor;
+ if (obj) {
+#ifdef SWIGPY_USE_CAPSULE
+ descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
+#else
+ descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
+ } else {
+ swig_module_info *swig_module = SWIG_Python_GetModule();
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
+#ifdef SWIGPY_USE_CAPSULE
+ obj = PyCapsule_New((void*) descriptor, NULL, NULL);
+#else
+ obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
+ PyDict_SetItem(cache, key, obj);
+ Py_DECREF(obj);
+ }
+ }
+ Py_DECREF(key);
+ return descriptor;
+}
+
+/*
+ For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION 0
+#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{
+ if (PyErr_Occurred()) {
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+ PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ char *tmp;
+ PyObject *old_str = PyObject_Str(value);
+ Py_XINCREF(type);
+ PyErr_Clear();
+ if (infront) {
+ PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
+ } else {
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ }
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(old_str);
+ }
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+ if (PyErr_Occurred()) {
+ /* add information about failing argument */
+ char mesg[256];
+ PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+ return SWIG_Python_AddErrMesg(mesg, 1);
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIMEINLINE const char *
+SwigPyObject_GetDesc(PyObject *self)
+{
+ SwigPyObject *v = (SwigPyObject *)self;
+ swig_type_info *ty = v ? v->ty : 0;
+ return ty ? ty->str : "";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+ if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+ if (obj && SwigPyObject_Check(obj)) {
+ const char *otype = (const char *) SwigPyObject_GetDesc(obj);
+ if (otype) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
+ type, otype);
+ return;
+ }
+ } else
+#endif
+ {
+ const char *otype = (obj ? obj->ob_type->tp_name : 0);
+ if (otype) {
+ PyObject *str = PyObject_Str(obj);
+ const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
+ if (cstr) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+ type, otype, cstr);
+ SWIG_Python_str_DelForPy3(cstr);
+ } else {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+ type, otype);
+ }
+ Py_XDECREF(str);
+ return;
+ }
+ }
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+ } else {
+ PyErr_Format(PyExc_TypeError, "unexpected type is received");
+ }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
+ void *result;
+ if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+ PyErr_Clear();
+#if SWIG_POINTER_EXCEPTION
+ if (flags) {
+ SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+ SWIG_Python_ArgFail(argnum);
+ }
+#endif
+ }
+ return result;
+}
+
+#ifdef SWIGPYTHON_BUILTIN
+SWIGRUNTIME int
+SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
+ PyTypeObject *tp = obj->ob_type;
+ PyObject *descr;
+ PyObject *encoded_name;
+ descrsetfunc f;
+ int res;
+
+# ifdef Py_USING_UNICODE
+ if (PyString_Check(name)) {
+ name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
+ if (!name)
+ return -1;
+ } else if (!PyUnicode_Check(name))
+# else
+ if (!PyString_Check(name))
+# endif
+ {
+ PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
+ return -1;
+ } else {
+ Py_INCREF(name);
+ }
+
+ if (!tp->tp_dict) {
+ if (PyType_Ready(tp) < 0)
+ goto done;
+ }
+
+ res = -1;
+ descr = _PyType_Lookup(tp, name);
+ f = NULL;
+ if (descr != NULL)
+ f = descr->ob_type->tp_descr_set;
+ if (!f) {
+ if (PyString_Check(name)) {
+ encoded_name = name;
+ Py_INCREF(name);
+ } else {
+ encoded_name = PyUnicode_AsUTF8String(name);
+ }
+ PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
+ Py_DECREF(encoded_name);
+ } else {
+ res = f(descr, obj, value);
+ }
+
+ done:
+ Py_DECREF(name);
+ return res;
+}
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
+
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_char swig_types[0]
+#define SWIGTYPE_p_f_int_int__int swig_types[1]
+#define SWIGTYPE_p_f_p_void__p_void swig_types[2]
+#define SWIGTYPE_p_f_void__void swig_types[3]
+#define SWIGTYPE_p_unsigned_char swig_types[4]
+static swig_type_info *swig_types[6];
+static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+#if (PY_VERSION_HEX <= 0x02000000)
+# if !defined(SWIG_PYTHON_CLASSIC)
+# error "This python version requires swig to be run with the '-classic' option"
+# endif
+#endif
+
+/*-----------------------------------------------
+ @(target):= _wiringpi.so
+ ------------------------------------------------*/
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_init PyInit__wiringpi
+
+#else
+# define SWIG_init init_wiringpi
+
+#endif
+#define SWIG_name "_wiringpi"
+
+#define SWIGVERSION 0x020007
+#define SWIG_VERSION SWIGVERSION
+
+
+#define SWIG_as_voidptr(a) (void *)((const void *)(a))
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
+
+
+#include "WiringPi/wiringPi/ds1302.h",
+#include "WiringPi/wiringPi/gertboard.h",
+#include "WiringPi/wiringPi/lcd.h",
+#include "WiringPi/wiringPi/mcp23008.h",
+#include "WiringPi/wiringPi/mcp23017.h",
+#include "WiringPi/wiringPi/mcp23s08.h",
+#include "WiringPi/wiringPi/mcp23s17.h",
+#include "WiringPi/wiringPi/mcp23x0817.h",
+#include "WiringPi/wiringPi/mcp23x08.h",
+#include "WiringPi/wiringPi/piFace.h",
+#include "WiringPi/wiringPi/piNes.h",
+#include "WiringPi/wiringPi/softPwm.h",
+#include "WiringPi/wiringPi/softServo.h",
+#include "WiringPi/wiringPi/softTone.h",
+#include "WiringPi/wiringPi/sr595.h",
+#include "WiringPi/wiringPi/wiringPi.h",
+#include "WiringPi/wiringPi/wiringPiI2C.h",
+#include "WiringPi/wiringPi/wiringPiSPI.h",
+#include "WiringPi/wiringPi/wiringSerial.h",
+#include "WiringPi/wiringPi/wiringShift.h"
+
+
+SWIGINTERNINLINE PyObject*
+ SWIG_From_int (int value)
+{
+ return PyInt_FromLong((long) value);
+}
+
+
+#include
+#if !defined(SWIG_NO_LLONG_MAX)
+# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
+# define LLONG_MAX __LONG_LONG_MAX__
+# define LLONG_MIN (-LLONG_MAX - 1LL)
+# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
+# endif
+#endif
+
+
+SWIGINTERN int
+SWIG_AsVal_double (PyObject *obj, double *val)
+{
+ int res = SWIG_TypeError;
+ if (PyFloat_Check(obj)) {
+ if (val) *val = PyFloat_AsDouble(obj);
+ return SWIG_OK;
+ } else if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ double v = PyLong_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ double d = PyFloat_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = d;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
+ } else {
+ PyErr_Clear();
+ }
+ }
+ }
+#endif
+ return res;
+}
+
+
+#include
+
+
+#include
+
+
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+ double x = *d;
+ if ((min <= x && x <= max)) {
+ double fx = floor(x);
+ double cx = ceil(x);
+ double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+ if ((errno == EDOM) || (errno == ERANGE)) {
+ errno = 0;
+ } else {
+ double summ, reps, diff;
+ if (rd < x) {
+ diff = x - rd;
+ } else if (rd > x) {
+ diff = rd - x;
+ } else {
+ return 1;
+ }
+ summ = rd + x;
+ reps = diff/summ;
+ if (reps < 8*DBL_EPSILON) {
+ *d = rd;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_long (PyObject *obj, long* val)
+{
+ if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ long v = PyInt_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+ if (val) *val = (long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_int (PyObject * obj, int *val)
+{
+ long v;
+ int res = SWIG_AsVal_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v < INT_MIN || v > INT_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = (int)(v);
+ }
+ }
+ return res;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
+{
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
+{
+ unsigned long v;
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v > UINT_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = (unsigned int)(v);
+ }
+ }
+ return res;
+}
+
+
+SWIGINTERNINLINE PyObject*
+ SWIG_From_unsigned_SS_int (unsigned int value)
+{
+ return PyInt_FromSize_t((size_t) value);
+}
+
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor(void)
+{
+ static int init = 0;
+ static swig_type_info* info = 0;
+ if (!init) {
+ info = SWIG_TypeQuery("_p_char");
+ init = 1;
+ }
+ return info;
+}
+
+
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
+{
+#if PY_VERSION_HEX>=0x03000000
+ if (PyUnicode_Check(obj))
+#else
+ if (PyString_Check(obj))
+#endif
+ {
+ char *cstr; Py_ssize_t len;
+#if PY_VERSION_HEX>=0x03000000
+ if (!alloc && cptr) {
+ /* We can't allow converting without allocation, since the internal
+ representation of string in Python 3 is UCS-2/UCS-4 but we require
+ a UTF-8 representation.
+ TODO(bhy) More detailed explanation */
+ return SWIG_RuntimeError;
+ }
+ obj = PyUnicode_AsUTF8String(obj);
+ PyBytes_AsStringAndSize(obj, &cstr, &len);
+ if(alloc) *alloc = SWIG_NEWOBJ;
+#else
+ PyString_AsStringAndSize(obj, &cstr, &len);
+#endif
+ if (cptr) {
+ if (alloc) {
+ /*
+ In python the user should not be able to modify the inner
+ string representation. To warranty that, if you define
+ SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
+ buffer is always returned.
+
+ The default behavior is just to return the pointer value,
+ so, be careful.
+ */
+#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
+ if (*alloc != SWIG_OLDOBJ)
+#else
+ if (*alloc == SWIG_NEWOBJ)
+#endif
+ {
+ *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
+ *alloc = SWIG_NEWOBJ;
+ }
+ else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ } else {
+ #if PY_VERSION_HEX>=0x03000000
+ assert(0); /* Should never reach here in Python 3 */
+ #endif
+ *cptr = SWIG_Python_str_AsChar(obj);
+ }
+ }
+ if (psize) *psize = len + 1;
+#if PY_VERSION_HEX>=0x03000000
+ Py_XDECREF(obj);
+#endif
+ return SWIG_OK;
+ } else {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ void* vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (char *) vptr;
+ if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+
+
+
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val)
+{
+ unsigned long v;
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v > UCHAR_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = (unsigned char)(v);
+ }
+ }
+ return res;
+}
+
+
+ #define SWIG_From_long PyLong_FromLong
+
+
+SWIGINTERNINLINE PyObject*
+SWIG_From_unsigned_SS_long (unsigned long value)
+{
+ return (value > LONG_MAX) ?
+ PyLong_FromUnsignedLong(value) : PyLong_FromLong((long)(value));
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_unsigned_SS_char (unsigned char value)
+{
+ return SWIG_From_unsigned_SS_long (value);
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SWIGINTERN PyObject *_wrap_wiringPiSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":wiringPiSetup")) SWIG_fail;
+ result = (int)wiringPiSetup();
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiSetupSys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":wiringPiSetupSys")) SWIG_fail;
+ result = (int)wiringPiSetupSys();
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiSetupGpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":wiringPiSetupGpio")) SWIG_fail;
+ result = (int)wiringPiSetupGpio();
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_piFaceSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:piFaceSetup",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piFaceSetup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)piFaceSetup(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_piBoardRev(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":piBoardRev")) SWIG_fail;
+ result = (int)piBoardRev();
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wpiPinToGpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:wpiPinToGpio",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wpiPinToGpio" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)wpiPinToGpio(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pinMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:pinMode",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pinMode" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pinMode" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ pinMode(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_getAlt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:getAlt",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "getAlt" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)getAlt(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pullUpDnControl(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:pullUpDnControl",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pullUpDnControl" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pullUpDnControl" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ pullUpDnControl(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_digitalWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:digitalWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "digitalWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ digitalWrite(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_digitalWriteByte(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:digitalWriteByte",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWriteByte" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ digitalWriteByte(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_gpioClockSet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:gpioClockSet",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gpioClockSet" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gpioClockSet" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ gpioClockSet(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pwmWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:pwmWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pwmWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ pwmWrite(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_setPadDrive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:setPadDrive",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "setPadDrive" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "setPadDrive" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ setPadDrive(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_digitalRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:digitalRead",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalRead" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)digitalRead(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pwmSetMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:pwmSetMode",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmSetMode" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ pwmSetMode(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pwmSetRange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ unsigned int arg1 ;
+ unsigned int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:pwmSetRange",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmSetRange" "', argument " "1"" of type '" "unsigned int""'");
+ }
+ arg1 = (unsigned int)(val1);
+ pwmSetRange(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_pwmSetClock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:pwmSetClock",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmSetClock" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ pwmSetClock(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN int Swig_var_waitForInterrupt_set(PyObject *_val) {
+ {
+ int res = SWIG_ConvertFunctionPtr(_val, (void**)(&waitForInterrupt), SWIGTYPE_p_f_int_int__int);
+ if (!SWIG_IsOK(res)) {
+ SWIG_exception_fail(SWIG_ArgError(res), "in variable '""waitForInterrupt""' of type '""int (*)(int,int)""'");
+ }
+ }
+ return 0;
+fail:
+ return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_waitForInterrupt_get(void) {
+ PyObject *pyobj = 0;
+
+ pyobj = SWIG_NewFunctionPtrObj((void *)(waitForInterrupt), SWIGTYPE_p_f_int_int__int);
+ return pyobj;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiISR(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ void (*arg3)(void) = (void (*)(void)) 0 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiISR",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiISR" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiISR" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ {
+ int res = SWIG_ConvertFunctionPtr(obj2, (void**)(&arg3), SWIGTYPE_p_f_void__void);
+ if (!SWIG_IsOK(res)) {
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "wiringPiISR" "', argument " "3"" of type '" "void (*)(void)""'");
+ }
+ }
+ result = (int)wiringPiISR(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_piThreadCreate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ void *(*arg1)(void *) = (void *(*)(void *)) 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:piThreadCreate",&obj0)) SWIG_fail;
+ {
+ int res = SWIG_ConvertFunctionPtr(obj0, (void**)(&arg1), SWIGTYPE_p_f_p_void__p_void);
+ if (!SWIG_IsOK(res)) {
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "piThreadCreate" "', argument " "1"" of type '" "void *(*)(void *)""'");
+ }
+ }
+ result = (int)piThreadCreate(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_piLock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:piLock",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piLock" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ piLock(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_piUnlock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:piUnlock",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piUnlock" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ piUnlock(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delay(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ unsigned int arg1 ;
+ unsigned int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delay",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "delay" "', argument " "1"" of type '" "unsigned int""'");
+ }
+ arg1 = (unsigned int)(val1);
+ delay(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delayMicroseconds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ unsigned int arg1 ;
+ unsigned int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delayMicroseconds",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "delayMicroseconds" "', argument " "1"" of type '" "unsigned int""'");
+ }
+ arg1 = (unsigned int)(val1);
+ delayMicroseconds(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_millis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ unsigned int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":millis")) SWIG_fail;
+ result = (unsigned int)millis();
+ resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_micros(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ unsigned int result;
+
+ if (!PyArg_ParseTuple(args,(char *)":micros")) SWIG_fail;
+ result = (unsigned int)micros();
+ resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ char *arg1 = (char *) 0 ;
+ int arg2 ;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:serialOpen",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "serialOpen" "', argument " "1"" of type '" "char *""'");
+ }
+ arg1 = (char *)(buf1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "serialOpen" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)serialOpen(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+ return resultobj;
+fail:
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:serialClose",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialClose" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ serialClose(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialFlush(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:serialFlush",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialFlush" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ serialFlush(arg1);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialPutchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ unsigned char arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ unsigned char val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:serialPutchar",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPutchar" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "serialPutchar" "', argument " "2"" of type '" "unsigned char""'");
+ }
+ arg2 = (unsigned char)(val2);
+ serialPutchar(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialPuts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ char *arg2 = (char *) 0 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:serialPuts",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPuts" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPuts" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = (char *)(buf2);
+ serialPuts(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialPrintf__varargs__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ char *arg2 = (char *) 0 ;
+ void *arg3 = 0 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:serialPrintf",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPrintf" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPrintf" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = (char *)(buf2);
+ serialPrintf(arg1,arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialPrintf(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj;
+ PyObject *varargs;
+ PyObject *newargs;
+
+ newargs = PyTuple_GetSlice(args,0,2);
+ varargs = PyTuple_GetSlice(args,2,PyTuple_Size(args)+1);
+ resultobj = _wrap_serialPrintf__varargs__(NULL,newargs,varargs);
+ Py_XDECREF(newargs);
+ Py_XDECREF(varargs);
+ return resultobj;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialDataAvail(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:serialDataAvail",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialDataAvail" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)serialDataAvail(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_serialGetchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:serialGetchar",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialGetchar" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)serialGetchar(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_shiftOut(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ uint8_t arg1 ;
+ uint8_t arg2 ;
+ uint8_t arg3 ;
+ uint8_t arg4 ;
+ unsigned char val1 ;
+ int ecode1 = 0 ;
+ unsigned char val2 ;
+ int ecode2 = 0 ;
+ unsigned char val3 ;
+ int ecode3 = 0 ;
+ unsigned char val4 ;
+ int ecode4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOO:shiftOut",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftOut" "', argument " "1"" of type '" "uint8_t""'");
+ }
+ arg1 = (uint8_t)(val1);
+ ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftOut" "', argument " "2"" of type '" "uint8_t""'");
+ }
+ arg2 = (uint8_t)(val2);
+ ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftOut" "', argument " "3"" of type '" "uint8_t""'");
+ }
+ arg3 = (uint8_t)(val3);
+ ecode4 = SWIG_AsVal_unsigned_SS_char(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "shiftOut" "', argument " "4"" of type '" "uint8_t""'");
+ }
+ arg4 = (uint8_t)(val4);
+ shiftOut(arg1,arg2,arg3,arg4);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_shiftIn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ uint8_t arg1 ;
+ uint8_t arg2 ;
+ uint8_t arg3 ;
+ unsigned char val1 ;
+ int ecode1 = 0 ;
+ unsigned char val2 ;
+ int ecode2 = 0 ;
+ unsigned char val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ uint8_t result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:shiftIn",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftIn" "', argument " "1"" of type '" "uint8_t""'");
+ }
+ arg1 = (uint8_t)(val1);
+ ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftIn" "', argument " "2"" of type '" "uint8_t""'");
+ }
+ arg2 = (uint8_t)(val2);
+ ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftIn" "', argument " "3"" of type '" "uint8_t""'");
+ }
+ arg3 = (uint8_t)(val3);
+ result = shiftIn(arg1,arg2,arg3);
+ resultobj = SWIG_From_unsigned_SS_char((unsigned char)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiSPIGetFd(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:wiringPiSPIGetFd",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIGetFd" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)wiringPiSPIGetFd(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiSPIDataRW(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ unsigned char *arg2 = (unsigned char *) 0 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiSPIDataRW",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIDataRW" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ {
+ arg2 = (unsigned char *) PyString_AsString(obj1);
+ arg3 = PyString_Size(obj1);
+ }
+ result = (int)wiringPiSPIDataRW(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiSPISetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiSPISetup",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPISetup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiSPISetup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)wiringPiSPISetup(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:wiringPiI2CRead",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CRead" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)wiringPiI2CRead(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiI2CReadReg8",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg8" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CReadReg8" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)wiringPiI2CReadReg8(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiI2CReadReg16",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg16" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CReadReg16" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)wiringPiI2CReadReg16(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiI2CWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)wiringPiI2CWrite(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg8",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg8" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CWriteReg8" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "wiringPiI2CWriteReg8" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ result = (int)wiringPiI2CWriteReg8(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg16(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg16",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg16" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CWriteReg16" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "wiringPiI2CWriteReg16" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ result = (int)wiringPiI2CWriteReg16(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softToneCreate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ PyObject * obj0 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:softToneCreate",&obj0)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneCreate" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ result = (int)softToneCreate(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softToneWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:softToneWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "softToneWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ softToneWrite(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softServoWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:softServoWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "softServoWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ softServoWrite(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softServoSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ int arg6 ;
+ int arg7 ;
+ int arg8 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int val6 ;
+ int ecode6 = 0 ;
+ int val7 ;
+ int ecode7 = 0 ;
+ int val8 ;
+ int ecode8 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
+ PyObject * obj7 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:softServoSetup",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoSetup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "softServoSetup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "softServoSetup" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "softServoSetup" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = (int)(val4);
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "softServoSetup" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = (int)(val5);
+ ecode6 = SWIG_AsVal_int(obj5, &val6);
+ if (!SWIG_IsOK(ecode6)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "softServoSetup" "', argument " "6"" of type '" "int""'");
+ }
+ arg6 = (int)(val6);
+ ecode7 = SWIG_AsVal_int(obj6, &val7);
+ if (!SWIG_IsOK(ecode7)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "softServoSetup" "', argument " "7"" of type '" "int""'");
+ }
+ arg7 = (int)(val7);
+ ecode8 = SWIG_AsVal_int(obj7, &val8);
+ if (!SWIG_IsOK(ecode8)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "softServoSetup" "', argument " "8"" of type '" "int""'");
+ }
+ arg8 = (int)(val8);
+ result = (int)softServoSetup(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softPwmCreate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:softPwmCreate",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmCreate" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "softPwmCreate" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "softPwmCreate" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ result = (int)softPwmCreate(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_softPwmWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:softPwmWrite",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmWrite" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "softPwmWrite" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ softPwmWrite(arg1,arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_mcp23s17Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s17Setup",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s17Setup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23s17Setup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "mcp23s17Setup" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ result = (int)mcp23s17Setup(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_mcp23017Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:mcp23017Setup",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23017Setup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23017Setup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)mcp23017Setup(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_mcp23s08Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s08Setup",&obj0,&obj1,&obj2)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s08Setup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23s08Setup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "mcp23s08Setup" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ result = (int)mcp23s08Setup(arg1,arg2,arg3);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_mcp23008Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:mcp23008Setup",&obj0,&obj1)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23008Setup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23008Setup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ result = (int)mcp23008Setup(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_sr595Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ int arg1 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ int result;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:sr595Setup",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ ecode1 = SWIG_AsVal_int(obj0, &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "sr595Setup" "', argument " "1"" of type '" "int""'");
+ }
+ arg1 = (int)(val1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sr595Setup" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = (int)(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sr595Setup" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = (int)(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "sr595Setup" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = (int)(val4);
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "sr595Setup" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = (int)(val5);
+ result = (int)sr595Setup(arg1,arg2,arg3,arg4,arg5);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+static PyMethodDef SwigMethods[] = {
+ { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
+ { (char *)"wiringPiSetup", _wrap_wiringPiSetup, METH_VARARGS, NULL},
+ { (char *)"wiringPiSetupSys", _wrap_wiringPiSetupSys, METH_VARARGS, NULL},
+ { (char *)"wiringPiSetupGpio", _wrap_wiringPiSetupGpio, METH_VARARGS, NULL},
+ { (char *)"piFaceSetup", _wrap_piFaceSetup, METH_VARARGS, NULL},
+ { (char *)"piBoardRev", _wrap_piBoardRev, METH_VARARGS, NULL},
+ { (char *)"wpiPinToGpio", _wrap_wpiPinToGpio, METH_VARARGS, NULL},
+ { (char *)"pinMode", _wrap_pinMode, METH_VARARGS, NULL},
+ { (char *)"getAlt", _wrap_getAlt, METH_VARARGS, NULL},
+ { (char *)"pullUpDnControl", _wrap_pullUpDnControl, METH_VARARGS, NULL},
+ { (char *)"digitalWrite", _wrap_digitalWrite, METH_VARARGS, NULL},
+ { (char *)"digitalWriteByte", _wrap_digitalWriteByte, METH_VARARGS, NULL},
+ { (char *)"gpioClockSet", _wrap_gpioClockSet, METH_VARARGS, NULL},
+ { (char *)"pwmWrite", _wrap_pwmWrite, METH_VARARGS, NULL},
+ { (char *)"setPadDrive", _wrap_setPadDrive, METH_VARARGS, NULL},
+ { (char *)"digitalRead", _wrap_digitalRead, METH_VARARGS, NULL},
+ { (char *)"pwmSetMode", _wrap_pwmSetMode, METH_VARARGS, NULL},
+ { (char *)"pwmSetRange", _wrap_pwmSetRange, METH_VARARGS, NULL},
+ { (char *)"pwmSetClock", _wrap_pwmSetClock, METH_VARARGS, NULL},
+ { (char *)"wiringPiISR", _wrap_wiringPiISR, METH_VARARGS, NULL},
+ { (char *)"piThreadCreate", _wrap_piThreadCreate, METH_VARARGS, NULL},
+ { (char *)"piLock", _wrap_piLock, METH_VARARGS, NULL},
+ { (char *)"piUnlock", _wrap_piUnlock, METH_VARARGS, NULL},
+ { (char *)"delay", _wrap_delay, METH_VARARGS, NULL},
+ { (char *)"delayMicroseconds", _wrap_delayMicroseconds, METH_VARARGS, NULL},
+ { (char *)"millis", _wrap_millis, METH_VARARGS, NULL},
+ { (char *)"micros", _wrap_micros, METH_VARARGS, NULL},
+ { (char *)"serialOpen", _wrap_serialOpen, METH_VARARGS, NULL},
+ { (char *)"serialClose", _wrap_serialClose, METH_VARARGS, NULL},
+ { (char *)"serialFlush", _wrap_serialFlush, METH_VARARGS, NULL},
+ { (char *)"serialPutchar", _wrap_serialPutchar, METH_VARARGS, NULL},
+ { (char *)"serialPuts", _wrap_serialPuts, METH_VARARGS, NULL},
+ { (char *)"serialPrintf", _wrap_serialPrintf, METH_VARARGS, NULL},
+ { (char *)"serialDataAvail", _wrap_serialDataAvail, METH_VARARGS, NULL},
+ { (char *)"serialGetchar", _wrap_serialGetchar, METH_VARARGS, NULL},
+ { (char *)"shiftOut", _wrap_shiftOut, METH_VARARGS, NULL},
+ { (char *)"shiftIn", _wrap_shiftIn, METH_VARARGS, NULL},
+ { (char *)"wiringPiSPIGetFd", _wrap_wiringPiSPIGetFd, METH_VARARGS, NULL},
+ { (char *)"wiringPiSPIDataRW", _wrap_wiringPiSPIDataRW, METH_VARARGS, NULL},
+ { (char *)"wiringPiSPISetup", _wrap_wiringPiSPISetup, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CRead", _wrap_wiringPiI2CRead, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CReadReg8", _wrap_wiringPiI2CReadReg8, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CReadReg16", _wrap_wiringPiI2CReadReg16, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CWrite", _wrap_wiringPiI2CWrite, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CWriteReg8", _wrap_wiringPiI2CWriteReg8, METH_VARARGS, NULL},
+ { (char *)"wiringPiI2CWriteReg16", _wrap_wiringPiI2CWriteReg16, METH_VARARGS, NULL},
+ { (char *)"softToneCreate", _wrap_softToneCreate, METH_VARARGS, NULL},
+ { (char *)"softToneWrite", _wrap_softToneWrite, METH_VARARGS, NULL},
+ { (char *)"softServoWrite", _wrap_softServoWrite, METH_VARARGS, NULL},
+ { (char *)"softServoSetup", _wrap_softServoSetup, METH_VARARGS, NULL},
+ { (char *)"softPwmCreate", _wrap_softPwmCreate, METH_VARARGS, NULL},
+ { (char *)"softPwmWrite", _wrap_softPwmWrite, METH_VARARGS, NULL},
+ { (char *)"mcp23s17Setup", _wrap_mcp23s17Setup, METH_VARARGS, NULL},
+ { (char *)"mcp23017Setup", _wrap_mcp23017Setup, METH_VARARGS, NULL},
+ { (char *)"mcp23s08Setup", _wrap_mcp23s08Setup, METH_VARARGS, NULL},
+ { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL},
+ { (char *)"sr595Setup", _wrap_sr595Setup, METH_VARARGS, NULL},
+ { NULL, NULL, 0, NULL }
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_int_int__int = {"_p_f_int_int__int", "int (*)(int,int)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_p_void__p_void = {"_p_f_p_void__p_void", "void *(*)(void *)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_void__void = {"_p_f_void__void", "void (*)(void)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+ &_swigt__p_char,
+ &_swigt__p_f_int_int__int,
+ &_swigt__p_f_p_void__p_void,
+ &_swigt__p_f_void__void,
+ &_swigt__p_unsigned_char,
+};
+
+static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_int_int__int[] = { {&_swigt__p_f_int_int__int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_p_void__p_void[] = { {&_swigt__p_f_p_void__p_void, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_void__void[] = { {&_swigt__p_f_void__void, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+ _swigc__p_char,
+ _swigc__p_f_int_int__int,
+ _swigc__p_f_p_void__p_void,
+ _swigc__p_f_void__void,
+ _swigc__p_unsigned_char,
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+static swig_const_info swig_const_table[] = {
+{0, 0, 0, 0.0, 0, 0}};
+
+#ifdef __cplusplus
+}
+#endif
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ * 1) If the cast->type has already been loaded AND the type we are adding
+ * casting info to has not been loaded (it is in this module), THEN we
+ * replace the cast->type pointer with the type pointer that has already
+ * been loaded.
+ * 2) If BOTH types (the one we are adding casting info to, and the
+ * cast->type) are loaded, THEN the cast info has already been loaded by
+ * the previous module so we just ignore it.
+ * 3) Finally, if cast->type has not already been loaded, then we add that
+ * swig_cast_info to the linked list (because the cast->type) pointer will
+ * be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+ size_t i;
+ swig_module_info *module_head, *iter;
+ int found, init;
+
+ clientdata = clientdata;
+
+ /* check to see if the circular list has been setup, if not, set it up */
+ if (swig_module.next==0) {
+ /* Initialize the swig_module */
+ swig_module.type_initial = swig_type_initial;
+ swig_module.cast_initial = swig_cast_initial;
+ swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
+ }
+
+ /* Try and load any already created modules */
+ module_head = SWIG_GetModule(clientdata);
+ if (!module_head) {
+ /* This is the first module loaded for this interpreter */
+ /* so set the swig module into the interpreter */
+ SWIG_SetModule(clientdata, &swig_module);
+ module_head = &swig_module;
+ } else {
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+ found=0;
+ iter=module_head;
+ do {
+ if (iter==&swig_module) {
+ found=1;
+ break;
+ }
+ iter=iter->next;
+ } while (iter!= module_head);
+
+ /* if the is found in the list, then all is done and we may leave */
+ if (found) return;
+ /* otherwise we must add out module into the list */
+ swig_module.next = module_head->next;
+ module_head->next = &swig_module;
+ }
+
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
+ /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+ for (i = 0; i < swig_module.size; ++i) {
+ swig_type_info *type = 0;
+ swig_type_info *ret;
+ swig_cast_info *cast;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+
+ /* if there is another module already loaded */
+ if (swig_module.next != &swig_module) {
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+ }
+ if (type) {
+ /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+ if (swig_module.type_initial[i]->clientdata) {
+ type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+ }
+ } else {
+ type = swig_module.type_initial[i];
+ }
+
+ /* Insert casting types */
+ cast = swig_module.cast_initial[i];
+ while (cast->type) {
+ /* Don't need to add information already in the list */
+ ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+ if (swig_module.next != &swig_module) {
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+ }
+ if (ret) {
+ if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+ cast->type = ret;
+ ret = 0;
+ } else {
+ /* Check for casting already in the list */
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+ if (!ocast) ret = 0;
+ }
+ }
+
+ if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+ if (type->cast) {
+ type->cast->prev = cast;
+ cast->next = type->cast;
+ }
+ type->cast = cast;
+ }
+ cast++;
+ }
+ /* Set entry in modules->types array equal to the type */
+ swig_module.types[i] = type;
+ }
+ swig_module.types[i] = 0;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+ for (i = 0; i < swig_module.size; ++i) {
+ int j = 0;
+ swig_cast_info *cast = swig_module.cast_initial[i];
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+ while (cast->type) {
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+ cast++;
+ ++j;
+ }
+ printf("---- Total casts: %d\n",j);
+ }
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types. It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+ size_t i;
+ swig_cast_info *equiv;
+ static int init_run = 0;
+
+ if (init_run) return;
+ init_run = 1;
+
+ for (i = 0; i < swig_module.size; i++) {
+ if (swig_module.types[i]->clientdata) {
+ equiv = swig_module.types[i]->cast;
+ while (equiv) {
+ if (!equiv->converter) {
+ if (equiv->type && !equiv->type->clientdata)
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+ }
+ equiv = equiv->next;
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+ /* c-mode */
+#endif
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Python-specific SWIG API */
+#define SWIG_newvarlink() SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
+
+ /* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+ typedef struct swig_globalvar {
+ char *name; /* Name of global variable */
+ PyObject *(*get_attr)(void); /* Return the current value */
+ int (*set_attr)(PyObject *); /* Set the value */
+ struct swig_globalvar *next;
+ } swig_globalvar;
+
+ typedef struct swig_varlinkobject {
+ PyObject_HEAD
+ swig_globalvar *vars;
+ } swig_varlinkobject;
+
+ SWIGINTERN PyObject *
+ swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_InternFromString("");
+#else
+ return PyString_FromString("");
+#endif
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_str(swig_varlinkobject *v) {
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *str = PyUnicode_InternFromString("(");
+ PyObject *tail;
+ PyObject *joined;
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ tail = PyUnicode_FromString(var->name);
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ if (var->next) {
+ tail = PyUnicode_InternFromString(", ");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ }
+ }
+ tail = PyUnicode_InternFromString(")");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+#else
+ PyObject *str = PyString_FromString("(");
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+ if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+ }
+ PyString_ConcatAndDel(&str,PyString_FromString(")"));
+#endif
+ return str;
+ }
+
+ SWIGINTERN int
+ swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+ char *tmp;
+ PyObject *str = swig_varlink_str(v);
+ fprintf(fp,"Swig global variables ");
+ fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(str);
+ return 0;
+ }
+
+ SWIGINTERN void
+ swig_varlink_dealloc(swig_varlinkobject *v) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+ PyObject *res = NULL;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->get_attr)();
+ break;
+ }
+ var = var->next;
+ }
+ if (res == NULL && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN int
+ swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+ int res = 1;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->set_attr)(p);
+ break;
+ }
+ var = var->next;
+ }
+ if (res == 1 && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN PyTypeObject*
+ swig_varlink_type(void) {
+ static char varlink__doc__[] = "Swig var link object";
+ static PyTypeObject varlink_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ (char *)"swigvarlink", /* tp_name */
+ sizeof(swig_varlinkobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor) swig_varlink_dealloc, /* tp_dealloc */
+ (printfunc) swig_varlink_print, /* tp_print */
+ (getattrfunc) swig_varlink_getattr, /* tp_getattr */
+ (setattrfunc) swig_varlink_setattr, /* tp_setattr */
+ 0, /* tp_compare */
+ (reprfunc) swig_varlink_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ (reprfunc) swig_varlink_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_flags */
+ varlink__doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+ 0, /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ varlink_type = tmp;
+ type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+ varlink_type.ob_type = &PyType_Type;
+#else
+ if (PyType_Ready(&varlink_type) < 0)
+ return NULL;
+#endif
+ }
+ return &varlink_type;
+ }
+
+ /* Create a variable linking object for use later */
+ SWIGINTERN PyObject *
+ SWIG_Python_newvarlink(void) {
+ swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+ if (result) {
+ result->vars = 0;
+ }
+ return ((PyObject*) result);
+ }
+
+ SWIGINTERN void
+ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+ swig_varlinkobject *v = (swig_varlinkobject *) p;
+ swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+ if (gv) {
+ size_t size = strlen(name)+1;
+ gv->name = (char *)malloc(size);
+ if (gv->name) {
+ strncpy(gv->name,name,size);
+ gv->get_attr = get_attr;
+ gv->set_attr = set_attr;
+ gv->next = v->vars;
+ }
+ }
+ v->vars = gv;
+ }
+
+ SWIGINTERN PyObject *
+ SWIG_globals(void) {
+ static PyObject *_SWIG_globals = 0;
+ if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
+ return _SWIG_globals;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * constants/methods manipulation
+ * ----------------------------------------------------------------------------- */
+
+ /* Install Constants */
+ SWIGINTERN void
+ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+ PyObject *obj = 0;
+ size_t i;
+ for (i = 0; constants[i].type; ++i) {
+ switch(constants[i].type) {
+ case SWIG_PY_POINTER:
+ obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+ break;
+ case SWIG_PY_BINARY:
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+ break;
+ default:
+ obj = 0;
+ break;
+ }
+ if (obj) {
+ PyDict_SetItemString(d, constants[i].name, obj);
+ Py_DECREF(obj);
+ }
+ }
+ }
+
+ /* -----------------------------------------------------------------------------*/
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ /* -----------------------------------------------------------------------------*/
+
+ SWIGINTERN void
+ SWIG_Python_FixMethods(PyMethodDef *methods,
+ swig_const_info *const_table,
+ swig_type_info **types,
+ swig_type_info **types_initial) {
+ size_t i;
+ for (i = 0; methods[i].ml_name; ++i) {
+ const char *c = methods[i].ml_doc;
+ if (c && (c = strstr(c, "swig_ptr: "))) {
+ int j;
+ swig_const_info *ci = 0;
+ const char *name = c + 10;
+ for (j = 0; const_table[j].type; ++j) {
+ if (strncmp(const_table[j].name, name,
+ strlen(const_table[j].name)) == 0) {
+ ci = &(const_table[j]);
+ break;
+ }
+ }
+ if (ci) {
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+ if (ptr) {
+ size_t shift = (ci->ptype) - types;
+ swig_type_info *ty = types_initial[shift];
+ size_t ldoc = (c - methods[i].ml_doc);
+ size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+ char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ if (ndoc) {
+ char *buff = ndoc;
+ strncpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ strncpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+SWIGEXPORT
+#if PY_VERSION_HEX >= 0x03000000
+PyObject*
+#else
+void
+#endif
+SWIG_init(void) {
+ PyObject *m, *d, *md;
+#if PY_VERSION_HEX >= 0x03000000
+ static struct PyModuleDef SWIG_module = {
+# if PY_VERSION_HEX >= 0x03020000
+ PyModuleDef_HEAD_INIT,
+# else
+ {
+ PyObject_HEAD_INIT(NULL)
+ NULL, /* m_init */
+ 0, /* m_index */
+ NULL, /* m_copy */
+ },
+# endif
+ (char *) SWIG_name,
+ NULL,
+ -1,
+ SwigMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+#endif
+
+#if defined(SWIGPYTHON_BUILTIN)
+ static SwigPyClientData SwigPyObject_clientdata = {
+ 0, 0, 0, 0, 0, 0, 0
+ };
+ static PyGetSetDef this_getset_def = {
+ (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
+ };
+ static SwigPyGetSet thisown_getset_closure = {
+ (PyCFunction) SwigPyObject_own,
+ (PyCFunction) SwigPyObject_own
+ };
+ static PyGetSetDef thisown_getset_def = {
+ (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
+ };
+ PyObject *metatype_args;
+ PyTypeObject *builtin_pytype;
+ int builtin_base_count;
+ swig_type_info *builtin_basetype;
+ PyObject *tuple;
+ PyGetSetDescrObject *static_getset;
+ PyTypeObject *metatype;
+ SwigPyClientData *cd;
+ PyObject *public_interface, *public_symbol;
+ PyObject *this_descr;
+ PyObject *thisown_descr;
+ int i;
+
+ (void)builtin_pytype;
+ (void)builtin_base_count;
+ (void)builtin_basetype;
+ (void)tuple;
+ (void)static_getset;
+
+ /* metatype is used to implement static member variables. */
+ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
+ assert(metatype_args);
+ metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);
+ assert(metatype);
+ Py_DECREF(metatype_args);
+ metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
+ assert(PyType_Ready(metatype) >= 0);
+#endif
+
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+
+#if PY_VERSION_HEX >= 0x03000000
+ m = PyModule_Create(&SWIG_module);
+#else
+ m = Py_InitModule((char *) SWIG_name, SwigMethods);
+#endif
+ md = d = PyModule_GetDict(m);
+
+ SWIG_InitializeModule(0);
+
+#ifdef SWIGPYTHON_BUILTIN
+ SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
+ assert(SwigPyObject_stype);
+ cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+ if (!cd) {
+ SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
+ SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();
+ } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {
+ PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
+# if PY_VERSION_HEX >= 0x03000000
+ return NULL;
+# else
+ return;
+# endif
+ }
+
+ /* All objects have a 'this' attribute */
+ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
+ (void)this_descr;
+
+ /* All objects have a 'thisown' attribute */
+ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
+ (void)thisown_descr;
+
+ public_interface = PyList_New(0);
+ public_symbol = 0;
+ (void)public_symbol;
+
+ PyDict_SetItemString(md, "__all__", public_interface);
+ Py_DECREF(public_interface);
+ for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
+ for (i = 0; swig_const_table[i].name != 0; ++i)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
+#endif
+
+ SWIG_InstallConstants(d,swig_const_table);
+
+ PyDict_SetItemString(md,(char*)"cvar", SWIG_globals());
+ SWIG_addvarlink(SWIG_globals(),(char*)"waitForInterrupt",Swig_var_waitForInterrupt_get, Swig_var_waitForInterrupt_set);
+#if PY_VERSION_HEX >= 0x03000000
+ return m;
+#else
+ return;
+#endif
+}
+