ChibiOS  19.1.4
Collaboration diagram for LIS3MDL:

Detailed Description

Macros

#define lis3mdlCompassGetAxesNumber(devp)   compassGetAxesNumber(&((devp)->comp_if))
 Return the number of axes of the BaseCompass. More...
 
#define lis3mdlCompassReadRaw(devp, axes)   compassReadRaw(&((devp)->comp_if), axes)
 Retrieves raw data from the BaseCompass. More...
 
#define lis3mdlCompassReadCooked(devp, axes)   compassReadCooked(&((devp)->comp_if), axes)
 Retrieves cooked data from the BaseCompass. More...
 
#define lis3mdlCompassSetBias(devp, bp)   compassSetBias(&((devp)->comp_if), bp)
 Set bias values for the BaseCompass. More...
 
#define lis3mdlCompassResetBias(devp)   compassResetBias(&((devp)->comp_if))
 Reset bias values for the BaseCompass. More...
 
#define lis3mdlCompassSetSensitivity(devp, sp)   compassSetSensitivity(&((devp)->comp_if), sp)
 Set sensitivity values for the BaseCompass. More...
 
#define lis3mdlCompassResetSensitivity(devp)   compassResetSensitivity(&((devp)->comp_if))
 Reset sensitivity values for the BaseCompass. More...
 
#define lis3mdlCompassSetFullScale(devp, fs)   (devp)->vmt->comp_set_full_scale(devp, fs)
 Changes the LIS3MDLDriver compass fullscale value. More...
 

Version identification

#define EX_LIS3MDL_VERSION   "1.1.2"
 LIS3MDL driver version string. More...
 
#define EX_LIS3MDL_MAJOR   1
 LIS3MDL driver version major number. More...
 
#define EX_LIS3MDL_MINOR   1
 LIS3MDL driver version minor number. More...
 
#define EX_LIS3MDL_PATCH   2
 LIS3MDL driver version patch number. More...
 
#define LIS3MDL_COMP_NUMBER_OF_AXES   3U
 LIS3MDL compass subsystem characteristics. More...
 

LIS3MDL communication interfaces related bit masks

#define LIS3MDL_DI_MASK   0xFF
 
#define LIS3MDL_DI(n)   (1 << n)
 
#define LIS3MDL_AD_MASK   0x3F
 
#define LIS3MDL_AD(n)   (1 << n)
 
#define LIS3MDL_MS   (1 << 6)
 
#define LIS3MDL_RW   (1 << 7)
 
#define LIS3MDL_SUB_MS   (1 << 7)
 

LIS3MDL register addresses

#define LIS3MDL_AD_WHO_AM_I   0x0F
 
#define LIS3MDL_AD_CTRL_REG1   0x20
 
#define LIS3MDL_AD_CTRL_REG2   0x21
 
#define LIS3MDL_AD_CTRL_REG3   0x22
 
#define LIS3MDL_AD_CTRL_REG4   0x23
 
#define LIS3MDL_AD_CTRL_REG5   0x24
 
#define LIS3MDL_AD_STATUS_REG   0x27
 
#define LIS3MDL_AD_OUT_X_L   0x28
 
#define LIS3MDL_AD_OUT_X_H   0x29
 
#define LIS3MDL_AD_OUT_Y_L   0x2A
 
#define LIS3MDL_AD_OUT_Y_H   0x2B
 
#define LIS3MDL_AD_OUT_Z_L   0x2C
 
#define LIS3MDL_AD_OUT_Z_H   0x2D
 
#define LIS3MDL_AD_TEMP_OUT_L   0x2E
 
#define LIS3MDL_AD_TEMP_OUT_H   0x2F
 
#define LIS3MDL_AD_INT_CFG   0x30
 
#define LIS3MDL_AD_INT_SOURCE   0x31
 
#define LIS3MDL_AD_INT_THS_L   0x32
 
#define LIS3MDL_AD_INT_THS_H   0x33
 

LIS3MDL_CTRL_REG1 register bits definitions

#define LIS3MDL_CTRL_REG1_MASK   0xFF
 
#define LIS3MDL_CTRL_REG1_ST   (1 << 0)
 
#define LIS3MDL_CTRL_REG1_FAST_ODR   (1 << 1)
 
#define LIS3MDL_CTRL_REG1_DO0   (1 << 2)
 
#define LIS3MDL_CTRL_REG1_DO1   (1 << 3)
 
#define LIS3MDL_CTRL_REG1_DO2   (1 << 4)
 
