245 void writeRegister(uint8_t
const& t_addr, uint8_t
const& t_val)
const;
255 void start(
void)
const;
278 bool isRaw(
void)
const;
325 void setDR_OS(uint8_t
const t_DROS);
378 void setOffset(
int const& t_bxoff,
int const& t_byoff,
379 int const& t_bzoff)
const;
390 void getOffset(
int* t_bxoff,
int* t_byoff,
int* t_bzoff)
const;
411 void getMag(
int* t_bx,
int* t_by,
int* t_bz)
const;
436 void getMagPoll(
int* t_bx,
int* t_by,
int* t_bz)
const;
450 int const& t_bz)
const;
461 void displayMag(
int const& t_bx,
int const& t_by,
int const& t_bz)
const;
473 void displayMag(
int const& t_bx,
int const& t_by,
int const& t_bz,
474 double const& t_mag)
const;
493 #endif // MAG3110_HPP static uint8_t const MAG3110_AUTO_MRST_EN
Automatic magnetic sensor reset.
Definition: mag3110.hpp:151
void setDebug(bool t_debug)
Control debug output.
Definition: mag3110.cpp:121
static uint8_t const MAG3110_DR_OS_1_25_16
Output rate = 1.25 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:119
static uint8_t const MAG3110_DR_OS_10_128
Output rate = 10 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:77
void setOffset(int const &t_bxoff, int const &t_byoff, int const &t_bzoff) const
Set magnetic offset.
Definition: mag3110.cpp:319
static uint8_t const MAG3110_OFF_Y_MSB
Bits [14:7] of user Y offset.
Definition: mag3110.hpp:52
static uint8_t const MAG3110_DR_STATUS_YDR
Y-axis new data available.
Definition: mag3110.hpp:175
static uint8_t const MAG3110_DR_OS_1_25_32
Output rate = 1.25 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:113
static uint8_t const MAG3110_DR_OS_2_5_128
Output rate = 2.5 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:93
static uint8_t const MAG3110_OUT_Y_LSB
Bits [7:0] of Y measurement.
Definition: mag3110.hpp:38
void getMagDelayed(int *t_bx, int *t_by, int *t_bz) const
Get magnetic field strength (delayed)
Definition: mag3110.cpp:411
void standby(void)
Standby.
Definition: mag3110.cpp:173
static uint8_t const MAG3110_DR_OS_5_32
Output rate = 5 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:97
static uint8_t const MAG3110_DR_OS_20_32
Output rate = 20 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:81
uint8_t getDR_OS(void) const
Get data rate and oversampling ratio.
Definition: mag3110.cpp:259
void calibrate(void)
Calibrate magnetic reading.
Definition: mag3110.cpp:348
static uint8_t const MAG3110_DR_OS_20_64
Output rate = 20 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:75
void displayMag(int const &t_bx, int const &t_by, int const &t_bz) const
Display magnetic field strength.
Definition: mag3110.cpp:440
int getTemperature(void) const
Get temperature.
Definition: mag3110.cpp:458
static uint8_t const MAG3110_Z_AXIS
Z-axis base address.
Definition: mag3110.hpp:198
static uint8_t const MAG3110_DR_OS_1_25_128
Output rate = 1.25 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:101
void getMagPoll(int *t_bx, int *t_by, int *t_bz) const
Poll magnetic field strength.
Definition: mag3110.cpp:417
static uint8_t const MAG3110_DR_STATUS_XYZDR
X-,Y- or Z-axis new data available.
Definition: mag3110.hpp:179
static uint8_t const MAG3110_DR_STATUS_XYZOW
X-, Y- or Z-axis data overwrite.
Definition: mag3110.hpp:187
void getOffset(int *t_bxoff, int *t_byoff, int *t_bzoff) const
Get magnetic offset.
Definition: mag3110.cpp:332
static uint8_t const MAG3110_X_AXIS
X-axis base address.
Definition: mag3110.hpp:194
static uint8_t const MAG3110_DR_OS_0_31_128
Output rate = 0.31 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:117
void setDelay(uint8_t t_DROS)
Set delay.
Definition: mag3110.cpp:265
bool isActive(void) const
Test if active.
Definition: mag3110.cpp:201
static uint8_t const MAG3110_OUT_Z_LSB
Bits [7:0] of Z measurement.
Definition: mag3110.hpp:42
static uint8_t const MAG3110_DR_OS_10_64
Output rate = 10 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:83
static uint8_t const MAG3110_DR_STATUS
Data ready status per axis.
Definition: mag3110.hpp:30
static uint8_t const MAG3110_DR_OS_5_16
Output rate = 5 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:103
void reset(void)
Reset.
Definition: mag3110.cpp:188
static uint8_t const MAG3110_DR_OS_0_31_64
Output rate = 0.31 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:123
void setRawMode(bool const t_raw) const
Set raw mode.
Definition: mag3110.cpp:213
static uint8_t const MAG3110_DR_STATUS_XOW
X-axis data overwrite.
Definition: mag3110.hpp:181
static uint8_t const MAG3110_OUT_Y_MSB
Bits [15:8] of Y measurement.
Definition: mag3110.hpp:36
static uint8_t const MAG3110_OFF_X_MSB
Bits [14:7] of user X offset.
Definition: mag3110.hpp:48
static uint8_t const MAG3110_DR_STATUS_XDR
X-axis new data available.
Definition: mag3110.hpp:173
static uint8_t const MAG3110_I2C_ADDRESS
I2C address of the chip.
Definition: mag3110.hpp:19
static uint8_t const MAG3110_DR_OS_0_63_16
Output rate = 0.63 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:127
double getMagnitude(int const &t_bx, int const &t_by, int const &t_bz) const
Calculate magnetic field strength.
Definition: mag3110.cpp:432
static uint8_t const MAG3110_OFF_Z_MSB
Bits [14:7] of user Z offset.
Definition: mag3110.hpp:56
static uint8_t const MAG3110_DR_OS_0_16_64
Output rate = 0.16 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:131
static uint8_t const MAG3110_DR_OS_80_16
Output rate = 80 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:71
void setDR_OS(uint8_t const t_DROS)
Set data rate and oversampling ratio.
Definition: mag3110.cpp:245
static uint8_t const MAG3110_DR_OS_10_32
Output rate = 10 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:89
void start(void) const
Start.
Definition: mag3110.cpp:182
static uint8_t const MAG3110_OUT_Z_MSB
Bits [15:8] of Z measurement.
Definition: mag3110.hpp:40
void triggerMeasurement(void) const
Trigger measurement.
Definition: mag3110.cpp:231
static uint8_t const MAG3110_DR_OS_0_31_32
Output rate = 0.31 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:129
static uint8_t const MAG3110_OUT_X_LSB
Bits [7:0] of X measurement.
Definition: mag3110.hpp:34
static uint8_t const MAG3110_DR_OS_0_08_128
Output rate = 0.08 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:133
static uint8_t const MAG3110_DR_OS_20_16
Output rate = 20 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:87
static uint8_t const MAG3110_DR_OS_10_16
Output rate = 10 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:95
static uint8_t const MAG3110_RAW_MODE
Data output correction.
Definition: mag3110.hpp:153
static uint8_t const MAG3110_DR_OS_2_5_32
Output rate = 2.5 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:105
static uint8_t const MAG3110_SYSMOD_ACTIVE_RAW
Active mode, raw data.
Definition: mag3110.hpp:164
static uint8_t const MAG3110_CTRL_REG2
Operation modes.
Definition: mag3110.hpp:64
static uint8_t const MAG3110_DR_OS_40_16
Output rate = 40 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:79
void setFastRead(bool const t_fast) const
Set fast read.
Definition: mag3110.cpp:222
static uint8_t const MAG3110_DR_OS_40_32
Output rate = 40 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:73
static uint8_t const MAG3110_Y_AXIS
Y-axis base address.
Definition: mag3110.hpp:196
static uint8_t const MAG3110_DR_OS_0_16_128
Output rate = 0.16 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:125
static uint8_t const MAG3110_DR_OS_5_128
Output rate = 5 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:85
int getDelay(void) const
Get delay.
Definition: mag3110.cpp:314
static uint8_t const MAG3110_OFF_X_LSB
Bits [6:0] of user X offset.
Definition: mag3110.hpp:50
static uint8_t const MAG3110_WHO_AM_I
Device identification.
Definition: mag3110.hpp:44
uint8_t readRegister(uint8_t const &t_addr) const
Read a register.
Definition: mag3110.cpp:145
static uint8_t const MAG3110_DIE_TEMP
Temperature, signed 8 bits in °C.
Definition: mag3110.hpp:60
static uint8_t const MAG3110_FAST_READ
Fast read mode.
Definition: mag3110.hpp:140
static uint8_t const MAG3110_MAG_RST
Magnetic sensor reset (one-shot).
Definition: mag3110.hpp:155
bool isRaw(void) const
Test if raw mode.
Definition: mag3110.cpp:207
void initialize(const char *t_bus)
Initialize I2C communication.
Definition: mag3110.cpp:126
bool isDataReady(void) const
Test if new data are ready.
Definition: mag3110.cpp:239
static uint8_t const MAG3110_OFF_Y_LSB
Bits [6:0] of user Y offset.
Definition: mag3110.hpp:54
static uint8_t const MAG3110_DR_OS_0_63_128
Output rate = 0.63 Hz, oversampling ratio = 128.
Definition: mag3110.hpp:109
static uint8_t const MAG3110_TRIGGER_MEASUREMENT
Trigger immediate measurement.
Definition: mag3110.hpp:142
static uint8_t const MAG3110_DR_OS_2_5_16
Output rate = 2.5 Hz, oversampling ratio = 16.
Definition: mag3110.hpp:111
static uint8_t const MAG3110_OUT_X_MSB
Bits [15:8] of X measurement.
Definition: mag3110.hpp:32
static uint8_t const MAG3110_CTRL_REG1
Operation modes.
Definition: mag3110.hpp:62
MAG3110(void)
Default constructor.
Definition: mag3110.cpp:100
static uint8_t const MAG3110_WHO_AM_I_RSP
Device identifier.
Definition: mag3110.hpp:21
void writeRegister(uint8_t const &t_addr, uint8_t const &t_val) const
Write a register.
Definition: mag3110.cpp:160
static uint8_t const MAG3110_DR_STATUS_ZDR
Z-axis new data available.
Definition: mag3110.hpp:177
static uint8_t const MAG3110_SYSMOD_ACTIVE
Active mode, user corrected data.
Definition: mag3110.hpp:166
~MAG3110(void)
Default destcructor.
Definition: mag3110.cpp:106
static uint8_t const MAG3110_SYSMOD_STANDBY
Standby mode.
Definition: mag3110.hpp:162
void getVersion(void) const
Definition: mag3110.cpp:113
static uint8_t const MAG3110_OFF_Z_LSB
Bits [6:0] of user Z offset.
Definition: mag3110.hpp:58
static uint8_t const MAG3110_DR_STATUS_ZOW
Z-axis data overwrite.
Definition: mag3110.hpp:185
void getMag(int *t_bx, int *t_by, int *t_bz) const
Get magnetic field strength.
Definition: mag3110.cpp:388
A class to drive the MAG3110 3-axis magnetometer.
Definition: mag3110.hpp:12
static uint8_t const MAG3110_SYSMOD
Current System Mode.
Definition: mag3110.hpp:46
static uint8_t const MAG3110_DR_STATUS_YOW
Y-axis data overwrite.
Definition: mag3110.hpp:183
static uint8_t const MAG3110_DR_OS_2_5_64
Output rate = 2.5 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:99
static uint8_t const MAG3110_DR_OS_0_63_64
Output rate = 0.63 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:115
static uint8_t const MAG3110_DR_OS_1_25_64
Output rate = 1.25 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:107
static uint8_t const MAG3110_ACTIVE_MODE
Operation mode.
Definition: mag3110.hpp:144
static int const MAG3110_DIE_TEMP_OFFSET
Temperature offset.
Definition: mag3110.hpp:23
static uint8_t const MAG3110_DR_OS_0_63_32
Output rate = 0.63 Hz, oversampling ratio = 32.
Definition: mag3110.hpp:121
static uint8_t const MAG3110_DR_OS_5_64
Output rate = 5 Hz, oversampling ratio = 64.
Definition: mag3110.hpp:91