11#pragma once
2- #include " sfe_ism330dhcx.h"
3- #include " sfe_bus.h"
2+ #include " SparkFun_Qwiic_KX13X.h"
43#include < Wire.h>
54#include < SPI.h>
65
7- class SparkFun_KX13X : public QwDevKX13X
6+ class SparkFun_KX132 : public QwDevKX132
87{
98
109 public:
1110
12- SparkFun_KX13X () {};
11+ SparkFun_KX132 () {};
1312
1413 // /////////////////////////////////////////////////////////////////////
1514 // begin()
@@ -31,7 +30,7 @@ class SparkFun_KX13X : public QwDevKX13X
3130 //
3231 // Version 1:
3332 // 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 )
3534 {
3635 // Setup I2C object and pass into the superclass
3736 setCommunicationBus (_i2cBus, deviceAddress);
@@ -40,12 +39,12 @@ class SparkFun_KX13X : public QwDevKX13X
4039 _i2cBus.init ();
4140
4241 // Initialize the system - return results
43- return this ->QwDevKX13X ::init ();
42+ return this ->QwDevKX132 ::init ();
4443 }
4544
4645 // Version 2:
4746 // 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 )
4948 {
5049 // Setup I2C object and pass into the superclass
5150 setCommunicationBus (_i2cBus, deviceAddress);
@@ -54,7 +53,7 @@ class SparkFun_KX13X : public QwDevKX13X
5453 _i2cBus.init (wirePort, true );
5554
5655 // Initialize the system - return results
57- return this ->QwDevKX13X ::init ();
56+ return this ->QwDevKX132 ::init ();
5857 }
5958
6059 private:
@@ -64,11 +63,11 @@ class SparkFun_KX13X : public QwDevKX13X
6463
6564};
6665
67- class SparkFun_KX13X_SPI : public QwDevKX13X
66+ class SparkFun_KX132_SPI : public QwDevKX132
6867{
6968 public:
7069
71- SparkFun_KX13X_SPI () {};
70+ SparkFun_KX132_SPI () {};
7271
7372 // /////////////////////////////////////////////////////////////////////
7473 // begin()
@@ -103,7 +102,7 @@ class SparkFun_KX13X_SPI : public QwDevKX13X
103102 _spiBus.init (cs, true );
104103
105104 // Initialize the system - return results
106- return this ->QwDevKX13X ::init ();
105+ return this ->QwDevKX132 ::init ();
107106 }
108107
109108 bool begin (SPIClass &spiPort, SPISettings ismSettings, uint8_t cs)
@@ -115,7 +114,128 @@ class SparkFun_KX13X_SPI : public QwDevKX13X
115114 _spiBus.init (spiPort, ismSettings, cs, true );
116115
117116 // 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 ();
119239 }
120240
121241 private:
0 commit comments