#define LIS3MDL_CTRL_REG1_OM0   (1 << 5)
 
#define LIS3MDL_CTRL_REG1_OM1   (1 << 6)
 
#define LIS3MDL_CTRL_REG1_TEMP_EN   (1 << 7)
 

LIS3MDL_CTRL_REG2 register bits definitions

#define LIS3MDL_CTRL_REG2_MASK   0x6C
 
#define LIS3MDL_CTRL_REG2_SOFT_RST   (1 << 2)
 
#define LIS3MDL_CTRL_REG2_REBOOT   (1 << 3)
 
#define LIS3MDL_CTRL_REG2_FS_MASK   0x60
 
#define LIS3MDL_CTRL_REG2_FS0   (1 << 5)
 
#define LIS3MDL_CTRL_REG2_FS1   (1 << 6)
 

LIS3MDL_CTRL_REG3 register bits definitions

#define LIS3MDL_CTRL_REG3_MASK   0x27
 
#define LIS3MDL_CTRL_REG3_MD0   (1 << 0)
 
#define LIS3MDL_CTRL_REG3_MD1   (1 << 1)
 
#define LIS3MDL_CTRL_REG3_SIM   (1 << 2)
 
#define LIS3MDL_CTRL_REG3_LP   (1 << 5)
 

LIS3MDL_CTRL_REG4 register bits definitions

#define LIS3MDL_CTRL_REG4_MASK   0x0E
 
#define LIS3MDL_CTRL_REG4_BLE   (1 << 1)
 
#define LIS3MDL_CTRL_REG4_OMZ0   (1 << 2)
 
#define LIS3MDL_CTRL_REG4_OMZ1   (1 << 3)
 

LIS3MDL_CTRL_REG5 register bits definitions

#define LIS3MDL_CTRL_REG5_MASK   0xC0
 
#define LIS3MDL_CTRL_REG5_BDU   (1 << 6)
 
#define LIS3MDL_CTRL_REG5_FAST_READ   (1 << 7)
 

Configuration options

#define LIS3MDL_USE_SPI   FALSE
 LIS3MDL SPI interface switch. More...
 
#define LIS3MDL_SHARED_SPI   FALSE
 LIS3MDL shared SPI switch. More...
 
#define LIS3MDL_USE_I2C   TRUE
 LIS3MDL I2C interface switch. More...
 
#define LIS3MDL_SHARED_I2C   FALSE
 LIS3MDL shared I2C switch. More...
 
#define LIS3MDL_USE_ADVANCED   FALSE
 LIS3MDL advanced configurations switch. More...
 

LIS3MDL data structures and types

Todo:
Add support for LIS3MDL over SPI.
typedef struct LIS3MDLDriver LIS3MDLDriver
 LIS3MDL slave address. More...
 
#define _lis3msl_methods_alone
 LIS3MDL specific methods. More...
 
#define _lis3mdl_methods
 LIS3MDL specific methods with inherited ones. More...
 
#define _lis3mdl_data
 LIS3MDLDriver specific data. More...
 

Data Structures

struct  LIS3MDLConfig
 LIS3MDL configuration structure. More...
 
struct  LIS3MDLVMT
 LIS3MDL virtual methods table. More...
 
struct  LIS3MDLDriver
 LIS3MDL 3-axis compass class. More...
 

Functions

