LIS3MDL 3-axis magnetometer

Device driver for the LIS3MDL 3-axis magnetometer. More...

Detailed Description

Device driver for the LIS3MDL 3-axis magnetometer.

Files

file  lis3mdl.h
 Device driver interface for the LIS3MDL 3-axis magnetometer.
 
file  lis3mdl-internal.h
 Definitions for the LIS3MDL 3-axis magnetometer.
 

Data Structures

struct  lis3mdl_3d_data_t
 3d data container of the LIS3MDL sensor More...
 
struct  lis3mdl_t
 Device descriptor for LIS3MDL sensor. More...
 

Enumerations

enum  lis3mdl_xy_mode_t { LIS3MDL_XY_MODE_LOW = 0x00, LIS3MDL_XY_MODE_MEDIUM = 0x20, LIS3MDL_XY_MODE_HIGH = 0x40, LIS3MDL_XY_MODE_ULTRA = 0x60 }
 Operating mode of x- and y-axis for LIS3MDL. More...
 
enum  lis3mdl_z_mode_t { LIS3MDL_Z_MODE_LOW = 0x00, LIS3MDL_Z_MODE_MEDIUM = 0x04, LIS3MDL_Z_MODE_HIGH = 0x08, LIS3MDL_Z_MODE_ULTRA = 0x0C }
 Operating mode of z-axis for LIS3MDL. More...
 
enum  lis3mdl_odr_t {
  LIS3MDL_ODR_0_625Hz = 0x00, LIS3MDL_ODR_1_25Hz = 0x04, LIS3MDL_ODR_2_5Hz = 0x08, LIS3MDL_ODR_10Hz = 0x10,
  LIS3DML_ODR_20HZ = 0x14, LIS3DML_ODR_40HZ = 0x18, LIS3MDL_ODR_80HZ = 0x1C
}
 Output data rate [Hz] for LIS3MDL. More...
 
enum  lis3mdl_scale_t { LIS3MDL_SCALE_4G = 0x00, LIS3MDL_SCALE_8G = 0x20, LIS3MDL_SCALE_12G = 0x40, LIS3MDL_SCALE_16G = 0x60 }
 Scale [gauss] for LIS3MDL. More...
 
enum  lis3mdl_op_t { LIS3MDL_OP_CONT_CONV = 0x00, LIS3MDL_OP_SNGL_CONV = 0x01, LIS3MDL_OP_PDOWN = 0x11 }
 Operating modes. More...
 

Functions

int lis3mdl_init (lis3mdl_t *dev, i2c_t i2c, uint8_t address, lis3mdl_xy_mode_t xy_mode, lis3mdl_z_mode_t z_mode, lis3mdl_odr_t odr, lis3mdl_scale_t scale, lis3mdl_op_t op_mode)
 Initialize a new LIS3DML device. More...
 
void lis3mdl_read_mag (const lis3mdl_t *dev, lis3mdl_3d_data_t *data)
 Reads the magnometer value of LIS3MDL. More...
 
void lis3mdl_read_temp (const lis3mdl_t *dev, int16_t *value)
 Reads the temperature value of LIS3MDL. More...
 
void lis3mdl_enable (const lis3mdl_t *dev)
 Enable the LIS3MDL device. More...
 
void lis3mdl_disable (const lis3mdl_t *dev)
 Disable the LIS3MDL device. More...
 

Enumeration Type Documentation

◆ lis3mdl_odr_t

Output data rate [Hz] for LIS3MDL.

Enumerator
LIS3MDL_ODR_0_625Hz 

0.625Hz

LIS3MDL_ODR_1_25Hz 

1.250Hz

LIS3MDL_ODR_2_5Hz 

5.000Hz

LIS3MDL_ODR_10Hz 

10.000Hz

LIS3DML_ODR_20HZ 

20.000Hz

LIS3DML_ODR_40HZ 

40.000Hz

LIS3MDL_ODR_80HZ 

80.000Hz

Definition at line 72 of file lis3mdl.h.

◆ lis3mdl_op_t

Operating modes.

Enumerator
LIS3MDL_OP_CONT_CONV 

Continous-conversion mode.

LIS3MDL_OP_SNGL_CONV 

Single-conversion mode.

LIS3MDL_OP_PDOWN 

Power-down mode.

Definition at line 95 of file lis3mdl.h.

◆ lis3mdl_scale_t

Scale [gauss] for LIS3MDL.

Enumerator
LIS3MDL_SCALE_4G 

+- 4 gauss

LIS3MDL_SCALE_8G 

+- 8 gauss

LIS3MDL_SCALE_12G 

+- 12 gauss

LIS3MDL_SCALE_16G 

+- 16 gauss

Definition at line 85 of file lis3mdl.h.

◆ lis3mdl_xy_mode_t

Operating mode of x- and y-axis for LIS3MDL.

Enumerator
LIS3MDL_XY_MODE_LOW 

Low-power mode.

LIS3MDL_XY_MODE_MEDIUM 

Medium-performance mode.

LIS3MDL_XY_MODE_HIGH 

High-performance mode.

LIS3MDL_XY_MODE_ULTRA 

Ultra-High-performance mode.

Definition at line 52 of file lis3mdl.h.

◆ lis3mdl_z_mode_t

Operating mode of z-axis for LIS3MDL.

Enumerator
LIS3MDL_Z_MODE_LOW 

Low-power mode.

LIS3MDL_Z_MODE_MEDIUM 

Medium-performance mode.

LIS3MDL_Z_MODE_HIGH 

High-performance mode.

LIS3MDL_Z_MODE_ULTRA 

Ultra-High-performance mode.

Definition at line 62 of file lis3mdl.h.

Function Documentation

◆ lis3mdl_disable()

void lis3mdl_disable ( const lis3mdl_t dev)

Disable the LIS3MDL device.

Parameters
[in]devdevice descriptor of LIS3MDL

◆ lis3mdl_enable()

void lis3mdl_enable ( const lis3mdl_t dev)

Enable the LIS3MDL device.

Parameters
[in]devdevice descriptor of LIS3MDL

◆ lis3mdl_init()

int lis3mdl_init ( lis3mdl_t dev,
i2c_t  i2c,
uint8_t  address,
lis3mdl_xy_mode_t  xy_mode,
lis3mdl_z_mode_t  z_mode,
lis3mdl_odr_t  odr,
lis3mdl_scale_t  scale,
lis3mdl_op_t  op_mode 
)

Initialize a new LIS3DML device.

Parameters
[in]devdevice descriptor of LIS3MDL
[in]i2cI2C device connected to
[in]addressI2C address of the magnometer
[in]xy_modepower mode of x- and y-axis
[in]z_modepower mode of z-axis
[in]odroutput data rate of magnometer
[in]scalescale configuration of magnometer
[in]op_modeoperation mode of the device
Returns
0 on success
-1 on error

◆ lis3mdl_read_mag()

void lis3mdl_read_mag ( const lis3mdl_t dev,
lis3mdl_3d_data_t data 
)

Reads the magnometer value of LIS3MDL.

Parameters
[in]devdevice descriptor of LIS3MDL
[in]datameasured magnetometer data

◆ lis3mdl_read_temp()

void lis3mdl_read_temp ( const lis3mdl_t dev,
int16_t *  value 
)

Reads the temperature value of LIS3MDL.

Parameters
[in]devdevice descriptor of LIS3MDL
[in]valuemeasured temperature in degree celsius