6 #ifndef LSM303DLHC_HPP_
7 #define LSM303DLHC_HPP_
9 #include "DrvI2cMaster.hpp"
13 LSM303DLHC(DrvI2cMaster* mI2c);
17 bool readAccXyz(
float* x,
float* y,
float* z);
21 constexpr
static uint8_t ACC_I2C_ADDRESS = 0x32;
22 constexpr
static uint8_t MAG_I2C_ADDRESS = 0x3C;
25 constexpr
static uint8_t LSM303DLHC_CTRL_REG1_A = 0x20;
26 constexpr
static uint8_t LSM303DLHC_CTRL_REG2_A = 0x21;
27 constexpr
static uint8_t LSM303DLHC_CTRL_REG3_A = 0x22;
28 constexpr
static uint8_t LSM303DLHC_CTRL_REG4_A = 0x23;
29 constexpr
static uint8_t LSM303DLHC_CTRL_REG5_A = 0x24;
30 constexpr
static uint8_t LSM303DLHC_CTRL_REG6_A = 0x25;
31 constexpr
static uint8_t LSM303DLHC_REFERENCE_A = 0x26;
32 constexpr
static uint8_t LSM303DLHC_STATUS_REG_A = 0x27;
33 constexpr
static uint8_t LSM303DLHC_OUT_X_L_A = 0x28;
34 constexpr
static uint8_t LSM303DLHC_OUT_X_H_A = 0x29;
35 constexpr
static uint8_t LSM303DLHC_OUT_Y_L_A = 0x2A;
36 constexpr
static uint8_t LSM303DLHC_OUT_Y_H_A = 0x2B;
37 constexpr
static uint8_t LSM303DLHC_OUT_Z_L_A = 0x2C;
38 constexpr
static uint8_t LSM303DLHC_OUT_Z_H_A = 0x2D;
39 constexpr
static uint8_t LSM303DLHC_FIFO_CTRL_REG_A = 0x2E;
40 constexpr
static uint8_t LSM303DLHC_FIFO_SRC_REG_A = 0x2F;
41 constexpr
static uint8_t LSM303DLHC_INT1_CFG_A = 0x30;
42 constexpr
static uint8_t LSM303DLHC_INT1_SOURCE_A = 0x31;
43 constexpr
static uint8_t LSM303DLHC_INT1_THS_A = 0x32;
44 constexpr
static uint8_t LSM303DLHC_INT1_DURATION_A = 0x33;
45 constexpr
static uint8_t LSM303DLHC_INT2_CFG_A = 0x34;
46 constexpr
static uint8_t LSM303DLHC_INT2_SOURCE_A = 0x35;
47 constexpr
static uint8_t LSM303DLHC_INT2_THS_A = 0x36;
48 constexpr
static uint8_t LSM303DLHC_INT2_DURATION_A = 0x37;
49 constexpr
static uint8_t LSM303DLHC_CLICK_CFG_A = 0x38;
50 constexpr
static uint8_t LSM303DLHC_CLICK_SOURCE_A = 0x39;
51 constexpr
static uint8_t LSM303DLHC_CLICK_THS_A = 0x3A;
52 constexpr
static uint8_t LSM303DLHC_TIME_LIMIT_A = 0x3B;
53 constexpr
static uint8_t LSM303DLHC_TIME_LATENCY_A = 0x3C;
54 constexpr
static uint8_t LSM303DLHC_TIME_WINDOW_A = 0x3D;
55 constexpr
static uint8_t LSM303DLHC_CRA_REG_M = 0x00;
56 constexpr
static uint8_t LSM303DLHC_CRB_REG_M = 0x01;
57 constexpr
static uint8_t LSM303DLHC_MR_REG_M = 0x02;
58 constexpr
static uint8_t LSM303DLHC_OUT_X_H_M = 0x03;
59 constexpr
static uint8_t LSM303DLHC_OUT_X_L_M = 0x04;
60 constexpr
static uint8_t LSM303DLHC_OUT_Z_H_M = 0x05;
61 constexpr
static uint8_t LSM303DLHC_OUT_Z_L_M = 0x06;
62 constexpr
static uint8_t LSM303DLHC_OUT_Y_H_M = 0x07;
63 constexpr
static uint8_t LSM303DLHC_OUT_Y_L_M = 0x08;
64 constexpr
static uint8_t LSM303DLHC_SR_REG_M = 0x09;
65 constexpr
static uint8_t LSM303DLHC_IRA_REG_M = 0x0A;
66 constexpr
static uint8_t LSM303DLHC_IRB_REG_M = 0x0B;
67 constexpr
static uint8_t LSM303DLHC_IRC_REG_M = 0x0C;
68 constexpr
static uint8_t LSM303DLHC_TEMP_OUT_H_M = 0x31;
69 constexpr
static uint8_t LSM303DLHC_TEMP_OUT_L_M = 0x32;
72 constexpr
static uint8_t LSM303DLHC_NORMAL_MODE = 0x00;
73 constexpr
static uint8_t LSM303DLHC_LOWPOWER_MODE = 0x08;
76 constexpr
static uint8_t LSM303DLHC_ODR_1_HZ = 0x10;
77 constexpr
static uint8_t LSM303DLHC_ODR_10_HZ = 0x20;
78 constexpr
static uint8_t LSM303DLHC_ODR_25_HZ = 0x30;
79 constexpr
static uint8_t LSM303DLHC_ODR_50_HZ = 0x40;
80 constexpr
static uint8_t LSM303DLHC_ODR_100_HZ = 0x50;
81 constexpr
static uint8_t LSM303DLHC_ODR_200_HZ = 0x60;
82 constexpr
static uint8_t LSM303DLHC_ODR_400_HZ = 0x70;
83 constexpr
static uint8_t LSM303DLHC_ODR_1620_HZ_LP = 0x80;
84 constexpr
static uint8_t LSM303DLHC_ODR_1344_HZ = 0x90;
87 constexpr
static uint8_t LSM303DLHC_X_ENABLE = 0x01;
88 constexpr
static uint8_t LSM303DLHC_Y_ENABLE = 0x02;
89 constexpr
static uint8_t LSM303DLHC_Z_ENABLE = 0x04;
90 constexpr
static uint8_t LSM303DLHC_AXES_ENABLE = 0x07;
91 constexpr
static uint8_t LSM303DLHC_AXES_DISABLE = 0x00;
94 constexpr
static uint8_t LSM303DLHC_HR_ENABLE = 0x08;
95 constexpr
static uint8_t LSM303DLHC_HR_DISABLE = 0x00;
98 constexpr
static uint8_t LSM303DLHC_FULLSCALE_2G = 0x00;
99 constexpr
static uint8_t LSM303DLHC_FULLSCALE_4G = 0x10;
100 constexpr
static uint8_t LSM303DLHC_FULLSCALE_8G = 0x20;
101 constexpr
static uint8_t LSM303DLHC_FULLSCALE_16G = 0x30;
104 constexpr
static uint8_t LSM303DLHC_BlockUpdate_Continous = 0x00;
105 constexpr
static uint8_t LSM303DLHC_BlockUpdate_Single = 0x80;
108 constexpr
static uint8_t LSM303DLHC_BLE_LSB = 0x00;
109 constexpr
static uint8_t LSM303DLHC_BLE_MSB = 0x40;
112 constexpr
static uint8_t LSM303DLHC_BOOT_NORMALMODE = 0x00;
113 constexpr
static uint8_t LSM303DLHC_BOOT_REBOOTMEMORY = 0x80;
116 constexpr
static uint8_t LSM303DLHC_HPM_NORMAL_MODE_RES = 0x00;
117 constexpr
static uint8_t LSM303DLHC_HPM_REF_SIGNAL = 0x40;
118 constexpr
static uint8_t LSM303DLHC_HPM_NORMAL_MODE = 0x80;
119 constexpr
static uint8_t LSM303DLHC_HPM_AUTORESET_INT = 0xC0;
122 constexpr
static uint8_t LSM303DLHC_HPFCF_8 = 0x00;
123 constexpr
static uint8_t LSM303DLHC_HPFCF_16 = 0x10;
124 constexpr
static uint8_t LSM303DLHC_HPFCF_32 = 0x20;
125 constexpr
static uint8_t LSM303DLHC_HPFCF_64 = 0x30;
128 constexpr
static uint8_t LSM303DLHC_HIGHPASSFILTER_DISABLE = 0x00;
129 constexpr
static uint8_t LSM303DLHC_HIGHPASSFILTER_ENABLE = 0x08;
132 constexpr
static uint8_t LSM303DLHC_HPF_CLICK_DISABLE = 0x00;
133 constexpr
static uint8_t LSM303DLHC_HPF_CLICK_ENABLE = 0x04;
136 constexpr
static uint8_t LSM303DLHC_HPF_AOI1_DISABLE = 0x00;
137 constexpr
static uint8_t LSM303DLHC_HPF_AOI1_ENABLE = 0x01;
140 constexpr
static uint8_t LSM303DLHC_HPF_AOI2_DISABLE = 0x00;
141 constexpr
static uint8_t LSM303DLHC_HPF_AOI2_ENABLE = 0x02;
144 constexpr
static uint8_t LSM303DLHC_IT1_CLICK = 0x80;
145 constexpr
static uint8_t LSM303DLHC_IT1_AOI1 = 0x40;
146 constexpr
static uint8_t LSM303DLHC_IT1_AOI2 = 0x20;
147 constexpr
static uint8_t LSM303DLHC_IT1_DRY1 = 0x10;
148 constexpr
static uint8_t LSM303DLHC_IT1_DRY2 = 0x08;
149 constexpr
static uint8_t LSM303DLHC_IT1_WTM = 0x04;
150 constexpr
static uint8_t LSM303DLHC_IT1_OVERRUN = 0x02;
153 constexpr
static uint8_t LSM303DLHC_IT2_CLICK = 0x80;
154 constexpr
static uint8_t LSM303DLHC_IT2_INT1 = 0x40;
155 constexpr
static uint8_t LSM303DLHC_IT2_INT2 = 0x20;
156 constexpr
static uint8_t LSM303DLHC_IT2_BOOT = 0x10;
157 constexpr
static uint8_t LSM303DLHC_IT2_ACT = 0x08;
158 constexpr
static uint8_t LSM303DLHC_IT2_HLACTIVE = 0x02;
161 constexpr
static uint8_t LSM303DLHC_OR_COMBINATION = 0x00;
162 constexpr
static uint8_t LSM303DLHC_AND_COMBINATION = 0x80;
163 constexpr
static uint8_t LSM303DLHC_MOV_RECOGNITION = 0x40;
164 constexpr
static uint8_t LSM303DLHC_POS_RECOGNITION = 0xC0;
167 constexpr
static uint8_t LSM303DLHC_Z_HIGH = 0x20;
168 constexpr
static uint8_t LSM303DLHC_Z_LOW = 0x10;
169 constexpr
static uint8_t LSM303DLHC_Y_HIGH = 0x08;
170 constexpr
static uint8_t LSM303DLHC_Y_LOW = 0x04;
171 constexpr
static uint8_t LSM303DLHC_X_HIGH = 0x02;
172 constexpr
static uint8_t LSM303DLHC_X_LOW = 0x01;
175 constexpr
static uint8_t LSM303DLHC_Z_DOUBLE_CLICK = 0x20;
176 constexpr
static uint8_t LSM303DLHC_Z_SINGLE_CLICK = 0x10;
177 constexpr
static uint8_t LSM303DLHC_Y_DOUBLE_CLICK = 0x08;
178 constexpr
static uint8_t LSM303DLHC_Y_SINGLE_CLICK = 0x04;
179 constexpr
static uint8_t LSM303DLHC_X_DOUBLE_CLICK = 0x02;
180 constexpr
static uint8_t LSM303DLHC_X_SINGLE_CLICK = 0x01;
183 constexpr
static uint8_t LSM303DLHC_INT1INTERRUPT_DISABLE = 0x00;
184 constexpr
static uint8_t LSM303DLHC_INT1INTERRUPT_ENABLE = 0x80;
187 constexpr
static uint8_t LSM303DLHC_INT1INTERRUPT_LOW_EDGE = 0x20;
188 constexpr
static uint8_t LSM303DLHC_INT1INTERRUPT_HIGH_EDGE = 0x00;
191 constexpr
static uint8_t LSM303DLHC_ODR_0_75_HZ = 0x00;
192 constexpr
static uint8_t LSM303DLHC_ODR_1_5_HZ = 0x04;
193 constexpr
static uint8_t LSM303DLHC_ODR_3_0_HZ = 0x08;
194 constexpr
static uint8_t LSM303DLHC_ODR_7_5_HZ = 0x0C;
195 constexpr
static uint8_t LSM303DLHC_ODR_15_HZ = 0x10;
196 constexpr
static uint8_t LSM303DLHC_ODR_30_HZ = 0x14;
197 constexpr
static uint8_t LSM303DLHC_ODR_75_HZ = 0x18;
198 constexpr
static uint8_t LSM303DLHC_ODR_220_HZ = 0x1C;
201 constexpr
static uint8_t LSM303DLHC_FS_1_3_GA = 0x20;
202 constexpr
static uint8_t LSM303DLHC_FS_1_9_GA = 0x40;
203 constexpr
static uint8_t LSM303DLHC_FS_2_5_GA = 0x60;
204 constexpr
static uint8_t LSM303DLHC_FS_4_0_GA = 0x80;
205 constexpr
static uint8_t LSM303DLHC_FS_4_7_GA = 0xA0;
206 constexpr
static uint8_t LSM303DLHC_FS_5_6_GA = 0xC0;
207 constexpr
static uint8_t LSM303DLHC_FS_8_1_GA = 0xE0;
210 constexpr
static uint8_t LSM303DLHC_CONTINUOS_CONVERSION = 0x00;
211 constexpr
static uint8_t LSM303DLHC_SINGLE_CONVERSION = 0x01;
212 constexpr
static uint8_t LSM303DLHC_SLEEP = 0x02;
215 constexpr
static uint8_t LSM303DLHC_TEMPSENSOR_ENABLE = 0x80;
216 constexpr
static uint8_t LSM303DLHC_TEMPSENSOR_DISABLE = 0x00;
218 bool writeMagRegister(uint8_t reg, uint8_t value);
219 bool readMagRegisters(uint8_t reg, uint8_t* buffer,
size_t len);
220 bool writeAccRegister(uint8_t reg, uint8_t value);
221 bool readAccRegisters(uint8_t reg, uint8_t* buffer,
size_t len);