msg_t lis3mdlI2CReadRegister (I2CDriver *i2cp, lis3mdl_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
 Reads registers value using I2C. More...
 
msg_t lis3mdlI2CWriteRegister (I2CDriver *i2cp, lis3mdl_sad_t sad, uint8_t *txbuf, uint8_t n)
 Writes a value into a register using I2C. More...
 
static size_t comp_get_axes_number (void *ip)
 Return the number of axes of the BaseCompass. More...
 
static msg_t comp_read_raw (void *ip, int32_t axes[])
 Retrieves raw data from the BaseCompass. More...
 
static msg_t comp_read_cooked (void *ip, float axes[])
 Retrieves cooked data from the BaseCompass. More...
 
static msg_t comp_set_bias (void *ip, float *bp)
 Set bias values for the BaseCompass. More...
 
static msg_t comp_reset_bias (void *ip)
 Reset bias values for the BaseCompass. More...
 
static msg_t comp_set_sensivity (void *ip, float *sp)
 Set sensitivity values for the BaseCompass. More...
 
static msg_t comp_reset_sensivity (void *ip)
 Reset sensitivity values for the BaseCompass. More...
 
static msg_t comp_set_full_scale (LIS3MDLDriver *devp, lis3mdl_comp_fs_t fs)
 Changes the LIS3MDLDriver compass fullscale value. More...
 
void lis3mdlObjectInit (LIS3MDLDriver *devp)
 Initializes an instance. More...
 
void lis3mdlStart (LIS3MDLDriver *devp, const LIS3MDLConfig *config)
 Configures and activates LIS3MDL Complex Driver peripheral. More...
 
void lis3mdlStop (LIS3MDLDriver *devp)
 Deactivates the LIS3MDL Complex Driver peripheral. More...
 

Macro Definition Documentation

#define EX_LIS3MDL_VERSION   "1.1.2"

LIS3MDL driver version string.

Definition at line 45 of file lis3mdl.h.

#define EX_LIS3MDL_MAJOR   1

LIS3MDL driver version major number.

Definition at line 50 of file lis3mdl.h.

#define EX_LIS3MDL_MINOR   1

LIS3MDL driver version minor number.

Definition at line 55 of file lis3mdl.h.

#define EX_LIS3MDL_PATCH   2

LIS3MDL driver version patch number.

Definition at line 60 of file lis3mdl.h.

#define LIS3MDL_COMP_NUMBER_OF_AXES   3U

LIS3MDL compass subsystem characteristics.

Note
Sensitivity is expressed as G/LSB whereas G stands for Gauss.
Bias is expressed as G.

Definition at line 70 of file lis3mdl.h.

Referenced by comp_get_axes_number(), comp_read_cooked(), comp_read_raw(), comp_reset_bias(), comp_reset_sensivity(), comp_set_bias(), comp_set_full_scale(), comp_set_sensivity(), lis3mdlObjectInit(), and lis3mdlStart().

#define LIS3MDL_USE_SPI   FALSE

LIS3MDL SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is FALSE.

Definition at line 195 of file lis3mdl.h.

#define LIS3MDL_SHARED_SPI   FALSE

LIS3MDL shared SPI switch.

If set to TRUE the device acquires SPI bus ownership on each transaction.

Note
The default is FALSE. Requires SPI_USE_MUTUAL_EXCLUSION.

Definition at line 205 of file lis3mdl.h.

#define LIS3MDL_USE_I2C   TRUE

LIS3MDL I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is TRUE.

Definition at line 214 of file lis3mdl.h.

#define LIS3MDL_SHARED_I2C   FALSE

LIS3MDL shared I2C switch.

If set to TRUE the device acquires I2C bus ownership on each transaction.

Note
The default is FALSE. Requires I2C_USE_MUTUAL_EXCLUSION

Definition at line 224 of file lis3mdl.h.

#define LIS3MDL_USE_ADVANCED   FALSE

LIS3MDL advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 233 of file lis3mdl.h.

#define _lis3msl_methods_alone
Value:
/* Change full scale value of LIS3MDL compass subsystem.*/ \
lis3mdl_comp_fs_t
LIS3MDL full scale.
Definition: lis3mdl.h:296
LIS3MDL 3-axis compass class.
Definition: lis3mdl.h:503
static msg_t comp_set_full_scale(LIS3MDLDriver *devp, lis3mdl_comp_fs_t fs)
Changes the LIS3MDLDriver compass fullscale value.
Definition: lis3mdl.c:345
int32_t msg_t
Definition: chtypes.h:51

LIS3MDL specific methods.

Definition at line 462 of file lis3mdl.h.

#define _lis3mdl_methods
Value:
#define _lis3msl_methods_alone
LIS3MDL specific methods.
Definition: lis3mdl.h:462

LIS3MDL specific methods with inherited ones.

Definition at line 469 of file lis3mdl.h.

#define _lis3mdl_data
Value:
/* Driver state.*/ \
/* Current configuration data.*/ \
const LIS3MDLConfig *config; \
/* Compass subsystem axes number.*/ \
size_t compaxes; \
/* Compass subsystem current sensitivity.*/ \
float compsensitivity[LIS3MDL_COMP_NUMBER_OF_AXES]; \
/* Compass subsystem current bias.*/ \
float compbias[LIS3MDL_COMP_NUMBER_OF_AXES]; \
/* Compass subsystem current full scale value.*/ \
float compfullscale;
#define LIS3MDL_COMP_NUMBER_OF_AXES
LIS3MDL compass subsystem characteristics.
Definition: lis3mdl.h:70
LIS3MDL configuration structure.
Definition: lis3mdl.h:390
#define _base_compass_data
BaseCompass specific data.
Definition: hal_compass.h:77
lis3mdl_state_t
Driver state machine possible states.
Definition: lis3mdl.h:381

LIS3MDLDriver specific data.

Definition at line 485 of file lis3mdl.h.

#define lis3mdlCompassGetAxesNumber (   devp)    compassGetAxesNumber(&((devp)->comp_if))

Return the number of axes of the BaseCompass.

Parameters
[in]devppointer to LIS3MDLDriver.
Returns
the number of axes.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 525 of file lis3mdl.h.

#define lis3mdlCompassReadRaw (   devp,
  axes 
)    compassReadRaw(&((devp)->comp_if), axes)

