ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
fxas21002.h
Go to the documentation of this file.
1 /**
2  * @file FXAS21002.h
3  * @brief The \b fxas21002.h file contains the FXAS21002 Magnetometer register definitions, access macros, and
4  * device access functions.
5  *
6  * @copyright Copyright (c) 2015, Freescale Semiconductor, Inc.
7  */
8 
9 #ifndef FXAS21002_H_
10 #define FXAS21002_H_
11 
12 // TODO - See if we can reduce the number of required includes (vestiges of Events.h).
13 #include "isf.h"
14 #include <isf_types.h>
15 #include <isf_devmsg.h>
16 #include <isf_bm.h>
17 #include <isf_sm_api.h>
18 #include <isf_dsa_adapter.h>
19 //#include <fsl_fxas21002_i2c_3D_gyro_config_types.h>
20 //#include <fsl_fxas21002_i2c_3D_gyro.h>
21 
22 #define FXAS21002_IIC_ADDRESS 0x20 // FXAS21002 I2C Address.
23 
24 /**
25  * @brief The FXAS21002 registers, masks, and constants.
26  */
27 #define FXAS21002_NUMBER_AXIS 3 // Number of Axis
28 #define FXAS21002_NUMBER_BYTES_AXIS 2 // Number of bytes in each axis
29 
30 /**
31  **
32  ** @brief The FXAS21002 Sensor Internal Register Map.
33  */
34 enum {
58 };
59 
60 /*
61  * General purpose macros to set/get a specific bit field within a register.
62  * The macro assumes that the root identifier for the field is a consistent character string (e.g., "BIT_FIELD").
63  * The bit field mask is the character string followed by "_MASK" (e.g., BIT_FIELD_MASK).
64  * The bit field shift is the character string followed by "_SHIFT" (e.g., BIT_FIELD_SHIFT).
65  */
66 #define FXAS21002_SET_FIELD(name,val) (((val)<<FXAS21002_##name##_SHIFT)&(FXAS21002_##name##_MASK))
67 #define FXAS21002_GET_FIELD(name,val) ((val&FXAS21002_##name##_MASK)>>FXAS21002_##name##_SHIFT)
68 
69 /*
70  ** DR_STATUS Register
71  */
72 #define FXAS21002_ZYXOW_MASK (0x80)
73 #define FXAS21002_ZYXOW_SHIFT 7
74 #define FXAS21002_ZOW_MASK (0x40)
75 #define FXAS21002_ZOW_SHIFT 6
76 #define FXAS21002_YOW_MASK (0x20)
77 #define FXAS21002_YOW_SHIFT 5
78 #define FXAS21002_XOW_MASK (0x10)
79 #define FXAS21002_XOW_SHIFT 4
80 #define FXAS21002_ZYXDR_MASK (0x08)
81 #define FXAS21002_ZYXDR_SHIFT 3
82 #define FXAS21002_ZDR_MASK (0x04)
83 #define FXAS21002_ZDR_SHIFT 2
84 #define FXAS21002_YDR_MASK (0x02)
85 #define FXAS21002_YDR_SHIFT 1
86 #define FXAS21002_XDR_MASK (0x01)
87 #define FXAS21002_XDR_SHIFT 0
88 
89 /*
90  ** F_STATUS Register
91  */
92 #define FXAS21002_F_OVF_MASK (0x80)
93 #define FXAS21002_F_OVF_SHIFT 7
94 #define FXAS21002_F_WMKF_MASK (0x40)
95 #define FXAS21002_F_WMKF_SHIFT 6
96 
97 /*
98  ** F_SETUP Register
99  */
100 #define FXAS21002_F_MODE_MASK (0xC0)
101 #define FXAS21002_F_MODE_SHIFT 6
102 #define FXAS21002_F_WMRK_MASK (0x3F)
103 #define FXAS21002_F_WMRK_SHIFT 0
104 
105 /*
106  ** F_EVENT Register
107  */
108 #define FXAS21002_F_EVENT_MASK (0x20)
109 #define FXAS21002_F_EVENT_SHIFT 5
110 #define FXAS21002_FE_TIME_MASK (0x1F)
111 #define FXAS21002_FE_TIME_SHIFT 0
112 
113 /*
114  ** INT_SOURCE_FLAG Register
115  */
116 #define FXAS21002_BOOTEND_MASK (0x08)
117 #define FXAS21002_BOOTEND_SHIFT 3
118 #define FXAS21002_SRC_FIFO_MASK (0x04)
119 #define FXAS21002_SRC_FIFO_SHIFT 2
120 #define FXAS21002_SRC_RT_MASK (0x02)
121 #define FXAS21002_SRC_RT_SHIFT 1
122 #define FXAS21002_SRC_DRDY_MASK (0x01)
123 #define FXAS21002_SRC_DRDY_SHIFT 0
124 
125 
126 
127 /*
128  ** CTRL0 Register
129  */
130 #define FXAS21002_BW_MASK (0xC0)
131 #define FXAS21002_BW_SHIFT 6
132 #define FXAS21002_SPIW_MASK (0x20)
133 #define FXAS21002_SPIW_SHIFT 5
134 #define FXAS21002_SEL_MASK (0x18)
135 #define FXAS21002_SEL_SHIFT 3
136 #define FXAS21002_HPF_EN_MASK (0x04)
137 #define FXAS21002_HPF_EN_SHIFT 2
138 #define FXAS21002_FS_MASK (0x02)
139 #define FXAS21002_FS_SHIFT 0
140 
141 /*
142  ** CTRL1 Register
143  */
144 #define FXAS21002_RST_MASK (0x40)
145 #define FXAS21002_RST_SHIFT 7
146 #define FXAS21002_ST_MASK (0x20)
147 #define FXAS21002_ST_SHIFT 5
148 #define FXAS21002_DR_MASK (0x1C)
149 #define FXAS21002_DR_SHIFT 2
150 #define FXAS21002_ACTIVE_MASK (0x02)
151 #define FXAS21002_ACTIVE_SHIFT 1
152 #define FXAS21002_READY_MASK (0x01)
153 #define FXAS21002_READY_SHIFT 0
154 
155 /*
156  ** CTRL2 Register
157  */
158 #define FXAS21002_INT_CFG_FIFO_MASK (0x80)
159 #define FXAS21002_INT_CFG_FIFO_SHIFT 7
160 #define FXAS21002_INT_EN_FIFO_MASK (0x40)
161 #define FXAS21002_INT_EN_FIFO_SHIFT 6
162 #define FXAS21002_INT_CFG_RT_MASK (0x20)
163 #define FXAS21002_INT_CFG_RT_SHIFT 5
164 #define FXAS21002_INT_EN_RT_MASK (0x10)
165 #define FXAS21002_INT_EN_RT_SHIFT 4
166 #define FXAS21002_INT_CFG_DRDY_MASK (0x08)
167 #define FXAS21002_INT_CFG_DRDY_SHIFT 3
168 #define FXAS21002_INT_EN_DRDY_MASK (0x04)
169 #define FXAS21002_INT_EN_DRDY_SHIFT 2
170 #define FXAS21002_IPOL_MASK (0x02)
171 #define FXAS21002_IPOL_SHIFT 1
172 #define FXAS21002_PP_OD_MASK (0x01)
173 #define FXAS21002_PP_OD_SHIFT 0
174 
175 /*
176  ** CTRL3 Register
177  */
178 #define FXAS21002_WRAPTOONE_MASK (0x08)
179 #define FXAS21002_WRAPTOONE_SHIFT 3
180 #define FXAS21002_EXTCTRLEN_MASK (0x04)
181 #define FXAS21002_EXTCTRLEN_SHIFT 2
182 #define FXAS21002_FSDOUBLE_MASK (0x01)
183 #define FXAS21002_FSDOUBLE_SHIFT 0
184 
185 
186 #define MAG3100_READ_BUF_SIZE (6)
187 #define NUMBER_OF_BYTES_TIMESTAMP (4)
188 #define FXAS21000_WHOAMI_VALUE (0xD1)
189 #define FXAS21002_WHOAMI_VALUE_PRE_RELEASE (0xD6)
190 #define FXAS21002_WHOAMI_VALUE_RELEASE (0xD7)
191 
192 // Device standby to active time, number of samples to wait. FXAS21002 datasheet states
193 // Standby to active mode transition time is (1/ODR + 60)ms. So for 800 Hz data rate (1.25ms sample period) we need to wait for 49 samples (61.25ms/1.25ms = 49)
194 #define FXAS21002_STANDBY_TO_ACTIVE_SAMPLE_WAIT (49)
195 
197 
198 /*! @brief The structure defines the FXAS21002 configuration.*/
199 typedef struct {
200  uint32 period; // The period used to process samples in microseconds.
201 
202 } gyro_config_t;
203 
204 typedef struct
205 {
209 
210 typedef struct
211 {
220 
221 
222 
223 #endif /* FXAS21002_H_ */
unsigned char uint8
Definition: isf_types.h:76
The structure defines the FXAS21002 configuration.
Definition: fxas21002.h:199
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
uint32 period
Definition: fxas21002.h:200
Main ISF header file. Contains code common to all ISF components.
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
signed long int int32
Definition: isf_types.h:74
int32 fxas21002_status_t
Definition: fxas21002.h:196
unsigned long int uint32
Definition: isf_types.h:78
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...