ChibiOS  19.1.4
Collaboration diagram for LSM303DLHC:

Detailed Description

Macros

#define lsm303dlhcAccelerometerGetAxesNumber(devp)   accelerometerGetAxesNumber(&((devp)->acc_if))
 Return the number of axes of the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerReadRaw(devp, axes)   accelerometerReadRaw(&((devp)->acc_if), axes)
 Retrieves raw data from the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerReadCooked(devp, axes)   accelerometerReadCooked(&((devp)->acc_if), axes)
 Retrieves cooked data from the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerSetBias(devp, bp)   accelerometerSetBias(&((devp)->acc_if), bp)
 Set bias values for the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerResetBias(devp)   accelerometerResetBias(&((devp)->acc_if))
 Reset bias values for the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerSetSensitivity(devp, sp)   accelerometerSetSensitivity(&((devp)->acc_if), sp)
 Set sensitivity values for the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerResetSensitivity(devp)   accelerometerResetSensitivity(&((devp)->acc_if))
 Reset sensitivity values for the BaseAccelerometer. More...
 
#define lsm303dlhcAccelerometerSetFullScale(devp, fs)   (devp)->vmt->acc_set_full_scale(devp, fs)
 Changes the LSM303DLHCDriver accelerometer fullscale value. More...
 
#define lsm303dlhcCompassGetAxesNumber(devp)   compassGetAxesNumber(&((devp)->comp_if))
 Return the number of axes of the BaseCompass. More...
 
#define lsm303dlhcCompassReadRaw(devp, axes)   compassReadRaw(&((devp)->comp_if), axes)
 Retrieves raw data from the BaseCompass. More...
 
#define lsm303dlhcCompassReadCooked(devp, axes)   compassReadCooked(&((devp)->comp_if), axes)
 Retrieves cooked data from the BaseCompass. More...
 
#define lsm303dlhcCompassSetBias(devp, bp)   compassSetBias(&((devp)->comp_if), bp)
 Set bias values for the BaseCompass. More...
 
#define lsm303dlhcCompassResetBias(devp)   compassResetBias(&((devp)->comp_if))
 Reset bias values for the BaseCompass. More...
 
#define lsm303dlhcCompassSetSensitivity(devp, sp)   compassSetSensitivity(&((devp)->comp_if), sp)
 Set sensitivity values for the BaseCompass. More...
 
#define lsm303dlhcCompassResetSensitivity(devp)   compassResetSensitivity(&((devp)->comp_if))
 Reset sensitivity values for the BaseCompass. More...
 
#define lsm303dlhcCompassSetFullScale(devp, fs)   (devp)->vmt->comp_set_full_scale(devp, fs)
 Changes the LSM303DLHCDriver compass fullscale value. More...
 

Version identification

#define EX_LSM303DLHC_VERSION   "1.1.2"
 LSM303DLHC driver version string. More...
 
#define EX_LSM303DLHC_MAJOR   1
 LSM303DLHC driver version major number. More...
 
#define EX_LSM303DLHC_MINOR   1
 LSM303DLHC driver version minor number. More...
 
#define EX_LSM303DLHC_PATCH   2
 LSM303DLHC driver version patch number. More...
 
#define LSM303DLHC_ACC_NUMBER_OF_AXES   3U
 LSM303DLHC accelerometer subsystem characteristics. More...
 
#define LSM303DLHC_COMP_NUMBER_OF_AXES   3U
 LSM303DLHC compass subsystem characteristics. More...
 

LSM303DLHC communication interfaces related bit masks

#define LSM303DLHC_DI_MASK   0xFF
 
#define LSM303DLHC_DI(n)   (1 << n)
 
#define LSM303DLHC_AD_MASK   0x7F
 
#define LSM303DLHC_AD(n)   (1 << n)
 
#define LSM303DLHC_MS   (1 << 7)
 

LSM303DLHC register addresses

#define LSM303DLHC_AD_ACC_CTRL_REG1   0x20
 
#define LSM303DLHC_AD_ACC_CTRL_REG2   0x21
 
#define LSM303DLHC_AD_ACC_CTRL_REG3   0x22
 
#define LSM303DLHC_AD_ACC_CTRL_REG4   0x23
 
#define LSM303DLHC_AD_ACC_CTRL_REG5   0x24
 
#define LSM303DLHC_AD_ACC_CTRL_REG6   0x25
 
#define LSM303DLHC_AD_ACC_REFERENCE   0x26
 
#define LSM303DLHC_AD_ACC_STATUS_REG   0x27
 
#define LSM303DLHC_AD_ACC_OUT_X_L   0x28
 
#define LSM303DLHC_AD_ACC_OUT_X_H   0x29
 
#define LSM303DLHC_AD_ACC_OUT_Y_L   0x2A
 
#define LSM303DLHC_AD_ACC_OUT_Y_H   0x2B
 
#define LSM303DLHC_AD_ACC_OUT_Z_L   0x2C
 