Retrieves raw data from the BaseCompass.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseCompass axes number.
Parameters
[in]devppointer to BaseCompass interface.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 546 of file lis3mdl.h.

#define lis3mdlCompassReadCooked (   devp,
  axes 
)    compassReadCooked(&((devp)->comp_if), axes)

Retrieves cooked data from the BaseCompass.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as G.
The axes array must be at least the same size of the BaseCompass axes number.
Parameters
[in]devppointer to BaseCompass interface.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 568 of file lis3mdl.h.

#define lis3mdlCompassSetBias (   devp,
  bp 
)    compassSetBias(&((devp)->comp_if), bp)

Set bias values for the BaseCompass.

Note
Bias must be expressed as G.
The bias buffer must be at least the same size of the BaseCompass axes number.
Parameters
[in]devppointer to BaseCompass interface.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 585 of file lis3mdl.h.

#define lis3mdlCompassResetBias (   devp)    compassResetBias(&((devp)->comp_if))

Reset bias values for the BaseCompass.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]devppointer to LIS3MDLDriver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 600 of file lis3mdl.h.

#define lis3mdlCompassSetSensitivity (   devp,
  sp 
)    compassSetSensitivity(&((devp)->comp_if), sp)

Set sensitivity values for the BaseCompass.

Note
Sensitivity must be expressed as G/LSB.
The sensitivity buffer must be at least the same size of the BaseCompass axes number.
Parameters
[in]devppointer to LIS3MDLDriver.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 617 of file lis3mdl.h.

#define lis3mdlCompassResetSensitivity (   devp)    compassResetSensitivity(&((devp)->comp_if))

Reset sensitivity values for the BaseCompass.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to LIS3MDLDriver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 632 of file lis3mdl.h.

#define lis3mdlCompassSetFullScale (   devp,
  fs 
)    (devp)->vmt->comp_set_full_scale(devp, fs)

Changes the LIS3MDLDriver compass fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to LIS3MDLDriver.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 650 of file lis3mdl.h.

Typedef Documentation

typedef struct LIS3MDLDriver LIS3MDLDriver

LIS3MDL slave address.

Structure representing a LIS3MDL driver.

Definition at line 283 of file lis3mdl.h.

Enumeration Type Documentation

LIS3MDL slave address.

Enumerator
LIS3MDL_SAD_GND 

Slave Address when SA1 is to GND

LIS3MDL_SAD_VCC 

Slave Address when SA1 is to VCC

Definition at line 288 of file lis3mdl.h.

LIS3MDL full scale.

Enumerator
LIS3MDL_COMP_FS_4GA 

±4 Gauss

LIS3MDL_COMP_FS_8GA 

±8 Gauss

LIS3MDL_COMP_FS_12GA 

±12 Gauss

LIS3MDL_COMP_FS_16GA 

±16 Gauss

Definition at line 296 of file lis3mdl.h.

LIS3MDL output data rate.

Enumerator
LIS3MDL_COMP_ODR_0_625HZ 

Output Data Rate = 0.625 Hz

LIS3MDL_COMP_ODR_1_25HZ 

Output Data Rate = 1.25 Hz

LIS3MDL_COMP_ODR_2_5HZ 

Output Data Rate = 2.5 Hz

LIS3MDL_COMP_ODR_5HZ 

Output Data Rate = 5 Hz

LIS3MDL_COMP_ODR_10HZ 

Output Data Rate = 10 Hz

LIS3MDL_COMP_ODR_20HZ 

Output Data Rate = 20 Hz

LIS3MDL_COMP_ODR_40HZ 

Output Data Rate = 40 Hz

LIS3MDL_COMP_ODR_80HZ 

Output Data Rate = 80 Hz

Definition at line 306 of file lis3mdl.h.

LIS3MDL low power mode configuration.

