3-axis MEMS ultra low power magnetometer

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3

Embed: (wiki syntax)

« Back to documentation index

LIS2MDLSensor Class Reference

LIS2MDLSensor Class Reference

Abstract class of an LIS2MDL Inertial Measurement Unit (IMU) 3 axes sensor. More...

#include <LIS2MDLSensor.h>

Public Member Functions

 LIS2MDLSensor (SPI *spi, PinName cs_pin, PinName int_pin=NC, SPI_type_t spi_type=SPI4W)
 Constructor.
 LIS2MDLSensor (DevI2C *i2c, uint8_t address=LIS2MDL_I2C_ADD, PinName int_pin=NC)
 Constructor.
virtual int init (void *init)
 Initializing the component.
virtual int read_id (uint8_t *id)
 Read component ID.
virtual int get_m_axes (int32_t *magnetic_field)
 Get the LIS2MDL magnetometer sensor axes.
virtual int get_m_axes_raw (int16_t *value)
 Get the LIS2MDL magnetometer sensor raw axes.
int enable (void)
 Enable the LIS2MDL magnetometer sensor.
int disable (void)
 Disable the LIS2MDL magnetometer sensor.
int get_m_sensitivity (float *sensitivity)
 Get the LIS2MDL magnetometer sensor sensitivity.
int get_m_odr (float *odr)
 Get the LIS2MDL magnetometer sensor output data rate.
int set_m_odr (float odr)
 Set the LIS2MDL magnetometer sensor output data rate.
int get_m_fs (float *full_scale)
 Get the LIS2MDL magnetometer sensor full scale.
int set_m_fs (float full_scale)
 Set the LIS2MDL magnetometer sensor full scale.
int read_reg (uint8_t reg, uint8_t *data)
 Get the LIS2MDL register value for magnetic sensor.
int write_reg (uint8_t reg, uint8_t data)
 Set the LIS2MDL register value for magnetic sensor.
int set_m_self_test (uint8_t status)
 Set self test.
int get_m_drdy_status (uint8_t *status)
 Get the LIS2MDL MAG data ready bit value.
void attach_int_irq (void(*fptr)(void))
 Attaching an interrupt handler to the INT interrupt.
void enable_int_irq (void)
 Enabling the INT interrupt handling.
void disable_int_irq (void)
 Disabling the INT interrupt handling.
