1
1
#pragma once
2
- #include " sfe_ism330dhcx.h"
3
- #include " sfe_bus.h"
2
+ #include " SparkFun_Qwiic_KX13X.h"
4
3
#include < Wire.h>
5
4
#include < SPI.h>
6
5
7
- class SparkFun_KX13X : public QwDevKX13X
6
+ class SparkFun_KX132 : public QwDevKX132
8
7
{
9
8
10
9
public:
11
10
12
- SparkFun_KX13X () {};
11
+ SparkFun_KX132 () {};
13
12
14
13
// /////////////////////////////////////////////////////////////////////
15
14
// begin()
@@ -31,7 +30,7 @@ class SparkFun_KX13X : public QwDevKX13X
31
30
//
32
31
// Version 1:
33
32
// User skips passing in an I2C object which then defaults to Wire.
34
- bool begin (uint8_t deviceAddress = ISM330DHCX_ADDRESS_HIGH )
33
+ bool begin (uint8_t deviceAddress = KX13X_ADDRESS_HIGH )
35
34
{
36
35
// Setup I2C object and pass into the superclass
37
36
setCommunicationBus (_i2cBus, deviceAddress);
@@ -40,12 +39,12 @@ class SparkFun_KX13X : public QwDevKX13X
40
39
_i2cBus.init ();
41
40
42
41
// Initialize the system - return results
43
- return this ->QwDevKX13X ::init ();
42
+ return this ->QwDevKX132 ::init ();
44
43
}
45
44
46
45
// Version 2:
47
46
// User passes in an I2C object and an address (optional).
48
- bool begin (TwoWire &wirePort, uint8_t deviceAddress = ISM330DHCX_ADDRESS_HIGH )
47
+ bool begin (TwoWire &wirePort, uint8_t deviceAddress = KX13X_ADDRESS_HIGH )
49
48
{
50
49
// Setup I2C object and pass into the superclass
51
50
setCommunicationBus (_i2cBus, deviceAddress);
@@ -54,7 +53,7 @@ class SparkFun_KX13X : public QwDevKX13X
54
53
_i2cBus.init (wirePort, true );
55
54
56
55
// Initialize the system - return results
57
- return this ->QwDevKX13X ::init ();
56
+ return this ->QwDevKX132 ::init ();
58
57
}
59
58
60
59
private:
@@ -64,11 +63,11 @@ class SparkFun_KX13X : public QwDevKX13X
64
63
65
64
};
66
65
67
- class SparkFun_KX13X_SPI : public QwDevKX13X
66
+ class SparkFun_KX132_SPI : public QwDevKX132
68
67
{
69
68
public:
70
69
71
- SparkFun_KX13X_SPI () {};
70
+ SparkFun_KX132_SPI () {};
72
71
73
72
// /////////////////////////////////////////////////////////////////////
74
73
// begin()
@@ -103,7 +102,7 @@ class SparkFun_KX13X_SPI : public QwDevKX13X
103
102
_spiBus.init (cs, true );
104
103
105
104
// Initialize the system - return results
106
- return this ->QwDevKX13X ::init ();
105
+ return this ->QwDevKX132 ::init ();
107
106
}
108
107
109
108
bool begin (SPIClass &spiPort, SPISettings ismSettings, uint8_t cs)
@@ -115,7 +114,128 @@ class SparkFun_KX13X_SPI : public QwDevKX13X
115
114
_spiBus.init (spiPort, ismSettings, cs, true );
116
115
117
116
// Initialize the system - return results
118
- return this ->QwDevKX13X ::init ();
117
+ return this ->QwDevKX132 ::init ();
118
+ }
119
+
120
+ private:
121
+
122
+ // SPI bus class
123
+ SfeSPI _spiBus;
124
+
125
+ };
126
+
127
+ class SparkFun_KX134 : public QwDevKX134
128
+ {
129
+
130
+ public:
131
+
132
+ SparkFun_KX134 () {};
133
+
134
+ // /////////////////////////////////////////////////////////////////////
135
+ // begin()
136
+ //
137
+ // This method is called to initialize the ISM330DHCX library and connect to
138
+ // the ISM330DHCX device. This method must be called before calling any other method
139
+ // that interacts with the device.
140
+ //
141
+ // This method follows the standard startup pattern in SparkFun Arduino
142
+ // libraries.
143
+ //
144
+ // Parameter Description
145
+ // --------- ----------------------------
146
+ // wirePort optional. The Wire port. If not provided, the default port is used
147
+ // address optional. I2C Address. If not provided, the default address is used.
148
+ // retval true on success, false on startup failure
149
+ //
150
+ // This methond is overridden, implementing two versions.
151
+ //
152
+ // Version 1:
153
+ // User skips passing in an I2C object which then defaults to Wire.
154
+ bool begin (uint8_t deviceAddress = KX13X_ADDRESS_HIGH)
155
+ {
156
+ // Setup I2C object and pass into the superclass
157
+ setCommunicationBus (_i2cBus, deviceAddress);
158
+
159
+ // Initialize the I2C buss class i.e. setup default Wire port
160
+ _i2cBus.init ();
161
+
162
+ // Initialize the system - return results
163
+ return this ->QwDevKX134 ::init ();
164
+ }
165
+
166
+ // Version 2:
167
+ // User passes in an I2C object and an address (optional).
168
+ bool begin (TwoWire &wirePort, uint8_t deviceAddress = KX13X_ADDRESS_HIGH)
169
+ {
170
+ // Setup I2C object and pass into the superclass
171
+ setCommunicationBus (_i2cBus, deviceAddress);
172
+
173
+ // Give the I2C port provided by the user to the I2C bus class.
174
+ _i2cBus.init (wirePort, true );
175
+
176
+ // Initialize the system - return results
177
+ return this ->QwDevKX134 ::init ();
178
+ }
179
+
180
+ private:
181
+
182
+ // I2C bus class
183
+ QwI2C _i2cBus;
184
+
185
+ };
186
+
187
+ class SparkFun_KX134_SPI : public QwDevKX134
188
+ {
189
+ public:
190
+
191
+ SparkFun_KX134_SPI () {};
192
+
193
+ // /////////////////////////////////////////////////////////////////////
194
+ // begin()
195
+ //
196
+ // This method is called to initialize the ISM330DHCX library and connect to
197
+ // the ISM330DHCX device. This method must be called before calling any other method
198
+ // that interacts with the device.
199
+ //
200
+ // This method follows the standard startup pattern in SparkFun Arduino
201
+ // libraries.
202
+ //
203
+ // Parameter Description
204
+ // --------- ----------------------------
205
+ // spiPort optional. The SPI port. If not provided, the default port is used
206
+ // SPISettings optional. SPI "transaction" settings are need for every data transfer.
207
+ // Default used if not provided.
208
+ // Chip Select mandatory. The chip select pin ("CS") can't be guessed, so must be provided.
209
+ // retval true on success, false on startup failure
210
+ //
211
+ // This methond is overridden, implementing two versions.
212
+ //
213
+ // Version 1:
214
+ // User skips passing in an SPI object which then defaults to SPI.
215
+
216
+ bool begin (uint8_t cs)
217
+ {
218
+ // Setup a SPI object and pass into the superclass
219
+ setCommunicationBus (_spiBus);
220
+
221
+ // Initialize the SPI bus class with the chip select pin, SPI port defaults to SPI,
222
+ // and SPI settings are set to class defaults.
223
+ _spiBus.init (cs, true );
224
+
225
+ // Initialize the system - return results
226
+ return this ->QwDevKX134 ::init ();
227
+ }
228
+
229
+ bool begin (SPIClass &spiPort, SPISettings ismSettings, uint8_t cs)
230
+ {
231
+ // Setup a SPI object and pass into the superclass
232
+ setCommunicationBus (_spiBus);
233
+
234
+ // Initialize the SPI bus class with provided SPI port, SPI setttings, and chip select pin.
235
+ _spiBus.init (spiPort, ismSettings, cs, true );
236
+
237
+ // Initialize the system - return results
238
+ return this ->QwDevKX134 ::init ();
119
239
}
120
240
121
241
private:
0 commit comments