| 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
mag3110.h
Go to the documentation of this file.
1 /**
2 * @file mag3110.h
3 * @brief The \b mag3110.h contains the MAG3110 Magnetometer register definitions, access macros, and
4 * device access functions.
5 *
6 * @copyright Copyright (c) 2014, Freescale Semiconductor, Inc.
7 */
8
9 #ifndef MAG3110_H_
10 #define MAG3110_H_
11
12 #define MAG3110_IIC_ADDRESS 0x0E // MAG3110 I2C Address.
13
14 /**
15 * @brief The MAG3110 registers, masks, and constants.
16 */
17 #define MAG3110_NUMBER_AXIS 0x3 // Number of Axis
18 #define MAG3110_NUMBER_BYTES_AXIS 0x2 // Number of bytes in each axis
19
20 /**
21 **
22 ** @brief The MAG3110 Sensor Internal Register Map.
23 */
24 enum {
25 MAG3110_DR_STATUS = 0x00,
26 MAG3110_OUT_X_MSB = 0x01,
27 MAG3110_OUT_X_LSB = 0x02,
28 MAG3110_OUT_Y_MSB = 0x03,
29 MAG3110_OUT_Y_LSB = 0x04,
30 MAG3110_OUT_Z_MSB = 0x05,
31 MAG3110_OUT_Z_LSB = 0x06,
32 MAG3110_WHO_AM_I = 0x07,
33 MAG3110_SYS_MOD = 0x08,
34 MAG3110_OFF_X_MSB = 0x09,
35 MAG3110_OFF_X_LSB = 0x0A,
36 MAG3110_OFF_Y_MSB = 0x0B,
37 MAG3110_OFF_Y_LSB = 0x0C,
38 MAG3110_OFF_Z_MSB = 0x0D,
39 MAG3110_OFF_Z_LSB = 0x0E,
40 MAG3110_DIE_TEMP = 0x0F,
41 MAG3110_CTRL_REG1 = 0x10,
42 MAG3110_CTRL_REG2 = 0x11,
43 MAG3110_DEVICE_ID = 0xC4,
44 };
45
46 /*
47 * General purpose macros to set/get a specific bit field within a register.
48 * The macro assumes that the root identifier for the field is a consistent character string (e.g., "BIT_FIELD").
49 * The bit field mask is the character string followed by "_MASK" (e.g., BIT_FIELD_MASK).
50 * The bit field shift is the character string followed by "_SHIFT" (e.g., BIT_FIELD_SHIFT).
51 */
52 #define MAG3110_SET_FIELD(name,val) (((val)<<MAG3110_##name##_SHIFT)&(MAG3110_##name##_MASK))
53 #define MAG3110_GET_FIELD(name,val) ((val&MAG3110_##name##_MASK)>>MAG3110_##name##_SHIFT)
54
55 /*
56 ** DR_STATUS Register
57 */
58 #define MAG3110_ZYXOW_MASK (0x80)
59 #define MAG3110_ZYXOW_SHIFT 7
60 #define MAG3110_ZOW_MASK (0x40)
61 #define MAG3110_ZOW_SHIFT 6
62 #define MAG3110_YOW_MASK (0x20)
63 #define MAG3110_YOW_SHIFT 5
64 #define MAG3110_XOW_MASK (0x10)
65 #define MAG3110_XOW_SHIFT 4
66 #define MAG3110_ZYXDR_MASK (0x08)
67 #define MAG3110_ZYXDR_SHIFT 3
68 #define MAG3110_ZDR_MASK (0x04)
69 #define MAG3110_ZDR_SHIFT 2
70 #define MAG3110_YDR_MASK (0x02)
71 #define MAG3110_YDR_SHIFT 1
72 #define MAG3110_XDR_MASK (0x01)
73 #define MAG3110_XDR_SHIFT 0
74
75 /*
76 ** SYSMOD Register
77 */
78 #define MAG3110_SYSMOD1_MASK (0x02)
79 #define MAG3110_SYSMOD1_SHIFT 1
80 #define MAG3110_SYSMOD0_MASK (0x01)
81 #define MAG3110_SYSMOD0_SHIFT 0
82
83 /*
84 ** CTRL1 Register
85 */
86 #define MAG3110_DR_MASK (0xE0)
87 #define MAG3110_DR_SHIFT 5
88 #define MAG3110_OS_MASK (0x18)
89 #define MAG3110_OS_SHIFT 3
90 #define MAG3110_FR_MASK (0x04)
91 #define MAG3110_FR_SHIFT 2
92 #define MAG3110_TM_MASK (0x02)
93 #define MAG3110_TM_SHIFT 1
94 #define MAG3110_AC_MASK (0x01)
95 #define MAG3110_AC_SHIFT 0
96
97 /*
98 ** CTRL2 Register
99 */
100 #define MAG3110_AUTO_MRST_EN_MASK (0x80)
101 #define MAG3110_AUTO_MRST_EN_SHIFT 7
102 #define MAG3110_RAW_MASK (0x20)
103 #define MAG3110_RAW_SHIFT 5
104 #define MAG3110_MAG_RST_MASK (0x10)
105 #define MAG3110_MAG_RST_SHIFT 4
106
107 #define MAG3100_READ_BUF_SIZE (6)
108 #define NUMBER_OF_BYTES_TIMESTAMP (4)
109 #define MAG3110_WHOAMI_VALUE (0xC4)
110
111 // Device standby to active time, number of samples to wait. MAG3110 datasheet states
112 // that for 80 ODR (12.5ms sample period), the standby to active time is 25ms which
113 // is 2 samples (2 * 12.5ms = 25ms).
114 #define MAG3110_STANDBY_TO_ACTIVE_SAMPLE_WAIT (2)
115
116 typedef int32 mag3110_status_t;
117
118 /*! @brief The structure defines the MAG3110 configuration.*/
119 typedef struct {
120 uint32 period; // The period used to process samples in microseconds.
121 uint8 overSampleRate; // The over sample rate.
122 } mag_config_t;
123
124 typedef struct
125 {
126 uint8 regAddr;
127 uint8 regValue;
128 } mag3110_Sensor_Specific_Reg_t;
129
130 typedef struct
131 {
132 uint8 overSamplingRatio;
133 uint32 regCount;
134 mag3110_Sensor_Specific_Reg_t regPairs[];
135 } mag3110_Sensor_Specific_Settings_t;
136
137
138
139 #endif /* MAG3110_H_ */
MAG3110_CTRL_REG1
Definition: mag3110.h:41
MAG3110_SYS_MOD
Definition: mag3110.h:33
uint8
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
MAG3110_OFF_Z_LSB
Definition: mag3110.h:39
mag_config_t::overSampleRate
uint8 overSampleRate
Definition: mag3110.h:121
MAG3110_OUT_X_LSB
Definition: mag3110.h:27
MAG3110_OFF_Y_LSB
Definition: mag3110.h:37
mag3110_Sensor_Specific_Reg_t
Definition: mag3110.h:124
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
mag_config_t::period
uint32 period
Definition: mag3110.h:120
mag3110_Sensor_Specific_Reg_t::regValue
uint8 regValue
Definition: mag3110.h:127
MAG3110_DIE_TEMP
Definition: mag3110.h:40
mag3110_Sensor_Specific_Settings_t::overSamplingRatio
uint8 overSamplingRatio
Definition: mag3110.h:132
mag3110_Sensor_Specific_Settings_t
Definition: mag3110.h:130
int32
long int32
This defines int32 as long.
Definition: isf_types.h:32
MAG3110_OUT_X_MSB
Definition: mag3110.h:26
MAG3110_WHO_AM_I
Definition: mag3110.h:32
mag_config_t
The structure defines the MAG3110 configuration.
Definition: mag3110.h:119
MAG3110_OFF_Z_MSB
Definition: mag3110.h:38
mag3110_Sensor_Specific_Reg_t::regAddr
uint8 regAddr
Definition: mag3110.h:126
mag3110_Sensor_Specific_Settings_t::regCount
uint32 regCount
Definition: mag3110.h:133
MAG3110_CTRL_REG2
Definition: mag3110.h:42
MAG3110_OFF_X_MSB
Definition: mag3110.h:34
MAG3110_DR_STATUS
Definition: mag3110.h:25
MAG3110_OFF_X_LSB
Definition: mag3110.h:35
MAG3110_OFF_Y_MSB
Definition: mag3110.h:36
MAG3110_OUT_Z_LSB
Definition: mag3110.h:31
MAG3110_OUT_Y_MSB
Definition: mag3110.h:28
MAG3110_DEVICE_ID
Definition: mag3110.h:43
MAG3110_OUT_Y_LSB
Definition: mag3110.h:29
mag3110_status_t
int32 mag3110_status_t
Definition: mag3110.h:116
MAG3110_OUT_Z_MSB
Definition: mag3110.h:30
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.