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 LIS3DH by
Diff: LIS3DH.h
- Revision:
- 7:50ac3372def2
- Parent:
- 6:e269772dad35
- Child:
- 8:0999d25ed7bc
--- a/LIS3DH.h Tue Feb 24 12:24:38 2015 +0000
+++ b/LIS3DH.h Sat Dec 12 06:06:43 2015 +0000
@@ -7,7 +7,7 @@
* http://www.page.sannet.ne.jp/kenjia/index.html
* http://mbed.org/users/kenjiArai/
* Created: July 14th, 2014
- * Revised: Feburary 24th, 2015
+ * Revised: December 12th, 2015
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -21,6 +21,9 @@
#include "mbed.h"
+// revision 6 have two bugs, (1) read_mg_data, (2) divided by 15 (16 is coorect value)
+#define OLD_REV 0 // KEEP 0!! (If you set 1, work as old revision)
+
// LIS3DH Address
// 7bit address = 0b001100x(0x18 or 0x19 depends on SA0/SDO)
#define LIS3DH_G_CHIP_ADDR (0x18 << 1) // SA0(=SDO pin) = Ground
@@ -48,7 +51,7 @@
#define LIS3DH_CTRL_REG5 0x24
#define LIS3DH_CTRL_REG6 0x25
#define LIS3DH_REFERENCE 0x26
-#define LIS3DH_STATUS_REG2 0x27
+#define LIS3DH_STATUS_REG 0x27
#define LIS3DH_OUT_X_L 0x28
#define LIS3DH_OUT_X_H 0x29
#define LIS3DH_OUT_Y_L 0x2a
@@ -105,13 +108,24 @@
#define LIS3DH_FS_16G 3
// definition for Nomalization
+#if OLD_REV
#define LIS3DH_SENSITIVITY_2G (0.001F)
#define LIS3DH_SENSITIVITY_4G (0.002F)
#define LIS3DH_SENSITIVITY_8G (0.004F)
#define LIS3DH_SENSITIVITY_16G (0.012F)
+#else
+#define LIS3DH_SENSITIVITY_2G 1
+#define LIS3DH_SENSITIVITY_4G 2
+#define LIS3DH_SENSITIVITY_8G 4
+#define LIS3DH_SENSITIVITY_16G 12
+#endif
//Gravity at Earth's surface in m/s/s
+#if OLD_REV
#define GRAVITY (9.80665F)
+#else
+#define GRAVITY (9.80665F / 1000)
+#endif
/** Interface for STMicronics MEMS motion sensor: 3-axis "nano" accelerometer
* Chip: LIS3DH
@@ -223,7 +237,11 @@
I2C _i2c;
private:
+#if OLD_REV
float fs_factor; // full scale factor
+#else
+ uint8_t fs_factor; // full scale factor
+#endif
char dt[2]; // working buffer
uint8_t acc_addr; // acc sensor address
uint8_t acc_id; // acc ID
