14 #ifndef __ENGDUINOMAGNETOMETER_H__
15 #define __ENGDUINOMAGNETOMETER_H__
21 #if defined (__BOARD_ENGDUINOV2) || defined(__BOARD_ENGDUINOV3)
28 #define FXMS3110_IIC_ADDRESS (0x0E)
36 FXMS3110_DR_STATUS = 0,
59 #define DR_STATUS_REG 0x00
61 #define ZYXOW_BIT Bit._7
62 #define ZOW_BIT Bit._6
63 #define YOW_BIT Bit._5
64 #define XOW_BIT Bit._4
65 #define ZYXDR_BIT Bit._3
66 #define ZDR_BIT Bit._2
67 #define YDR_BIT Bit._1
68 #define XDR_BIT Bit._0
70 #define ZYXOW_MASK 0x80
74 #define ZYXDR_MASK 0x08
83 #define OUT_X_MSB_REG 0x01
84 #define OUT_X_LSB_REG 0x02
85 #define OUT_Y_MSB_REG 0x03
86 #define OUT_Y_LSB_REG 0x04
87 #define OUT_Z_MSB_REG 0x05
88 #define OUT_Z_LSB_REG 0x06
93 #define WHO_AM_I_REG 0x07
102 #define SYSMOD_REG 0x08
104 #define SYSMOD1_BIT Bit._1
105 #define SYSMOD0_BIT Bit._0
107 #define SYSMOD1_MASK 0x02
108 #define SYSMOD0_MASK 0x01
109 #define SYSMOD_MASK 0x03
111 #define SYSMOD_STANDBY 0x00
112 #define SYSMOD_ACTIVE_RAW (SYSMOD0_MASK)
113 #define SYSMOD_ACTIVE_USER (SYSMOD1_MASK)
118 #define OFF_X_MSB_REG 0x09
119 #define OFF_X_LSB_REG 0x0A
120 #define OFF_Y_MSB_REG 0x0B
121 #define OFF_Y_LSB_REG 0x0C
122 #define OFF_Z_MSB_REG 0x0D
123 #define OFF_Z_LSB_REG 0x0E
128 #define OFF_X_MSB_REG 0x0F
133 #define CTRL_REG1 0x10
135 #define DR2_BIT Bit._7
136 #define DR1_BIT Bit._6
137 #define DR0_BIT Bit._5
138 #define OS1_BIT Bit._4
139 #define OS0_BIT Bit._3
140 #define FREAD_BIT Bit._2
141 #define TM_BIT Bit._1
142 #define ACTIVE_BIT Bit._0
144 #define DR2_MASK 0x80
145 #define DR1_MASK 0x40
146 #define DR0_MASK 0x20
147 #define OS1_MASK 0x10
148 #define OS0_MASK 0x08
149 #define FREAD_MASK 0x04
151 #define ACTIVE_MASK 0x01
152 #define DR_MASK (DR2_MASK+DR1_MASK+DR0_MASK)
153 #define OS_MASK (OS1_MASK+OS0_MASK)
155 #define DATA_RATE_1280_16 0x00
156 #define DATA_RATE_1280_32 (OS0_MASK)
157 #define DATA_RATE_1280_64 (OS1_MASK)
158 #define DATA_RATE_1280_128 (OS0_MASK+OS1_MASK)
159 #define DATA_RATE_640_16 (DR0)
160 #define DATA_RATE_640_32 (DR0+OS0_MASK)
161 #define DATA_RATE_640_64 (DR0+OS1_MASK)
162 #define DATA_RATE_640_128 (DR0+OS0_MASK+OS1_MASK)
163 #define DATA_RATE_320_16 (DR1)
164 #define DATA_RATE_320_32 (DR1+OS0_MASK)
165 #define DATA_RATE_320_64 (DR1+OS1_MASK)
166 #define DATA_RATE_320_128 (DR1+OS0_MASK+OS1_MASK)
167 #define DATA_RATE_160_16 (DR0+DR1)
168 #define DATA_RATE_160_32 (DR0+DR1+OS0_MASK)
169 #define DATA_RATE_160_64 (DR0+DR1+OS1_MASK)
170 #define DATA_RATE_160_128 (DR0+DR1+OS0_MASK+OS1_MASK)
171 #define DATA_RATE_80_16 (DR2)
172 #define DATA_RATE_80_32 (DR2+OS0_MASK)
173 #define DATA_RATE_80_64 (DR2+OS1_MASK)
174 #define DATA_RATE_80_128 (DR2+OS0_MASK+OS1_MASK)
178 #define TRIGGER_OFF 0x00
179 #define TRIGGER_ON (ACTIVE_MASK)
180 #define ACTIVE (ACTIVE_MASK)
186 #define CTRL_REG2 0x11
188 #define AUTO_MRST_EN_BIT Bit._7
189 #define RAW_BIT Bit._5
190 #define MAG_RST_BIT Bit._4
192 #define AUTO_MRST_EN_MASK 0x80
193 #define RAW_MASK 0x20
194 #define MAG_RST_MASK 0x10
214 void writeReg(
int firstReg,
const uint8_t *buf, uint8_t nRegs=1);
215 void readReg(
int firstReg, uint8_t *buf, uint8_t nRegs=1);
221 void xyz(
float buf[3]);
Definition: EngduinoMagnetometer.h:209
EngduinoMagnetometerClass()
Constructor.
Definition: EngduinoMagnetometer.cpp:28
void begin()
begin function - must be called before using other functions
Definition: EngduinoMagnetometer.cpp:43
void end()
end function - switch off the magnetometer
Definition: EngduinoMagnetometer.cpp:93
int8_t temperature()
Read the temperature value from the magnetometer.
Definition: EngduinoMagnetometer.cpp:151
void xyz(float buf[3])
Read the xyz values from the magnetometer.
Definition: EngduinoMagnetometer.cpp:108