wiring_lmk 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/ext/wiringpi/WiringPi/devLib/ds1302.c +254 -0
  3. data/ext/wiringpi/WiringPi/devLib/ds1302.h +44 -0
  4. data/ext/wiringpi/WiringPi/devLib/font.h +2577 -0
  5. data/ext/wiringpi/WiringPi/devLib/gertboard.c +164 -0
  6. data/ext/wiringpi/WiringPi/devLib/gertboard.h +45 -0
  7. data/ext/wiringpi/WiringPi/devLib/lcd.c +507 -0
  8. data/ext/wiringpi/WiringPi/devLib/lcd.h +52 -0
  9. data/ext/wiringpi/WiringPi/devLib/lcd128x64.c +684 -0
  10. data/ext/wiringpi/WiringPi/devLib/lcd128x64.h +39 -0
  11. data/ext/wiringpi/WiringPi/devLib/maxdetect.c +167 -0
  12. data/ext/wiringpi/WiringPi/devLib/maxdetect.h +40 -0
  13. data/ext/wiringpi/WiringPi/devLib/piFace.c +112 -0
  14. data/ext/wiringpi/WiringPi/devLib/piFace.h +32 -0
  15. data/ext/wiringpi/WiringPi/devLib/piFaceOld.c +178 -0
  16. data/ext/wiringpi/WiringPi/devLib/piGlow.c +118 -0
  17. data/ext/wiringpi/WiringPi/devLib/piGlow.h +45 -0
  18. data/ext/wiringpi/WiringPi/devLib/piNes.c +117 -0
  19. data/ext/wiringpi/WiringPi/devLib/piNes.h +45 -0
  20. data/ext/wiringpi/WiringPi/gpio/extensions.c +700 -0
  21. data/ext/wiringpi/WiringPi/gpio/extensions.h +26 -0
  22. data/ext/wiringpi/WiringPi/gpio/gpio.c +1280 -0
  23. data/ext/wiringpi/WiringPi/gpio/pins.c +33 -0
  24. data/ext/wiringpi/WiringPi/gpio/readall.c +337 -0
  25. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +201 -0
  26. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.h +33 -0
  27. data/ext/wiringpi/WiringPi/wiringPi/max31855.c +99 -0
  28. data/ext/wiringpi/WiringPi/wiringPi/max31855.h +33 -0
  29. data/ext/wiringpi/WiringPi/wiringPi/max5322.c +84 -0
  30. data/ext/wiringpi/WiringPi/wiringPi/max5322.h +33 -0
  31. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +149 -0
  32. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.h +33 -0
  33. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +164 -0
  34. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.h +33 -0
  35. data/ext/wiringpi/WiringPi/wiringPi/mcp23016reg.h +48 -0
  36. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +195 -0
  37. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.h +33 -0
  38. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +189 -0
  39. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.h +33 -0
  40. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +234 -0
  41. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.h +33 -0
  42. data/ext/wiringpi/WiringPi/wiringPi/mcp23x08.h +73 -0
  43. data/ext/wiringpi/WiringPi/wiringPi/mcp23x0817.h +87 -0
  44. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +76 -0
  45. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.h +33 -0
  46. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +76 -0
  47. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.h +33 -0
  48. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +113 -0
  49. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +43 -0
  50. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +76 -0
  51. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.h +33 -0
  52. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +126 -0
  53. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.h +33 -0
  54. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +92 -0
  55. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.h +33 -0
  56. data/ext/wiringpi/WiringPi/wiringPi/piHiPri.c +51 -0
  57. data/ext/wiringpi/WiringPi/wiringPi/piThread.c +63 -0
  58. data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +75 -0
  59. data/ext/wiringpi/WiringPi/wiringPi/sn3218.h +33 -0
  60. data/ext/wiringpi/WiringPi/wiringPi/softPwm.c +168 -0
  61. data/ext/wiringpi/WiringPi/wiringPi/softPwm.h +35 -0
  62. data/ext/wiringpi/WiringPi/wiringPi/softServo.c +247 -0
  63. data/ext/wiringpi/WiringPi/wiringPi/softServo.h +35 -0
  64. data/ext/wiringpi/WiringPi/wiringPi/softTone.c +150 -0
  65. data/ext/wiringpi/WiringPi/wiringPi/softTone.h +39 -0
  66. data/ext/wiringpi/WiringPi/wiringPi/sr595.c +113 -0
  67. data/ext/wiringpi/WiringPi/wiringPi/sr595.h +34 -0
  68. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +3688 -0
  69. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +229 -0
  70. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.c +236 -0
  71. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.h +42 -0
  72. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.c +121 -0
  73. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.h +35 -0
  74. data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.c +253 -0
  75. data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.h +38 -0
  76. data/ext/wiringpi/WiringPi/wiringPi/wiringShift.c +83 -0
  77. data/ext/wiringpi/WiringPi/wiringPi/wiringShift.h +41 -0
  78. data/ext/wiringpi/extconf.rb +8 -0
  79. data/ext/wiringpi/wiringpi_wrap.c +4396 -0
  80. data/lib/wiring_lmk.rb +42 -0
  81. data/lib/wiring_lmk/event.rb +21 -0
  82. data/lib/wiring_lmk/gpio.rb +139 -0
  83. data/lib/wiring_lmk/i2c.rb +26 -0
  84. data/lib/wiring_lmk/mcp23x17.rb +31 -0
  85. data/lib/wiring_lmk/serial.rb +49 -0
  86. data/lib/wiring_lmk/spi.rb +15 -0
  87. metadata +136 -0
