Shih-Ho Hsieh / XYZ_sensor_Platform_SPI

Fork of XYZ_sensor_Platform by Shih-Ho Hsieh

Embed: (wiki syntax)

« Back to documentation index

LIS3MDL Class Reference

Class representing a LIS3MDL sensor component. More...

#include <lis3mdl_class.h>

Inherits MagneticSensor.

Public Member Functions

 LIS3MDL (DevSPI &spi, PinName cs)
 Constructor.
virtual ~LIS3MDL ()
 Destructor.
virtual int init (void *init_struct)
 Initializing the component.
virtual int read_id (uint8_t *m_id)
 Getting the ID of the component.
virtual int get_m_axes (int32_t *pData)
 Get current magnetometer magnetic X/Y/Z-axes values in standard data units [mgauss].
virtual int get_m_axes_raw (int16_t *pData)
 Get current magnetometer raw data X/Y/Z-axes values in device sepcific LSB units.

Protected Member Functions

MAGNETO_StatusTypeDef LIS3MDL_Init (MAGNETO_InitTypeDef *LIS3MDL_Init)
 Set LIS3MDL Initialization.
MAGNETO_StatusTypeDef LIS3MDL_Read_M_ID (uint8_t *m_id)
 Read ID of LIS3MDL Magnetic sensor.
MAGNETO_StatusTypeDef LIS3MDL_M_GetAxes (int32_t *pData)
 Read data from LIS3MDL Magnetic sensor and calculate Magnetic in mgauss.
MAGNETO_StatusTypeDef LIS3MDL_M_GetAxesRaw (int16_t *pData)
 Read raw data from LIS3MDL Magnetic sensor output register.
void LIS3MDL_IO_ITConfig (void)
 Configures LIS3MDL interrupt lines for NUCLEO boards.
MAGNETO_StatusTypeDef LIS3MDL_IO_Init (void)
 Configures LIS3MDL I2C interface.
MAGNETO_StatusTypeDef LIS3MDL_IO_Read (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Utility function to read data from LIS3MDL.
MAGNETO_StatusTypeDef LIS3MDL_IO_Write (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Utility function to write data to LIS3MDL.

Detailed Description

Class representing a LIS3MDL sensor component.

Definition at line 50 of file lis3mdl_class.h.


Constructor & Destructor Documentation

LIS3MDL ( DevSPI spi,
PinName  cs 
)

Constructor.

Parameters:
[in]spidevice I2C to be used for communication

Definition at line 55 of file lis3mdl_class.h.

virtual ~LIS3MDL (  ) [virtual]

Destructor.

Definition at line 63 of file lis3mdl_class.h.


Member Function Documentation

virtual int get_m_axes ( int32_t *  p_data ) [virtual]

Get current magnetometer magnetic X/Y/Z-axes values in standard data units [mgauss].

Parameters:
[out]p_dataPointer to where to store magnetic values to. p_data must point to an array of (at least) three elements, where: p_data[0] corresponds to X-axis, p_data[1] corresponds to Y-axis, and p_data[2] corresponds to Z-axis.
Returns:
0 in case of success, an error code otherwise

Implements MagneticSensor.

Definition at line 74 of file lis3mdl_class.h.

virtual int get_m_axes_raw ( int16_t *  p_data ) [virtual]

Get current magnetometer raw data X/Y/Z-axes values in device sepcific LSB units.

Parameters:
[out]p_dataPointer to where to store magnetometer raw data to. p_data must point to an array of (at least) three elements, where: p_data[0] corresponds to X-axis, p_data[1] corresponds to Y-axis, and p_data[2] corresponds to Z-axis.
Returns:
0 in case of success, an error code otherwise

Implements MagneticSensor.

Definition at line 78 of file lis3mdl_class.h.

virtual int init ( void *  init ) [virtual]

Initializing the component.

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

Implements Component.

Definition at line 66 of file lis3mdl_class.h.

MAGNETO_StatusTypeDef LIS3MDL_Init ( MAGNETO_InitTypeDef LIS3MDL_Init ) [protected]

Set LIS3MDL Initialization.

Parameters:
LIS3MDL_Initthe configuration setting for the LIS3MDL
Return values:
MAGNETO_OKin case of success, an error code otherwise

Definition at line 53 of file lis3mdl_class.cpp.

MAGNETO_StatusTypeDef LIS3MDL_IO_Init ( void   ) [protected]

Configures LIS3MDL I2C interface.

Returns:
MAGNETO_OK in case of success, an error code otherwise

Definition at line 131 of file lis3mdl_class.h.

void LIS3MDL_IO_ITConfig ( void   ) [protected]

Configures LIS3MDL interrupt lines for NUCLEO boards.

Definition at line 122 of file lis3mdl_class.h.

MAGNETO_StatusTypeDef LIS3MDL_IO_Read ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
) [protected]

Utility function to read data from LIS3MDL.

Parameters:
[out]pBufferpointer to the byte-array to read data in to
[in]RegisterAddrspecifies internal address register to read from.
[in]NumByteToReadnumber of bytes to be read.
Return values:
MAGNETO_OKif ok,
MAGNETO_ERRORif an I2C error has occured

Definition at line 144 of file lis3mdl_class.h.

MAGNETO_StatusTypeDef LIS3MDL_IO_Write ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
) [protected]

Utility function to write data to LIS3MDL.

Parameters:
[in]pBufferpointer to the byte-array data to send
[in]RegisterAddrspecifies internal address register to read from.
[in]NumByteToWritenumber of bytes to write.
Return values:
MAGNETO_OKif ok,
MAGNETO_ERRORif an I2C error has occured

Definition at line 168 of file lis3mdl_class.h.

MAGNETO_StatusTypeDef LIS3MDL_M_GetAxes ( int32_t *  pData ) [protected]

Read data from LIS3MDL Magnetic sensor and calculate Magnetic in mgauss.

Parameters:
pDatathe pointer where the magnetometer data are stored
Return values:
MAGNETO_OKin case of success, an error code otherwise

Definition at line 144 of file lis3mdl_class.cpp.

MAGNETO_StatusTypeDef LIS3MDL_M_GetAxesRaw ( int16_t *  pData ) [protected]

Read raw data from LIS3MDL Magnetic sensor output register.

Parameters:
pDatathe pointer where the magnetometer raw data are stored
Return values:
MAGNETO_OKin case of success, an error code otherwise

Definition at line 113 of file lis3mdl_class.cpp.

MAGNETO_StatusTypeDef LIS3MDL_Read_M_ID ( uint8_t *  m_id ) [protected]

Read ID of LIS3MDL Magnetic sensor.

Parameters:
m_idthe pointer where the ID of the device is stored
Return values:
MAGNETO_OKin case of success, an error code otherwise

Definition at line 98 of file lis3mdl_class.cpp.

virtual int read_id ( uint8_t *  id ) [virtual]

Getting the ID of the component.

Parameters:
[out]idpointer to an allocated variable to store the ID into.
Return values:
0in case of success, an error code otherwise.

Implements Component.

Definition at line 70 of file lis3mdl_class.h.