Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
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 | get_m_lp (uint8_t *lp) |
| Get the LIS2MDL magnetometer sensor power mode. | |
| int | set_m_lp (uint8_t lp) |
| Set the LIS2MDL magnetometer sensor power mode. | |
| int | get_m_lpf (uint8_t *lpf) |
| Get the LIS2MDL magnetometer sensor bandwidth. | |
| int | set_m_lpf (uint8_t lpf) |
| Set the LIS2MDL magnetometer sensor bandwidth. | |
| int | get_m_comp_temp_en (uint8_t *comp_temp_en) |
| Get the LIS2MDL magnetometer sensor temperature compensation. | |
| int | set_m_comp_temp_en (uint8_t comp_temp_en) |
| Set the LIS2MDL magnetometer sensor temperature compensation. | |
| int | get_m_off_canc (uint8_t *off_canc) |
| Get the LIS2MDL magnetometer sensor offset cancellation. | |
| int | set_m_off_canc (uint8_t off_canc) |
| Set the LIS2MDL magnetometer sensor offset cancellation. | |
| 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:
-
spi object of an helper class which handles the SPI peripheral cs_pin the chip select pin int_pin the interrupt pin spi_type the 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:
-
i2c object of an helper class which handles the I2C peripheral address the address of the component's instance int_pin the 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:
-
fptr An interrupt handler.
- Return values:
-
None.
Definition at line 112 of file LIS2MDLSensor.h.
| int disable | ( | void | ) |
Disable the LIS2MDL magnetometer sensor.
- Return values:
-
0 in 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 132 of file LIS2MDLSensor.h.
| int enable | ( | void | ) |
Enable the LIS2MDL magnetometer sensor.
- Return values:
-
0 in 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 122 of file LIS2MDLSensor.h.
| int get_m_axes | ( | int32_t * | magnetic_field ) | [virtual] |
Get the LIS2MDL magnetometer sensor axes.
- Parameters:
-
magnetic_field pointer where the values of the axes are written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 464 of file LIS2MDLSensor.cpp.
| int get_m_axes_raw | ( | int16_t * | value ) | [virtual] |
Get the LIS2MDL magnetometer sensor raw axes.
- Parameters:
-
value pointer where the raw values of the axes are written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 492 of file LIS2MDLSensor.cpp.
| int get_m_comp_temp_en | ( | uint8_t * | comp_temp_en ) |
Get the LIS2MDL magnetometer sensor temperature compensation.
- Parameters:
-
comp_temp_en pointer where the temperature compensation is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 382 of file LIS2MDLSensor.cpp.
| int get_m_drdy_status | ( | uint8_t * | status ) |
Get the LIS2MDL MAG data ready bit value.
- Parameters:
-
status the status of data ready bit
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 559 of file LIS2MDLSensor.cpp.
| int get_m_fs | ( | float * | full_scale ) |
Get the LIS2MDL magnetometer sensor full scale.
- Parameters:
-
full_scale pointer where the full scale is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 257 of file LIS2MDLSensor.cpp.
| int get_m_lp | ( | uint8_t * | lp ) |
Get the LIS2MDL magnetometer sensor power mode.
- Parameters:
-
lp pointer where the power mode is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 280 of file LIS2MDLSensor.cpp.
| int get_m_lpf | ( | uint8_t * | lpf ) |
Get the LIS2MDL magnetometer sensor bandwidth.
- Parameters:
-
lpf pointer where the bandwidth is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 331 of file LIS2MDLSensor.cpp.
| int get_m_odr | ( | float * | odr ) |
Get the LIS2MDL magnetometer sensor output data rate.
- Parameters:
-
odr pointer where the output data rate is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 196 of file LIS2MDLSensor.cpp.
| int get_m_off_canc | ( | uint8_t * | off_canc ) |
Get the LIS2MDL magnetometer sensor offset cancellation.
- Parameters:
-
off_canc pointer where the offset cancellation is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 408 of file LIS2MDLSensor.cpp.
| int get_m_sensitivity | ( | float * | sensitivity ) |
Get the LIS2MDL magnetometer sensor sensitivity.
- Parameters:
-
sensitivity pointer where the sensitivity is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 184 of file LIS2MDLSensor.cpp.
| int init | ( | void * | init ) | [virtual] |
Initializing the component.
- Parameters:
-
init pointer to device specific initalization structure
- Return values:
-
0 in 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:
-
0 if ok, an error code otherwise.
Definition at line 144 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:
-
0 if ok, an error code otherwise.
Definition at line 177 of file LIS2MDLSensor.h.
| int read_id | ( | uint8_t * | id ) | [virtual] |
Read component ID.
- Parameters:
-
id the WHO_AM_I value
- Return values:
-
0 in 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:
-
reg address to be read data pointer where the value is written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 515 of file LIS2MDLSensor.cpp.
| int set_m_comp_temp_en | ( | uint8_t | comp_temp_en ) |
Set the LIS2MDL magnetometer sensor temperature compensation.
- Parameters:
-
comp_temp_en the temperature compensation value to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 395 of file LIS2MDLSensor.cpp.
| int set_m_fs | ( | float | full_scale ) |
Set the LIS2MDL magnetometer sensor full scale.
- Parameters:
-
full_scale the functional full scale to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 269 of file LIS2MDLSensor.cpp.
| int set_m_lp | ( | uint8_t | lp ) |
Set the LIS2MDL magnetometer sensor power mode.
- Parameters:
-
lp the power mode value to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 312 of file LIS2MDLSensor.cpp.
| int set_m_lpf | ( | uint8_t | lpf ) |
Set the LIS2MDL magnetometer sensor bandwidth.
- Parameters:
-
lpf the bandwidth value to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 363 of file LIS2MDLSensor.cpp.
| int set_m_odr | ( | float | odr ) |
Set the LIS2MDL magnetometer sensor output data rate.
- Parameters:
-
odr the output data rate value to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 236 of file LIS2MDLSensor.cpp.
| int set_m_off_canc | ( | uint8_t | off_canc ) |
Set the LIS2MDL magnetometer sensor offset cancellation.
- Parameters:
-
off_canc the offset cancellation value to be set
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 444 of file LIS2MDLSensor.cpp.
| int set_m_self_test | ( | uint8_t | status ) |
Set self test.
- Parameters:
-
status the value of self_test in reg CFG_REG_C
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 545 of file LIS2MDLSensor.cpp.
| int write_reg | ( | uint8_t | reg, |
| uint8_t | data | ||
| ) |
Set the LIS2MDL register value for magnetic sensor.
- Parameters:
-
pObj the device pObj reg address to be written data value to be written
- Return values:
-
0 in case of success, an error code otherwise
Definition at line 531 of file LIS2MDLSensor.cpp.
Generated on Sat Jul 16 2022 02:16:13 by
1.7.2