Enumerator
LIS3MDL_COMP_LP_DISABLED 

Low Power mode disabled

LIS3MDL_COMP_LP_ENABLED 

Low Power mode enabled

Definition at line 320 of file lis3mdl.h.

LIS3MDL conversion mode.

Enumerator
LIS3MDL_COMP_MD_CONTINUOUS 

Continuous conversion mode

LIS3MDL_COMP_MD_SINGLE 

Single conversion mode

LIS3MDL_COMP_MD_POWER_DOWN 

Power down mode

Definition at line 328 of file lis3mdl.h.

LIS3MDL operation mode for X and Y axes.

Enumerator
LIS3MDL_COMP_OMXY_LP 

X-Y axes low power mode

LIS3MDL_COMP_OMXY_MEDIUM 

X-Y axes medium performance mode

LIS3MDL_COMP_OMXY_HIGH 

X-Y axes high performance mode

LIS3MDL_COMP_OMXY_ULTRA 

X-Y axes ultra performance mode

Definition at line 337 of file lis3mdl.h.

LIS3MDL operation mode for Z axis.

Enumerator
LIS3MDL_COMP_OMZ_LP 

Z axis low power mode

LIS3MDL_COMP_OMZ_MEDIUM 

Z axis medium performance mode

LIS3MDL_COMP_OMZ_HIGH 

Z axis high performance mode

LIS3MDL_COMP_OMZ_ULTRA 

Z axis ultra performance mode

Definition at line 347 of file lis3mdl.h.

LIS3MDL temperature sensor enabling.

Enumerator
LIS3MDL_TEMP_DISABLED 

Temperature sensor disabled.

LIS3MDL_TEMP_ENABLED 

Temperature sensor enabled.

Definition at line 357 of file lis3mdl.h.

LIS3MDL block data update.

Enumerator
LIS3MDL_BDU_CONTINUOUS 

Continuous Update

LIS3MDL_BDU_BLOCKED 

Block data updated after reading.

Definition at line 365 of file lis3mdl.h.

LIS3MDL endianness.

Enumerator
LIS3MDL_END_LITTLE 

Little endian.

LIS3MDL_END_BIG 

Big endian.

Definition at line 373 of file lis3mdl.h.

Driver state machine possible states.

Enumerator
LIS3MDL_UNINIT 

Not initialized.

LIS3MDL_STOP 

Stopped.

LIS3MDL_READY 

Ready.

Definition at line 381 of file lis3mdl.h.

Function Documentation

msg_t lis3mdlI2CReadRegister ( I2CDriver i2cp,
lis3mdl_sad_t  sad,
uint8_t  reg,
uint8_t *  rxbuf,
size_t  n 
)

Reads registers value using I2C.

Precondition
The I2C interface must be initialized and the driver started.
Parameters
[in]i2cppointer to the I2C interface
[in]sadslave address without R bit
[in]regfirst sub-register address
[out]rxbufpointer to an output buffer
[in]nnumber of consecutive register to read
Returns
the operation status.
Function Class:Not an API, this function is for internal use only.

Definition at line 62 of file lis3mdl.c.

References i2cMasterTransmitTimeout(), and TIME_INFINITE.

Referenced by comp_read_raw(), and comp_set_full_scale().

Here is the call graph for this function:

msg_t lis3mdlI2CWriteRegister ( I2CDriver i2cp,
lis3mdl_sad_t  sad,
uint8_t *  txbuf,
uint8_t  n 
)

Writes a value into a register using I2C.

Precondition
The I2C interface must be initialized and the driver started.
Parameters
[in]i2cppointer to the I2C interface
[in]sadslave address without R bit
[in]txbufbuffer containing sub-address value in first position and values to write
[in]nsize of txbuf less one (not considering the first element)
Returns
the operation status.
Function Class:Not an API, this function is for internal use only.

Definition at line 85 of file lis3mdl.c.

References i2cMasterTransmitTimeout(), and TIME_INFINITE.

Referenced by comp_set_full_scale(), lis3mdlStart(), and lis3mdlStop().

Here is the call graph for this function:

static size_t comp_get_axes_number ( void *  ip)
static

Return the number of axes of the BaseCompass.

Parameters
[in]ippointer to BaseCompass interface
Returns
the number of axes.

Definition at line 102 of file lis3mdl.c.

References LIS3MDL_COMP_NUMBER_OF_AXES, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_read_raw ( void *  ip,
int32_t  axes[] 
)
static

