| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
35 FXAS21002_STATUS = 0x00,
36 FXAS21002_OUT_X_MSB = 0x01,
37 FXAS21002_OUT_X_LSB = 0x02,
38 FXAS21002_OUT_Y_MSB = 0x03,
39 FXAS21002_OUT_Y_LSB = 0x04,
40 FXAS21002_OUT_Z_MSB = 0x05,
41 FXAS21002_OUT_Z_LSB = 0x06,
42 FXAS21002_DR_STATUS = 0x07,
43 FXAS21002_F_STATUS = 0x08,
44 FXAS21002_F_SETUP = 0x09,
45 FXAS21002_F_EVENT = 0x0A,
46 FXAS21002_INT_SRC_FLAG = 0x0B,
47 FXAS21002_WHO_AM_I = 0x0C,
48 FXAS21002_CTRL_REG0 = 0x0D,
49 FXAS21002_RT_CFG = 0x0E,
50 FXAS21002_RT_SRC = 0x0F,
51 FXAS21002_RT_THS = 0x10,
52 FXAS21002_RT_COUNT = 0x11,
53 FXAS21002_TEMP = 0x12,
54 FXAS21002_CTRL_REG1 = 0x13,
55 FXAS21002_CTRL_REG2 = 0x14,
56 FXAS21002_CTRL_REG3 = 0x15,
57 FXAS21002_RESERVED = 0x16,
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
196 typedef int32 fxas21002_status_t;
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 {
206 uint8 regAddr;
207 uint8 regValue;
208 } fxas21002_Sensor_Specific_Reg_t;
209
210 typedef struct
211 {
212 uint8 bandwidth;
213 uint8 gyroFullScaleRange;
214 uint8 wraptoone;
215 uint8 extctrlen;
216 uint8 fsdouble;
217 uint32 regCount;
218 fxas21002_Sensor_Specific_Reg_t regPairs[];
219 } fxas21002_Sensor_Specific_Settings_t;
220
221
222
223 #endif /* FXAS21002_H_ */
fxas21002_Sensor_Specific_Settings_t::gyroFullScaleRange
uint8 gyroFullScaleRange
Definition: fxas21002.h:213
uint8
unsigned char uint8
Definition: isf_types.h:76
FXAS21002_OUT_Z_MSB
Definition: fxas21002.h:40
isf_dsa_adapter.h
FXAS21002_TEMP
Definition: fxas21002.h:53
fxas21002_Sensor_Specific_Settings_t::wraptoone
uint8 wraptoone
Definition: fxas21002.h:214
FXAS21002_OUT_Y_LSB
Definition: fxas21002.h:39
FXAS21002_RESERVED
Definition: fxas21002.h:57
FXAS21002_WHO_AM_I
Definition: fxas21002.h:47
gyro_config_t
The structure defines the FXAS21002 configuration.
Definition: fxas21002.h:199
FXAS21002_OUT_Y_MSB
Definition: fxas21002.h:38
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
FXAS21002_F_STATUS
Definition: fxas21002.h:43
fxas21002_Sensor_Specific_Settings_t::bandwidth
uint8 bandwidth
Definition: fxas21002.h:212
FXAS21002_RT_SRC
Definition: fxas21002.h:50
FXAS21002_OUT_X_LSB
Definition: fxas21002.h:37
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
FXAS21002_OUT_Z_LSB
Definition: fxas21002.h:41
FXAS21002_DR_STATUS
Definition: fxas21002.h:42
FXAS21002_CTRL_REG3
Definition: fxas21002.h:56
fxas21002_Sensor_Specific_Settings_t::extctrlen
uint8 extctrlen
Definition: fxas21002.h:215
FXAS21002_CTRL_REG1
Definition: fxas21002.h:54
fxas21002_Sensor_Specific_Settings_t::regCount
uint32 regCount
Definition: fxas21002.h:217
gyro_config_t::period
uint32 period
Definition: fxas21002.h:200
fxas21002_Sensor_Specific_Settings_t
Definition: fxas21002.h:210
FXAS21002_STATUS
Definition: fxas21002.h:35
FXAS21002_RT_COUNT
Definition: fxas21002.h:52
FXAS21002_RT_THS
Definition: fxas21002.h:51
FXAS21002_F_SETUP
Definition: fxas21002.h:44
FXAS21002_INT_SRC_FLAG
Definition: fxas21002.h:46
isf.h
Main ISF header file. Contains code common to all ISF components.
isf_sm_api.h
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
int32
signed long int int32
Definition: isf_types.h:74
fxas21002_status_t
int32 fxas21002_status_t
Definition: fxas21002.h:196
FXAS21002_CTRL_REG0
Definition: fxas21002.h:48
fxas21002_Sensor_Specific_Reg_t::regAddr
uint8 regAddr
Definition: fxas21002.h:206
fxas21002_Sensor_Specific_Settings_t::fsdouble
uint8 fsdouble
Definition: fxas21002.h:216
fxas21002_Sensor_Specific_Reg_t::regValue
uint8 regValue
Definition: fxas21002.h:207
FXAS21002_F_EVENT
Definition: fxas21002.h:45
FXAS21002_RT_CFG
Definition: fxas21002.h:49
uint32
unsigned long int uint32
Definition: isf_types.h:78
fxas21002_Sensor_Specific_Reg_t
Definition: fxas21002.h:204
FXAS21002_OUT_X_MSB
Definition: fxas21002.h:36
isf_devmsg.h
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
FXAS21002_CTRL_REG2
Definition: fxas21002.h:55
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.