ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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) 2014, 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 "Cpu.h"
14 #include "PE_Types.h"
15 #include "PE_Error.h"
16 #include "PE_Const.h"
17 #include "IO_Map.h"
18 #include <isf_types.h>
19 #include <isf_devmsg.h>
20 #include <isf_bm.h>
21 #include <isf_sm_api.h>
22 #include <isf_dsa_adapter.h>
23 //#include <fsl_fxas21002_i2c_3D_gyro_config_types.h>
24 //#include <fsl_fxas21002_i2c_3D_gyro.h>
25 
26 #define FXAS21002_IIC_ADDRESS 0x20 // FXAS21002 I2C Address.
27 
28 /**
29  * @brief The FXAS21002 registers, masks, and constants.
30  */
31 #define FXAS21002_NUMBER_AXIS 3 // Number of Axis
32 #define FXAS21002_NUMBER_BYTES_AXIS 2 // Number of bytes in each axis
33 
34 /**
35  **
36  ** @brief The FXAS21002 Sensor Internal Register Map.
37  */
38 enum {
62 };
63 
64 /*
65  * General purpose macros to set/get a specific bit field within a register.
66  * The macro assumes that the root identifier for the field is a consistent character string (e.g., "BIT_FIELD").
67  * The bit field mask is the character string followed by "_MASK" (e.g., BIT_FIELD_MASK).
68  * The bit field shift is the character string followed by "_SHIFT" (e.g., BIT_FIELD_SHIFT).
69  */
70 #define FXAS21002_SET_FIELD(name,val) (((val)<<FXAS21002_##name##_SHIFT)&(FXAS21002_##name##_MASK))
71 #define FXAS21002_GET_FIELD(name,val) ((val&FXAS21002_##name##_MASK)>>FXAS21002_##name##_SHIFT)
72 
73 /*
74  ** DR_STATUS Register
75  */
76 #define FXAS21002_ZYXOW_MASK (0x80)
77 #define FXAS21002_ZYXOW_SHIFT 7
78 #define FXAS21002_ZOW_MASK (0x40)
79 #define FXAS21002_ZOW_SHIFT 6
80 #define FXAS21002_YOW_MASK (0x20)
81 #define FXAS21002_YOW_SHIFT 5
82 #define FXAS21002_XOW_MASK (0x10)
83 #define FXAS21002_XOW_SHIFT 4
84 #define FXAS21002_ZYXDR_MASK (0x08)
85 #define FXAS21002_ZYXDR_SHIFT 3
86 #define FXAS21002_ZDR_MASK (0x04)
87 #define FXAS21002_ZDR_SHIFT 2
88 #define FXAS21002_YDR_MASK (0x02)
89 #define FXAS21002_YDR_SHIFT 1
90 #define FXAS21002_XDR_MASK (0x01)
91 #define FXAS21002_XDR_SHIFT 0
92 
93 /*
94  ** F_STATUS Register
95  */
96 #define FXAS21002_F_OVF_MASK (0x80)
97 #define FXAS21002_F_OVF_SHIFT 7
98 #define FXAS21002_F_WMKF_MASK (0x40)
99 #define FXAS21002_F_WMKF_SHIFT 6
100 
101 /*
102  ** F_SETUP Register
103  */
104 #define FXAS21002_F_MODE_MASK (0xC0)
105 #define FXAS21002_F_MODE_SHIFT 6
106 #define FXAS21002_F_WMRK_MASK (0x3F)
107 #define FXAS21002_F_WMRK_SHIFT 0
108 
109 /*
110  ** F_EVENT Register
111  */
112 #define FXAS21002_F_EVENT_MASK (0x20)
113 #define FXAS21002_F_EVENT_SHIFT 5
114 #define FXAS21002_FE_TIME_MASK (0x1F)
115 #define FXAS21002_FE_TIME_SHIFT 0
116 
117 /*
118  ** INT_SOURCE_FLAG Register
119  */
120 #define FXAS21002_BOOTEND_MASK (0x08)
121 #define FXAS21002_BOOTEND_SHIFT 3
122 #define FXAS21002_SRC_FIFO_MASK (0x04)
123 #define FXAS21002_SRC_FIFO_SHIFT 2
124 #define FXAS21002_SRC_RT_MASK (0x02)
125 #define FXAS21002_SRC_RT_SHIFT 1
126 #define FXAS21002_SRC_DRDY_MASK (0x01)
127 #define FXAS21002_SRC_DRDY_SHIFT 0
128 
129 
130 
131 /*
132  ** CTRL0 Register
133  */
134 #define FXAS21002_BW_MASK (0xC0)
135 #define FXAS21002_BW_SHIFT 6
136 #define FXAS21002_SPIW_MASK (0x20)
137 #define FXAS21002_SPIW_SHIFT 5
138 #define FXAS21002_SEL_MASK (0x18)
139 #define FXAS21002_SEL_SHIFT 3
140 #define FXAS21002_HPF_EN_MASK (0x04)
141 #define FXAS21002_HPF_EN_SHIFT 2
142 #define FXAS21002_FS_MASK (0x02)
143 #define FXAS21002_FS_SHIFT 0
144 
145 /*
146  ** CTRL1 Register
147  */
148 #define FXAS21002_RST_MASK (0x40)
149 #define FXAS21002_RST_SHIFT 7
150 #define FXAS21002_ST_MASK (0x20)
151 #define FXAS21002_ST_SHIFT 5
152 #define FXAS21002_DR_MASK (0x1C)
153 #define FXAS21002_DR_SHIFT 2
154 #define FXAS21002_ACTIVE_MASK (0x02)
155 #define FXAS21002_ACTIVE_SHIFT 1
156 #define FXAS21002_READY_MASK (0x01)
157 #define FXAS21002_READY_SHIFT 0
158 
159 /*
160  ** CTRL2 Register
161  */
162 #define FXAS21002_INT_CFG_FIFO_MASK (0x80)
163 #define FXAS21002_INT_CFG_FIFO_SHIFT 7
164 #define FXAS21002_INT_EN_FIFO_MASK (0x40)
165 #define FXAS21002_INT_EN_FIFO_SHIFT 6
166 #define FXAS21002_INT_CFG_RT_MASK (0x20)
167 #define FXAS21002_INT_CFG_RT_SHIFT 5
168 #define FXAS21002_INT_EN_RT_MASK (0x10)
169 #define FXAS21002_INT_EN_RT_SHIFT 4
170 #define FXAS21002_INT_CFG_DRDY_MASK (0x08)
171 #define FXAS21002_INT_CFG_DRDY_SHIFT 3
172 #define FXAS21002_INT_EN_DRDY_MASK (0x04)
173 #define FXAS21002_INT_EN_DRDY_SHIFT 2
174 #define FXAS21002_IPOL_MASK (0x02)
175 #define FXAS21002_IPOL_SHIFT 1
176 #define FXAS21002_PP_OD_MASK (0x01)
177 #define FXAS21002_PP_OD_SHIFT 0
178 
179 /*
180  ** CTRL3 Register
181  */
182 #define FXAS21002_WRAPTOONE_MASK (0x08)
183 #define FXAS21002_WRAPTOONE_SHIFT 3
184 #define FXAS21002_EXTCTRLEN_MASK (0x04)
185 #define FXAS21002_EXTCTRLEN_SHIFT 2
186 #define FXAS21002_FSDOUBLE_MASK (0x01)
187 #define FXAS21002_FSDOUBLE_SHIFT 0
188 
189 
190 #define MAG3100_READ_BUF_SIZE (6)
191 #define NUMBER_OF_BYTES_TIMESTAMP (4)
192 #define FXAS21000_WHOAMI_VALUE (0xD1)
193 #define FXAS21002_WHOAMI_VALUE (0xD6)
194 
195 // Device standby to active time, number of samples to wait. FXAS21002 datasheet states
196 // 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)
197 #define FXAS21002_STANDBY_TO_ACTIVE_SAMPLE_WAIT (49)
198 
200 
201 /*! @brief The structure defines the FXAS21002 configuration.*/
202 typedef struct {
203  uint32 period; // The period used to process samples in microseconds.
204 
205 } gyro_config_t;
206 
207 typedef struct
208 {
212 
213 typedef struct
214 {
223 
224 
225 
226 #endif /* FXAS21002_H_ */
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
The structure defines the FXAS21002 configuration.
Definition: fxas21002.h:202
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
uint32 period
Definition: fxas21002.h:203
long int32
This defines int32 as long.
Definition: isf_types.h:32
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
int32 fxas21002_status_t
Definition: fxas21002.h:199
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...