30 #include <mraa/i2c.hpp> 34 #define MAG3110_NAME "MAG3110" 35 #define MAG3110_I2C_ADDRESS 0x0E 36 #define MAG3110_DEVICE_ID 0xC4 37 #define MAG3110_DEVICE_ID_REG 0x07 40 #define MAG3110_DR_STATUS 0x00 41 #define MAG3110_OUT_X_MSB 0x01 42 #define MAG3110_OUT_X_LSB 0x02 43 #define MAG3110_OUT_Y_MSB 0x03 44 #define MAG3110_OUT_Y_LSB 0x04 45 #define MAG3110_OUT_Z_MSB 0x05 46 #define MAG3110_OUT_Z_LSB 0x06 47 #define MAG3110_SYSMOD 0x08 48 #define MAG3110_OFF_X_MSB 0x09 49 #define MAG3110_OFF_X_LSB 0x0A 50 #define MAG3110_OFF_Y_MSB 0x0B 51 #define MAG3110_OFF_Y_LSB 0x0C 52 #define MAG3110_OFF_Z_MSB 0x0D 53 #define MAG3110_OFF_Z_LSB 0x0E 54 #define MAG3110_DIE_TEMP 0x0F 55 #define MAG3110_CTRL_REG1 0x10 56 #define MAG3110_CTRL_REG2 0x11 59 #define MAG3110_DR_STATUS_ZYXOW (1 << 7) 60 #define MAG3110_DR_STATUS_ZOW (1 << 6) 61 #define MAG3110_DR_STATUS_YOW (1 << 5) 62 #define MAG3110_DR_STATUS_XOW (1 << 4) 63 #define MAG3110_DR_STATUS_ZYXDR (1 << 3) 64 #define MAG3110_DR_STATUS_ZDR (1 << 2) 65 #define MAG3110_DR_STATUS_YDR (1 << 1) 66 #define MAG3110_DR_STATUS_XDR (1 << 0) 69 #define MAG3110_SYSMOD_STANDBY 0 70 #define MAG3110_SYSMOD_ACTIVE_RAW 1 71 #define MAG3110_SYSMOD_ACTIVE 2 74 #define MAG3110_CTRL_REG1_DROS_SHIFT 3 75 #define MAG3110_CTRL_REG1_DROS_MASK 0xF8 76 #define MAG3110_CTRL_REG1_DROS(x) (((uint8_t)(((uint8_t)(x))<<\ 77 MAG3110_CTRL_REG1_DROS_SHIFT))\ 78 &MAG3110_CTRL_REG1_DROS_MASK) 79 #define MAG3110_CTRL_REG1_FR (1 << 2) 80 #define MAG3110_CTRL_REG1_TM (1 << 1) 81 #define MAG3110_CTRL_REG1_AC (1 << 0) 84 #define MAG3110_CTRL_REG2_AUTO_MRST_EN (1 << 7) 85 #define MAG3110_CTRL_REG2_RAW (1 << 5) 86 #define MAG3110_CTRL_REG2_MAG_RST (1 << 4) 89 #define MAG3110_DROS_8000_16 0 90 #define MAG3110_DROS_4000_32 1 91 #define MAG3110_DROS_2000_64 2 92 #define MAG3110_DROS_1000_128 3 93 #define MAG3110_DROS_4000_16 4 94 #define MAG3110_DROS_2000_32 5 95 #define MAG3110_DROS_1000_64 6 96 #define MAG3110_DROS_0500_128 7 97 #define MAG3110_DROS_2000_16 8 98 #define MAG3110_DROS_1000_32 9 99 #define MAG3110_DROS_0500_64 10 100 #define MAG3110_DROS_0250_128 11 101 #define MAG3110_DROS_1000_16 12 102 #define MAG3110_DROS_0500_32 13 103 #define MAG3110_DROS_0250_64 14 104 #define MAG3110_DROS_0125_128 15 105 #define MAG3110_DROS_0500_16 16 106 #define MAG3110_DROS_0250_32 17 107 #define MAG3110_DROS_0125_64 18 108 #define MAG3110_DROS_0063_128 19 109 #define MAG3110_DROS_0250_16 20 110 #define MAG3110_DROS_0125_32 21 111 #define MAG3110_DROS_0063_64 22 112 #define MAG3110_DROS_0031_128 23 113 #define MAG3110_DROS_0125_16 24 114 #define MAG3110_DROS_0063_32 25 115 #define MAG3110_DROS_0031_64 26 116 #define MAG3110_DROS_0016_128 27 117 #define MAG3110_DROS_0063_16 28 118 #define MAG3110_DROS_0031_32 29 119 #define MAG3110_DROS_0016_64 30 120 #define MAG3110_DROS_0008_128 31 121 #define MAG3110_DROS_DEFAULT MAG3110_DROS_0125_128 175 MAG3110 (
int bus, uint8_t dros=MAG3110_DROS_DEFAULT,
176 int devAddr=MAG3110_I2C_ADDRESS);
241 int16_t
getX(
int bSampleData = 0);
250 int16_t
getY(
int bSampleData = 0);
259 int16_t
getZ(
int bSampleData = 0);
291 mraa::I2c m_i2ControlCtx;
int getData(mag3110_data_t *data, int bSampleData=0)
Definition: mag3110.cpp:253
int checkID(void)
Definition: mag3110.cpp:87
int16_t getX(int bSampleData=0)
Definition: mag3110.cpp:202
int16_t getY(int bSampleData=0)
Definition: mag3110.cpp:215
int8_t getDieTemperature(void)
Definition: mag3110.cpp:247
MAG3110(int bus, uint8_t dros=MAG3110_DROS_DEFAULT, int devAddr=MAG3110_I2C_ADDRESS)
Definition: mag3110.cpp:39
Definition: mag3110.hpp:126
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
int setUserOffset(int16_t x, int16_t y, int16_t z)
Definition: mag3110.cpp:101
uint8_t getStatus(void)
Definition: mag3110.cpp:241
int16_t getZ(int bSampleData=0)
Definition: mag3110.cpp:228
API for the MAG3110 Three-Axis Digital Magnetometer.
Definition: mag3110.hpp:165
int setStandby(void)
Definition: mag3110.cpp:148
int setActive(void)
Definition: mag3110.cpp:129
int sampleData(void)
Definition: mag3110.cpp:177
int isReady(void)
Definition: mag3110.cpp:167