Class to interface with the LIS3MDL magnetometer.
More...
#include <IMU.h>
|
| LIS3MDL (TwoWire &i2c, uint8_t address=0x1E) |
| Header for LIS3MDL object. More...
|
|
void | config_reg1 (bool temp_en=0, OM OMXY=LPM, uint8_t DOR=5, bool FAST_ODR=0, bool ST=0) |
| Header to configure register 1. More...
|
|
void | config_reg2 (FS FULL_SCALE=GAUSS_4, bool REBOOT=0, bool SOFT_RST=0) |
| Header to configure register 2. More...
|
|
void | config_reg3 (bool LP=0, bool SIM=0, MD SYS_OP_MODE=CONTINUOUS_CONVERSION) |
| Header to configure register 3. More...
|
|
void | config_reg4 (OM OMZ=LPM, BLE Endian_Data_Selec=LSB) |
| Header to configure register 4. More...
|
|
void | config_reg5 (bool FAST_READ=0, bool BDU=1) |
| Header to configure register 5. More...
|
|
void | read_xyz_mag (int16_t &MAG_X, int16_t &MAG_Y, int16_t &MAG_Z) |
| Header to read all magnetometer data at once. More...
|
|
|
enum | OM { LPM = 0b00
, MPM = 0b01
, HPM =0b10
, UHPM = 0b11
} |
|
enum | FS { GAUSS_4 = 0b00
, GAUSS_8 = 0b01
, GAUSS_12 = 0b10
, GAUSS_16 = 0b11
} |
|
enum | MD { CONTINUOUS_CONVERSION = 0b00
, SINGLE_CONVERSION = 0b01
, POWER_DOWN = 0b11
} |
|
enum | BLE { LSB = 0b1
, MSB = 0b1
} |
|
|
uint8_t | _LIS3MDLAddress = 0x1E |
| Initialize I2C.
|
|
const byte | _CTRL_REG1 = 0x20 |
| "CTRL_REG1" address
|
|
const byte | _CTRL_REG2 = 0x21 |
| "CTRL_REG2" address
|
|
const byte | _CTRL_REG3 = 0x22 |
| "CTRL_REG3" address
|
|
const byte | _CTRL_REG4 = 0x23 |
| "CTRL_REG4" address
|
|
const byte | _CTRL_REG5 = 0x24 |
| "CTRL_REG5" address
|
|
const byte | _STATUS_REG = 0x27 |
| "STATUS_REG" address
|
|
const byte | _OUT_X_L = 0x28 |
| "OUT_X_L" address for X-axis data output LSB
|
|
const byte | _OUT_X_H = 0x29 |
| "OUT_X_H" address for X-axis data output MSB
|
|
const byte | _OUT_Y_L = 0x2A |
| "OUT_Y_L" address for Y-axis data output LSB
|
|
const byte | _OUT_Y_H = 0x2B |
| "OUT_Y_H" address for Y-axis data output MSB
|
|
const byte | _OUT_Z_L = 0x2C |
| "OUT_Z_L" address for Z-axis data output LSB
|
|
const byte | _OUT_Z_H = 0x2D |
| "OUT_Z_H" address for Z-axis data output MSB
|
|
const byte | _INT_CFG = 0x30 |
| "INT_CFG" address
|
|
const byte | _INT_THS_L = 0x32 |
| "INT_THS_L" address LSB
|
|
const byte | _INT_THS_H = 0x33 |
| "INT_THS_H" address MSB
|
|
TwoWire * | p_i2c |
| Initialize I2C.
|
|
Class to interface with the LIS3MDL magnetometer.
◆ LIS3MDL()
LIS3MDL::LIS3MDL |
( |
TwoWire & |
i2c, |
|
|
uint8_t |
address = 0x1E |
|
) |
| |
Header for LIS3MDL object.
Constructor for LIS3MDL object, which operates with the magnetometer.
- Parameters
-
i2c | Default two wire method, default set to Wire |
address | Address for i2c communication, default set to 0x1E |
◆ config_reg1()
void LIS3MDL::config_reg1 |
( |
bool |
temp_en = 0 , |
|
|
OM |
OMXY = LPM , |
|
|
uint8_t |
DOR = 5 , |
|
|
bool |
FAST_ODR = 0 , |
|
|
bool |
ST = 0 |
|
) |
| |
Header to configure register 1.
Function to configure Register 1.
- Parameters
-
temp_en | Bool to enable temp sensor or not |
OMXY | Set operating mode of XY sensors |
DOR | Set data output rate |
FAST_ODR | Bool to enable fast output data rate |
ST | Bool to enable, disable ST |
◆ config_reg2()
void LIS3MDL::config_reg2 |
( |
FS |
FULL_SCALE = GAUSS_4 , |
|
|
bool |
REBOOT = 0 , |
|
|
bool |
SOFT_RST = 0 |
|
) |
| |
Header to configure register 2.
Function to configure Register 2.
- Parameters
-
FULL_SCALE | Sets the full scale value |
REBOOT | Bool to reboot memory content |
SOFT_RST | Bool to configure registers and user register reset function |
◆ config_reg3()
void LIS3MDL::config_reg3 |
( |
bool |
LP = 0 , |
|
|
bool |
SIM = 0 , |
|
|
MD |
SYS_OP_MODE = CONTINUOUS_CONVERSION |
|
) |
| |
Header to configure register 3.
Function to configure Register 3.
- Parameters
-
LP | Set Low-power mode configuration |
SIM | Set SPI serial interface mode configuration |
SYS_OP_MODE | Set system operating mode selection |
◆ config_reg4()
void LIS3MDL::config_reg4 |
( |
OM |
OMZ = LPM , |
|
|
BLE |
Endian_Data_Selec = LSB |
|
) |
| |
Header to configure register 4.
Function to configure Register 4.
- Parameters
-
OMZ | Z-axis operative mode selection |
Endian_Data_Selec | Big/little endian data selection |
◆ config_reg5()
void LIS3MDL::config_reg5 |
( |
bool |
FAST_READ = 0 , |
|
|
bool |
BDU = 1 |
|
) |
| |
Header to configure register 5.
Function to configure Register 5.
- Parameters
-
FAST_READ | Enable or disable fast read |
BDU | Sets block data update for magnetic data |
◆ read_xyz_mag()
void LIS3MDL::read_xyz_mag |
( |
int16_t & |
MAG_X, |
|
|
int16_t & |
MAG_Y, |
|
|
int16_t & |
MAG_Z |
|
) |
| |
Header to read all magnetometer data at once.
Reads the data for X, Y, and Z magnetometer data.
- Parameters
-
MAG_X | Reference parameter for X-reading for magnetometer. |
MAG_Y | Reference parameter for Y-reading for magnetometer. |
MAG_Z | Reference parameter for Z-reading for magnetometer. |
◆ readRegister()
uint8_t LIS3MDL::readRegister |
( |
byte |
Register | ) |
|
|
protected |
Header function to read from registers.
Reads from register.
- Parameters
-
Register | Register to read from |
- Returns
- Reading from register
◆ writeRegister()
void LIS3MDL::writeRegister |
( |
byte |
Register, |
|
|
byte |
RegData |
|
) |
| |
|
protected |
Header function to write to registers.
Writes to register.
- Parameters
-
Register | Register address to write to |
RegData | Data to write to address |
The documentation for this class was generated from the following files: