Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of KX022 by
Diff: KX022.cpp
- Revision:
- 3:e2d1659fe67e
- Parent:
- 0:e642dd732c4b
diff -r 5ac8e9e5f63e -r e2d1659fe67e KX022.cpp
--- a/KX022.cpp Wed Mar 23 03:32:14 2016 +0000
+++ b/KX022.cpp Wed Sep 14 09:16:41 2016 +0000
@@ -49,10 +49,11 @@
unsigned char buf;
unsigned char reg[2];
+ DEBUG_PRINT("KX022 init started\n\r");
readRegs(KX022_WHO_AM_I, &buf, sizeof(buf));
if (buf != KX022_WAI_VAL) {
- DEBUG_PRINT("KX022 initialization error. (%d)\n", buf);
- return;
+ DEBUG_PRINT("KX022 initialization error. (WAI %d, not %d)\n\r", buf, KX022_WAI_VAL);
+ DEBUG_PRINT("Trying to config anyway, in case there is some compatible sensor connected.\n\r");
}
reg[0] = KX022_CNTL1;
@@ -110,9 +111,14 @@
void KX022::readRegs(int addr, uint8_t * data, int len)
{
+ int read_nok;
char t[1] = {addr};
+
m_i2c.write(m_addr, t, 1, true);
- m_i2c.read(m_addr, (char *)data, len);
+ read_nok = m_i2c.read(m_addr, (char *)data, len);
+ if (read_nok){
+ DEBUG_PRINT("Read fail\n\r");
+ }
}
void KX022::writeRegs(uint8_t * data, int len)