Retrieves raw data from the BaseCompass.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseCompass axes number.
Parameters
[in]ippointer to BaseCompass interface.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 124 of file lis3mdl.c.

References I2C_READY, i2cAcquireBus(), i2cReleaseBus(), i2cStart(), LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, lis3mdlI2CReadRegister(), MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_read_cooked(), and comp_set_full_scale().

Here is the call graph for this function:

static msg_t comp_read_cooked ( void *  ip,
float  axes[] 
)
static

Retrieves cooked data from the BaseCompass.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as G.
The axes array must be at least the same size of the BaseCompass axes number.
Parameters
[in]ippointer to BaseCompass interface.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 178 of file lis3mdl.c.

References comp_read_raw(), LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

Here is the call graph for this function:

static msg_t comp_set_bias ( void *  ip,
float *  bp 
)
static

Set bias values for the BaseCompass.

Note
Bias must be expressed as G.
The bias buffer must be at least the same size of the BaseCompass axes number.
Parameters
[in]ippointer to BaseCompass interface.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 212 of file lis3mdl.c.

References LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_reset_bias ( void *  ip)
static

Reset bias values for the BaseCompass.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]ippointer to BaseCompass interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 241 of file lis3mdl.c.

References LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_set_sensivity ( void *  ip,
float *  sp 
)
static

Set sensitivity values for the BaseCompass.

Note
Sensitivity must be expressed as G/LSB.
The sensitivity buffer must be at least the same size of the BaseCompass axes number.
Parameters
[in]ippointer to BaseCompass interface.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 271 of file lis3mdl.c.

References LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_reset_sensivity ( void *  ip)
static

Reset sensitivity values for the BaseCompass.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]ippointer to BaseCompass interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 300 of file lis3mdl.c.

References FALSE, LIS3MDL_COMP_FS_12GA, LIS3MDL_COMP_FS_16GA, LIS3MDL_COMP_FS_4GA, LIS3MDL_COMP_FS_8GA, LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_set_full_scale ( LIS3MDLDriver devp,
lis3mdl_comp_fs_t  fs 
)
static

Changes the LIS3MDLDriver compass fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to LIS3MDLDriver interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 345 of file lis3mdl.c.

References comp_get_axes_number(), comp_read_cooked(), comp_read_raw(), comp_reset_bias(), comp_reset_sensivity(), comp_set_bias(), comp_set_sensivity(), I2C_READY, i2cAcquireBus(), i2cReleaseBus(), i2cStart(), LIS3MDL_COMP_FS_12GA, LIS3MDL_COMP_FS_16GA, LIS3MDL_COMP_FS_4GA, LIS3MDL_COMP_FS_8GA, LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, lis3mdlI2CReadRegister(), lis3mdlI2CWriteRegister(), MSG_OK, MSG_RESET, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:

void lis3mdlObjectInit ( LIS3MDLDriver devp)

Initializes an instance.

Parameters
[out]devppointer to the LIS3MDLDriver object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 446 of file lis3mdl.c.

References LIS3MDLDriver::comp_if, LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_STOP, BaseCompass::vmt, and LIS3MDLDriver::vmt.

void lis3mdlStart ( LIS3MDLDriver devp,
const LIS3MDLConfig config 
)

Configures and activates LIS3MDL Complex Driver peripheral.

Parameters
[in]devppointer to the LIS3MDLDriver object
[in]configpointer to the LIS3MDLConfig object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 465 of file lis3mdl.c.

References I2CDriver::config, FALSE, i2cAcquireBus(), LIS3MDLConfig::i2cp, i2cReleaseBus(), i2cStart(), LIS3MDL_COMP_FS_12GA, LIS3MDL_COMP_FS_16GA, LIS3MDL_COMP_FS_4GA, LIS3MDL_COMP_FS_8GA, LIS3MDL_COMP_NUMBER_OF_AXES, LIS3MDL_READY, LIS3MDL_STOP, lis3mdlI2CWriteRegister(), osalDbgAssert, osalDbgCheck, and osalThreadSleepMilliseconds.

Here is the call graph for this function:

void lis3mdlStop ( LIS3MDLDriver devp)

Deactivates the LIS3MDL Complex Driver peripheral.

Parameters
[in]devppointer to the LIS3MDLDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 598 of file lis3mdl.c.

References i2cAcquireBus(), i2cReleaseBus(), i2cStart(), i2cStop(), LIS3MDL_READY, LIS3MDL_STOP, lis3mdlI2CWriteRegister(), osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function: