KX022 Accelerometer library
Fork of KX022 by
Revision 5:9519f53d9965, committed 2019-02-05
- Comitter:
- deldering95
- Date:
- Tue Feb 05 15:23:38 2019 +0000
- Parent:
- 4:4038b02c530d
- Commit message:
- Changed Initialization code to check whether it is needed to initialize
Changed in this revision
| KXTJ3.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/KXTJ3.cpp Thu Oct 18 12:25:00 2018 +0000
+++ b/KXTJ3.cpp Tue Feb 05 15:23:38 2019 +0000
@@ -56,17 +56,21 @@
DEBUG_PRINT("Trying to config anyway, in case there is some compatible sensor connected.\n\r");
}
*/
- reg[0] = KXTJ3_CNTL1;
- reg[1] = 0x40;
- writeRegs(reg, 2);
+
+ readRegs(KXTJ3_CNTL1, reg, 1);
+ if(reg[0]!=0xC0){
+
+ reg[0] = KXTJ3_CNTL1;
+ reg[1] = 0x40;
+ writeRegs(reg, 2);
- reg[0] = KXTJ3_ODCNTL;
- reg[1] = 0x01;
- writeRegs(reg, 2);
+ reg[0] = KXTJ3_ODCNTL;
+ reg[1] = 0x01;
+ writeRegs(reg, 2);
- reg[0] = KXTJ3_CNTL1;
- reg[1] = 0xC0;
- writeRegs(reg, 2);
+ reg[0] = KXTJ3_CNTL1;
+ reg[1] = 0xC0;
+ writeRegs(reg, 2);}
}
float KXTJ3::getAccX()
