29 #ifndef __FXOS8700CQ_H__
30 #define __FXOS8700CQ_H__
35 #define FXOS8700CQ_ADDRESS 0x1E
38 #define ZYXOW_MASK 0x80
42 #define ZYXDR_MASK 0x08
48 #define F_OVF_MASK 0x80
49 #define F_WMRK_FLAG_MASK 0x40
50 #define F_CNT5_MASK 0x20
51 #define F_CNT4_MASK 0x10
52 #define F_CNT3_MASK 0x08
53 #define F_CNT2_MASK 0x04
54 #define F_CNT1_MASK 0x02
55 #define F_CNT0_MASK 0x01
56 #define F_CNT_MASK 0x3F
59 #define OUT_X_MSB_REG 0x01
60 #define OUT_X_LSB_REG 0x02
61 #define OUT_Y_MSB_REG 0x03
62 #define OUT_Y_LSB_REG 0x04
63 #define OUT_Z_MSB_REG 0x05
64 #define OUT_Z_LSB_REG 0x06
67 #define F_MODE1_MASK 0x80
68 #define F_MODE0_MASK 0x40
69 #define F_WMRK5_MASK 0x20
70 #define F_WMRK4_MASK 0x10
71 #define F_WMRK3_MASK 0x08
72 #define F_WMRK2_MASK 0x04
73 #define F_WMRK1_MASK 0x02
74 #define F_WMRK0_MASK 0x01
75 #define F_MODE_MASK 0xC0
76 #define F_WMRK_MASK 0x3F
78 #define F_MODE_DISABLED 0x00
79 #define F_MODE_CIRCULAR (F_MODE0_MASK)
80 #define F_MODE_FILL (F_MODE1_MASK)
81 #define F_MODE_TRIGGER (F_MODE1_MASK+F_MODE0_MASK)
84 #define TRIG_TRANS_MASK 0x20
85 #define TRIG_LNDPRT_MASK 0x10
86 #define TRIG_PULSE_MASK 0x08
87 #define TRIG_FF_MT_MASK 0x04
90 #define FGERR_MASK 0x80
91 #define FGT_4_MASK 0x40
92 #define FGT_3_MASK 0x20
93 #define FGT_2_MASK 0x10
94 #define FGT_1_MASK 0x08
95 #define FGT_0_MASK 0x04
97 #define SYSMOD1_MASK 0x02
98 #define SYSMOD0_MASK 0x01
99 #define SYSMOD_MASK 0x03
101 #define SYSMOD_STANDBY 0x00
102 #define SYSMOD_WAKE (SYSMOD0_MASK)
103 #define SYSMOD_SLEEP (SYSMOD1_MASK)
106 #define SRC_ASLP_MASK 0x80
107 #define SRC_FIFO_MASK 0x40
108 #define SRC_TRANS_MASK 0x20
109 #define SRC_LNDPRT_MASK 0x10
110 #define SRC_PULSE_MASK 0x08
111 #define SRC_FF_MT_MASK 0x04
112 #define SRC_DRDY_MASK 0x01
115 #define FXOS8700CQ 0xC7
116 #define MXOS8700CQ 0xC4
119 #define HPF_OUT_MASK 0x10 // MMA8451 and MMA8452 only
120 #define FS1_MASK 0x02
121 #define FS0_MASK 0x01
124 #define FULL_SCALE_2G 0x00
125 #define FULL_SCALE_4G (FS0_MASK)
126 #define FULL_SCALE_8G (FS1_MASK)
130 #define PULSE_HPF_BYP_MASK 0x20
131 #define PULSE_LPF_EN_MASK 0x10
132 #define SEL1_MASK 0x02
133 #define SEL0_MASK 0x01
134 #define SEL_MASK 0x03
137 #define NEWLP_MASK 0x80
139 #define LAPO1_MASK 0x04
140 #define LAPO0_MASK 0x02
141 #define BAFRO_MASK 0x01
142 #define LAPO_MASK 0x06
146 #define DBCNTM_MASK 0x80
147 #define PL_EN_MASK 0x40
151 #define BKFR1_MASK 0x80
152 #define BKFR0_MASK 0x40
153 #define ZLOCK2_MASK 0x04
154 #define ZLOCK1_MASK 0x02
155 #define ZLOCK0_MASK 0x01
156 #define BKFR_MASK 0xC0
157 #define ZLOCK_MASK 0x07
160 #define PL_P_L_THS_REG 0x14
162 #define P_L_THS4_MASK 0x80
163 #define P_L_THS3_MASK 0x40
164 #define P_L_THS2_MASK 0x20
165 #define P_L_THS1_MASK 0x10
166 #define P_L_THS0_MASK 0x08
167 #define HYS2_MASK 0x04
168 #define HYS1_MASK 0x02
169 #define HYS0_MASK 0x01
170 #define P_L_THS_MASK 0xF8
171 #define HYS_MASK 0x07
174 #define FF_MT_CFG_REG 0x15
176 #define ELE_MASK 0x80
177 #define OAE_MASK 0x40
178 #define ZEFE_MASK 0x20
179 #define YEFE_MASK 0x10
180 #define XEFE_MASK 0x08
183 #define FF_MT_SRC_REG 0x16
186 #define ZHE_MASK 0x20
187 #define ZHP_MASK 0x10
188 #define YHE_MASK 0x08
189 #define YHP_MASK 0x04
190 #define XHE_MASK 0x02
191 #define XHP_MASK 0x01
194 #define FT_MT_THS_REG 0x17
195 #define TRANSIENT_THS_REG 0x1F
197 #define DBCNTM_MASK 0x80
198 #define THS6_MASK 0x40
199 #define THS5_MASK 0x20
200 #define THS4_MASK 0x10
201 #define THS3_MASK 0x08
202 #define THS2_MASK 0x04
203 #define TXS1_MASK 0x02
204 #define THS0_MASK 0x01
205 #define THS_MASK 0x7F
209 #define FF_MT_COUNT_REG 0x18
213 #define TELE_MASK 0x10
214 #define ZTEFE_MASK 0x08
215 #define YTEFE_MASK 0x04
216 #define XTEFE_MASK 0x02
217 #define HPF_BYP_MASK 0x01
221 #define TEA_MASK 0x40
222 #define ZTRANSE_MASK 0x20
223 #define Z_TRANS_POL_MASK 0x10
224 #define YTRANSE_MASK 0x08
225 #define Y_TRANS_POL_MASK 0x04
226 #define XTRANSE_MASK 0x02
227 #define X_TRANS_POL_MASK 0x01
232 #define DPA_MASK 0x80
233 #define PELE_MASK 0x40
234 #define ZDPEFE_MASK 0x20
235 #define ZSPEFE_MASK 0x10
236 #define YDPEFE_MASK 0x08
237 #define YSPEFE_MASK 0x04
238 #define XDPEFE_MASK 0x02
239 #define XSPEFE_MASK 0x01
244 #define PEA_MASK 0x80
245 #define AXZ_MASK 0x40
246 #define AXY_MASK 0x20
247 #define AXX_MASK 0x10
248 #define DPE_MASK 0x08
249 #define POLZ_MASK 0x04
250 #define POLY_MASK 0x02
251 #define POLX_MASK 0x01
253 #define PTHS_MASK 0x7F
256 #define ASLP_RATE1_MASK 0x80
257 #define ASLP_RATE0_MASK 0x40
258 #define DR2_MASK 0x20
259 #define DR1_MASK 0x10
260 #define DR0_MASK 0x08
261 #define LNOISE_MASK 0x04
262 #define FREAD_MASK 0x02
263 #define ACTIVE_MASK 0x01
264 #define ASLP_RATE_MASK 0xC0
267 #define ASLP_RATE_20MS 0x00
268 #define ASLP_RATE_80MS (ASLP_RATE0_MASK)
269 #define ASLP_RATE_160MS (ASLP_RATE1_MASK)
270 #define ASLP_RATE_640MS (ASLP_RATE1_MASK+ASLP_RATE0_MASK)
272 #define ASLP_RATE_50HZ (ASLP_RATE_20MS)
273 #define ASLP_RATE_12_5HZ (ASLP_RATE_80MS)
274 #define ASLP_RATE_6_25HZ (ASLP_RATE_160MS)
275 #define ASLP_RATE_1_56HZ (ASLP_RATE_640MS)
277 #define HYB_ASLP_RATE_25HZ (ASLP_RATE_20MS)
278 #define HYB_ASLP_RATE_6_25HZ (ASLP_RATE_80MS)
279 #define HYB_ASLP_RATE_1_56HZ (ASLP_RATE_160MS)
280 #define HYB_ASLP_RATE_0_8HZ (ASLP_RATE_640MS)
282 #define DATA_RATE_1250US 0x00
283 #define DATA_RATE_2500US (DR0_MASK)
284 #define DATA_RATE_5MS (DR1_MASK)
285 #define DATA_RATE_10MS (DR1_MASK+DR0_MASK)
286 #define DATA_RATE_20MS (DR2_MASK)
287 #define DATA_RATE_80MS (DR2_MASK+DR0_MASK)
288 #define DATA_RATE_160MS (DR2_MASK+DR1_MASK)
289 #define DATA_RATE_640MS (DR2_MASK+DR1_MASK+DR0_MASK)
291 #define DATA_RATE_800HZ (DATA_RATE_1250US)
292 #define DATA_RATE_400HZ (DATA_RATE_2500US)
293 #define DATA_RATE_200HZ (DATA_RATE_5MS)
294 #define DATA_RATE_100HZ (DATA_RATE_10MS)
295 #define DATA_RATE_50HZ (DATA_RATE_20MS)
296 #define DATA_RATE_12_5HZ (DATA_RATE_80MS)
297 #define DATA_RATE_6_25HZ (DATA_RATE_160MS)
298 #define DATA_RATE_1_56HZ (DATA_RATE_640MS)
300 #define HYB_DATA_RATE_400HZ (DATA_RATE_1250US)
301 #define HYB_DATA_RATE_200HZ (DATA_RATE_2500US)
302 #define HYB_DATA_RATE_100HZ (DATA_RATE_5MS)
303 #define HYB_DATA_RATE_50HZ (DATA_RATE_10MS)
304 #define HYB_DATA_RATE_25HZ (DATA_RATE_20MS)
305 #define HYB_DATA_RATE_6_25HZ (DATA_RATE_80MS)
306 #define HYB_DATA_RATE_3_15HZ (DATA_RATE_160MS)
307 #define HYB_DATA_RATE_0_8HZ (DATA_RATE_640MS)
309 #define ACTIVE (ACTIVE_MASK)
313 #define CTRL_REG2 0x2B
316 #define RST_MASK 0x40
317 #define SMODS1_MASK 0x10
318 #define SMODS0_MASK 0x08
319 #define SLPE_MASK 0x04
320 #define MODS1_MASK 0x02
321 #define MODS0_MASK 0x01
322 #define SMODS_MASK 0x18
323 #define MODS_MASK 0x03
325 #define SMOD_NORMAL 0x00
326 #define SMOD_LOW_NOISE (SMODS0_MASK)
327 #define SMOD_HIGH_RES (SMODS1_MASK)
328 #define SMOD_LOW_POWER (SMODS1_MASK+SMODS0_MASK)
330 #define MOD_NORMAL 0x00
331 #define MOD_LOW_NOISE (MODS0_MASK)
332 #define MOD_HIGH_RES (MODS1_MASK)
333 #define MOD_LOW_POWER (MODS1_MASK+MODS0_MASK)
337 #define FIFO_GATE_MASK 0x80
338 #define WAKE_TRANS_MASK 0x40
339 #define WAKE_LNDPRT_MASK 0x20
340 #define WAKE_PULSE_MASK 0x10
341 #define WAKE_FF_MT_MASK 0x08
342 #define IPOL_MASK 0x02
343 #define PP_OD_MASK 0x01
346 #define INT_EN_ASLP_MASK 0x80
347 #define INT_EN_FIFO_MASK 0x40
348 #define INT_EN_TRANS_MASK 0x20
349 #define INT_EN_LNDPRT_MASK 0x10
350 #define INT_EN_PULSE_MASK 0x08
351 #define INT_EN_FF_MT_MASK 0x04
352 #define INT_EN_DRDY_MASK 0x01
355 #define INT_CFG_ASLP_MASK 0x80
356 #define INT_CFG_FIFO_MASK 0x40
357 #define INT_CFG_TRANS_MASK 0x20
358 #define INT_CFG_LNDPRT_MASK 0x10
359 #define INT_CFG_PULSE_MASK 0x08
360 #define INT_CFG_FF_MT_MASK 0x04
361 #define INT_CFG_DRDY_MASK 0x01
366 #define OFF_X_REG 0x2F
367 #define OFF_Y_REG 0x30
368 #define OFF_Z_REG 0x31
373 #define M_ACAL_MASK 0x80
374 #define M_RST_MASK 0x40
375 #define M_OST_MASK 0x20
376 #define M_OSR2_MASK 0x10
377 #define M_OSR1_MASK 0x08
378 #define M_OSR0_MASK 0x04
379 #define M_HMS1_MASK 0x02
380 #define M_HMS0_MASK 0x01
381 #define M_OSR_MASK 0x1C
382 #define M_HMS_MASK 0x03
385 #define M_OSR_1_56_HZ 0x00
386 #define M_OSR_6_25_HZ M_OSR0_MASK
387 #define M_OSR_12_5_HZ M_OSR1_MASK
388 #define M_OSR_50_HZ M_OSR1_MASK+M_OSR0_MASK
389 #define M_OSR_100_HZ M_OSR2_MASK
390 #define M_OSR_200_HZ M_OSR2_MASK+M_OSR0_MASK
391 #define M_OSR_400_HZ M_OSR2_MASK+M_OSR1_MASK
392 #define M_OSR_800_HZ M_OSR2_MASK+M_OSR1_MASK+M_OSR0_MASK
395 #define ACCEL_ACTIVE 0x00
396 #define MAG_ACTIVE M_HMS0_MASK
397 #define HYBRID_ACTIVE (M_HMS1_MASK | M_HMS0_MASK)
403 #define M_HYB_AUTOINC_MASK 0x20
404 #define M_MAXMIN_DIS_MASK 0x10
405 #define M_MAXMIN_DIS_THS_MASK 0x08
406 #define M_MAXMIN_RST_MASK 0x04
407 #define M_RST_CNT1_MASK 0x02
408 #define M_RST_CNT0_MASK 0x01
411 #define RST_ODR_CYCLE 0x00
412 #define RST_16_ODR_CYCLE M_RST_CNT0_MASK
413 #define RST_512_ODR_CYCLE M_RST_CNT1_MASK
414 #define RST_DISABLED M_RST_CNT1_MASK+M_RST_CNT0_MASK
420 #define M_RAW_MASK 0x80
421 #define M_ASLP_OS_2_MASK 0x40
422 #define M_ASLP_OS_1_MASK 0x20
423 #define M_ASLP_OS_0_MASK 0x10
424 #define M_THS_XYZ_MASK 0x08
425 #define M_ST_Z_MASK 0x04
426 #define M_ST_XY1_MASK 0x02
427 #define M_ST_XY0_MASK 0x01
428 #define M_ASLP_OSR_MASK 0x70
429 #define M_ST_XY_MASK 0x03
432 #define M_ASLP_OSR_1_56_HZ 0x00
433 #define M_ASLP_OSR_6_25_HZ M_ASLP_OS_0_MASK
434 #define M_ASLP_OSR_12_5_HZ M_ASLP_OS_1_MASK
435 #define M_ASLP_OSR_50_HZ M_ASLP_OS_1_MASK+M_ASLP_OS_0_MASK
436 #define M_ASLP_OSR_100_HZ M_ASLP_OS_2_MASK
437 #define M_ASLP_OSR_200_HZ M_ASLP_OS_2_MASK+M_ASLP_OS_0_MASK
438 #define M_ASLP_OSR_400_HZ M_ASLP_OS_2_MASK+M_ASLP_OS_1_MASK
439 #define M_ASLP_OSR_800_HZ M_ASLP_OS_2_MASK+M_ASLP_OS_1_MASK+M_ASLP_OS_0_MASK
444 #define M_INT_SOURCE 0x5E
446 #define SRC_M_DRDY_MASK 0x04
447 #define SRC_M_VECM_MASK 0x02
448 #define SRC_M_THS_MASK 0x01
454 #define A_VECM_INIT_CFG_MASK 0x40
455 #define A_VECM_INIT_EN_MASK 0x20
456 #define A_VECM_WAKE_EN_MASK 0x10
457 #define A_VECM_EN_MASK 0x08
458 #define A_VECM_UPDM_MASK 0x04
459 #define A_VECM_INITM_MASK 0x02
460 #define A_VECM_ELE_MASK 0x01
466 #define A_VECM_DBCNTM_MASK 0x80
472 #define M_VECM_INIT_CFG_MASK 0x40
473 #define M_VECM_INIT_EN_MASK 0x20
474 #define M_VECM_WAKE_EN_MASK 0x10
475 #define M_VECM_EN_MASK 0x08
476 #define M_VECM_UPDM_MASK 0x04
477 #define M_VECM_INITM_MASK 0x02
478 #define M_VECM_ELE_MASK 0x01
484 #define M_VECM_DBCNTM_MASK 0x80
490 #define A_FFMT_THS_XYZ_EN_MASK 0x80
491 #define A_FFMT_THS_X_LSB_MASK 0xFC
497 #define A_FFMT_THS_Y_EN_MASK 0x80
498 #define A_FFMT_THS_Y_LSB_MASK 0xFC
504 #define A_FFMT_THS_Z_EN_MASK 0x80
505 #define A_FFMT_THS_Z_LSB_MASK 0xFC
507 #define FXOS8700CQ_WHOAMI_VAL 0xC7 // FXOS8700CQ WHOAMI production register value
508 #define FXOS8700CQ_READ_LEN 12 // 6 channels of two bytes = 12 bytes
509 #define UINT14_MAX 16383 // For processing the accelerometer data to right-justified 2's complement
char FXOS8700CQ_GetTemperature(void)
Returns the silicon die chip temperature.
void FXOS8700CQ_FIFOMode(mode_t mode)
Returns current mode of the chip.
char FXOS8700CQ_GetChipMode(void)
Returns current mode of the chip.
void FXOS8700CQ_ConfigureOrientation(void)
Configure Orientation mode.
unsigned char buffer[256]
void FXOS8700CQ_ConfigureGenericTapMode(void)
Configure Single Tap mode.
void FXOS8700CQ_WriteByte(char reg, char value)
Writes a value to a register.
void FXOS8700CQ_WriteByteArray(char reg, char *buffer, char value)
Writes an array of bytes to the sensor.
void FXOS8700CQ_HighPassFilter(char status)
Enables or disables higpass filter on accelerometer data.
void FXOS8700CQ_HybridMode(void)
Configure the sensor in hybrid mode both the accelerometer and the magnetometer are active for data o...
char FXOS8700CQ_MagnetometerStatus(void)
Get magnetometer status.
Structure encapsulating triple axis raw data.
void FXOS8700CQ_ConfigureSingleTapMode(void)
Configure Single Tap mode.
void FXOS8700CQ_ConfigureAccelerometer(void)
Configure the accelerometer for data output.
void FXOS8700CQ_PollAccelerometer(rawdata_t *accel_data)
Accelerometer data is left justified.
void FXOS8700CQ_SetODR(char DataRateValue)
Set output data rate.
void FXOS8700CQ_ConfigureDoubleTapMode(void)
DoubleTap_LowPowerMode_NoLPF_400HzODR.
char FXOS8700CQ_ReadByte(char reg)
Starts up the sensor in Active mode.
void FXOS8700CQ_ActiveMode(void)
Starts up the sensor in Active mode.
void FXOS8700CQ_FullScaleRange(range_t range)
Configures the full scale range of the Accelerometer.
void FXOS8700CQ_ConfigureMagnetometer(void)
Configure the magnetometer for data output.
void FXOS8700CQ_PollMagnetometer(rawdata_t *mag_data)
Return the raw magnetometer data.
char FXOS8700CQ_ReadStatusReg(void)
Return the value of the status register.
void FXOS8700CQ_Initialize(void)
Initialize FXOS8700CQ, configure for an output rate of 200Hz with a +/- 2g scale. ...
void FXOS8700CQ_ReadByteArray(char reg, char *buffer, unsigned int length)
Read a number of contigous bytes from the chip.
struct rawdata rawdata_t
Structure encapsulating triple axis raw data.
void FXOS8700CQ_SetAccelerometerDynamicRange(range_t range)
Returns current mode of the chip.
char FXOS8700CQ_GetOrientation(void)
Returns current mode of the chip.
Register memory map header.
void FXOS8700CQ_GetData(rawdata_t *accel_data, rawdata_t *magn_data)
Get raw data from both accelerometer and magnetometer.
char FXOS8700CQ_StandbyMode(void)
Starts up the sensor in Active mode.
char FXOS8700CQ_ID(void)
Returns the chip ID.
char FXOS8700CQ_GetODR(void)
Get output data rate.