Skip to content

Commit 6582bb8

Browse files
author
dherrada
committed
Made pass using info from datasheet and circuitpython library
1 parent 5330068 commit 6582bb8

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

Adafruit_LSM9DS0.h

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,47 @@
1515
#include <Adafruit_Sensor.h>
1616
#include <SPI.h>
1717

18-
#define LSM9DS0_ADDRESS_ACCELMAG (0x1D) // 3B >> 1 = 7bit default
19-
#define LSM9DS0_ADDRESS_GYRO (0x6B) // D6 >> 1 = 7bit default
20-
#define LSM9DS0_XM_ID (0b01001001)
21-
#define LSM9DS0_G_ID (0b11010100)
18+
#define LSM9DS0_ADDRESS_ACCELMAG (0x1D) //!< 3B >> 1 = 7bit default
19+
#define LSM9DS0_ADDRESS_GYRO (0x6B) //!< D6 >> 1 = 7bit default
20+
#define LSM9DS0_XM_ID \
21+
(0b01001001) //!< Accelerometer & magnetometer ID register, WHO_AM_I_XM
22+
#define LSM9DS0_G_ID (0b11010100) //!< Gyroscope ID register, WHO_AM_I_G
2223

2324
// Linear Acceleration: mg per LSB
24-
#define LSM9DS0_ACCEL_MG_LSB_2G (0.061F)
25-
#define LSM9DS0_ACCEL_MG_LSB_4G (0.122F)
26-
#define LSM9DS0_ACCEL_MG_LSB_6G (0.183F)
27-
#define LSM9DS0_ACCEL_MG_LSB_8G (0.244F)
28-
#define LSM9DS0_ACCEL_MG_LSB_16G (0.732F) // Is this right? Was expecting 0.488F
25+
#define LSM9DS0_ACCEL_MG_LSB_2G \
26+
(0.061F) //!< Linear acceleration sensitivity FS=+-2g
27+
#define LSM9DS0_ACCEL_MG_LSB_4G \
28+
(0.122F) //!< Linear acceleration sensitivity FS=+-4g
29+
30+
#define LSM9DS0_ACCEL_MG_LSB_6G \
31+
(0.183F) //!< Linear acceleration sensitivity FS=+-6g
32+
#define LSM9DS0_ACCEL_MG_LSB_8G \
33+
(0.244F) //!< Linear acceleration sensitivity FS=+-8g
34+
#define LSM9DS0_ACCEL_MG_LSB_16G \
35+
(0.732F) //!< Linear acceleration sensitivity FS=+-16g
2936

3037
// Magnetic Field Strength: gauss range
31-
#define LSM9DS0_MAG_MGAUSS_2GAUSS (0.08F)
32-
#define LSM9DS0_MAG_MGAUSS_4GAUSS (0.16F)
33-
#define LSM9DS0_MAG_MGAUSS_8GAUSS (0.32F)
34-
#define LSM9DS0_MAG_MGAUSS_12GAUSS (0.48F)
38+
#define LSM9DS0_MAG_MGAUSS_2GAUSS (0.08F) //!< Magnetic sensitivity FS=+-2 gauss
39+
#define LSM9DS0_MAG_MGAUSS_4GAUSS (0.16F) //!< Magnetic sensitivity FS=+-4 gauss
40+
#define LSM9DS0_MAG_MGAUSS_8GAUSS (0.32F) //!< Magnetic sensitivity FS=+-8 gauss
41+
#define LSM9DS0_MAG_MGAUSS_12GAUSS \
42+
(0.48F) //!< Magnetic sensitivity FS=+-12 gauss
3543

3644
// Angular Rate: dps per LSB
37-
#define LSM9DS0_GYRO_DPS_DIGIT_245DPS (0.00875F)
38-
#define LSM9DS0_GYRO_DPS_DIGIT_500DPS (0.01750F)
39-
#define LSM9DS0_GYRO_DPS_DIGIT_2000DPS (0.07000F)
45+
#define LSM9DS0_GYRO_DPS_DIGIT_245DPS \
46+
(0.00875F) //!< Angular rate sensitivity FS=+-245dps
47+
#define LSM9DS0_GYRO_DPS_DIGIT_500DPS \
48+
(0.01750F) //!< Angular rate sensitivity FS=+-500dps
49+
#define LSM9DS0_GYRO_DPS_DIGIT_2000DPS \
50+
(0.07000F) //!< Angular rate sensitivity FS=+-2000dps
4051

4152
// Temperature: LSB per degree celsius
42-
#define LSM9DS0_TEMP_LSB_DEGREE_CELSIUS (8) // 1°C = 8, 25° = 200, etc.
53+
#define LSM9DS0_TEMP_LSB_DEGREE_CELSIUS \
54+
(8) //!< Temperature sensor output change vs. temperature. 1°C = 8, 25° = 200,
55+
//!< etc.
4356

44-
#define GYROTYPE (true)
45-
#define XMTYPE (false)
57+
#define GYROTYPE (true) //!< Used to enable gyroscope device
58+
#define XMTYPE (false) //!< Used to enable accellerometer & magnetometer device
4659

4760
/* Forward reference required for function pointers below. */
4861
class Adafruit_LSM9DS0;
@@ -51,10 +64,15 @@ class Adafruit_LSM9DS0;
5164
* used */
5265
/* by the Adafruit_LSM9DS0::Sensor class to read and retrieve individual
5366
* sensors. */
54-
typedef void (Adafruit_LSM9DS0::*lsm9ds0_read_func)(void);
55-
typedef void (Adafruit_LSM9DS0::*lsm9ds0_get_event_func)(sensors_event_t *,
56-
uint32_t);
57-
typedef void (Adafruit_LSM9DS0::*lsm9ds0_get_sensor_func)(sensor_t *);
67+
typedef void (Adafruit_LSM9DS0::*lsm9ds0_read_func)(
68+
void); //!< Pointer to member functions to read. Used by
69+
//!< Adafruit_LSM9DS0::Sensor class.
70+
typedef void (Adafruit_LSM9DS0::*lsm9ds0_get_event_func)(
71+
sensors_event_t *, uint32_t); //!< Pointer to member functions to get event.
72+
//!< Used by Adafruit_LSM9DS0::Sensor class.
73+
typedef void (Adafruit_LSM9DS0::*lsm9ds0_get_sensor_func)(
74+
sensor_t *); //!< Pointer to member functions to get sensor function. Used
75+
//!< by Adafruit_LSM9DS0::Sensor class.
5876

5977
/**! Interface object for LSM9DS0 9-DoF sensor */
6078
class Adafruit_LSM9DS0 {

0 commit comments

Comments
 (0)