ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
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) 2015, 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 {
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 
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 {
129 
130 typedef struct
131 {
136 
137 
138 
139 #endif /* MAG3110_H_ */
unsigned char uint8
Definition: isf_types.h:76
uint8 overSampleRate
Definition: mag3110.h:121
uint32 period
Definition: mag3110.h:120
The structure defines the MAG3110 configuration.
Definition: mag3110.h:119
signed long int int32
Definition: isf_types.h:74
unsigned long int uint32
Definition: isf_types.h:78
int32 mag3110_status_t
Definition: mag3110.h:116