uint8_t io_read (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Utility function to read data.
uint8_t io_write (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Utility function to write data.

Detailed Description

Abstract class of an LIS2MDL Inertial Measurement Unit (IMU) 3 axes sensor.

Definition at line 78 of file LIS2MDLSensor.h.


Constructor & Destructor Documentation

LIS2MDLSensor ( SPI *  spi,
PinName  cs_pin,
PinName  int_pin = NC,
SPI_type_t  spi_type = SPI4W 
)

Constructor.

Parameters:
spiobject of an helper class which handles the SPI peripheral
cs_pinthe chip select pin
int_pinthe interrupt pin
spi_typethe SPI type

Definition at line 52 of file LIS2MDLSensor.cpp.

LIS2MDLSensor ( DevI2C *  i2c,
uint8_t  address = LIS2MDL_I2C_ADD,
PinName  int_pin = NC 
)

Constructor.

Parameters:
i2cobject of an helper class which handles the I2C peripheral
addressthe address of the component's instance
int_pinthe interrupt pin

Definition at line 81 of file LIS2MDLSensor.cpp.


Member Function Documentation

void attach_int_irq ( void(*)(void)  fptr )

Attaching an interrupt handler to the INT interrupt.

Parameters:
fptrAn interrupt handler.
Return values:
None.

Definition at line 104 of file LIS2MDLSensor.h.

int disable ( void   )

Disable the LIS2MDL magnetometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 162 of file LIS2MDLSensor.cpp.

void disable_int_irq ( void   )

Disabling the INT interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 124 of file LIS2MDLSensor.h.

int enable ( void   )

Enable the LIS2MDL magnetometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 141 of file LIS2MDLSensor.cpp.

void enable_int_irq ( void   )

Enabling the INT interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 114 of file LIS2MDLSensor.h.

int get_m_axes ( int32_t *  magnetic_field ) [virtual]

Get the LIS2MDL magnetometer sensor axes.

Parameters:
magnetic_fieldpointer where the values of the axes are written
Return values:
0in case of success, an error code otherwise

Definition at line 280 of file LIS2MDLSensor.cpp.

int get_m_axes_raw ( int16_t *  value ) [virtual]

Get the LIS2MDL magnetometer sensor raw axes.

Parameters:
valuepointer where the raw values of the axes are written
Return values:
0in case of success, an error code otherwise

Definition at line 308 of file LIS2MDLSensor.cpp.

int get_m_drdy_status ( uint8_t *  status )

Get the LIS2MDL MAG data ready bit value.

Parameters:
statusthe status of data ready bit
Return values:
0in case of success, an error code otherwise

Definition at line 375 of file LIS2MDLSensor.cpp.

int get_m_fs ( float *  full_scale )

Get the LIS2MDL magnetometer sensor full scale.

Parameters:
full_scalepointer where the full scale is written
Return values:
0in case of success, an error code otherwise

Definition at line 257 of file LIS2MDLSensor.cpp.

int get_m_odr ( float *  odr )

Get the LIS2MDL magnetometer sensor output data rate.

Parameters:
odrpointer where the output data rate is written
Return values:
0in case of success, an error code otherwise

Definition at line 196 of file LIS2MDLSensor.cpp.

int get_m_sensitivity ( float *  sensitivity )

Get the LIS2MDL magnetometer sensor sensitivity.

Parameters:
sensitivitypointer where the sensitivity is written
Return values:
0in case of success, an error code otherwise

Definition at line 184 of file LIS2MDLSensor.cpp.

int init ( void *  init ) [virtual]

Initializing the component.

Parameters:
initpointer to device specific initalization structure
Return values:
0in case of success, an error code otherwise

Definition at line 95 of file LIS2MDLSensor.cpp.

uint8_t io_read ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
)

Utility function to read data.

Parameters:
pBuffer,:pointer to data to be read.
RegisterAddr,:specifies internal address register to be read.
NumByteToRead,:number of bytes to be read.
Return values:
0if ok, an error code otherwise.

Definition at line 136 of file LIS2MDLSensor.h.

uint8_t io_write ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
)

Utility function to write data.

Parameters:
pBuffer,:pointer to data to be written.
RegisterAddr,:specifies internal address register to be written.
NumByteToWrite,:number of bytes to write.
Return values:
0if ok, an error code otherwise.

Definition at line 169 of file LIS2MDLSensor.h.

int read_id ( uint8_t *  id ) [virtual]

Read component ID.

Parameters:
idthe WHO_AM_I value
Return values:
0in case of success, an error code otherwise

Definition at line 127 of file LIS2MDLSensor.cpp.

int read_reg ( uint8_t  reg,
uint8_t *  data 
)

Get the LIS2MDL register value for magnetic sensor.

Parameters:
regaddress to be read
datapointer where the value is written
Return values:
0in case of success, an error code otherwise

Definition at line 331 of file LIS2MDLSensor.cpp.

int set_m_fs ( float  full_scale )

Set the LIS2MDL magnetometer sensor full scale.

Parameters:
full_scalethe functional full scale to be set
Return values:
0in case of success, an error code otherwise

Definition at line 269 of file LIS2MDLSensor.cpp.

int set_m_odr ( float  odr )

Set the LIS2MDL magnetometer sensor output data rate.

Parameters:
odrthe output data rate value to be set
Return values:
0in case of success, an error code otherwise

Definition at line 236 of file LIS2MDLSensor.cpp.

int set_m_self_test ( uint8_t  status )

Set self test.

Parameters:
statusthe value of self_test in reg CFG_REG_C
Return values:
0in case of success, an error code otherwise

Definition at line 361 of file LIS2MDLSensor.cpp.

int write_reg ( uint8_t  reg,
uint8_t  data 
)

Set the LIS2MDL register value for magnetic sensor.

Parameters:
pObjthe device pObj
regaddress to be written
datavalue to be written
Return values:
0in case of success, an error code otherwise

Definition at line 347 of file LIS2MDLSensor.cpp.