@@ -35,6 +35,7 @@ uint8_t QwiicKX13xCore::beginSPICore(uint8_t CSPin, uint32_t spiPortSpeed, SPICl
35
35
{
36
36
_i2cPort = NULL ;
37
37
_spiPortSpeed = spiPortSpeed;
38
+ _spiPort = &spiPort;
38
39
39
40
if ( _spiPortSpeed > 10000000 )
40
41
_spiPortSpeed = 10000000 ;
@@ -70,7 +71,7 @@ uint8_t QwiicKX13xCore::beginSPICore(uint8_t CSPin, uint32_t spiPortSpeed, SPICl
70
71
bool QwiicKX13xCore::initialize (uint8_t settings)
71
72
{
72
73
73
- KX13X_STATUS_t returnError;
74
+ KX13X_STATUS_t returnError = KX13X_GENERAL_ERROR ;
74
75
if ( !accelControl (false ) ){
75
76
return false ;
76
77
}
@@ -133,7 +134,7 @@ uint8_t QwiicKX13xCore::readAccelState(){
133
134
// Possible KX134 arguments: 0x00 (8g), 0x01 (16g), 0x02 (32g), 0x03 (64g)
134
135
bool QwiicKX13xCore::setRange (uint8_t range){
135
136
136
- if ( range < 0 | range > 3 )
137
+ if ( range > 3 )
137
138
return false ;
138
139
139
140
uint8_t accelState = readAccelState ();
@@ -156,7 +157,7 @@ bool QwiicKX13xCore::setRange(uint8_t range){
156
157
// 0.781 * (2 * (n)) derived from pg. 26 of Techincal Reference Manual
157
158
bool QwiicKX13xCore::setOutputDataRate (uint8_t rate){
158
159
159
- if ( rate < 0 | rate > 15 )
160
+ if ( rate > 15 )
160
161
return false ;
161
162
162
163
uint8_t accelState = readAccelState (); // Put it back where we found it.
@@ -197,8 +198,6 @@ bool QwiicKX13xCore::setInterruptPin(bool enable, uint8_t polarity, uint8_t puls
197
198
return false ;
198
199
else if ( pulseWidth != 1 && pulseWidth != 0 )
199
200
return false ;
200
- else if ( latchControl < 0 | latchControl > 4 )
201
- return false ;
202
201
203
202
uint8_t accelState = readAccelState (); // Put it back where we found it.
204
203
accelControl (false ); // Can't adjust without putting to sleep
@@ -220,7 +219,7 @@ bool QwiicKX13xCore::setInterruptPin(bool enable, uint8_t polarity, uint8_t puls
220
219
// interrupt pin one or pin two.
221
220
bool QwiicKX13xCore::routeHardwareInterrupt (uint8_t rdr, uint8_t pin){
222
221
223
- if ( rdr < 0 | rdr > 128 )
222
+ if ( rdr > 128 )
224
223
return false ;
225
224
if ( pin != 1 && pin != 2 )
226
225
return false ;
@@ -287,7 +286,7 @@ bool QwiicKX13xCore::dataTrigger(){
287
286
// set in the BUF_CNTL2 (0x5F) register (see "setBufferOperation" below).
288
287
bool QwiicKX13xCore::setBufferThreshold (uint8_t threshold){
289
288
290
- if ( threshold < 2 | threshold > 171 )
289
+ if ( threshold < 2 || threshold > 171 )
291
290
return false ;
292
291
293
292
@@ -300,7 +299,7 @@ bool QwiicKX13xCore::setBufferThreshold(uint8_t threshold){
300
299
return false ;
301
300
302
301
if ( threshold > 86 && resolution == 1 ) // 1 = 16bit resolution, max samples: 86
303
- threshold == 86 ;
302
+ threshold = 86 ;
304
303
305
304
returnError = writeRegister (KX13X_BUF_CNTL1, 0x00 , threshold, 0 );
306
305
if ( returnError == KX13X_SUCCESS )
@@ -316,9 +315,9 @@ bool QwiicKX13xCore::setBufferThreshold(uint8_t threshold){
316
315
// to be powered own to adjust settings.
317
316
bool QwiicKX13xCore::setBufferOperation (uint8_t operationMode, uint8_t resolution){
318
317
319
- if ( resolution < 0 | resolution > 1 )
318
+ if ( resolution > 1 )
320
319
return false ;
321
- if ( operationMode < 0 | operationMode > 2 )
320
+ if ( operationMode > 2 )
322
321
return false ;
323
322
324
323
@@ -438,7 +437,7 @@ KX13X_STATUS_t QwiicKX13xCore::readRegister(uint8_t *dataPointer, uint8_t reg)
438
437
}
439
438
440
439
// Sends a request to read a number of registers
441
- KX13X_STATUS_t QwiicKX13xCore::readMultipleRegisters (uint8_t reg, uint8_t dataBuffer[], int16_t numBytes)
440
+ KX13X_STATUS_t QwiicKX13xCore::readMultipleRegisters (uint8_t reg, uint8_t dataBuffer[], uint16_t numBytes)
442
441
{
443
442
444
443
if ( _i2cPort == NULL ) {
@@ -590,8 +589,6 @@ bool QwiicKX132::beginSPI(uint8_t csPin, uint32_t spiPortSpeed, SPIClass &spiPor
590
589
// converted.
591
590
outputData QwiicKX132::getAccelData (){
592
591
593
- uint8_t tempRegVal;
594
- KX13X_STATUS_t returnError;
595
592
if ( getRawAccelData (&rawAccelData) &&
596
593
convAccelData (&userAccel, &rawAccelData) )
597
594
return userAccel;
@@ -679,8 +676,6 @@ bool QwiicKX134::beginSPI(uint8_t csPin, uint32_t spiPortSpeed, SPIClass &spiPor
679
676
// converted.
680
677
outputData QwiicKX134::getAccelData (){
681
678
682
- uint8_t tempRegVal;
683
- KX13X_STATUS_t returnError;
684
679
if ( getRawAccelData (&rawAccelData) &&
685
680
convAccelData (&userAccel, &rawAccelData) )
686
681
return userAccel;
0 commit comments