wiringpi 2.0.0 → 2.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/wiringpi/WiringPi/devLib/maxdetect.c +100 -27
- data/ext/wiringpi/WiringPi/devLib/maxdetect.h +0 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhat.c +430 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhat.h +39 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhatFont.h +544 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/ladder.c +0 -0
- data/ext/wiringpi/WiringPi/examples/max31855.c +60 -0
- data/ext/wiringpi/WiringPi/examples/rht03.c +32 -15
- data/ext/wiringpi/WiringPi/examples/scrollPhat/scphat.c +230 -0
- data/ext/wiringpi/WiringPi/examples/scrollPhat/test.c +115 -0
- data/ext/wiringpi/WiringPi/gpio/gpio.c +88 -37
- data/ext/wiringpi/WiringPi/gpio/readall.c +41 -9
- data/ext/wiringpi/WiringPi/gpio/version.h +1 -1
- data/ext/wiringpi/WiringPi/wiringPi/ads1115.c +293 -0
- data/ext/wiringpi/WiringPi/wiringPi/ads1115.h +55 -0
- data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +4 -9
- data/ext/wiringpi/WiringPi/wiringPi/max31855.c +41 -23
- data/ext/wiringpi/WiringPi/wiringPi/max5322.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +3 -4
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +3 -4
- data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +33 -18
- data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +6 -6
- data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +2 -2
- data/ext/wiringpi/WiringPi/wiringPi/sr595.c +1 -1
- data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +418 -132
- data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +47 -37
- data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.c +38 -9
- data/ext/wiringpi/extconf.rb +26 -2
- data/ext/wiringpi/wiringpi_wrap.c +3456 -981
- metadata +9 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
/*
|
2
|
+
* ads1115.c:
|
3
|
+
* Extend wiringPi with the ADS1115 I2C 16-bit ADC
|
4
|
+
* Copyright (c) 2016 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
|
+
// Constants for some of the internal functions
|
26
|
+
|
27
|
+
// Gain
|
28
|
+
|
29
|
+
#define ADS1115_GAIN_6 0
|
30
|
+
#define ADS1115_GAIN_4 1
|
31
|
+
#define ADS1115_GAIN_2 2
|
32
|
+
#define ADS1115_GAIN_1 3
|
33
|
+
#define ADS1115_GAIN_HALF 4
|
34
|
+
#define ADS1115_GAIN_QUARTER 5
|
35
|
+
|
36
|
+
// Data rate
|
37
|
+
|
38
|
+
#define ADS1115_DR_8 0
|
39
|
+
#define ADS1115_DR_16 1
|
40
|
+
#define ADS1115_DR_32 2
|
41
|
+
#define ADS1115_DR_64 3
|
42
|
+
#define ADS1115_DR_128 4
|
43
|
+
#define ADS1115_DR_250 5
|
44
|
+
#define ADS1115_DR_475 6
|
45
|
+
#define ADS1115_DR_860 7
|
46
|
+
|
47
|
+
#ifdef __cplusplus
|
48
|
+
extern "C" {
|
49
|
+
#endif
|
50
|
+
|
51
|
+
extern int ads1115Setup (int pinBase, int i2cAddress) ;
|
52
|
+
|
53
|
+
#ifdef __cplusplus
|
54
|
+
}
|
55
|
+
#endif
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* drcSerial.c:
|
3
3
|
* Extend wiringPi with the DRC Serial protocol (e.g. to Arduino)
|
4
|
-
* Copyright (c) 2013 Gordon Henderson
|
4
|
+
* Copyright (c) 2013-2016 Gordon Henderson
|
5
5
|
***********************************************************************
|
6
6
|
* This file is part of wiringPi:
|
7
7
|
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
@@ -32,11 +32,6 @@
|
|
32
32
|
|
33
33
|
#include "drcSerial.h"
|
34
34
|
|
35
|
-
#ifndef TRUE
|
36
|
-
# define TRUE (1==1)
|
37
|
-
# define FALSE (1==2)
|
38
|
-
#endif
|
39
|
-
|
40
35
|
|
41
36
|
/*
|
42
37
|
* myPinMode:
|
@@ -156,7 +151,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
|
|
156
151
|
struct wiringPiNodeStruct *node ;
|
157
152
|
|
158
153
|
if ((fd = serialOpen (device, baud)) < 0)
|
159
|
-
return
|
154
|
+
return FALSE ;
|
160
155
|
|
161
156
|
delay (10) ; // May need longer if it's an Uno that reboots on the open...
|
162
157
|
|
@@ -184,7 +179,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
|
|
184
179
|
if (!ok)
|
185
180
|
{
|
186
181
|
serialClose (fd) ;
|
187
|
-
return
|
182
|
+
return FALSE ;
|
188
183
|
}
|
189
184
|
|
190
185
|
node = wiringPiNewNode (pinBase, numPins) ;
|
@@ -197,5 +192,5 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
|
|
197
192
|
node->digitalWrite = myDigitalWrite ;
|
198
193
|
node->pwmWrite = myPwmWrite ;
|
199
194
|
|
200
|
-
return
|
195
|
+
return TRUE ;
|
201
196
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* max31855.c:
|
3
3
|
* Extend wiringPi with the max31855 SPI Analog to Digital convertor
|
4
|
-
* Copyright (c) 2012-
|
4
|
+
* Copyright (c) 2012-2015 Gordon Henderson
|
5
5
|
***********************************************************************
|
6
6
|
* This file is part of wiringPi:
|
7
7
|
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
@@ -22,39 +22,57 @@
|
|
22
22
|
***********************************************************************
|
23
23
|
*/
|
24
24
|
|
25
|
+
#include <byteswap.h>
|
26
|
+
#include <stdint.h>
|
27
|
+
|
25
28
|
#include <wiringPi.h>
|
26
29
|
#include <wiringPiSPI.h>
|
27
30
|
|
28
31
|
#include "max31855.h"
|
29
32
|
|
30
|
-
/*
|
31
|
-
* myAnalogRead:
|
32
|
-
* Return the analog value of the given pin
|
33
|
-
* Note: The chip really only has one read "channel", but we're faking it
|
34
|
-
* here so we can read the error registers. Channel 0 will be the data
|
35
|
-
* channel, and 1 is the error register code.
|
36
|
-
* Note: Temperature returned is temp in C * 4, so divide result by 4
|
37
|
-
*********************************************************************************
|
38
|
-
*/
|
39
|
-
|
40
33
|
static int myAnalogRead (struct wiringPiNodeStruct *node, int pin)
|
41
34
|
{
|
42
|
-
|
35
|
+
uint32_t spiData ;
|
43
36
|
int temp ;
|
44
37
|
int chan = pin - node->pinBase ;
|
45
38
|
|
46
39
|
wiringPiSPIDataRW (node->fd, (unsigned char *)&spiData, 4) ;
|
47
40
|
|
48
|
-
|
41
|
+
spiData = __bswap_32(spiData) ;
|
42
|
+
|
43
|
+
switch (chan)
|
49
44
|
{
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
case 0: // Existing read - return raw value * 4
|
46
|
+
spiData >>= 18 ;
|
47
|
+
temp = spiData & 0x1FFF ; // Bottom 13 bits
|
48
|
+
if ((spiData & 0x2000) != 0) // Negative
|
49
|
+
temp = -temp ;
|
50
|
+
|
51
|
+
return temp ;
|
52
|
+
|
53
|
+
case 1: // Return error bits
|
54
|
+
return spiData & 0x7 ;
|
55
|
+
|
56
|
+
case 2: // Return temp in C * 10
|
57
|
+
spiData >>= 18 ;
|
58
|
+
temp = spiData & 0x1FFF ; // Bottom 13 bits
|
59
|
+
if ((spiData & 0x2000) != 0) // Negative
|
60
|
+
temp = -temp ;
|
61
|
+
|
62
|
+
return (int)((((double)temp * 25) + 0.5) / 10.0) ;
|
63
|
+
|
64
|
+
case 3: // Return temp in F * 10
|
65
|
+
spiData >>= 18 ;
|
66
|
+
temp = spiData & 0x1FFF ; // Bottom 13 bits
|
67
|
+
if ((spiData & 0x2000) != 0) // Negative
|
68
|
+
temp = -temp ;
|
69
|
+
|
70
|
+
return (int)((((((double)temp * 0.25 * 9.0 / 5.0) + 32.0) * 100.0) + 0.5) / 10.0) ;
|
71
|
+
|
72
|
+
default: // Who knows...
|
73
|
+
return 0 ;
|
74
|
+
|
55
75
|
}
|
56
|
-
else // Return error bits
|
57
|
-
return spiData & 0x7 ;
|
58
76
|
}
|
59
77
|
|
60
78
|
|
@@ -70,12 +88,12 @@ int max31855Setup (const int pinBase, int spiChannel)
|
|
70
88
|
struct wiringPiNodeStruct *node ;
|
71
89
|
|
72
90
|
if (wiringPiSPISetup (spiChannel, 5000000) < 0) // 5MHz - prob 4 on the Pi
|
73
|
-
return
|
91
|
+
return FALSE ;
|
74
92
|
|
75
|
-
node = wiringPiNewNode (pinBase,
|
93
|
+
node = wiringPiNewNode (pinBase, 4) ;
|
76
94
|
|
77
95
|
node->fd = spiChannel ;
|
78
96
|
node->analogRead = myAnalogRead ;
|
79
97
|
|
80
|
-
return
|
98
|
+
return TRUE ;
|
81
99
|
}
|
@@ -66,7 +66,7 @@ int max5322Setup (const int pinBase, int spiChannel)
|
|
66
66
|
unsigned char spiData [2] ;
|
67
67
|
|
68
68
|
if (wiringPiSPISetup (spiChannel, 8000000) < 0) // 10MHz Max
|
69
|
-
return
|
69
|
+
return FALSE ;
|
70
70
|
|
71
71
|
node = wiringPiNewNode (pinBase, 2) ;
|
72
72
|
|
@@ -80,5 +80,5 @@ int max5322Setup (const int pinBase, int spiChannel)
|
|
80
80
|
|
81
81
|
wiringPiSPIDataRW (node->fd, spiData, 2) ;
|
82
82
|
|
83
|
-
return
|
83
|
+
return TRUE ;
|
84
84
|
}
|
@@ -132,7 +132,7 @@ int mcp23008Setup (const int pinBase, const int i2cAddress)
|
|
132
132
|
struct wiringPiNodeStruct *node ;
|
133
133
|
|
134
134
|
if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
|
135
|
-
return
|
135
|
+
return FALSE ;
|
136
136
|
|
137
137
|
wiringPiI2CWriteReg8 (fd, MCP23x08_IOCON, IOCON_INIT) ;
|
138
138
|
|
@@ -145,5 +145,5 @@ int mcp23008Setup (const int pinBase, const int i2cAddress)
|
|
145
145
|
node->digitalWrite = myDigitalWrite ;
|
146
146
|
node->data2 = wiringPiI2CReadReg8 (fd, MCP23x08_OLAT) ;
|
147
147
|
|
148
|
-
return
|
148
|
+
return TRUE ;
|
149
149
|
}
|
@@ -146,7 +146,7 @@ int mcp23016Setup (const int pinBase, const int i2cAddress)
|
|
146
146
|
struct wiringPiNodeStruct *node ;
|
147
147
|
|
148
148
|
if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
|
149
|
-
return
|
149
|
+
return FALSE ;
|
150
150
|
|
151
151
|
wiringPiI2CWriteReg8 (fd, MCP23016_IOCON0, IOCON_INIT) ;
|
152
152
|
wiringPiI2CWriteReg8 (fd, MCP23016_IOCON1, IOCON_INIT) ;
|
@@ -160,5 +160,5 @@ int mcp23016Setup (const int pinBase, const int i2cAddress)
|
|
160
160
|
node->data2 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT0) ;
|
161
161
|
node->data3 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT1) ;
|
162
162
|
|
163
|
-
return
|
163
|
+
return TRUE ;
|
164
164
|
}
|
@@ -177,7 +177,7 @@ int mcp23017Setup (const int pinBase, const int i2cAddress)
|
|
177
177
|
struct wiringPiNodeStruct *node ;
|
178
178
|
|
179
179
|
if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
|
180
|
-
return
|
180
|
+
return FALSE ;
|
181
181
|
|
182
182
|
wiringPiI2CWriteReg8 (fd, MCP23x17_IOCON, IOCON_INIT) ;
|
183
183
|
|
@@ -191,5 +191,5 @@ int mcp23017Setup (const int pinBase, const int i2cAddress)
|
|
191
191
|
node->data2 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATA) ;
|
192
192
|
node->data3 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATB) ;
|
193
193
|
|
194
|
-
return
|
194
|
+
return TRUE ;
|
195
195
|
}
|
@@ -167,11 +167,10 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
|
|
167
167
|
|
168
168
|
int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
|
169
169
|
{
|
170
|
-
int x ;
|
171
170
|
struct wiringPiNodeStruct *node ;
|
172
171
|
|
173
|
-
if (
|
174
|
-
return
|
172
|
+
if (wiringPiSPISetup (spiPort, MCP_SPEED) < 0)
|
173
|
+
return FALSE ;
|
175
174
|
|
176
175
|
writeByte (spiPort, devId, MCP23x08_IOCON, IOCON_INIT) ;
|
177
176
|
|
@@ -185,5 +184,5 @@ int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
|
|
185
184
|
node->digitalWrite = myDigitalWrite ;
|
186
185
|
node->data2 = readByte (spiPort, devId, MCP23x08_OLAT) ;
|
187
186
|
|
188
|
-
return
|
187
|
+
return TRUE ;
|
189
188
|
}
|
@@ -212,11 +212,10 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
|
|
212
212
|
|
213
213
|
int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
|
214
214
|
{
|
215
|
-
int x ;
|
216
215
|
struct wiringPiNodeStruct *node ;
|
217
216
|
|
218
|
-
if (
|
219
|
-
return
|
217
|
+
if (wiringPiSPISetup (spiPort, MCP_SPEED) < 0)
|
218
|
+
return FALSE ;
|
220
219
|
|
221
220
|
writeByte (spiPort, devId, MCP23x17_IOCON, IOCON_INIT | IOCON_HAEN) ;
|
222
221
|
writeByte (spiPort, devId, MCP23x17_IOCONB, IOCON_INIT | IOCON_HAEN) ;
|
@@ -232,5 +231,5 @@ int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
|
|
232
231
|
node->data2 = readByte (spiPort, devId, MCP23x17_OLATA) ;
|
233
232
|
node->data3 = readByte (spiPort, devId, MCP23x17_OLATB) ;
|
234
233
|
|
235
|
-
return
|
234
|
+
return TRUE ;
|
236
235
|
}
|
@@ -65,12 +65,12 @@ int mcp3002Setup (const int pinBase, int spiChannel)
|
|
65
65
|
struct wiringPiNodeStruct *node ;
|
66
66
|
|
67
67
|
if (wiringPiSPISetup (spiChannel, 1000000) < 0)
|
68
|
-
return
|
68
|
+
return FALSE ;
|
69
69
|
|
70
70
|
node = wiringPiNewNode (pinBase, 2) ;
|
71
71
|
|
72
72
|
node->fd = spiChannel ;
|
73
73
|
node->analogRead = myAnalogRead ;
|
74
74
|
|
75
|
-
return
|
75
|
+
return TRUE ;
|
76
76
|
}
|
@@ -65,12 +65,12 @@ int mcp3004Setup (const int pinBase, int spiChannel)
|
|
65
65
|
struct wiringPiNodeStruct *node ;
|
66
66
|
|
67
67
|
if (wiringPiSPISetup (spiChannel, 1000000) < 0)
|
68
|
-
return
|
68
|
+
return FALSE ;
|
69
69
|
|
70
70
|
node = wiringPiNewNode (pinBase, 8) ;
|
71
71
|
|
72
72
|
node->fd = spiChannel ;
|
73
73
|
node->analogRead = myAnalogRead ;
|
74
74
|
|
75
|
-
return
|
75
|
+
return TRUE ;
|
76
76
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/*
|
2
2
|
* mcp3422.c:
|
3
|
-
* Extend wiringPi with the MCP3422 I2C ADC chip
|
4
|
-
*
|
5
|
-
*
|
3
|
+
* Extend wiringPi with the MCP3422/3/4 I2C ADC chip
|
4
|
+
* This code assumes single-ended mode only.
|
5
|
+
* Tested on actual hardware: 20th Feb 2016.
|
6
|
+
* Copyright (c) 2013-2016 Gordon Henderson
|
6
7
|
***********************************************************************
|
7
8
|
* This file is part of wiringPi:
|
8
9
|
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
@@ -29,7 +30,6 @@
|
|
29
30
|
#include <stdint.h>
|
30
31
|
#include <fcntl.h>
|
31
32
|
#include <sys/ioctl.h>
|
32
|
-
#include <linux/spi/spidev.h>
|
33
33
|
|
34
34
|
#include <wiringPi.h>
|
35
35
|
#include <wiringPiI2C.h>
|
@@ -37,6 +37,23 @@
|
|
37
37
|
#include "mcp3422.h"
|
38
38
|
|
39
39
|
|
40
|
+
/*
|
41
|
+
* waitForConversion:
|
42
|
+
* Common code to wait for the ADC to finish conversion
|
43
|
+
*********************************************************************************
|
44
|
+
*/
|
45
|
+
|
46
|
+
void waitForConversion (int fd, unsigned char *buffer, int n)
|
47
|
+
{
|
48
|
+
for (;;)
|
49
|
+
{
|
50
|
+
read (fd, buffer, n) ;
|
51
|
+
if ((buffer [n-1] & 0x80) == 0)
|
52
|
+
break ;
|
53
|
+
delay (1) ;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
40
57
|
/*
|
41
58
|
* myAnalogRead:
|
42
59
|
* Read a channel from the device
|
@@ -48,37 +65,34 @@ int myAnalogRead (struct wiringPiNodeStruct *node, int chan)
|
|
48
65
|
unsigned char config ;
|
49
66
|
unsigned char buffer [4] ;
|
50
67
|
int value = 0 ;
|
68
|
+
int realChan = (chan & 3) - node->pinBase ;
|
51
69
|
|
52
70
|
// One-shot mode, trigger plus the other configs.
|
53
71
|
|
54
|
-
config = 0x80 | (
|
72
|
+
config = 0x80 | (realChan << 5) | (node->data0 << 2) | (node->data1) ;
|
55
73
|
|
56
74
|
wiringPiI2CWrite (node->fd, config) ;
|
57
75
|
|
58
76
|
switch (node->data0) // Sample rate
|
59
77
|
{
|
60
78
|
case MCP3422_SR_3_75: // 18 bits
|
61
|
-
|
62
|
-
|
63
|
-
value = ((buffer [0] & 3) << 16) | (buffer [1] << 8) | buffer [0] ;
|
79
|
+
waitForConversion (node->fd, &buffer [0], 4) ;
|
80
|
+
value = ((buffer [0] & 3) << 16) | (buffer [1] << 8) | buffer [2] ;
|
64
81
|
break ;
|
65
82
|
|
66
83
|
case MCP3422_SR_15: // 16 bits
|
67
|
-
|
68
|
-
read (node->fd, buffer, 3) ;
|
84
|
+
waitForConversion (node->fd, buffer, 3) ;
|
69
85
|
value = (buffer [0] << 8) | buffer [1] ;
|
70
86
|
break ;
|
71
87
|
|
72
88
|
case MCP3422_SR_60: // 14 bits
|
73
|
-
|
74
|
-
read (node->fd, buffer, 3) ;
|
89
|
+
waitForConversion (node->fd, buffer, 3) ;
|
75
90
|
value = ((buffer [0] & 0x3F) << 8) | buffer [1] ;
|
76
91
|
break ;
|
77
92
|
|
78
|
-
case MCP3422_SR_240: // 12 bits
|
79
|
-
|
80
|
-
|
81
|
-
value = ((buffer [0] & 0x0F) << 8) | buffer [0] ;
|
93
|
+
case MCP3422_SR_240: // 12 bits - default
|
94
|
+
waitForConversion (node->fd, buffer, 3) ;
|
95
|
+
value = ((buffer [0] & 0x0F) << 8) | buffer [1] ;
|
82
96
|
break ;
|
83
97
|
}
|
84
98
|
|
@@ -98,13 +112,14 @@ int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain)
|
|
98
112
|
struct wiringPiNodeStruct *node ;
|
99
113
|
|
100
114
|
if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
|
101
|
-
return
|
115
|
+
return FALSE ;
|
102
116
|
|
103
117
|
node = wiringPiNewNode (pinBase, 4) ;
|
104
118
|
|
119
|
+
node->fd = fd ;
|
105
120
|
node->data0 = sampleRate ;
|
106
121
|
node->data1 = gain ;
|
107
122
|
node->analogRead = myAnalogRead ;
|
108
123
|
|
109
|
-
return
|
124
|
+
return TRUE ;
|
110
125
|
}
|