@@ -0,0 +1,189 @@
1
+ /*
2
+ * mcp23s08.c:
3
+ * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip
4
+ * Copyright (c) 2013 Gordon Henderson
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as
11
+ * published by the Free Software Foundation, either version 3 of the
12
+ * License, or (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with wiringPi.
21
+ * If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdio.h>
26
+ #include <stdint.h>
27
+
28
+ #include "wiringPi.h"
29
+ #include "wiringPiSPI.h"
30
+ #include "mcp23x0817.h"
31
+
32
+ #include "mcp23s08.h"
33
+
34
+ #define MCP_SPEED 4000000
35
+
36
+
37
+
38
+ /*
39
+ * writeByte:
40
+ * Write a byte to a register on the MCP23s08 on the SPI bus.
41
+ *********************************************************************************
42
+ */
43
+
44
+ static void writeByte (uint8_t spiPort, uint8_t devId, uint8_t reg, uint8_t data)
45
+ {
46
+ uint8_t spiData [4] ;
47
+
48
+ spiData [0] = CMD_WRITE | ((devId & 7) << 1) ;
49
+ spiData [1] = reg ;
50
+ spiData [2] = data ;
51
+
52
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
53
+ }
54
+
55
+ /*
56
+ * readByte:
57
+ * Read a byte from a register on the MCP23s08 on the SPI bus.
58
+ *********************************************************************************
59
+ */
60
+
61
+ static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg)
62
+ {
63
+ uint8_t spiData [4] ;
64
+
65
+ spiData [0] = CMD_READ | ((devId & 7) << 1) ;
66
+ spiData [1] = reg ;
67
+
68
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
69
+
70
+ return spiData [2] ;
71
+ }
72
+
73
+
74
+ /*
75
+ * myPinMode:
76
+ *********************************************************************************
77
+ */
78
+
79
+ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
80
+ {
81
+ int mask, old, reg ;
82
+
83
+ reg = MCP23x08_IODIR ;
84
+ mask = 1 << (pin - node->pinBase) ;
85
+ old = readByte (node->data0, node->data1, reg) ;
86
+
87
+ if (mode == OUTPUT)
88
+ old &= (~mask) ;
89
+ else
90
+ old |= mask ;
91
+
92
+ writeByte (node->data0, node->data1, reg, old) ;
93
+ }
94
+
95
+
96
+ /*
97
+ * myPullUpDnControl:
98
+ *********************************************************************************
99
+ */
100
+
101
+ static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
102
+ {
103
+ int mask, old, reg ;
104
+
105
+ reg = MCP23x08_GPPU ;
106
+ mask = 1 << (pin - node->pinBase) ;
107
+
108
+ old = readByte (node->data0, node->data1, reg) ;
109
+
110
+ if (mode == PUD_UP)
111
+ old |= mask ;
112
+ else
113
+ old &= (~mask) ;
114
+
115
+ writeByte (node->data0, node->data1, reg, old) ;
116
+ }
117
+
118
+
119
+ /*
120
+ * myDigitalWrite:
121
+ *********************************************************************************
122
+ */
123
+
124
+ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
125
+ {
126
+ int bit, old ;
127
+
128
+ bit = 1 << ((pin - node->pinBase) & 7) ;
129
+
130
+ old = node->data2 ;
131
+ if (value == LOW)
132
+ old &= (~bit) ;
133
+ else
134
+ old |= bit ;
135
+
136
+ writeByte (node->data0, node->data1, MCP23x08_GPIO, old) ;
137
+ node->data2 = old ;
138
+ }
139
+
140
+
141
+ /*
142
+ * myDigitalRead:
143
+ *********************************************************************************
144
+ */
145
+
146
+ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
147
+ {
148
+ int mask, value ;
149
+
150
+ mask = 1 << ((pin - node->pinBase) & 7) ;
151
+ value = readByte (node->data0, node->data1, MCP23x08_GPIO) ;
152
+
153
+ if ((value & mask) == 0)
154
+ return LOW ;
155
+ else
156
+ return HIGH ;
157
+ }
158
+
159
+
160
+ /*
161
+ * mcp23s08Setup:
162
+ * Create a new instance of an MCP23s08 SPI GPIO interface. We know it
163
+ * has 8 pins, so all we need to know here is the SPI address and the
164
+ * user-defined pin base.
165
+ *********************************************************************************
166
+ */
167
+
168
+ int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
169
+ {
170
+ int x ;
171
+ struct wiringPiNodeStruct *node ;
172
+
173
+ if ((x = wiringPiSPISetup (spiPort, MCP_SPEED)) < 0)
174
+ return x ;
175
+
176
+ writeByte (spiPort, devId, MCP23x08_IOCON, IOCON_INIT) ;
177
+
178
+ node = wiringPiNewNode (pinBase, 8) ;
179
+
180
+ node->data0 = spiPort ;
181
+ node->data1 = devId ;
182
+ node->pinMode = myPinMode ;
183
+ node->pullUpDnControl = myPullUpDnControl ;
184
+ node->digitalRead = myDigitalRead ;
185
+ node->digitalWrite = myDigitalWrite ;
186
+ node->data2 = readByte (spiPort, devId, MCP23x08_OLAT) ;
187
+
188
+ return 0 ;
189
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * 23s08.h:
3
+ * Extend wiringPi with the MCP 23s08 SPI GPIO expander chip
4
+ * Copyright (c) 2013 Gordon Henderson
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as
11
+ * published by the Free Software Foundation, either version 3 of the
12
+ * License, or (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with wiringPi.
21
+ * If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ;
30
+
31
+ #ifdef __cplusplus
32
+ }
33
+ #endif
@@ -0,0 +1,234 @@
1
+ /*
2
+ * mcp23s17.c:
3
+ * Extend wiringPi with the MCP 23s17 SPI GPIO expander chip
4
+ * Copyright (c) 2013 Gordon Henderson
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as
11
+ * published by the Free Software Foundation, either version 3 of the
12
+ * License, or (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with wiringPi.
21
+ * If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdio.h>
26
+ #include <stdint.h>
27
+
28
+ #include "wiringPi.h"
29
+ #include "wiringPiSPI.h"
30
+ #include "mcp23x0817.h"
31
+
32
+ #include "mcp23s17.h"
33
+
34
+ #define MCP_SPEED 4000000
35
+
36
+
37
+
38
+ /*
39
+ * writeByte:
40
+ * Write a byte to a register on the MCP23s17 on the SPI bus.
41
+ *********************************************************************************
42
+ */
43
+
44
+ static void writeByte (uint8_t spiPort, uint8_t devId, uint8_t reg, uint8_t data)
45
+ {
46
+ uint8_t spiData [4] ;
47
+
48
+ spiData [0] = CMD_WRITE | ((devId & 7) << 1) ;
49
+ spiData [1] = reg ;
50
+ spiData [2] = data ;
51
+
52
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
53
+ }
54
+
55
+ /*
56
+ * readByte:
57
+ * Read a byte from a register on the MCP23s17 on the SPI bus.
58
+ *********************************************************************************
59
+ */
60
+
61
+ static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg)
62
+ {
63
+ uint8_t spiData [4] ;
64
+
65
+ spiData [0] = CMD_READ | ((devId & 7) << 1) ;
66
+ spiData [1] = reg ;
67
+
68
+ wiringPiSPIDataRW (spiPort, spiData, 3) ;
69
+
70
+ return spiData [2] ;
71
+ }
72
+
73
+
74
+ /*
75
+ * myPinMode:
76
+ *********************************************************************************
77
+ */
78
+
79
+ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode)
80
+ {
81
+ int mask, old, reg ;
82
+
83
+ pin -= node->pinBase ;
84
+
85
+ if (pin < 8) // Bank A
86
+ reg = MCP23x17_IODIRA ;
87
+ else
88
+ {
89
+ reg = MCP23x17_IODIRB ;
90
+ pin &= 0x07 ;
91
+ }
92
+
93
+ mask = 1 << pin ;
94
+ old = readByte (node->data0, node->data1, reg) ;
95
+
96
+ if (mode == OUTPUT)
97
+ old &= (~mask) ;
98
+ else
99
+ old |= mask ;
100
+
101
+ writeByte (node->data0, node->data1, reg, old) ;
102
+ }
103
+
104
+
105
+ /*
106
+ * myPullUpDnControl:
107
+ *********************************************************************************
108
+ */
109
+
110
+ static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode)
111
+ {
112
+ int mask, old, reg ;
113
+
114
+ pin -= node->pinBase ;
115
+
116
+ if (pin < 8) // Bank A
117
+ reg = MCP23x17_GPPUA ;
118
+ else
119
+ {
120
+ reg = MCP23x17_GPPUB ;
121
+ pin &= 0x07 ;
122
+ }
123
+
124
+ mask = 1 << pin ;
125
+ old = readByte (node->data0, node->data1, reg) ;
126
+
127
+ if (mode == PUD_UP)
128
+ old |= mask ;
129
+ else
130
+ old &= (~mask) ;
131
+
132
+ writeByte (node->data0, node->data1, reg, old) ;
133
+ }
134
+
135
+
136
+ /*
137
+ * myDigitalWrite:
138
+ *********************************************************************************
139
+ */
140
+
141
+ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
142
+ {
143
+ int bit, old ;
144
+
145
+ pin -= node->pinBase ; // Pin now 0-15
146
+ bit = 1 << (pin & 7) ;
147
+
148
+ if (pin < 8) // Bank A
149
+ {
150
+ old = node->data2 ;
151
+
152
+ if (value == LOW)
153
+ old &= (~bit) ;
154
+ else
155
+ old |= bit ;
156
+
157
+ writeByte (node->data0, node->data1, MCP23x17_GPIOA, old) ;
158
+ node->data2 = old ;
159
+ }
160
+ else // Bank B
161
+ {
162
+ old = node->data3 ;
163
+
164
+ if (value == LOW)
165
+ old &= (~bit) ;
166
+ else
167
+ old |= bit ;
168
+
169
+ writeByte (node->data0, node->data1, MCP23x17_GPIOB, old) ;
170
+ node->data3 = old ;
171
+ }
172
+ }
173
+
174
+
175
+ /*
176
+ * myDigitalRead:
177
+ *********************************************************************************
178
+ */
179
+
180
+ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
181
+ {
182
+ int mask, value, gpio ;
183
+
184
+ pin -= node->pinBase ;
185
+
186
+ if (pin < 8) // Bank A
187
+ gpio = MCP23x17_GPIOA ;
188
+ else
189
+ {
190
+ gpio = MCP23x17_GPIOB ;
191
+ pin &= 0x07 ;
192
+ }
193
+
194
+ mask = 1 << pin ;
195
+ value = readByte (node->data0, node->data1, gpio) ;
196
+
197
+ if ((value & mask) == 0)
198
+ return LOW ;
199
+ else
200
+ return HIGH ;
201
+ }
202
+
203
+
204
+ /*
205
+ * mcp23s17Setup:
206
+ * Create a new instance of an MCP23s17 SPI GPIO interface. We know it
207
+ * has 16 pins, so all we need to know here is the SPI address and the
208
+ * user-defined pin base.
209
+ *********************************************************************************
210
+ */
211
+
212
+ int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
213
+ {
214
+ int x ;
215
+ struct wiringPiNodeStruct *node ;
216
+ if ((x = wiringPiSPISetup (spiPort, MCP_SPEED)) < 0)
217
+ return x ;
218
+
219
+ writeByte (spiPort, devId, MCP23x17_IOCON, IOCON_INIT | IOCON_HAEN) ;
220
+ writeByte (spiPort, devId, MCP23x17_IOCONB, IOCON_INIT | IOCON_HAEN) ;
221
+
222
+ node = wiringPiNewNode (pinBase, 16) ;
223
+
224
+ node->data0 = spiPort ;
225
+ node->data1 = devId ;
226
+ node->pinMode = myPinMode ;
227
+ node->pullUpDnControl = myPullUpDnControl ;
228
+ node->digitalRead = myDigitalRead ;
229
+ node->digitalWrite = myDigitalWrite ;
230
+ node->data2 = readByte (spiPort, devId, MCP23x17_OLATA) ;
231
+ node->data3 = readByte (spiPort, devId, MCP23x17_OLATB) ;
232
+
233
+ return 0 ;
234
+ }