#define LSM303DLHC_AD_ACC_OUT_Z_H   0x2D
 
#define LSM303DLHC_AD_ACC_FIFO_CTRL_REG   0x2E
 
#define LSM303DLHC_AD_ACC_FIFO_SRC_REG   0x2F
 
#define LSM303DLHC_AD_ACC_INT1_CFG   0x30
 
#define LSM303DLHC_AD_ACC_INT1_SRC   0x31
 
#define LSM303DLHC_AD_ACC_INT1_THS   0x32
 
#define LSM303DLHC_AD_ACC_INT1_DURATION   0x33
 
#define LSM303DLHC_AD_ACC_INT2_CFG   0x34
 
#define LSM303DLHC_AD_ACC_INT2_SRC   0x35
 
#define LSM303DLHC_AD_ACC_INT2_THS   0x36
 
#define LSM303DLHC_AD_ACC_INT2_DURATION   0x37
 
#define LSM303DLHC_AD_ACC_CLICK_CFG   0x38
 
#define LSM303DLHC_AD_ACC_CLICK_SRC   0x39
 
#define LSM303DLHC_AD_ACC_CLICK_THS   0x3A
 
#define LSM303DLHC_AD_ACC_TIME_LIMIT   0x3B
 
#define LSM303DLHC_AD_ACC_TIME_LATENCY   0x3C
 
#define LSM303DLHC_AD_ACC_TIME_WINDOW   0x3D
 
#define LSM303DLHC_AD_COMP_CRA_REG   0x00
 
#define LSM303DLHC_AD_COMP_CRB_REG   0x01
 
#define LSM303DLHC_AD_COMP_MR_REG   0x02
 
#define LSM303DLHC_AD_COMP_OUT_X_H   0x03
 
#define LSM303DLHC_AD_COMP_OUT_X_L   0x04
 
#define LSM303DLHC_AD_COMP_OUT_Z_H   0x05
 
#define LSM303DLHC_AD_COMP_OUT_Z_L   0x06
 
#define LSM303DLHC_AD_COMP_OUT_Y_H   0x07
 
#define LSM303DLHC_AD_COMP_OUT_Y_L   0x08
 
#define LSM303DLHC_AD_COMP_SR_REG   0x09
 
#define LSM303DLHC_AD_COMP_IRA_REG   0x0A
 
#define LSM303DLHC_AD_COMP_IRB_REG   0x0B
 
#define LSM303DLHC_AD_COMP_IRC_REG   0x0C
 
#define LSM303DLHC_AD_COMP_TEMP_OUT_H   0x31
 
#define LSM303DLHC_AD_COMP_TEMP_OUT_L   0x32
 

LSM303DLHC_CTRL_REG1_A register bits definitions

#define LSM303DLHC_CTRL_REG1_A_MASK   0xFF
 
#define LSM303DLHC_CTRL_REG1_A_XEN   (1 << 0)
 
#define LSM303DLHC_CTRL_REG1_A_YEN   (1 << 1)
 
#define LSM303DLHC_CTRL_REG1_A_ZEN   (1 << 2)
 
#define LSM303DLHC_CTRL_REG1_A_LPEN   (1 << 3)
 
#define LSM303DLHC_CTRL_REG1_A_ODR0   (1 << 4)
 
#define LSM303DLHC_CTRL_REG1_A_ODR1   (1 << 5)
 
#define LSM303DLHC_CTRL_REG1_A_ODR2   (1 << 6)
 
#define LSM303DLHC_CTRL_REG1_A_ODR3   (1 << 7)
 

LSM303DLHC_CTRL_REG2_A register bits definitions

#define LSM303DLHC_CTRL_REG2_A_MASK   0xFF
 
#define LSM303DLHC_CTRL_REG2_A_HPIS1   (1 << 0)
 
#define LSM303DLHC_CTRL_REG2_A_HPIS2   (1 << 1)
 
#define LSM303DLHC_CTRL_REG2_A_HPCLICK   (1 << 2)
 
#define LSM303DLHC_CTRL_REG2_A_FDS   (1 << 3)
 
#define LSM303DLHC_CTRL_REG2_A_HPCF1   (1 << 4)
 
#define LSM303DLHC_CTRL_REG2_A_HPCF2   (1 << 5)
 
#define LSM303DLHC_CTRL_REG2_A_HPM0   (1 << 6)
 
#define LSM303DLHC_CTRL_REG2_A_HPM1   (1 << 7)
 

LSM303DLHC_CTRL_REG3_A register bits definitions

#define LSM303DLHC_CTRL_REG3_A_MASK   0xFD
 
#define LSM303DLHC_CTRL_REG3_A_I1_OVERRUN   (1 << 1)
 
#define LSM303DLHC_CTRL_REG3_A_I1_WTM   (1 << 2)
 
#define LSM303DLHC_CTRL_REG3_A_I1_DRDY2   (1 << 3)
 
