| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
39 FXAS21002_STATUS = 0x00,
40 FXAS21002_OUT_X_MSB = 0x01,
41 FXAS21002_OUT_X_LSB = 0x02,
42 FXAS21002_OUT_Y_MSB = 0x03,
43 FXAS21002_OUT_Y_LSB = 0x04,
44 FXAS21002_OUT_Z_MSB = 0x05,
45 FXAS21002_OUT_Z_LSB = 0x06,
46 FXAS21002_DR_STATUS = 0x07,
47 FXAS21002_F_STATUS = 0x08,
48 FXAS21002_F_SETUP = 0x09,
49 FXAS21002_F_EVENT = 0x0A,
50 FXAS21002_INT_SRC_FLAG = 0x0B,
51 FXAS21002_WHO_AM_I = 0x0C,
52 FXAS21002_CTRL_REG0 = 0x0D,
53 FXAS21002_RT_CFG = 0x0E,
54 FXAS21002_RT_SRC = 0x0F,
55 FXAS21002_RT_THS = 0x10,
56 FXAS21002_RT_COUNT = 0x11,
57 FXAS21002_TEMP = 0x12,
58 FXAS21002_CTRL_REG1 = 0x13,
59 FXAS21002_CTRL_REG2 = 0x14,
60 FXAS21002_CTRL_REG3 = 0x15,
61 FXAS21002_RESERVED = 0x16,
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
199 typedef int32 fxas21002_status_t;
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 {
209 uint8 regAddr;
210 uint8 regValue;
211 } fxas21002_Sensor_Specific_Reg_t;
212
213 typedef struct
214 {
215 uint8 bandwidth;
216 uint8 gyroFullScaleRange;
217 uint8 wraptoone;
218 uint8 extctrlen;
219 uint8 fsdouble;
220 uint32 regCount;
221 fxas21002_Sensor_Specific_Reg_t regPairs[];
222 } fxas21002_Sensor_Specific_Settings_t;
223
224
225
226 #endif /* FXAS21002_H_ */
fxas21002_Sensor_Specific_Settings_t::gyroFullScaleRange
uint8 gyroFullScaleRange
Definition: fxas21002.h:216
uint8
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
FXAS21002_OUT_Z_MSB
Definition: fxas21002.h:44
isf_dsa_adapter.h
FXAS21002_TEMP
Definition: fxas21002.h:57
fxas21002_Sensor_Specific_Settings_t::wraptoone
uint8 wraptoone
Definition: fxas21002.h:217
FXAS21002_OUT_Y_LSB
Definition: fxas21002.h:43
FXAS21002_RESERVED
Definition: fxas21002.h:61
FXAS21002_WHO_AM_I
Definition: fxas21002.h:51
gyro_config_t
The structure defines the FXAS21002 configuration.
Definition: fxas21002.h:202
FXAS21002_OUT_Y_MSB
Definition: fxas21002.h:42
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
FXAS21002_F_STATUS
Definition: fxas21002.h:47
fxas21002_Sensor_Specific_Settings_t::bandwidth
uint8 bandwidth
Definition: fxas21002.h:215
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
FXAS21002_RT_SRC
Definition: fxas21002.h:54
FXAS21002_OUT_X_LSB
Definition: fxas21002.h:41
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:45
FXAS21002_DR_STATUS
Definition: fxas21002.h:46
FXAS21002_CTRL_REG3
Definition: fxas21002.h:60
fxas21002_Sensor_Specific_Settings_t::extctrlen
uint8 extctrlen
Definition: fxas21002.h:218
FXAS21002_CTRL_REG1
Definition: fxas21002.h:58
fxas21002_Sensor_Specific_Settings_t::regCount
uint32 regCount
Definition: fxas21002.h:220
gyro_config_t::period
uint32 period
Definition: fxas21002.h:203
fxas21002_Sensor_Specific_Settings_t
Definition: fxas21002.h:213
FXAS21002_STATUS
Definition: fxas21002.h:39
FXAS21002_RT_COUNT
Definition: fxas21002.h:56
FXAS21002_RT_THS
Definition: fxas21002.h:55
FXAS21002_F_SETUP
Definition: fxas21002.h:48
FXAS21002_INT_SRC_FLAG
Definition: fxas21002.h:50
int32
long int32
This defines int32 as long.
Definition: isf_types.h:32
isf_sm_api.h
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
fxas21002_status_t
int32 fxas21002_status_t
Definition: fxas21002.h:199
FXAS21002_CTRL_REG0
Definition: fxas21002.h:52
fxas21002_Sensor_Specific_Reg_t::regAddr
uint8 regAddr
Definition: fxas21002.h:209
fxas21002_Sensor_Specific_Settings_t::fsdouble
uint8 fsdouble
Definition: fxas21002.h:219
fxas21002_Sensor_Specific_Reg_t::regValue
uint8 regValue
Definition: fxas21002.h:210
FXAS21002_F_EVENT
Definition: fxas21002.h:49
FXAS21002_RT_CFG
Definition: fxas21002.h:53
fxas21002_Sensor_Specific_Reg_t
Definition: fxas21002.h:207
FXAS21002_OUT_X_MSB
Definition: fxas21002.h:40
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:59
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.