Philip Howard | 2215ad3 | 2013-03-27 23:04:22 +0000 | [diff] [blame] | 1 | %module wiringpi2 |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 2 | |
| 3 | %{ |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 4 | #include "WiringPi/wiringPi/wiringPi.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 5 | #include "WiringPi/wiringPi/wiringPiI2C.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 6 | #include "WiringPi/wiringPi/wiringPiSPI.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 7 | #include "WiringPi/wiringPi/wiringSerial.h" |
| 8 | #include "WiringPi/wiringPi/wiringShift.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 9 | #include "WiringPi/wiringPi/drcSerial.h" |
Philip Howard | d9fc85a | 2013-08-13 16:38:26 +0100 | [diff] [blame] | 10 | #include "WiringPi/wiringPi/max31855.h" |
| 11 | #include "WiringPi/wiringPi/max5322.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 12 | #include "WiringPi/wiringPi/mcp23008.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 13 | #include "WiringPi/wiringPi/mcp23016.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 14 | #include "WiringPi/wiringPi/mcp23016reg.h" |
| 15 | #include "WiringPi/wiringPi/mcp23017.h" |
| 16 | #include "WiringPi/wiringPi/mcp23s08.h" |
| 17 | #include "WiringPi/wiringPi/mcp23s17.h" |
| 18 | #include "WiringPi/wiringPi/mcp23x0817.h" |
| 19 | #include "WiringPi/wiringPi/mcp23x08.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 20 | #include "WiringPi/wiringPi/mcp3002.h" |
Philip Howard | d9fc85a | 2013-08-13 16:38:26 +0100 | [diff] [blame] | 21 | #include "WiringPi/wiringPi/mcp3004.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 22 | #include "WiringPi/wiringPi/mcp3422.h" |
| 23 | #include "WiringPi/wiringPi/mcp4802.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 24 | #include "WiringPi/wiringPi/pcf8574.h" |
| 25 | #include "WiringPi/wiringPi/pcf8591.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 26 | #include "WiringPi/wiringPi/sn3218.h" |
Philip Howard | 2215ad3 | 2013-03-27 23:04:22 +0000 | [diff] [blame] | 27 | #include "WiringPi/wiringPi/softPwm.h" |
| 28 | #include "WiringPi/wiringPi/softServo.h" |
| 29 | #include "WiringPi/wiringPi/softTone.h" |
| 30 | #include "WiringPi/wiringPi/sr595.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 31 | #include "WiringPi/devLib/ds1302.h" |
| 32 | #include "WiringPi/devLib/font.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 33 | #include "WiringPi/devLib/gertboard.h" |
| 34 | #include "WiringPi/devLib/lcd128x64.h" |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 35 | #include "WiringPi/devLib/lcd.h" |
| 36 | #include "WiringPi/devLib/maxdetect.h" |
| 37 | #include "WiringPi/devLib/piFace.h" |
Philip Howard | d9fc85a | 2013-08-13 16:38:26 +0100 | [diff] [blame] | 38 | #include "WiringPi/devLib/piGlow.h" |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 39 | #include "WiringPi/devLib/piNes.h" |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 40 | %} |
| 41 | |
| 42 | %apply unsigned char { uint8_t }; |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 43 | %typemap(in) (unsigned char *data, int len) { |
| 44 | $1 = (unsigned char *) PyString_AsString($input); |
| 45 | $2 = PyString_Size($input); |
| 46 | }; |
| 47 | |
| 48 | extern int wiringPiFailure (int fatal, const char *message, ...) ; |
| 49 | extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ; |
| 50 | extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 51 | |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 52 | // Core wiringPi functions |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 53 | extern int wiringPiSetup (void) ; |
| 54 | extern int wiringPiSetupSys (void) ; |
| 55 | extern int wiringPiSetupGpio (void) ; |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 56 | extern int wiringPiSetupPhys (void) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 57 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 58 | extern void pinModeAlt (int pin, int mode) ; |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 59 | extern void pinMode (int pin, int mode) ; |
| 60 | extern void pullUpDnControl (int pin, int pud) ; |
| 61 | extern int digitalRead (int pin) ; |
| 62 | extern void digitalWrite (int pin, int value) ; |
| 63 | extern void pwmWrite (int pin, int value) ; |
| 64 | extern int analogRead (int pin) ; |
| 65 | extern void analogWrite (int pin, int value) ; |
| 66 | |
| 67 | // On-Board Raspberry Pi hardware specific stuff |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 68 | extern int piBoardRev (void) ; |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 69 | extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 70 | extern int wpiPinToGpio (int wpiPin) ; |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 71 | extern int physPinToGpio (int physPin) ; |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 72 | extern void setPadDrive (int group, int value) ; |
| 73 | extern int getAlt (int pin) ; |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 74 | extern void pwmToneWrite (int pin, int freq) ; |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 75 | extern void digitalWriteByte (int value) ; |
| 76 | extern void pwmSetMode (int mode) ; |
| 77 | extern void pwmSetRange (unsigned int range) ; |
| 78 | extern void pwmSetClock (int divisor) ; |
| 79 | extern void gpioClockSet (int pin, int freq) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 80 | |
| 81 | // Interrupts |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 82 | extern int waitForInterrupt (int pin, int mS) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 83 | extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; |
| 84 | |
| 85 | // Threads |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 86 | extern int piThreadCreate (void *(*fn)(void *)) ; |
| 87 | extern void piLock (int key) ; |
| 88 | extern void piUnlock (int key) ; |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 89 | |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 90 | // Schedulling priority |
| 91 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 92 | extern int piHiPri (const int pri) ; |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 93 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 94 | // Delays and Timing |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 95 | extern void delay (unsigned int howLong) ; |
| 96 | extern void delayMicroseconds (unsigned int howLong) ; |
| 97 | extern unsigned int millis (void) ; |
| 98 | extern unsigned int micros (void) ; |
| 99 | |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 100 | // ds1302 |
| 101 | extern unsigned int ds1302rtcRead (const int reg) ; |
| 102 | extern void ds1302rtcWrite (const int reg, const unsigned int data) ; |
| 103 | extern unsigned int ds1302ramRead (const int addr) ; |
| 104 | extern void ds1302ramWrite (const int addr, const unsigned int data) ; |
| 105 | extern void ds1302clockRead (int clockData [8]) ; |
| 106 | extern void ds1302clockWrite (const int clockData [8]) ; |
| 107 | extern void ds1302trickleCharge (const int diodes, const int resistors) ; |
| 108 | extern void ds1302setup (const int clockPin, const int dataPin, const int csPin) ; |
| 109 | |
| 110 | // Gertboard |
| 111 | extern void gertboardAnalogWrite (const int chan, const int value) ; |
| 112 | extern int gertboardAnalogRead (const int chan) ; |
| 113 | extern int gertboardSPISetup (void) ; |
| 114 | extern int gertboardAnalogSetup (const int pinBase) ; |
| 115 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 116 | // LCD 128x64 |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 117 | extern void lcd128x64setOrigin (int x, int y) ; |
| 118 | extern void lcd128x64setOrientation (int orientation) ; |
| 119 | extern void lcd128x64orientCoordinates (int *x, int *y) ; |
| 120 | extern void lcd128x64getScreenSize (int *x, int *y) ; |
| 121 | extern void lcd128x64point (int x, int y, int colour) ; |
| 122 | extern void lcd128x64line (int x0, int y0, int x1, int y1, int colour) ; |
| 123 | extern void lcd128x64lineTo (int x, int y, int colour) ; |
| 124 | extern void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) ; |
| 125 | extern void lcd128x64circle (int x, int y, int r, int colour, int filled) ; |
| 126 | extern void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) ; |
| 127 | extern void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) ; |
| 128 | extern void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) ; |
| 129 | extern void lcd128x64update (void) ; |
| 130 | extern void lcd128x64clear (int colour) ; |
| 131 | extern int lcd128x64setup (void) ; |
| 132 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 133 | // LCD |
| 134 | extern void lcdHome (const int fd) ; |
| 135 | extern void lcdClear (const int fd) ; |
| 136 | extern void lcdDisplay (const int fd, int state) ; |
| 137 | extern void lcdCursor (const int fd, int state) ; |
| 138 | extern void lcdCursorBlink (const int fd, int state) ; |
| 139 | extern void lcdSendCommand (const int fd, unsigned char command) ; |
| 140 | extern void lcdPosition (const int fd, int x, int y) ; |
| 141 | extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; |
| 142 | extern void lcdPutchar (const int fd, unsigned char data) ; |
| 143 | extern void lcdPuts (const int fd, const char *string) ; |
| 144 | extern void lcdPrintf (const int fd, const char *message, ...) ; |
| 145 | extern int lcdInit (const int rows, const int cols, const int bits, |
| 146 | const int rs, const int strb, |
| 147 | const int d0, const int d1, const int d2, const int d3, const int d4, |
| 148 | const int d5, const int d6, const int d7) ; |
| 149 | |
| 150 | // PiFace |
| 151 | extern int piFaceSetup (const int pinBase) ; |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 152 | |
Philip Howard | d9fc85a | 2013-08-13 16:38:26 +0100 | [diff] [blame] | 153 | // PiGlow |
| 154 | extern void piGlow1 (const int leg, const int ring, const int intensity) ; |
| 155 | extern void piGlowLeg (const int leg, const int intensity) ; |
| 156 | extern void piGlowRing (const int ring, const int intensity) ; |
Philip Howard | 77a4244 | 2013-08-15 22:32:14 +0100 | [diff] [blame] | 157 | extern void piGlowSetup (int clear) ; |
Philip Howard | 6ae3e5b | 2013-05-21 22:48:41 +0100 | [diff] [blame] | 158 | |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame^] | 159 | // NES |
| 160 | extern int setupNesJoystick (int dPin, int cPin, int lPin) ; |
| 161 | extern unsigned int readNesJoystick (int joystick) ; |
| 162 | |
| 163 | // Various IC setup functions |
| 164 | extern int sr595Setup (const int pinBase, const int numPins, const int dataPin, const int clockPin, const int latchPin) ; |
| 165 | extern int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) ; |
| 166 | extern int max31855Setup (int pinBase, int spiChannel) ; |
| 167 | extern int max5322Setup (int pinBase, int spiChannel) ; |
| 168 | extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; |
| 169 | extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; |
| 170 | extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; |
| 171 | extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; |
| 172 | extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; |
| 173 | extern int mcp3002Setup (int pinBase, int spiChannel) ; |
| 174 | extern int mcp3004Setup (int pinBase, int spiChannel) ; |
| 175 | extern int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) ; |
| 176 | extern int mcp4802Setup (int pinBase, int spiChannel) ; |
| 177 | extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; |
| 178 | extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; |
| 179 | extern int sn3218Setup (int pinBase) ; |
| 180 | |
| 181 | // Soft PWM |
| 182 | extern int softPwmCreate (int pin, int value, int range) ; |
| 183 | extern void softPwmWrite (int pin, int value) ; |
| 184 | extern void softPwmStop (int pin) ; |
| 185 | |
| 186 | // Soft Servo |
| 187 | extern void softServoWrite (int pin, int value) ; |
| 188 | extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; |
| 189 | |
| 190 | // Soft Tone |
| 191 | extern int softToneCreate (int pin) ; |
| 192 | extern void softToneStop (int pin) ; |
| 193 | extern void softToneWrite (int pin, int freq) ; |
| 194 | |
| 195 | // SPI |
| 196 | int wiringPiSPIGetFd (int channel) ; |
| 197 | int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; |
| 198 | int wiringPiSPISetup (int channel, int speed) ; |
| 199 | |
| 200 | // I2C |
| 201 | extern int wiringPiI2CRead (int fd) ; |
| 202 | extern int wiringPiI2CReadReg8 (int fd, int reg) ; |
| 203 | extern int wiringPiI2CReadReg16 (int fd, int reg) ; |
| 204 | extern int wiringPiI2CWrite (int fd, int data) ; |
| 205 | extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; |
| 206 | extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; |
| 207 | extern int wiringPiI2CSetupInterface (const char *device, int devId) ; |
| 208 | extern int wiringPiI2CSetup (const int devId) ; |
| 209 | |
| 210 | // WiringSerial |
| 211 | extern int serialOpen (const char *device, const int baud) ; |
| 212 | extern void serialClose (const int fd) ; |
| 213 | extern void serialFlush (const int fd) ; |
| 214 | extern void serialPutchar (const int fd, const unsigned char c) ; |
| 215 | extern void serialPuts (const int fd, const char *s) ; |
| 216 | extern void serialPrintf (const int fd, const char *message, ...) ; |
| 217 | extern int serialDataAvail (const int fd) ; |
| 218 | extern int serialGetchar (const int fd) ; |
| 219 | |
| 220 | // Shift Register |
| 221 | extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ; |
| 222 | extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ; |
| 223 | |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 224 | %include "wiringpi2-class.py" |