#define LSM303DLHC_CTRL_REG3_A_I1_DRDY1   (1 << 4)
 
#define LSM303DLHC_CTRL_REG3_A_I1_AOI2   (1 << 5)
 
#define LSM303DLHC_CTRL_REG3_A_I1_AOI1   (1 << 6)
 
#define LSM303DLHC_CTRL_REG3_A_I1_CLICK   (1 << 7)
 

LSM303DLHC_CTRL_REG4_A register bits definitions

#define LSM303DLHC_CTRL_REG4_A_MASK   0xF9
 
#define LSM303DLHC_CTRL_REG4_A_SIM   (1 << 0)
 
#define LSM303DLHC_CTRL_REG4_A_HR   (1 << 3)
 
#define LSM303DLHC_CTRL_REG4_A_FS_MASK   0x30
 
#define LSM303DLHC_CTRL_REG4_A_FS0   (1 << 4)
 
#define LSM303DLHC_CTRL_REG4_A_FS1   (1 << 5)
 
#define LSM303DLHC_CTRL_REG4_A_BLE   (1 << 6)
 
#define LSM303DLHC_CTRL_REG4_A_BDU   (1 << 7)
 

LSM303DLHC_CTRL_REG5_A register bits definitions

#define LSM303DLHC_CTRL_REG5_A_MASK   0xCF
 
#define LSM303DLHC_CTRL_REG5_A_D4D_INT2   (1 << 0)
 
#define LSM303DLHC_CTRL_REG5_A_LIR_INT2   (1 << 1)
 
#define LSM303DLHC_CTRL_REG5_A_D4D_INT1   (1 << 2)
 
#define LSM303DLHC_CTRL_REG5_A_LIR_INT1   (1 << 3)
 
#define LSM303DLHC_CTRL_REG5_A_FIFO_EN   (1 << 6)
 
#define LSM303DLHC_CTRL_REG5_A_BOOT   (1 << 7)
 

LSM303DLHC_CTRL_REG6_A register bits definitions

#define LSM303DLHC_CTRL_REG6_A_MASK   0xFA
 
#define LSM303DLHC_CTRL_REG6_A_H_LACTIVE   (1 << 1)
 
#define LSM303DLHC_CTRL_REG6_A_P2_ACT   (1 << 3)
 
#define LSM303DLHC_CTRL_REG6_A_BOOT_I1   (1 << 4)
 
#define LSM303DLHC_CTRL_REG6_A_I2_INT2   (1 << 5)
 
#define LSM303DLHC_CTRL_REG6_A_I2_INT1   (1 << 6)
 
#define LSM303DLHC_CTRL_REG6_A_I2_CLICKEN   (1 << 7)
 

LSM303DLHC_CRA_REG_M register bits definitions

#define LSM303DLHC_CRA_REG_M_MASK   0x9C
 
#define LSM303DLHC_CRA_REG_M_DO0   (1 << 2)
 
#define LSM303DLHC_CRA_REG_M_DO1   (1 << 3)
 
#define LSM303DLHC_CRA_REG_M_DO2   (1 << 4)
 
#define LSM303DLHC_CRA_REG_M_TEMP_EN   (1 << 7)
 

LSM303DLHC_CRB_REG_M register bits definitions

#define LSM303DLHC_CRB_REG_M_MASK   0xE0
 
#define LSM303DLHC_CRB_REG_M_GN_MASK   0xE0
 
#define LSM303DLHC_CRB_REG_M_GN0   (1 << 5)
 
#define LSM303DLHC_CRB_REG_M_GN1   (1 << 6)
 
#define LSM303DLHC_CRB_REG_M_GN2   (1 << 7)
 
#define LSM303DLHC_MR_REG_M_MASK   0x03
 
#define LSM303DLHC_MR_REG_M_MD0   (1 << 0)
 
#define LSM303DLHC_MR_REG_M_MD1   (1 << 1)
 

Configuration options

#define LSM303DLHC_USE_SPI   FALSE
 LSM303DLHC SPI interface switch. More...
 
#define LSM303DLHC_SHARED_SPI   FALSE
 LSM303DLHC shared SPI switch. More...
 
#define LSM303DLHC_USE_I2C   TRUE
 LSM303DLHC I2C interface switch. More...
 
#define LSM303DLHC_SHARED_I2C   FALSE
 LSM303DLHC shared I2C switch. More...
 
#define LSM303DLHC_USE_ADVANCED   FALSE
 LSM303DLHC advanced configurations switch. More...
 

LSM303DLHC accelerometer subsystem data structures and types.

Todo:
Add support for LSM303DLHC over SPI.
typedef struct LSM303DLHCDriver LSM303DLHCDriver
 Structure representing a LSM303DLHC driver. More...
 

LSM303DLHC compass subsystem data structures and types.

LSM303DLHC main system data structures and types.

#define _lsm303dlhc_methods_alone
 LSM303DLHC specific methods. More...
 
