ISSDK  1.7
IoT Sensing Software Development Kit
fxas21002.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file fxas21002.h
37  * @brief The fxas21002.h contains the fxas21002 sensor register definitions and its bit mask.
38 */
39 
40 #ifndef FXAS21002_H_
41 #define FXAS21002_H_
42 
43 /**
44  ** FXAS21002 I2C Address
45  */
46 #define FXAS21002_I2C_ADDRESS 0x20
47 
48 /**
49  **
50  ** @brief The FXAS21002 Sensor Register Map.
51  */
52 enum {
75 };
76 
77 
78 /*--------------------------------
79 ** Register: STATUS
80 ** Enum: FXAS21002_STATUS
81 ** --
82 ** Offset : 0x00 - Alias for DR_STATUS or F_STATUS.
83 ** ------------------------------*/
84 typedef uint8_t FXAS21002_STATUS_t;
85 
86 
87 
88 /*--------------------------------
89 ** Register: OUT_X_MSB
90 ** Enum: FXAS21002_OUT_X_MSB
91 ** --
92 ** Offset : 0x01 - 8 MSBs of 16 bit X-axis data sample
93 ** ------------------------------*/
94 typedef uint8_t FXAS21002_OUT_X_MSB_t;
95 
96 
97 /*--------------------------------
98 ** Register: OUT_X_LSB
99 ** Enum: FXAS21002_OUT_X_LSB
100 ** --
101 ** Offset : 0x02 - 8 LSBs of 16 bit X-axis data sample
102 ** ------------------------------*/
103 typedef uint8_t FXAS21002_OUT_X_LSB_t;
104 
105 
106 
107 /*--------------------------------
108 ** Register: OUT_Y_MSB
109 ** Enum: FXAS21002_OUT_Y_MSB
110 ** --
111 ** Offset : 0x03 - 8 MSBs of 16 bit Y-axis data sample
112 ** ------------------------------*/
113 typedef uint8_t FXAS21002_OUT_Y_MSB_t;
114 
115 
116 /*--------------------------------
117 ** Register: OUT_Y_LSB
118 ** Enum: FXAS21002_OUT_Y_LSB
119 ** --
120 ** Offset : 0x04 - 8 LSBs of 16 bit Y-axis data sample
121 ** ------------------------------*/
122 typedef uint8_t FXAS21002_OUT_Y_LSB_t;
123 
124 
125 
126 /*--------------------------------
127 ** Register: OUT_Z_MSB
128 ** Enum: FXAS21002_OUT_Z_MSB
129 ** --
130 ** Offset : 0x05 - 8 MSBs of 16 bit Z-axis data sample
131 ** ------------------------------*/
132 typedef uint8_t FXAS21002_OUT_Z_MSB_t;
133 
134 
135 /*--------------------------------
136 ** Register: OUT_Z_LSB
137 ** Enum: FXAS21002_OUT_Z_LSB
138 ** --
139 ** Offset : 0x06 - 8 LSBs of 16 bit Z-axis data sample
140 ** ------------------------------*/
141 typedef uint8_t FXAS21002_OUT_Z_LSB_t;
142 
143 
144 
145 /*--------------------------------
146 ** Register: DR_STATUS
147 ** Enum: FXAS21002_DR_STATUS
148 ** --
149 ** Offset : 0x07 - Data-ready status information (FIFO disabled by setting F_SETUP :: F_MODE = 0)
150 ** ------------------------------*/
151 typedef union {
152  struct {
153  uint8_t xdr : 1; /* X-axis new data available. */
154 
155  uint8_t ydr : 1; /* Y-axis new data available. */
156 
157  uint8_t zdr : 1; /* Z-axis new data available. */
158 
159  uint8_t zyxdr : 1; /* X-, Y-, and Z-axis data available. */
160 
161  uint8_t xow : 1; /* X-axis data overwrite. */
162 
163  uint8_t yow : 1; /* Y-axis data overwrite. */
164 
165  uint8_t zow : 1; /* Z-axis data overwrite. */
166 
167  uint8_t zyxow : 1; /* X-, Y-, Z-axis data overwrite. */
168 
169  } b;
170  uint8_t w;
172 
173 
174 /*
175 ** DR_STATUS - Bit field mask definitions
176 */
177 #define FXAS21002_DR_STATUS_XDR_MASK ((uint8_t) 0x01)
178 #define FXAS21002_DR_STATUS_XDR_SHIFT ((uint8_t) 0)
179 
180 #define FXAS21002_DR_STATUS_YDR_MASK ((uint8_t) 0x02)
181 #define FXAS21002_DR_STATUS_YDR_SHIFT ((uint8_t) 1)
182 
183 #define FXAS21002_DR_STATUS_ZDR_MASK ((uint8_t) 0x04)
184 #define FXAS21002_DR_STATUS_ZDR_SHIFT ((uint8_t) 2)
185 
186 #define FXAS21002_DR_STATUS_ZYXDR_MASK ((uint8_t) 0x08)
187 #define FXAS21002_DR_STATUS_ZYXDR_SHIFT ((uint8_t) 3)
188 
189 #define FXAS21002_DR_STATUS_XOW_MASK ((uint8_t) 0x10)
190 #define FXAS21002_DR_STATUS_XOW_SHIFT ((uint8_t) 4)
191 
192 #define FXAS21002_DR_STATUS_YOW_MASK ((uint8_t) 0x20)
193 #define FXAS21002_DR_STATUS_YOW_SHIFT ((uint8_t) 5)
194 
195 #define FXAS21002_DR_STATUS_ZOW_MASK ((uint8_t) 0x40)
196 #define FXAS21002_DR_STATUS_ZOW_SHIFT ((uint8_t) 6)
197 
198 #define FXAS21002_DR_STATUS_ZYXOW_MASK ((uint8_t) 0x80)
199 #define FXAS21002_DR_STATUS_ZYXOW_SHIFT ((uint8_t) 7)
200 
201 
202 /*
203 ** DR_STATUS - Bit field value definitions
204 */
205 #define FXAS21002_DR_STATUS_XDR_DRDY ((uint8_t) 0x01) /* Set to 1 whenever a new X-axis data acquisition */
206  /* is completed. Cleared anytime the OUT_X_MSB */
207  /* register is read. */
208 #define FXAS21002_DR_STATUS_YDR_DRDY ((uint8_t) 0x02) /* Set to 1 whenever a new Y-axis data acquisition */
209  /* is completed. Cleared anytime the OUT_Y_MSB */
210  /* register is read. */
211 #define FXAS21002_DR_STATUS_ZDR_DRDY ((uint8_t) 0x04) /* Set to 1 whenever a new Z-axis data acquisition */
212  /* is completed. Cleared anytime the OUT_Z_MSB */
213  /* register is read. */
214 #define FXAS21002_DR_STATUS_ZYXDR_DRDY ((uint8_t) 0x08) /* Cleared when the high-bytes of the acceleration */
215  /* data (OUT_X_MSB, OUT_Y_MSB, OUT_Z_MSB) are read. */
216 #define FXAS21002_DR_STATUS_XOW_OWR ((uint8_t) 0x10) /* Asserted whenever a new X-axis acquisition is */
217  /* completed before the retrieval of the previous */
218  /* data. */
219 #define FXAS21002_DR_STATUS_YOW_OWR ((uint8_t) 0x20) /* Asserted whenever a new Y-axis acquisition is */
220  /* completed before the retrieval of the previous */
221  /* data. */
222 #define FXAS21002_DR_STATUS_ZOW_OWR ((uint8_t) 0x40) /* Asserted whenever a new Z-axis acquisition is */
223  /* completed before the retrieval of the previous */
224  /* data. */
225 #define FXAS21002_DR_STATUS_ZYXOW_OWR ((uint8_t) 0x80) /* Asserted whenever new X-, Y-, and Z-axis data is */
226  /* acquired before completing the retrieval of the */
227  /* previous set. */
228 /*------------------------------*/
229 
230 
231 
232 /*--------------------------------
233 ** Register: F_STATUS
234 ** Enum: FXAS21002_F_STATUS
235 ** --
236 ** Offset : 0x08 - FIFO status information (FIFO enabled by setting F_SETUP :: F_MODE > 0)
237 ** ------------------------------*/
238 typedef union {
239  struct {
240  uint8_t f_cnt : 6; /* FIFO sample counter; indicates the number of samples currently stored in */
241  /* the FIFO. */
242 
243  uint8_t f_wmkf : 1; /* FIFO sample count greater than or equal to the watermark count (F_SETUP :: */
244  /* F_WMRK) has been detected. */
245 
246  uint8_t f_ovf : 1; /* FIFO overflow event, such as when F_CNT = 32 and a new sample arrives, */
247  /* asserts the F_OVF flag. */
248 
249  } b;
250  uint8_t w;
252 
253 
254 /*
255 ** F_STATUS - Bit field mask definitions
256 */
257 #define FXAS21002_F_STATUS_F_CNT_MASK ((uint8_t) 0x3F)
258 #define FXAS21002_F_STATUS_F_CNT_SHIFT ((uint8_t) 0)
259 
260 #define FXAS21002_F_STATUS_F_WMKF_MASK ((uint8_t) 0x40)
261 #define FXAS21002_F_STATUS_F_WMKF_SHIFT ((uint8_t) 6)
262 
263 #define FXAS21002_F_STATUS_F_OVF_MASK ((uint8_t) 0x80)
264 #define FXAS21002_F_STATUS_F_OVF_SHIFT ((uint8_t) 7)
265 
266 
267 /*
268 ** F_STATUS - Bit field value definitions
269 */
270 #define FXAS21002_F_STATUS_F_WMKF_DETECT ((uint8_t) 0x40) /* FIFO Watermark event has been detected. */
271 #define FXAS21002_F_STATUS_F_OVF_DETECT ((uint8_t) 0x80) /* FIFO Overflow event has been detected. */
272 /*------------------------------*/
273 
274 
275 
276 /*--------------------------------
277 ** Register: F_SETUP
278 ** Enum: FXAS21002_F_SETUP
279 ** --
280 ** Offset : 0x09 - FIFO configuration
281 ** ------------------------------*/
282 typedef union {
283  struct {
284  uint8_t f_wmrk : 6; /* FIFO operating mode selection. */
285 
286  uint8_t f_mode : 2; /* FIFO sample count watermark setting. */
287 
288  } b;
289  uint8_t w;
291 
292 
293 /*
294 ** F_SETUP - Bit field mask definitions
295 */
296 #define FXAS21002_F_SETUP_F_WMRK_MASK ((uint8_t) 0x3F)
297 #define FXAS21002_F_SETUP_F_WMRK_SHIFT ((uint8_t) 0)
298 
299 #define FXAS21002_F_SETUP_F_MODE_MASK ((uint8_t) 0xC0)
300 #define FXAS21002_F_SETUP_F_MODE_SHIFT ((uint8_t) 6)
301 
302 
303 /*
304 ** F_SETUP - Bit field value definitions
305 */
306 #define FXAS21002_F_SETUP_F_MODE_FIFO_OFF ((uint8_t) 0x00) /* FIFO is disabled. */
307 #define FXAS21002_F_SETUP_F_MODE_CIR_MODE ((uint8_t) 0x40) /* FIFO is in Circular Buffer mode. */
308 #define FXAS21002_F_SETUP_F_MODE_STOP_MODE ((uint8_t) 0x80) /* FIFO is in Stop mode. */
309 /*------------------------------*/
310 
311 
312 
313 /*--------------------------------
314 ** Register: F_EVENT
315 ** Enum: FXAS21002_F_EVENT
316 ** --
317 ** Offset : 0x0A - FIFO event status
318 ** ------------------------------*/
319 typedef union {
320  struct {
321  uint8_t fe_time : 5; /* Number of ODR periods elapsed since F_EVENT was set. */
322 
323  uint8_t f_event : 1; /* FIFO Event: Indicates if either F_WMKF or F_OVF flags are set (logical */
324  /* OR). */
325 
326  } b;
327  uint8_t w;
329 
330 
331 /*
332 ** F_EVENT - Bit field mask definitions
333 */
334 #define FXAS21002_F_EVENT_FE_TIME_MASK ((uint8_t) 0x1F)
335 #define FXAS21002_F_EVENT_FE_TIME_SHIFT ((uint8_t) 0)
336 
337 #define FXAS21002_F_EVENT_F_EVENT_MASK ((uint8_t) 0x20)
338 #define FXAS21002_F_EVENT_F_EVENT_SHIFT ((uint8_t) 5)
339 
340 
341 /*
342 ** F_EVENT - Bit field value definitions
343 */
344 #define FXAS21002_F_EVENT_F_EVENT_DETECTED ((uint8_t) 0x20) /* FIFO event was detected */
345 /*------------------------------*/
346 
347 
348 
349 /*--------------------------------
350 ** Register: INT_SRC_FLAG
351 ** Enum: FXAS21002_INT_SRC_FLAG
352 ** --
353 ** Offset : 0x0B - Interrupt source status
354 ** ------------------------------*/
355 typedef union {
356  struct {
357  uint8_t src_drdy : 1; /* Data ready event source flag. */
358 
359  uint8_t src_rt : 1; /* Rate threshold event source flag. */
360 
361  uint8_t src_fifo : 1; /* FIFO event source flag. */
362 
363  uint8_t bootend : 1; /* Boot sequence complete event flag. */
364 
365  } b;
366  uint8_t w;
368 
369 
370 /*
371 ** INT_SRC_FLAG - Bit field mask definitions
372 */
373 #define FXAS21002_INT_SRC_FLAG_SRC_DRDY_MASK ((uint8_t) 0x01)
374 #define FXAS21002_INT_SRC_FLAG_SRC_DRDY_SHIFT ((uint8_t) 0)
375 
376 #define FXAS21002_INT_SRC_FLAG_SRC_RT_MASK ((uint8_t) 0x02)
377 #define FXAS21002_INT_SRC_FLAG_SRC_RT_SHIFT ((uint8_t) 1)
378 
379 #define FXAS21002_INT_SRC_FLAG_SRC_FIFO_MASK ((uint8_t) 0x04)
380 #define FXAS21002_INT_SRC_FLAG_SRC_FIFO_SHIFT ((uint8_t) 2)
381 
382 #define FXAS21002_INT_SRC_FLAG_BOOTEND_MASK ((uint8_t) 0x08)
383 #define FXAS21002_INT_SRC_FLAG_BOOTEND_SHIFT ((uint8_t) 3)
384 
385 
386 /*
387 ** INT_SRC_FLAG - Bit field value definitions
388 */
389 #define FXAS21002_INT_SRC_FLAG_SRC_DRDY_READY ((uint8_t) 0x01) /* Asserted whenever a data-ready event triggers */
390  /* the interrupt. */
391 #define FXAS21002_INT_SRC_FLAG_SRC_RT_THRESH ((uint8_t) 0x02) /* Indicates that the rate threshold event flag */
392  /* triggered the interrupt. */
393 #define FXAS21002_INT_SRC_FLAG_SRC_FIFO_EVENT ((uint8_t) 0x04) /* F_OVF or F_WMKF are set, provided the FIFO */
394  /* interrupt is enabled. */
395 #define FXAS21002_INT_SRC_FLAG_BOOTEND_BOOT_DONE ((uint8_t) 0x08) /* Boot sequence is complete. */
396 /*------------------------------*/
397 
398 
399 
400 /*--------------------------------
401 ** Register: WHO_AM_I
402 ** Enum: FXAS21002_WHO_AM_I
403 ** --
404 ** Offset : 0x0C - The WHO_AM_I register contains the device idenifier.
405 ** ------------------------------*/
406 typedef union {
407  struct {
408  uint8_t whoami; /* The WHO_AM_I register contains the device identifier which is factory */
409  /* programmed. */
410 
411  } b;
412  uint8_t w;
414 
415 
416 /*
417 ** WHO_AM_I - Bit field mask definitions
418 */
419 #define FXAS21002_WHO_AM_I_WHOAMI_MASK ((uint8_t) 0xFF)
420 #define FXAS21002_WHO_AM_I_WHOAMI_SHIFT ((uint8_t) 0)
421 
422 
423 /*
424 ** WHO_AM_I - Bit field value definitions
425 */
426 #define FXAS21002_WHO_AM_I_WHOAMI_OLD_VALUE ((uint8_t) 0xd1) /* FXAS21000 */
427 #define FXAS21002_WHO_AM_I_WHOAMI_PRE_VALUE ((uint8_t) 0xd6) /* Engineering Samples */
428 #define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE ((uint8_t) 0xd7) /* FXAS21002 Rev 2.1 (production) */
429 /*------------------------------*/
430 
431 
432 
433 /*--------------------------------
434 ** Register: CTRL_REG0
435 ** --
436 ** Offset : 0x0D - Used for general control and configuration.
437 ** ------------------------------*/
438 typedef union {
439  struct {
440  uint8_t fs : 2; /* Full-scale range selection. */
441 
442  uint8_t hpf_en : 1; /* High-pass filter enable. The high-pass filter is initialized on operating */
443  /* mode and ODR change. When enabled, the HPF is applied to the angular rate */
444  /* data supplied to the output registers/FIFO and the embedded rate threshold */
445  /* algorithm. */
446 
447  uint8_t sel : 2; /* High-pass filter cutoff frequency selection. */
448 
449  uint8_t spiw : 1; /* SPI interface mode selection. */
450 
451  uint8_t bw : 2; /* Bandwidth selects the cut-off frequency of the digital low-pass filter. */
452 
453  } b;
454  uint8_t w;
456 
457 
458 /*
459 ** CTRL_REG0 - Bit field mask definitions
460 */
461 #define FXAS21002_CTRL_REG0_FS_MASK ((uint8_t) 0x03)
462 #define FXAS21002_CTRL_REG0_FS_SHIFT ((uint8_t) 0)
463 
464 #define FXAS21002_CTRL_REG0_HPF_EN_MASK ((uint8_t) 0x04)
465 #define FXAS21002_CTRL_REG0_HPF_EN_SHIFT ((uint8_t) 2)
466 
467 #define FXAS21002_CTRL_REG0_SEL_MASK ((uint8_t) 0x18)
468 #define FXAS21002_CTRL_REG0_SEL_SHIFT ((uint8_t) 3)
469 
470 #define FXAS21002_CTRL_REG0_SPIW_MASK ((uint8_t) 0x20)
471 #define FXAS21002_CTRL_REG0_SPIW_SHIFT ((uint8_t) 5)
472 
473 #define FXAS21002_CTRL_REG0_BW_MASK ((uint8_t) 0xC0)
474 #define FXAS21002_CTRL_REG0_BW_SHIFT ((uint8_t) 6)
475 
476 
477 /*
478 ** CTRL_REG0 - Bit field value definitions
479 */
480 #define FXAS21002_CTRL_REG0_FS_DPS2000 ((uint8_t) 0x00) /* 2000 degrees per second (4000 dps if CTRL_REG3 : */
481  /* FS_DOUBLE = 1). */
482 #define FXAS21002_CTRL_REG0_FS_DPS1000 ((uint8_t) 0x01) /* 1000 degrees per second (2000 dps if CTRL_REG3 : */
483  /* FS_DOUBLE = 1). */
484 #define FXAS21002_CTRL_REG0_FS_DPS500 ((uint8_t) 0x02) /* 500 degrees per second (1000 dps if CTRL_REG3 : */
485  /* FS_DOUBLE = 1). */
486 #define FXAS21002_CTRL_REG0_FS_DPS250 ((uint8_t) 0x03) /* 250 degrees per second (500 dps if CTRL_REG3 : */
487  /* FS_DOUBLE = 1). */
488 #define FXAS21002_CTRL_REG0_HPF_EN_ENABLE ((uint8_t) 0x04)
489 #define FXAS21002_CTRL_REG0_HPF_EN_DISABLE ((uint8_t) 0x00)
490 #define FXAS21002_CTRL_REG0_SPIW_4WIRE ((uint8_t) 0x00) /* SPI 4-wire mode (default). */
491 #define FXAS21002_CTRL_REG0_SPIW_3WIRE ((uint8_t) 0x20) /* SPI 3-wire mode (MOSI pin is used for SPI input */
492  /* and output signals). */
493 /*------------------------------*/
494 
495 
496 
497 /*--------------------------------
498 ** Register: RT_CFG
499 ** Enum: FXAS21002_RT_CFG
500 ** --
501 ** Offset : 0x0E - Used to enable the Rate Threshold interrupt generation.
502 ** ------------------------------*/
503 typedef union {
504  struct {
505  uint8_t xtefe : 1; /* Event flag enable on X rate. */
506 
507  uint8_t ytefe : 1; /* Event flag enable on Y rate. */
508 
509  uint8_t ztefe : 1; /* Event flag enable on Z rate. */
510 
511  uint8_t ele : 1; /* Event latch enable. */
512 
513  } b;
514  uint8_t w;
516 
517 
518 /*
519 ** RT_CFG - Bit field mask definitions
520 */
521 #define FXAS21002_RT_CFG_XTEFE_MASK ((uint8_t) 0x01)
522 #define FXAS21002_RT_CFG_XTEFE_SHIFT ((uint8_t) 0)
523 
524 #define FXAS21002_RT_CFG_YTEFE_MASK ((uint8_t) 0x02)
525 #define FXAS21002_RT_CFG_YTEFE_SHIFT ((uint8_t) 1)
526 
527 #define FXAS21002_RT_CFG_ZTEFE_MASK ((uint8_t) 0x04)
528 #define FXAS21002_RT_CFG_ZTEFE_SHIFT ((uint8_t) 2)
529 
530 #define FXAS21002_RT_CFG_ELE_MASK ((uint8_t) 0x08)
531 #define FXAS21002_RT_CFG_ELE_SHIFT ((uint8_t) 3)
532 
533 
534 /*
535 ** RT_CFG - Bit field value definitions
536 */
537 #define FXAS21002_RT_CFG_XTEFE_ENABLE ((uint8_t) 0x01) /* X event detection enabled. */
538 #define FXAS21002_RT_CFG_XTEFE_DISABLE ((uint8_t) 0x00) /* X event detection disabled. */
539 #define FXAS21002_RT_CFG_YTEFE_ENABLE ((uint8_t) 0x02) /* Y event detection enabled. */
540 #define FXAS21002_RT_CFG_YTEFE_DISABLE ((uint8_t) 0x00) /* Y event detection disabled. */
541 #define FXAS21002_RT_CFG_ZTEFE_ENABLE ((uint8_t) 0x04) /* Z event detection enabled. */
542 #define FXAS21002_RT_CFG_ZTEFE_DISABLE ((uint8_t) 0x00) /* Z event detection disabled. */
543 #define FXAS21002_RT_CFG_ELE_ENABLE ((uint8_t) 0x08) /* Event flag latch enabled. */
544 #define FXAS21002_RT_CFG_ELE_DISABLE ((uint8_t) 0x00) /* Event flag latch disabled. */
545 /*------------------------------*/
546 
547 
548 
549 /*--------------------------------
550 ** Register: RT_SRC
551 ** Enum: FXAS21002_RT_SRC
552 ** --
553 ** Offset : 0x0F - Indicates the source of the Rate Threshold event. It also clears the RT_SRC flag in the INT_SOURCE_FLAG register.
554 ** ------------------------------*/
555 typedef union {
556  struct {
557  uint8_t x_rt_pol : 1; /* Polarity of X event. */
558 
559  uint8_t xrt : 1; /* X rate Event. */
560 
561  uint8_t y_rt_pol : 1; /* Polarity of Y event. */
562 
563  uint8_t yrt : 1; /* Y rate event. */
564 
565  uint8_t z_rt_pol : 1; /* Polarity of Z event. */
566 
567  uint8_t zrt : 1; /* Z rate event. */
568 
569  uint8_t ea : 1; /* Event active flag. */
570 
571  } b;
572  uint8_t w;
574 
575 
576 /*
577 ** RT_SRC - Bit field mask definitions
578 */
579 #define FXAS21002_RT_SRC_X_RT_POL_MASK ((uint8_t) 0x01)
580 #define FXAS21002_RT_SRC_X_RT_POL_SHIFT ((uint8_t) 0)
581 
582 #define FXAS21002_RT_SRC_XRT_MASK ((uint8_t) 0x02)
583 #define FXAS21002_RT_SRC_XRT_SHIFT ((uint8_t) 1)
584 
585 #define FXAS21002_RT_SRC_Y_RT_POL_MASK ((uint8_t) 0x04)
586 #define FXAS21002_RT_SRC_Y_RT_POL_SHIFT ((uint8_t) 2)
587 
588 #define FXAS21002_RT_SRC_YRT_MASK ((uint8_t) 0x08)
589 #define FXAS21002_RT_SRC_YRT_SHIFT ((uint8_t) 3)
590 
591 #define FXAS21002_RT_SRC_Z_RT_POL_MASK ((uint8_t) 0x10)
592 #define FXAS21002_RT_SRC_Z_RT_POL_SHIFT ((uint8_t) 4)
593 
594 #define FXAS21002_RT_SRC_ZRT_MASK ((uint8_t) 0x20)
595 #define FXAS21002_RT_SRC_ZRT_SHIFT ((uint8_t) 5)
596 
597 #define FXAS21002_RT_SRC_EA_MASK ((uint8_t) 0x40)
598 #define FXAS21002_RT_SRC_EA_SHIFT ((uint8_t) 6)
599 
600 
601 /*
602 ** RT_SRC - Bit field value definitions
603 */
604 #define FXAS21002_RT_SRC_X_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
605 #define FXAS21002_RT_SRC_X_RT_POL_NEG ((uint8_t) 0x01) /* Rate Event was Negative. */
606 #define FXAS21002_RT_SRC_XRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
607 #define FXAS21002_RT_SRC_XRT_GREATER ((uint8_t) 0x02) /* Rate greater than RT_THS value. Event has occured. */
608 #define FXAS21002_RT_SRC_Y_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
609 #define FXAS21002_RT_SRC_Y_RT_POL_NEG ((uint8_t) 0x04) /* Rate Event was Negative. */
610 #define FXAS21002_RT_SRC_YRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
611 #define FXAS21002_RT_SRC_YRT_GREATER ((uint8_t) 0x08) /* Rate greater than RT_THS value. Event has occured. */
612 #define FXAS21002_RT_SRC_Z_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
613 #define FXAS21002_RT_SRC_Z_RT_POL_NEG ((uint8_t) 0x10) /* Rate Event was Negative. */
614 #define FXAS21002_RT_SRC_ZRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
615 #define FXAS21002_RT_SRC_ZRT_GREATER ((uint8_t) 0x20) /* Rate greater than RT_THS value. Event has occured. */
616 #define FXAS21002_RT_SRC_EA_NOEVENT ((uint8_t) 0x00) /* No event flags have been asserted. */
617 #define FXAS21002_RT_SRC_EA_EVENT ((uint8_t) 0x40) /* One or more event flags have been asserted. */
618 /*------------------------------*/
619 
620 
621 
622 /*--------------------------------
623 ** Register: RT_THS
624 ** Enum: FXAS21002_RT_THS
625 ** --
626 ** Offset : 0x10 - The RT_THS register sets the threshold limit for the detection of the rate and the debounce counter mode.
627 ** ------------------------------*/
628 typedef union {
629  struct {
630  uint8_t ths : 7; /* Unsigned 7-bit rate threshold value; The contents should only be modified */
631  /* when the device is in Standby mode; The internal state of the Rate */
632  /* Threshold function is reset when a transition from Standby to Active or */
633  /* Ready to Active modes occurs. */
634 
635  uint8_t dbcntm : 1; /* Debounce counter mode selection. */
636 
637  } b;
638  uint8_t w;
640 
641 
642 /*
643 ** RT_THS - Bit field mask definitions
644 */
645 #define FXAS21002_RT_THS_THS_MASK ((uint8_t) 0x7F)
646 #define FXAS21002_RT_THS_THS_SHIFT ((uint8_t) 0)
647 
648 #define FXAS21002_RT_THS_DBCNTM_MASK ((uint8_t) 0x80)
649 #define FXAS21002_RT_THS_DBCNTM_SHIFT ((uint8_t) 7)
650 
651 
652 /*
653 ** RT_THS - Bit field value definitions
654 */
655 #define FXAS21002_RT_THS_DBCNTM_CLEAR ((uint8_t) 0x80) /* Clear counter when angular rate is below the */
656  /* threshold value. */
657 #define FXAS21002_RT_THS_DBCNTM_DECREMENT ((uint8_t) 0x00) /* Decrement counter on every ODR cycle that the */
658  /* angular rate is below the threshold value. */
659 /*------------------------------*/
660 
661 
662 
663 /*--------------------------------
664 ** Register: RT_COUNT
665 ** Enum: FXAS21002_RT_COUNT
666 ** --
667 ** Offset : 0x11 - Sets the number of debounce counts.
668 ** ------------------------------*/
669 typedef uint8_t FXAS21002_RT_COUNT_t;
670 
671 
672 
673 /*--------------------------------
674 ** Register: TEMP
675 ** Enum: FXAS21002_TEMP
676 ** --
677 ** Offset : 0x12 - The TEMP register contains an 8-bit 2's complement temperature value with a range of –128 °C to +127 °C and a scaling of 1 °C/LSB.
678 ** ------------------------------*/
679 typedef uint8_t FXAS21002_TEMP_t;
680 
681 
682 
683 /*--------------------------------
684 ** Register: CTRL_REG1
685 ** Enum: FXAS21002_CTRL_REG1
686 ** --
687 ** Offset : 0x13 - The CTRL_REG1 register is used to configure the device ODR, set the operating mode, soft-reset the device, and exercise the Self-Test function.
688 ** ------------------------------*/
689 typedef union {
690  struct {
691  uint8_t mode : 2; /* Operational Mode. */
692 
693  uint8_t dr : 3; /* Output Data Rate selection. */
694 
695  uint8_t st : 1; /* Self-Test Enable. */
696 
697  uint8_t rst : 1; /* Software Reset. */
698 
699  } b;
700  uint8_t w;
702 
703 
704 /*
705 ** CTRL_REG1 - Bit field mask definitions
706 */
707 #define FXAS21002_CTRL_REG1_MODE_MASK ((uint8_t) 0x03)
708 #define FXAS21002_CTRL_REG1_MODE_SHIFT ((uint8_t) 0)
709 
710 #define FXAS21002_CTRL_REG1_DR_MASK ((uint8_t) 0x1C)
711 #define FXAS21002_CTRL_REG1_DR_SHIFT ((uint8_t) 2)
712 
713 #define FXAS21002_CTRL_REG1_ST_MASK ((uint8_t) 0x20)
714 #define FXAS21002_CTRL_REG1_ST_SHIFT ((uint8_t) 5)
715 
716 #define FXAS21002_CTRL_REG1_RST_MASK ((uint8_t) 0x40)
717 #define FXAS21002_CTRL_REG1_RST_SHIFT ((uint8_t) 6)
718 
719 
720 /*
721 ** CTRL_REG1 - Bit field value definitions
722 */
723 #define FXAS21002_CTRL_REG1_MODE_STANDBY ((uint8_t) 0x00) /* Standby Mode. Register setting allowed. Lowest */
724  /* power. */
725 #define FXAS21002_CTRL_REG1_MODE_READY ((uint8_t) 0x01) /* Ready Mode. The device is ready to measure */
726  /* angular rate but no data acquisitions are being */
727  /* made. Register reads only. Reduced power. */
728 #define FXAS21002_CTRL_REG1_MODE_ACTIVE ((uint8_t) 0x02) /* Active Mode. The device is fully functional. */
729  /* Register reads only. Maximum power. */
730 #define FXAS21002_CTRL_REG1_DR_800HZ ((uint8_t) 0x00)
731 #define FXAS21002_CTRL_REG1_DR_400HZ ((uint8_t) 0x04)
732 #define FXAS21002_CTRL_REG1_DR_200HZ ((uint8_t) 0x08)
733 #define FXAS21002_CTRL_REG1_DR_100HZ ((uint8_t) 0x0c)
734 #define FXAS21002_CTRL_REG1_DR_50HZ ((uint8_t) 0x10)
735 #define FXAS21002_CTRL_REG1_DR_25HZ ((uint8_t) 0x14)
736 #define FXAS21002_CTRL_REG1_DR_12_5HZ ((uint8_t) 0x18)
737 #define FXAS21002_CTRL_REG1_ST_ENABLE ((uint8_t) 0x20)
738 #define FXAS21002_CTRL_REG1_ST_DISABLE ((uint8_t) 0x00)
739 #define FXAS21002_CTRL_REG1_RST_TRIGGER ((uint8_t) 0x40)
740 #define FXAS21002_CTRL_REG1_RST_NOTTRIGGERED ((uint8_t) 0x00)
741 /*------------------------------*/
742 
743 
744 
745 /*--------------------------------
746 ** Register: CTRL_REG2
747 ** Enum: FXAS21002_CTRL_REG2
748 ** --
749 ** Offset : 0x14 - This register enables and assigns the output pin(s) and logic polarities for the various interrupt sources available on the device.
750 ** ------------------------------*/
751 typedef union {
752  struct {
753  uint8_t pp_od : 1; /* INT1 and INT2 pin output driver configuration. */
754 
755  uint8_t ipol : 1; /* Interrupt logic polarity. */
756 
757  uint8_t int_en_drdy : 1; /* Data ready interrupt enable. */
758 
759  uint8_t int_cfg_drdy : 1; /* Data-ready interrupt pin routing. */
760 
761  uint8_t int_en_rt : 1; /* Rate threshold interrupt enable. */
762 
763  uint8_t int_cfg_rt : 1; /* Rate threshold interrupt pin routing. */
764 
765  uint8_t int_en_fifo : 1; /* FIFO Interrupt Enable. */
766 
767  uint8_t int_cfg_fifo : 1; /* FIFO interrupt pin routing. */
768 
769  } b;
770  uint8_t w;
772 
773 
774 /*
775 ** CTRL_REG2 - Bit field mask definitions
776 */
777 #define FXAS21002_CTRL_REG2_PP_OD_MASK ((uint8_t) 0x01)
778 #define FXAS21002_CTRL_REG2_PP_OD_SHIFT ((uint8_t) 0)
779 
780 #define FXAS21002_CTRL_REG2_IPOL_MASK ((uint8_t) 0x02)
781 #define FXAS21002_CTRL_REG2_IPOL_SHIFT ((uint8_t) 1)
782 
783 #define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK ((uint8_t) 0x04)
784 #define FXAS21002_CTRL_REG2_INT_EN_DRDY_SHIFT ((uint8_t) 2)
785 
786 #define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK ((uint8_t) 0x08)
787 #define FXAS21002_CTRL_REG2_INT_CFG_DRDY_SHIFT ((uint8_t) 3)
788 
789 #define FXAS21002_CTRL_REG2_INT_EN_RT_MASK ((uint8_t) 0x10)
790 #define FXAS21002_CTRL_REG2_INT_EN_RT_SHIFT ((uint8_t) 4)
791 
792 #define FXAS21002_CTRL_REG2_INT_CFG_RT_MASK ((uint8_t) 0x20)
793 #define FXAS21002_CTRL_REG2_INT_CFG_RT_SHIFT ((uint8_t) 5)
794 
795 #define FXAS21002_CTRL_REG2_INT_EN_FIFO_MASK ((uint8_t) 0x40)
796 #define FXAS21002_CTRL_REG2_INT_EN_FIFO_SHIFT ((uint8_t) 6)
797 
798 #define FXAS21002_CTRL_REG2_INT_CFG_FIFO_MASK ((uint8_t) 0x80)
799 #define FXAS21002_CTRL_REG2_INT_CFG_FIFO_SHIFT ((uint8_t) 7)
800 
801 
802 /*
803 ** CTRL_REG2 - Bit field value definitions
804 */
805 #define FXAS21002_CTRL_REG2_PP_OD_PUSHPULL ((uint8_t) 0x00) /* Push-pull output driver. */
806 #define FXAS21002_CTRL_REG2_PP_OD_OPENDRAIN ((uint8_t) 0x01) /* Open-drain output driver. */
807 #define FXAS21002_CTRL_REG2_IPOL_ACTIVE_LOW ((uint8_t) 0x00)
808 #define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH ((uint8_t) 0x02)
809 #define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE ((uint8_t) 0x04)
810 #define FXAS21002_CTRL_REG2_INT_EN_DRDY_DISABLE ((uint8_t) 0x00)
811 #define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
812 #define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1 ((uint8_t) 0x08) /* Interrupt is routed to INT1 pin. */
813 #define FXAS21002_CTRL_REG2_INT_EN_RT_ENABLE ((uint8_t) 0x10)
814 #define FXAS21002_CTRL_REG2_INT_EN_RT_DISABLE ((uint8_t) 0x00)
815 #define FXAS21002_CTRL_REG2_INT_CFG_RT_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
816 #define FXAS21002_CTRL_REG2_INT_CFG_RT_INT1 ((uint8_t) 0x20) /* Interrupt is routed to INT1 pin. */
817 #define FXAS21002_CTRL_REG2_INT_EN_FIFO_ENABLE ((uint8_t) 0x40)
818 #define FXAS21002_CTRL_REG2_INT_EN_FIFO_DISABLE ((uint8_t) 0x00)
819 #define FXAS21002_CTRL_REG2_INT_CFG_FIFO_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
820 #define FXAS21002_CTRL_REG2_INT_CFG_FIFO_INT1 ((uint8_t) 0x80) /* Interrupt is routed to INT1 pin. */
821 /*------------------------------*/
822 
823 
824 
825 /*--------------------------------
826 ** Register: CTRL_REG3
827 ** Enum: FXAS21002_CTRL_REG3
828 ** --
829 ** Offset : 0x15 - Auto-increment address configuration, external power control, Full Scale Range (FSR) expansion
830 ** ------------------------------*/
831 typedef union {
832  struct {
833  uint8_t fs_double : 1; /* Increases the dynamic range for each CTRL_REG0 : FS selection by a factor */
834  /* of two. */
835 
836  uint8_t _reserved_ : 1;
837  uint8_t extctrlen : 1; /* External power mode control input. */
838 
839  uint8_t wraptoone : 1; /* Auto-increment read address pointer roll-over behavior. */
840 
841  } b;
842  uint8_t w;
844 
845 
846 /*
847 ** CTRL_REG3 - Bit field mask definitions
848 */
849 #define FXAS21002_CTRL_REG3_FS_DOUBLE_MASK ((uint8_t) 0x01)
850 #define FXAS21002_CTRL_REG3_FS_DOUBLE_SHIFT ((uint8_t) 0)
851 
852 #define FXAS21002_CTRL_REG3_EXTCTRLEN_MASK ((uint8_t) 0x04)
853 #define FXAS21002_CTRL_REG3_EXTCTRLEN_SHIFT ((uint8_t) 2)
854 
855 #define FXAS21002_CTRL_REG3_WRAPTOONE_MASK ((uint8_t) 0x08)
856 #define FXAS21002_CTRL_REG3_WRAPTOONE_SHIFT ((uint8_t) 3)
857 
858 
859 /*
860 ** CTRL_REG3 - Bit field value definitions
861 */
862 #define FXAS21002_CTRL_REG3_FS_DOUBLE_ENABLE ((uint8_t) 0x01) /* Maximum full-scale range selections are doubled */
863  /* (4000, 2000, 1000, 500 dps). */
864 #define FXAS21002_CTRL_REG3_FS_DOUBLE_DISABLE ((uint8_t) 0x00) /* Maximum full-scale range selections are as per */
865  /* selectable full-scale ranges (2000, 1000, 500, */
866  /* 250 dps). */
867 #define FXAS21002_CTRL_REG3_EXTCTRLEN_INT2 ((uint8_t) 0x00) /* INT2 pin is used as an interrupt output */
868  /* (default). */
869 #define FXAS21002_CTRL_REG3_EXTCTRLEN_POWER_CONTROL ((uint8_t) 0x04) /* INT2 pin becomes an input pin that may be used */
870  /* to control the power mode. */
871 #define FXAS21002_CTRL_REG3_WRAPTOONE_ROLL_STATUS ((uint8_t) 0x00) /* The auto-increment read address pointer rolls */
872  /* over to address 0x00 (STATUS) after the Z-axis */
873  /* LSB is read (default). */
874 #define FXAS21002_CTRL_REG3_WRAPTOONE_ROLL_DATA ((uint8_t) 0x08) /* The auto-increment pointer rolls over to address */
875  /* 0x01 (X-axis MSB) in order to facilitate the */
876  /* faster read out of the FIFO data in a single */
877  /* burst read operation. */
878 /*------------------------------*/
879 
880 
881 #endif /* FXAS21002_H_ */
uint8_t FXAS21002_OUT_X_LSB_t
Definition: fxas21002.h:103
uint8_t FXAS21002_OUT_X_MSB_t
Definition: fxas21002.h:94
uint8_t FXAS21002_OUT_Y_LSB_t
Definition: fxas21002.h:122
uint8_t FXAS21002_STATUS_t
Definition: fxas21002.h:84
uint8_t FXAS21002_TEMP_t
Definition: fxas21002.h:679
uint8_t FXAS21002_OUT_Z_MSB_t
Definition: fxas21002.h:132
uint8_t FXAS21002_OUT_Z_LSB_t
Definition: fxas21002.h:141
uint8_t FXAS21002_RT_COUNT_t
Definition: fxas21002.h:669
uint8_t FXAS21002_OUT_Y_MSB_t
Definition: fxas21002.h:113