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