#define _lsm303dlhc_methods
 LSM303DLHC specific methods with inherited ones. More...
 
#define _lsm303dlhc_data
 LSM303DLHCDriver specific data. More...
 

Data Structures

struct  LSM303DLHCConfig
 LSM303DLHC configuration structure. More...
 
struct  LSM303DLHCVMT
 LSM303DLHC virtual methods table. More...
 
struct  LSM303DLHCDriver
 LSM303DLHC 6-axis accelerometer/compass class. More...
 

Functions

static msg_t lsm303dlhcI2CReadRegister (I2CDriver *i2cp, lsm303dlhc_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
 Reads registers value using I2C. More...
 
static msg_t lsm303dlhcI2CWriteRegister (I2CDriver *i2cp, lsm303dlhc_sad_t sad, uint8_t *txbuf, size_t n)
 Writes a value into a register using I2C. More...
 
static size_t acc_get_axes_number (void *ip)
 Return the number of axes of the BaseAccelerometer. More...
 
static msg_t acc_read_raw (void *ip, int32_t axes[])
 Retrieves raw data from the BaseAccelerometer. More...
 
static msg_t acc_read_cooked (void *ip, float axes[])
 Retrieves cooked data from the BaseAccelerometer. More...
 
static msg_t acc_set_bias (void *ip, float *bp)
 Set bias values for the BaseAccelerometer. More...
 
static msg_t acc_reset_bias (void *ip)
 Reset bias values for the BaseAccelerometer. More...
 
static msg_t acc_set_sensivity (void *ip, float *sp)
 Set sensitivity values for the BaseAccelerometer. More...
 
static msg_t acc_reset_sensivity (void *ip)
 Reset sensitivity values for the BaseAccelerometer. More...
 
static msg_t acc_set_full_scale (LSM303DLHCDriver *devp, lsm303dlhc_acc_fs_t fs)
 Changes the LSM303DLHCDriver accelerometer fullscale value. 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 (LSM303DLHCDriver *devp, lsm303dlhc_comp_fs_t fs)
 Changes the LSM303DLHCDriver compass fullscale value. More...
 
void lsm303dlhcObjectInit (LSM303DLHCDriver *devp)
 Initializes an instance. More...
 
void lsm303dlhcStart (LSM303DLHCDriver *devp, const LSM303DLHCConfig *config)
 Configures and activates LSM303DLHC Complex Driver peripheral. More...
 
void lsm303dlhcStop (LSM303DLHCDriver *devp)
 Deactivates the LSM303DLHC Complex Driver peripheral. More...
 

Enumerations

Macro Definition Documentation

#define EX_LSM303DLHC_VERSION   "1.1.2"

LSM303DLHC driver version string.

Definition at line 46 of file lsm303dlhc.h.

#define EX_LSM303DLHC_MAJOR   1

LSM303DLHC driver version major number.

Definition at line 51 of file lsm303dlhc.h.

#define EX_LSM303DLHC_MINOR   1

LSM303DLHC driver version minor number.

Definition at line 56 of file lsm303dlhc.h.

#define EX_LSM303DLHC_PATCH   2

LSM303DLHC driver version patch number.

Definition at line 61 of file lsm303dlhc.h.

#define LSM303DLHC_ACC_NUMBER_OF_AXES   3U

LSM303DLHC accelerometer subsystem characteristics.

Note
Sensitivity is expressed as milli-G/LSB whereas 1 milli-G = 0.00980665 m/s^2.
Bias is expressed as milli-G.

Definition at line 72 of file lsm303dlhc.h.

Referenced by acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_full_scale(), acc_set_sensivity(), lsm303dlhcObjectInit(), and lsm303dlhcStart().

#define LSM303DLHC_COMP_NUMBER_OF_AXES   3U

LSM303DLHC compass subsystem characteristics.

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

Definition at line 94 of file lsm303dlhc.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(), lsm303dlhcObjectInit(), and lsm303dlhcStart().

#define LSM303DLHC_USE_SPI   FALSE

LSM303DLHC SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is FALSE.

Definition at line 313 of file lsm303dlhc.h.

#define LSM303DLHC_SHARED_SPI   FALSE

LSM303DLHC 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 323 of file lsm303dlhc.h.

#define LSM303DLHC_USE_I2C   TRUE

LSM303DLHC I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is TRUE.

Definition at line 332 of file lsm303dlhc.h.

#define LSM303DLHC_SHARED_I2C   FALSE

LSM303DLHC 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 342 of file lsm303dlhc.h.

#define LSM303DLHC_USE_ADVANCED   FALSE

LSM303DLHC advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 351 of file lsm303dlhc.h.

#define _lsm303dlhc_methods_alone
Value:
/* Change full scale value of LSM303DLHC accelerometer subsystem.*/ \
/* Change full scale value of LSM303DLHC compass subsystem.*/ \
static msg_t acc_set_full_scale(LIS302DLDriver *devp, lis302dl_acc_fs_t fs)
Changes the LIS302DLDriver accelerometer fullscale value.
Definition: lis302dl.c:332
LSM303DLHC 6-axis accelerometer/compass class.
Definition: lsm303dlhc.h:650
lsm303dlhc_acc_fs_t
LSM303DLHC accelerometer subsystem full scale.
Definition: lsm303dlhc.h:402
static msg_t comp_set_full_scale(LIS3MDLDriver *devp, lis3mdl_comp_fs_t fs)
Changes the LIS3MDLDriver compass fullscale value.
Definition: lis3mdl.c:345
lsm303dlhc_comp_fs_t
LSM303DLHC compass subsystem full scale.
Definition: lsm303dlhc.h:478
int32_t msg_t
Definition: chtypes.h:51

LSM303DLHC specific methods.

Definition at line 597 of file lsm303dlhc.h.

#define _lsm303dlhc_methods
Value:
#define _lsm303dlhc_methods_alone
LSM303DLHC specific methods.
Definition: lsm303dlhc.h:597

LSM303DLHC specific methods with inherited ones.

Definition at line 608 of file lsm303dlhc.h.

#define _lsm303dlhc_data
Value:
/* Driver state.*/ \
/* Current configuration data.*/ \
const LSM303DLHCConfig *config; \
/* Accelerometer subsystem axes number.*/ \
size_t accaxes; \
/* Accelerometer subsystem current sensitivity.*/ \
float accsensitivity[LSM303DLHC_ACC_NUMBER_OF_AXES]; \
/* Accelerometer subsystem current bias .*/ \
/* Accelerometer subsystem current full scale value.*/ \
float accfullscale; \
/* Compass subsystem axes number.*/ \
size_t compaxes; \
/* Compass subsystem current sensitivity.*/ \
float compsensitivity[LSM303DLHC_COMP_NUMBER_OF_AXES];\
/* Compass subsystem current bias.*/ \
float compbias[LSM303DLHC_COMP_NUMBER_OF_AXES]; \
/* Compass subsystem current full scale value.*/ \
float compfullscale;
#define LSM303DLHC_ACC_NUMBER_OF_AXES
LSM303DLHC accelerometer subsystem characteristics.
Definition: lsm303dlhc.h:72
LSM303DLHC configuration structure.
Definition: lsm303dlhc.h:527
#define LSM303DLHC_COMP_NUMBER_OF_AXES
LSM303DLHC compass subsystem characteristics.
Definition: lsm303dlhc.h:94
lsm303dlhc_state_t
Driver state machine possible states.
Definition: lsm303dlhc.h:518
#define _base_sensor_data
BaseSensor specific data.
Definition: hal_sensors.h:74

LSM303DLHCDriver specific data.

Definition at line 624 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerGetAxesNumber (   devp)    accelerometerGetAxesNumber(&((devp)->acc_if))

Return the number of axes of the BaseAccelerometer.

Parameters
[in]devppointer to LSM303DLHCDriver.
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 674 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerReadRaw (   devp,
  axes 
)    accelerometerReadRaw(&((devp)->acc_if), axes)

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LSM303DLHCDriver.
[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 695 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerReadCooked (   devp,
  axes 
)    accelerometerReadCooked(&((devp)->acc_if), axes)

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LSM303DLHCDriver.
[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 717 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerSetBias (   devp,
  bp 
)    accelerometerSetBias(&((devp)->acc_if), bp)

Set bias values for the BaseAccelerometer.

Note
Bias must be expressed as milli-G.
The bias buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LSM303DLHCDriver.
[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 734 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerResetBias (   devp)    accelerometerResetBias(&((devp)->acc_if))

Reset bias values for the BaseAccelerometer.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]devppointer to LSM303DLHCDriver.
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 749 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerSetSensitivity (   devp,
  sp 
)    accelerometerSetSensitivity(&((devp)->acc_if), sp)

Set sensitivity values for the BaseAccelerometer.

Note
Sensitivity must be expressed as milli-G/LSB.
The sensitivity buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LSM303DLHCDriver.
[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 766 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerResetSensitivity (   devp)    accelerometerResetSensitivity(&((devp)->acc_if))

Reset sensitivity values for the BaseAccelerometer.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to LSM303DLHCDriver.
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 781 of file lsm303dlhc.h.

#define lsm303dlhcAccelerometerSetFullScale (   devp,
  fs 
)    (devp)->vmt->acc_set_full_scale(devp, fs)

Changes the LSM303DLHCDriver accelerometer 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 LSM303DLHCDriver.
[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 799 of file lsm303dlhc.h.

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

Return the number of axes of the BaseCompass.

Parameters
[in]devppointer to LSM303DLHCDriver.
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 811 of file lsm303dlhc.h.

#define lsm303dlhcCompassReadRaw (   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 832 of file lsm303dlhc.h.

#define lsm303dlhcCompassReadCooked (   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 854 of file lsm303dlhc.h.

#define lsm303dlhcCompassSetBias (   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 871 of file lsm303dlhc.h.

#define lsm303dlhcCompassResetBias (   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 LSM303DLHCDriver.
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 886 of file lsm303dlhc.h.

#define lsm303dlhcCompassSetSensitivity (   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 LSM303DLHCDriver.
[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 903 of file lsm303dlhc.h.

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

Reset sensitivity values for the BaseCompass.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to LSM303DLHCDriver.
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 918 of file lsm303dlhc.h.

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

Changes the LSM303DLHCDriver 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 LSM303DLHCDriver.
[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 936 of file lsm303dlhc.h.

Typedef Documentation

Structure representing a LSM303DLHC driver.

Definition at line 397 of file lsm303dlhc.h.

Enumeration Type Documentation

Accelerometer and Compass Slave Address.

Enumerator
LSM303DLHC_SAD_ACC 

SAD for accelerometer.

LSM303DLHC_SAD_COMP 

SAD for compass.

Definition at line 48 of file lsm303dlhc.c.

LSM303DLHC accelerometer subsystem full scale.

Enumerator
LSM303DLHC_ACC_FS_2G 

Full scale ±2g.

LSM303DLHC_ACC_FS_4G 

Full scale ±4g.

LSM303DLHC_ACC_FS_8G 

Full scale ±8g.

LSM303DLHC_ACC_FS_16G 

Full scale ±16g.

Definition at line 402 of file lsm303dlhc.h.

LSM303DLHC accelerometer subsystem output data rate.

Enumerator
LSM303DLHC_ACC_ODR_PD 

Power down

LSM303DLHC_ACC_ODR_1Hz 

ODR 1 Hz

LSM303DLHC_ACC_ODR_10Hz 

ODR 10 Hz

LSM303DLHC_ACC_ODR_25Hz 

ODR 25 Hz

LSM303DLHC_ACC_ODR_50Hz 

ODR 50 Hz

LSM303DLHC_ACC_ODR_100Hz 

ODR 100 Hz

LSM303DLHC_ACC_ODR_200Hz 

ODR 200 Hz

LSM303DLHC_ACC_ODR_400Hz 

ODR 400 Hz

LSM303DLHC_ACC_ODR_1620Hz 

ODR 1620 Hz (LP only)

LSM303DLHC_ACC_ODR_1344Hz 

ODR 1344 Hz or 5376 Hz in LP

Definition at line 412 of file lsm303dlhc.h.

LSM303DLHC accelerometer subsystem axes enabling.

Enumerator
LSM303DLHC_ACC_AE_DISABLED 

All axes disabled.

LSM303DLHC_ACC_AE_X 

Only X-axis enabled.

LSM303DLHC_ACC_AE_Y 

Only Y-axis enabled.

LSM303DLHC_ACC_AE_XY 

X and Y axes enabled.

LSM303DLHC_ACC_AE_Z 

Only Z-axis enabled.

LSM303DLHC_ACC_AE_XZ 

X and Z axes enabled.

LSM303DLHC_ACC_AE_YZ 

Y and Z axes enabled.

LSM303DLHC_ACC_AE_XYZ 

All axes enabled.

Definition at line 428 of file lsm303dlhc.h.

LSM303DLHC accelerometer subsystem low power mode.

Enumerator
LSM303DLHC_ACC_LP_DISABLED 

Low power mode disabled.

LSM303DLHC_ACC_LP_ENABLED 

Low power mode enabled.

Definition at line 442 of file lsm303dlhc.h.

LSM303DLHC accelerometer subsystem high resolution mode.

Enumerator
LSM303DLHC_ACC_HR_DISABLED 

High resolution mode disabled.

LSM303DLHC_ACC_HR_ENABLED 

High resolution mode enabled.

Definition at line 450 of file lsm303dlhc.h.

LSM303DLHC accelerometer subsystem block data update.

Enumerator
LSM303DLHC_ACC_BDU_CONT 

Continuous update

LSM303DLHC_ACC_BDU_BLOCK 

Update blocked

Definition at line 458 of file lsm303dlhc.h.

LSM303DLHC accelerometer endianness.

Enumerator
LSM303DLHC_ACC_END_LITTLE 

Little Endian

LSM303DLHC_ACC_END_BIG 

Big Endian

Definition at line 466 of file lsm303dlhc.h.

LSM303DLHC compass subsystem full scale.

Enumerator
LSM303DLHC_COMP_FS_1P3GA 

Full scale ±1.3 Gauss

LSM303DLHC_COMP_FS_1P9GA 

Full scale ±1.9 Gauss

LSM303DLHC_COMP_FS_2P5GA 

Full scale ±2.5 Gauss

LSM303DLHC_COMP_FS_4P0GA 

Full scale ±4.0 Gauss

LSM303DLHC_COMP_FS_4P7GA 

Full scale ±4.7 Gauss

LSM303DLHC_COMP_FS_5P6GA 

Full scale ±5.6 Gauss

LSM303DLHC_COMP_FS_8P1GA 

Full scale ±8.1 Gauss

Definition at line 478 of file lsm303dlhc.h.

LSM303DLHC compass subsystem output data rate.

Enumerator
LSM303DLHC_COMP_ODR_0P75HZ 

ODR 0.75 Hz

LSM303DLHC_COMP_ODR_1P5HZ 

ODR 1.5 Hz

LSM303DLHC_COMP_ODR_3P0HZ 

ODR 3 Hz

LSM303DLHC_COMP_ODR_7P5HZ 

ODR 7.5 Hz

LSM303DLHC_COMP_ODR_15HZ 

ODR 15 Hz

LSM303DLHC_COMP_ODR_30HZ 

ODR 30 Hz

LSM303DLHC_COMP_ODR_75HZ 

ODR 75 Hz

LSM303DLHC_COMP_ODR_220HZ 

ODR 220 Hz

Definition at line 491 of file lsm303dlhc.h.

LSM303DLHC compass subsystem working mode.

Enumerator
LSM303DLHC_COMP_MD_CONT 

Continuous-Conversion Mode

LSM303DLHC_COMP_MD_BLOCK 

Single-Conversion Mode

LSM303DLHC_COMP_MD_SLEEP 

Sleep Mode

Definition at line 505 of file lsm303dlhc.h.

Driver state machine possible states.

Enumerator
LSM303DLHC_UNINIT 

Not initialized.

LSM303DLHC_STOP 

Stopped.

LSM303DLHC_READY 

Ready.

Definition at line 518 of file lsm303dlhc.h.

Function Documentation

static msg_t lsm303dlhcI2CReadRegister ( I2CDriver i2cp,
lsm303dlhc_sad_t  sad,
uint8_t  reg,
uint8_t *  rxbuf,
size_t  n 
)
static

Reads registers value using I2C.

Precondition
The I2C interface must be initialized and the driver started.
Note
IF_ADD_INC bit must be 1 in CTRL_REG8.
Parameters
[in]i2cppointer to the I2C interface.
[in]sadslave address without R bit.
[in]regfirst sub-register address.
[in]rxbufreceiving buffer.
[in]nsize of rxbuf.
Returns
the operation status.

Definition at line 69 of file lsm303dlhc.c.

References i2cMasterTransmitTimeout(), and TIME_INFINITE.

Referenced by acc_read_raw(), acc_set_full_scale(), comp_read_raw(), and comp_set_full_scale().

Here is the call graph for this function:

static msg_t lsm303dlhcI2CWriteRegister ( I2CDriver i2cp,
lsm303dlhc_sad_t  sad,
uint8_t *  txbuf,
size_t  n 
)
static

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.

Definition at line 89 of file lsm303dlhc.c.

References i2cMasterTransmitTimeout(), and TIME_INFINITE.

Referenced by acc_set_full_scale(), comp_set_full_scale(), lsm303dlhcStart(), and lsm303dlhcStop().

Here is the call graph for this function:

static size_t acc_get_axes_number ( void *  ip)
static

Return the number of axes of the BaseAccelerometer.

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

Definition at line 104 of file lsm303dlhc.c.

References LSM303DLHC_ACC_NUMBER_OF_AXES.

Referenced by comp_set_full_scale().

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

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer 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 126 of file lsm303dlhc.c.

References I2C_READY, i2cAcquireBus(), i2cReleaseBus(), i2cStart(), LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, LSM303DLHC_SAD_ACC, lsm303dlhcI2CReadRegister(), MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_read_cooked(), and comp_set_full_scale().

Here is the call graph for this function:

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

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer 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 181 of file lsm303dlhc.c.

References acc_read_raw(), LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

Here is the call graph for this function:

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

Set bias values for the BaseAccelerometer.

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

Definition at line 214 of file lsm303dlhc.c.

References LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t acc_reset_bias ( void *  ip)
static

Reset bias values for the BaseAccelerometer.

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

Definition at line 243 of file lsm303dlhc.c.

References LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

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

Set sensitivity values for the BaseAccelerometer.

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

Definition at line 273 of file lsm303dlhc.c.

References LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t acc_reset_sensivity ( void *  ip)
static

Reset sensitivity values for the BaseAccelerometer.

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

Definition at line 302 of file lsm303dlhc.c.

References FALSE, LSM303DLHC_ACC_FS_16G, LSM303DLHC_ACC_FS_2G, LSM303DLHC_ACC_FS_4G, LSM303DLHC_ACC_FS_8G, LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t acc_set_full_scale ( LSM303DLHCDriver devp,
lsm303dlhc_acc_fs_t  fs 
)
static

Changes the LSM303DLHCDriver accelerometer 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 LSM303DLHCDriver interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 347 of file lsm303dlhc.c.

References I2C_READY, i2cAcquireBus(), i2cReleaseBus(), i2cStart(), LSM303DLHC_ACC_FS_16G, LSM303DLHC_ACC_FS_2G, LSM303DLHC_ACC_FS_4G, LSM303DLHC_ACC_FS_8G, LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_READY, LSM303DLHC_SAD_ACC, lsm303dlhcI2CReadRegister(), lsm303dlhcI2CWriteRegister(), MSG_OK, MSG_RESET, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

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 437 of file lsm303dlhc.c.

References LSM303DLHC_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 459 of file lsm303dlhc.c.

References I2C_READY, i2cAcquireBus(), i2cReleaseBus(), i2cStart(), LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_READY, LSM303DLHC_SAD_COMP, lsm303dlhcI2CReadRegister(), 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 513 of file lsm303dlhc.c.

References comp_read_raw(), LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_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 547 of file lsm303dlhc.c.

References LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_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 576 of file lsm303dlhc.c.

References LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_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 606 of file lsm303dlhc.c.

References LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_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 635 of file lsm303dlhc.c.

References FALSE, LSM303DLHC_COMP_FS_1P3GA, LSM303DLHC_COMP_FS_1P9GA, LSM303DLHC_COMP_FS_2P5GA, LSM303DLHC_COMP_FS_4P0GA, LSM303DLHC_COMP_FS_4P7GA, LSM303DLHC_COMP_FS_5P6GA, LSM303DLHC_COMP_FS_8P1GA, LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_set_full_scale().

static msg_t comp_set_full_scale ( LSM303DLHCDriver devp,
lsm303dlhc_comp_fs_t  fs 
)
static

Changes the LSM303DLHCDriver 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 LSM303DLHCDriver interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 731 of file lsm303dlhc.c.

References acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_full_scale(), acc_set_sensivity(), 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(), LSM303DLHC_COMP_FS_1P3GA, LSM303DLHC_COMP_FS_1P9GA, LSM303DLHC_COMP_FS_2P5GA, LSM303DLHC_COMP_FS_4P0GA, LSM303DLHC_COMP_FS_4P7GA, LSM303DLHC_COMP_FS_5P6GA, LSM303DLHC_COMP_FS_8P1GA, LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_READY, LSM303DLHC_SAD_COMP, lsm303dlhcI2CReadRegister(), lsm303dlhcI2CWriteRegister(), MSG_OK, MSG_RESET, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:

void lsm303dlhcObjectInit ( LSM303DLHCDriver devp)

Initializes an instance.

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

Definition at line 847 of file lsm303dlhc.c.

References LSM303DLHCDriver::acc_if, LSM303DLHCDriver::comp_if, LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_STOP, BaseAccelerometer::vmt, BaseCompass::vmt, and LSM303DLHCDriver::vmt.

void lsm303dlhcStart ( LSM303DLHCDriver devp,
const LSM303DLHCConfig config 
)

Configures and activates LSM303DLHC Complex Driver peripheral.

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

Definition at line 868 of file lsm303dlhc.c.

References I2CDriver::config, FALSE, i2cAcquireBus(), LSM303DLHCConfig::i2cp, i2cReleaseBus(), i2cStart(), LSM303DLHC_ACC_FS_16G, LSM303DLHC_ACC_FS_2G, LSM303DLHC_ACC_FS_4G, LSM303DLHC_ACC_FS_8G, LSM303DLHC_ACC_NUMBER_OF_AXES, LSM303DLHC_COMP_FS_1P3GA, LSM303DLHC_COMP_FS_1P9GA, LSM303DLHC_COMP_FS_2P5GA, LSM303DLHC_COMP_FS_4P0GA, LSM303DLHC_COMP_FS_4P7GA, LSM303DLHC_COMP_FS_5P6GA, LSM303DLHC_COMP_FS_8P1GA, LSM303DLHC_COMP_NUMBER_OF_AXES, LSM303DLHC_READY, LSM303DLHC_SAD_ACC, LSM303DLHC_SAD_COMP, LSM303DLHC_STOP, lsm303dlhcI2CWriteRegister(), osalDbgAssert, osalDbgCheck, and osalThreadSleepMilliseconds.

Here is the call graph for this function:

void lsm303dlhcStop ( LSM303DLHCDriver devp)

Deactivates the LSM303DLHC Complex Driver peripheral.

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

Definition at line 1142 of file lsm303dlhc.c.

References i2cAcquireBus(), i2cReleaseBus(), i2cStart(), i2cStop(), LSM303DLHC_ACC_AE_DISABLED, LSM303DLHC_ACC_ODR_PD, LSM303DLHC_COMP_MD_SLEEP, LSM303DLHC_READY, LSM303DLHC_SAD_ACC, LSM303DLHC_SAD_COMP, LSM303DLHC_STOP, lsm303dlhcI2CWriteRegister(), osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function: