ChibiOS  21.6.0
Collaboration diagram for LSM303AGR:

Detailed Description

Macros

#define lsm303agrAccelerometerGetAxesNumber(devp)   accelerometerGetAxesNumber(&((devp)->acc_if))
 Return the number of axes of the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerReadRaw(devp, axes)   accelerometerReadRaw(&((devp)->acc_if), axes)
 Retrieves raw data from the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerReadCooked(devp, axes)   accelerometerReadCooked(&((devp)->acc_if), axes)
 Retrieves cooked data from the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerSetBias(devp, bp)   accelerometerSetBias(&((devp)->acc_if), bp)
 Set bias values for the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerResetBias(devp)   accelerometerResetBias(&((devp)->acc_if))
 Reset bias values for the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerSetSensitivity(devp, sp)   accelerometerSetSensitivity(&((devp)->acc_if), sp)
 Set sensitivity values for the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerResetSensitivity(devp)   accelerometerResetSensitivity(&((devp)->acc_if))
 Reset sensitivity values for the BaseAccelerometer. More...
 
#define lsm303agrAccelerometerSetFullScale(devp, fs)   (devp)->vmt->acc_set_full_scale(devp, fs)
 Changes the LSM303AGRDriver accelerometer fullscale value. More...
 
#define lsm303agrCompassGetAxesNumber(devp)   compassGetAxesNumber(&((devp)->comp_if))
 Return the number of axes of the BaseCompass. More...
 
#define lsm303agrCompassReadRaw(devp, axes)   compassReadRaw(&((devp)->comp_if), axes)
 Retrieves raw data from the BaseCompass. More...
 
#define lsm303agrCompassReadCooked(devp, axes)   compassReadCooked(&((devp)->comp_if), axes)
 Retrieves cooked data from the BaseCompass. More...
 
#define lsm303agrCompassSetBias(devp, bp)   compassSetBias(&((devp)->comp_if), bp)
 Set bias values for the BaseCompass. More...
 
#define lsm303agrCompassResetBias(devp)   compassResetBias(&((devp)->comp_if))
 Reset bias values for the BaseCompass. More...
 
#define lsm303agrCompassSetSensitivity(devp, sp)   compassSetSensitivity(&((devp)->comp_if), sp)
 Set sensitivity values for the BaseCompass. More...
 
#define lsm303agrCompassResetSensitivity(devp)   compassResetSensitivity(&((devp)->comp_if))
 Reset sensitivity values for the BaseCompass. More...
 

Version identification

#define EX_LSM303AGR_VERSION   "1.0.1"
 LSM303AGR driver version string. More...
 
#define EX_LSM303AGR_MAJOR   1
 LSM303AGR driver version major number. More...
 
#define EX_LSM303AGR_MINOR   0
 LSM303AGR driver version minor number. More...
 
#define EX_LSM303AGR_PATCH   1
 LSM303AGR driver version patch number. More...
 
#define LSM303AGR_ACC_NUMBER_OF_AXES   3U
 LSM303AGR accelerometer subsystem characteristics. More...
 
#define LSM303AGR_COMP_NUMBER_OF_AXES   3U
 LSM303AGR compass subsystem characteristics. More...
 

LSM303AGR communication interfaces related bit masks

#define LSM303AGR_DI_MASK   0xFF
 
#define LSM303AGR_DI(n)   (1 << n)
 
#define LSM303AGR_AD_MASK   0x7F
 
#define LSM303AGR_AD(n)   (1 << n)
 
#define LSM303AGR_MS   (1 << 7)
 

LSM303AGR register addresses

#define LSM303AGR_AD_STATUS_REG_AUX_A   0x07
 
#define LSM303AGR_AD_OUT_TEMP_L_A   0x0C
 
#define LSM303AGR_AD_OUT_TEMP_H_A   0x0D
 
#define LSM303AGR_AD_INT_COUNTER_REG_A   0x0E
 
#define LSM303AGR_AD_WHO_AM_I_A   0x0F
 
#define LSM303AGR_AD_TEMP_CFG_REG_A   0x1F
 
#define LSM303AGR_AD_CTRL_REG1_A   0x20
 
#define LSM303AGR_AD_CTRL_REG2_A   0x21
 
#define LSM303AGR_AD_CTRL_REG3_A   0x22
 
#define LSM303AGR_AD_CTRL_REG4_A   0x23
 
#define LSM303AGR_AD_CTRL_REG5_A   0x24
 
#define LSM303AGR_AD_CTRL_REG6_A   0x25
 
#define LSM303AGR_AD_REFERENCE_A   0x26
 
#define LSM303AGR_AD_STATUS_REG_A   0x27
 
#define LSM303AGR_AD_OUT_X_L_A   0x28
 
#define LSM303AGR_AD_OUT_X_H_A   0x29
 
#define LSM303AGR_AD_OUT_Y_L_A   0x2A
 
#define LSM303AGR_AD_OUT_Y_H_A   0x2B
 
#define LSM303AGR_AD_OUT_Z_L_A   0x2C
 
#define LSM303AGR_AD_OUT_Z_H_A   0x2D
 
#define LSM303AGR_AD_FIFO_CTRL_REG_A   0x2E
 
#define LSM303AGR_AD_FIFO_SRC_REG_A   0x2F
 
#define LSM303AGR_AD_INT1_CFG_A   0x30
 
#define LSM303AGR_AD_INT1_SRC_A   0x31
 
#define LSM303AGR_AD_INT1_THS_A   0x32
 
#define LSM303AGR_AD_INT1_DURATION_A   0x33
 
#define LSM303AGR_AD_INT2_CFG_A   0x34
 
#define LSM303AGR_AD_INT2_SRC_A   0x35
 
#define LSM303AGR_AD_INT2_THS_A   0x36
 
#define LSM303AGR_AD_INT2_DURATION_A   0x37
 
#define LSM303AGR_AD_CLICK_CFG_A   0x38
 
#define LSM303AGR_AD_CLICK_SRC_A   0x39
 
#define LSM303AGR_AD_CLICK_THS_A   0x3A
 
#define LSM303AGR_AD_TIME_LIMIT_A   0x3B
 
#define LSM303AGR_AD_TIME_LATENCY_A   0x3C
 
#define LSM303AGR_AD_TIME_WINDOW_A   0x3D
 
#define LSM303AGR_AD_ACT_THS_A   0x3E
 
#define LSM303AGR_AD_ACT_DUR_A   0x3F
 
#define LSM303AGR_AD_OFFSET_X_REG_L_M   0x45
 
#define LSM303AGR_AD_OFFSET_X_REG_H_M   0x46
 
#define LSM303AGR_AD_OFFSET_Y_REG_L_M   0x47
 
#define LSM303AGR_AD_OFFSET_Y_REG_H_M   0x48
 
#define LSM303AGR_AD_OFFSET_Z_REG_L_M   0x49
 
#define LSM303AGR_AD_OFFSET_Z_REG_H_M   0x4A
 
#define LSM303AGR_AD_WHO_AM_I_M   0x4F
 
#define LSM303AGR_AD_CFG_REG_A_M   0x60
 
#define LSM303AGR_AD_CFG_REG_B_M   0x61
 
#define LSM303AGR_AD_CFG_REG_C_M   0x62
 
#define LSM303AGR_AD_INT_CRTL_REG_M   0x63
 
#define LSM303AGR_AD_INT_SOURCE_REG_M   0x64
 
#define LSM303AGR_AD_INT_THS_L_REG_M   0x65
 
#define LSM303AGR_AD_INT_THS_H_REG_M   0x66
 
#define LSM303AGR_AD_STATUS_REG_M   0x67
 
#define LSM303AGR_AD_OUTX_L_REG_M   0x68
 
#define LSM303AGR_AD_OUTX_H_REG_M   0x69
 
#define LSM303AGR_AD_OUTY_L_REG_M   0x6A
 
#define LSM303AGR_AD_OUTY_H_REG_M   0x6B
 
#define LSM303AGR_AD_OUTZ_L_REG_M   0x6C
 
#define LSM303AGR_AD_OUTZ_H_REG_M   0x6D
 

LSM303AGR_TEMP_CFG_REG_A register bits definitions

#define LSM303AGR_TEMP_CFG_REG_A_TEMP_EN0   (1 << 0)
 
#define LSM303AGR_TEMP_CFG_REG_A_TEMP_EN1   (1 << 0)
 

LSM303AGR_CTRL_REG1_A register bits definitions

#define LSM303AGR_CTRL_REG1_A_XEN   (1 << 0)
 
#define LSM303AGR_CTRL_REG1_A_YEN   (1 << 1)
 
#define LSM303AGR_CTRL_REG1_A_ZEN   (1 << 2)
 
#define LSM303AGR_CTRL_REG1_A_LPEN   (1 << 3)
 
#define LSM303AGR_CTRL_REG1_A_ODR0   (1 << 4)
 
#define LSM303AGR_CTRL_REG1_A_ODR1   (1 << 5)
 
#define LSM303AGR_CTRL_REG1_A_ODR2   (1 << 6)
 
#define LSM303AGR_CTRL_REG1_A_ODR3   (1 << 7)
 

LSM303AGR_CTRL_REG2_A register bits definitions

#define LSM303AGR_CTRL_REG2_A_HPIS1   (1 << 0)
 
#define LSM303AGR_CTRL_REG2_A_HPIS2   (1 << 1)
 
#define LSM303AGR_CTRL_REG2_A_HPCLICK   (1 << 2)
 
#define LSM303AGR_CTRL_REG2_A_FDS   (1 << 3)
 
#define LSM303AGR_CTRL_REG2_A_HPCF1   (1 << 4)
 
#define LSM303AGR_CTRL_REG2_A_HPCF2   (1 << 5)
 
#define LSM303AGR_CTRL_REG2_A_HPM0   (1 << 6)
 
#define LSM303AGR_CTRL_REG2_A_HPM1   (1 << 7)
 

LSM303AGR_CTRL_REG3_A register bits definitions

#define LSM303AGR_CTRL_REG3_A_I1_OVERRUN   (1 << 1)
 
#define LSM303AGR_CTRL_REG3_A_I1_WTM   (1 << 2)
 
#define LSM303AGR_CTRL_REG3_A_I1_DRDY2   (1 << 3)
 
#define LSM303AGR_CTRL_REG3_A_I1_DRDY1   (1 << 4)
 
#define LSM303AGR_CTRL_REG3_A_I1_AOI2   (1 << 5)
 
#define LSM303AGR_CTRL_REG3_A_I1_AOI1   (1 << 6)
 
#define LSM303AGR_CTRL_REG3_A_I1_CLICK   (1 << 7)
 

LSM303AGR_CTRL_REG4_A register bits definitions

#define LSM303AGR_CTRL_REG4_A_SPI_ENABLE   (1 << 0)
 
#define LSM303AGR_CTRL_REG4_A_ST0   (1 << 1)
 
#define LSM303AGR_CTRL_REG4_A_ST1   (1 << 2)
 
#define LSM303AGR_CTRL_REG4_A_HR   (1 << 3)
 
#define LSM303AGR_CTRL_REG4_A_FS_MASK   0x30
 
#define LSM303AGR_CTRL_REG4_A_FS0   (1 << 4)
 
#define LSM303AGR_CTRL_REG4_A_FS1   (1 << 5)
 
#define LSM303AGR_CTRL_REG4_A_BLE   (1 << 6)
 
#define LSM303AGR_CTRL_REG4_A_BDU   (1 << 7)
 

LSM303AGR_CTRL_REG5_A register bits definitions

#define LSM303AGR_CTRL_REG5_A_D4D_INT2   (1 << 0)
 
#define LSM303AGR_CTRL_REG5_A_LIR_INT2   (1 << 1)
 
#define LSM303AGR_CTRL_REG5_A_D4D_INT1   (1 << 2)
 
#define LSM303AGR_CTRL_REG5_A_LIR_INT1   (1 << 3)
 
#define LSM303AGR_CTRL_REG5_A_FIFO_EN   (1 << 6)
 
#define LSM303AGR_CTRL_REG5_A_BOOT   (1 << 7)
 

LSM303AGR_CTRL_REG6_A register bits definitions

#define LSM303AGR_CTRL_REG6_A_H_LACTIVE   (1 << 1)
 
#define LSM303AGR_CTRL_REG6_A_P2_ACT   (1 << 3)
 
#define LSM303AGR_CTRL_REG6_A_BOOT_I2   (1 << 4)
 
#define LSM303AGR_CTRL_REG6_A_I2_INT2   (1 << 5)
 
#define LSM303AGR_CTRL_REG6_A_I2_INT1   (1 << 6)
 
#define LSM303AGR_CTRL_REG6_A_I2_CLICKEN   (1 << 7)
 

LSM303AGR_CFG_REG_A register bits definitions

#define LSM303AGR_CFG_REG_A_M_MD0   (1 << 0)
 
#define LSM303AGR_CFG_REG_A_M_MD1   (1 << 1)
 
#define LSM303AGR_CFG_REG_A_M_ODR0   (1 << 2)
 
#define LSM303AGR_CFG_REG_A_M_ODR1   (1 << 3)
 
#define LSM303AGR_CFG_REG_A_M_LP   (1 << 4)
 
#define LSM303AGR_CFG_REG_A_M_SOFT_RST   (1 << 5)
 
#define LSM303AGR_CFG_REG_A_M_REBOOT   (1 << 6)
 
#define LSM303AGR_CFG_REG_A_M_COMP_TEMP_EN   (1 << 7)
 

LSM303AGR_CFG_REG_B register bits definitions

#define LSM303AGR_CFG_REG_B_M_LPF   (1 << 0)
 
#define LSM303AGR_CFG_REG_B_M_OFF_CANC   (1 << 1)
 
#define LSM303AGR_CFG_REG_B_M_SET_FREQ   (1 << 2)
 
#define LSM303AGR_CFG_REG_B_M_INT_ON   (1 << 3)
 
#define LSM303AGR_CFG_REG_B_M_OFF_CANC_OS   (1 << 4)
 

LSM303AGR_CFG_REG_C register bits definitions

#define LSM303AGR_CFG_REG_C_M_INT_MAG   (1 << 0)
 
#define LSM303AGR_CFG_REG_C_M_SELF_TEST   (1 << 1)
 
#define LSM303AGR_CFG_REG_C_M_BLE   (1 << 3)
 
#define LSM303AGR_CFG_REG_C_M_BDU   (1 << 4)
 
#define LSM303AGR_CFG_REG_C_M_I2C_DIS   (1 << 5)
 
#define LSM303AGR_CFG_REG_C_M_INT_MAG_PIN   (1 << 6)
 

Configuration options

#define LSM303AGR_USE_SPI   FALSE
 LSM303AGR SPI interface switch. More...
 
#define LSM303AGR_SHARED_SPI   FALSE
 LSM303AGR shared SPI switch. More...
 
#define LSM303AGR_USE_I2C   TRUE
 LSM303AGR I2C interface switch. More...
 
#define LSM303AGR_SHARED_I2C   FALSE
 LSM303AGR shared I2C switch. More...
 
#define LSM303AGR_USE_ADVANCED   FALSE
 LSM303AGR advanced configurations switch. More...
 

LSM303AGR accelerometer subsystem data structures and types.

enum  lsm303agr_acc_fs_t { LSM303AGR_ACC_FS_2G = 0x00, LSM303AGR_ACC_FS_4G = 0x10, LSM303AGR_ACC_FS_8G = 0x20, LSM303AGR_ACC_FS_16G = 0x30 }
 LSM303AGR accelerometer subsystem full scale. More...
 
enum  lsm303agr_acc_odr_t {
  LSM303AGR_ACC_ODR_PD = 0x00, LSM303AGR_ACC_ODR_1Hz = 0x10, LSM303AGR_ACC_ODR_10Hz = 0x20, LSM303AGR_ACC_ODR_25Hz = 0x30,
  LSM303AGR_ACC_ODR_50Hz = 0x40, LSM303AGR_ACC_ODR_100Hz = 0x50, LSM303AGR_ACC_ODR_200Hz = 0x60, LSM303AGR_ACC_ODR_400Hz = 0x70,
  LSM303AGR_ACC_ODR_1620Hz = 0x80, LSM303AGR_ACC_ODR_1344Hz = 0x90
}
 LSM303AGR accelerometer subsystem output data rate. More...
 
enum  lsm303agr_acc_ae_t {
  LSM303AGR_ACC_AE_DISABLED = 0x00, LSM303AGR_ACC_AE_X = 0x01, LSM303AGR_ACC_AE_Y = 0x02, LSM303AGR_ACC_AE_XY = 0x03,
  LSM303AGR_ACC_AE_Z = 0x04, LSM303AGR_ACC_AE_XZ = 0x05, LSM303AGR_ACC_AE_YZ = 0x06, LSM303AGR_ACC_AE_XYZ = 0x07
}
 LSM303AGR accelerometer subsystem axes enabling. More...
 
enum  lsm303agr_acc_mode_t { LSM303AGR_ACC_MODE_NORM = 0, LSM303AGR_ACC_MODE_LPOW = 1, LSM303AGR_ACC_MODE_HRES = 2 }
 LSM303AGR accelerometer subsystem operation mode. More...
 
enum  lsm303agr_acc_bdu_t { LSM303AGR_ACC_BDU_CONT = 0x00, LSM303AGR_ACC_BDU_BLOCK = 0x80 }
 LSM303AGR accelerometer subsystem block data update. More...
 
enum  lsm303agr_acc_end_t { LSM303AGR_ACC_END_LITTLE = 0x00, LSM303AGR_ACC_END_BIG = 0x40 }
 LSM303AGR accelerometer endianness. More...
 
typedef struct LSM303AGRDriver LSM303AGRDriver
 Structure representing a LSM303AGR driver. More...
 

LSM303AGR compass subsystem data structures and types.

enum  lsm303agr_comp_odr_t { LSM303AGR_COMP_ODR_10HZ = 0x00, LSM303AGR_COMP_ODR_20HZ = 0x04, LSM303AGR_COMP_ODR_50HZ = 0x08, LSM303AGR_COMP_ODR_100HZ = 0x0C }
 LSM303AGR compass subsystem output data rate. More...
 
enum  lsm303agr_comp_mode_t { LSM303AGR_COMP_MODE_NORM = 0x00, LSM303AGR_COMP_MODE_SINGLE = 0x01, LSM303AGR_COMP_MODE_IDLE = 0x02 }
 LSM303AGR compass subsystem working mode. More...
 
enum  lsm303agr_comp_lpow_t { LSM303AGR_COMP_LPOW_DIS = 0x00, LSM303AGR_COMP_LPOW_EN = 0x10 }
 LSM303AGR compass subsystem working mode. More...
 

LSM303AGR main system data structures and types.

enum  lsm303agr_state_t { LSM303AGR_UNINIT = 0, LSM303AGR_STOP = 1, LSM303AGR_READY = 2 }
 Driver state machine possible states. More...
 
#define _lsm303agr_methods_alone
 LSM303AGR specific methods. More...
 
#define _lsm303agr_methods
 LSM303AGR specific methods with inherited ones. More...
 
#define _lsm303agr_data
 LSM303AGRDriver specific data. More...
 

Data Structures

struct  LSM303AGRConfig
 LSM303AGR configuration structure. More...
 
struct  LSM303AGRVMT
 LSM303AGR virtual methods table. More...
 
struct  LSM303AGRDriver
 LSM303AGR 6-axis accelerometer/compass class. More...
 

Functions

static msg_t lsm303agrI2CReadRegister (I2CDriver *i2cp, lsm303agr_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
 Reads registers value using I2C. More...
 
static msg_t lsm303agrI2CWriteRegister (I2CDriver *i2cp, lsm303agr_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 (LSM303AGRDriver *devp, lsm303agr_acc_fs_t fs)
 Changes the LSM303AGRDriver 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...
 
void lsm303agrObjectInit (LSM303AGRDriver *devp)
 Initializes an instance. More...
 
void lsm303agrStart (LSM303AGRDriver *devp, const LSM303AGRConfig *config)
 Configures and activates LSM303AGR Complex Driver peripheral. More...
 
void lsm303agrStop (LSM303AGRDriver *devp)
 Deactivates the LSM303AGR Complex Driver peripheral. More...
 

Enumerations

enum  lsm303agr_sad_t { LSM303AGR_SAD_ACC = 0x19, LSM303AGR_SAD_COMP = 0x1E }
 Accelerometer and Compass Slave Address. More...
 

Macro Definition Documentation

◆ EX_LSM303AGR_VERSION

#define EX_LSM303AGR_VERSION   "1.0.1"

LSM303AGR driver version string.

Definition at line 46 of file lsm303agr.h.

◆ EX_LSM303AGR_MAJOR

#define EX_LSM303AGR_MAJOR   1

LSM303AGR driver version major number.

Definition at line 51 of file lsm303agr.h.

◆ EX_LSM303AGR_MINOR

#define EX_LSM303AGR_MINOR   0

LSM303AGR driver version minor number.

Definition at line 56 of file lsm303agr.h.

◆ EX_LSM303AGR_PATCH

#define EX_LSM303AGR_PATCH   1

LSM303AGR driver version patch number.

Definition at line 61 of file lsm303agr.h.

◆ LSM303AGR_ACC_NUMBER_OF_AXES

#define LSM303AGR_ACC_NUMBER_OF_AXES   3U

LSM303AGR 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 lsm303agr.h.

◆ LSM303AGR_COMP_NUMBER_OF_AXES

#define LSM303AGR_COMP_NUMBER_OF_AXES   3U

LSM303AGR 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 lsm303agr.h.

◆ LSM303AGR_USE_SPI

#define LSM303AGR_USE_SPI   FALSE

LSM303AGR SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is FALSE.

Definition at line 318 of file lsm303agr.h.

◆ LSM303AGR_SHARED_SPI

#define LSM303AGR_SHARED_SPI   FALSE

LSM303AGR 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 328 of file lsm303agr.h.

◆ LSM303AGR_USE_I2C

#define LSM303AGR_USE_I2C   TRUE

LSM303AGR I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is TRUE.

Definition at line 337 of file lsm303agr.h.

◆ LSM303AGR_SHARED_I2C

#define LSM303AGR_SHARED_I2C   FALSE

LSM303AGR 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 347 of file lsm303agr.h.

◆ LSM303AGR_USE_ADVANCED

#define LSM303AGR_USE_ADVANCED   FALSE

LSM303AGR advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 356 of file lsm303agr.h.

◆ _lsm303agr_methods_alone

#define _lsm303agr_methods_alone
Value:
/* Change full scale value of LSM303AGR accelerometer subsystem.*/ \
lsm303agr_acc_fs_t fs);

LSM303AGR specific methods.

Definition at line 584 of file lsm303agr.h.

◆ _lsm303agr_methods

#define _lsm303agr_methods
Value:
_base_object_methods \
_lsm303agr_methods_alone

LSM303AGR specific methods with inherited ones.

Definition at line 592 of file lsm303agr.h.

◆ _lsm303agr_data

#define _lsm303agr_data
Value:
/* Driver state.*/ \
lsm303agr_state_t state; \
/* Current configuration data.*/ \
const LSM303AGRConfig *config; \
/* Accelerometer subsystem axes number.*/ \
size_t accaxes; \
/* Accelerometer subsystem current sensitivity.*/ \
float accsensitivity[LSM303AGR_ACC_NUMBER_OF_AXES]; \
/* Accelerometer subsystem current bias .*/ \
float accbias[LSM303AGR_ACC_NUMBER_OF_AXES]; \
/* Accelerometer subsystem current full scale value.*/ \
float accfullscale; \
/* Compass subsystem axes number.*/ \
size_t compaxes; \
/* Compass subsystem current sensitivity.*/ \
float compsensitivity[LSM303AGR_COMP_NUMBER_OF_AXES]; \
/* Compass subsystem current bias.*/ \
float compbias[LSM303AGR_COMP_NUMBER_OF_AXES]; \
/* Compass subsystem current full scale value.*/ \
float compfullscale;

LSM303AGRDriver specific data.

Definition at line 608 of file lsm303agr.h.

◆ lsm303agrAccelerometerGetAxesNumber

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

Return the number of axes of the BaseAccelerometer.

Parameters
[in]devppointer to LSM303AGRDriver.
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 658 of file lsm303agr.h.

◆ lsm303agrAccelerometerReadRaw

#define lsm303agrAccelerometerReadRaw (   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 LSM303AGRDriver.
[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 679 of file lsm303agr.h.

◆ lsm303agrAccelerometerReadCooked

#define lsm303agrAccelerometerReadCooked (   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 LSM303AGRDriver.
[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 701 of file lsm303agr.h.

◆ lsm303agrAccelerometerSetBias

#define lsm303agrAccelerometerSetBias (   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 LSM303AGRDriver.
[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 718 of file lsm303agr.h.

◆ lsm303agrAccelerometerResetBias

#define lsm303agrAccelerometerResetBias (   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 LSM303AGRDriver.
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 733 of file lsm303agr.h.

◆ lsm303agrAccelerometerSetSensitivity

#define lsm303agrAccelerometerSetSensitivity (   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 LSM303AGRDriver.
[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 750 of file lsm303agr.h.

◆ lsm303agrAccelerometerResetSensitivity

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

Reset sensitivity values for the BaseAccelerometer.

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

◆ lsm303agrAccelerometerSetFullScale

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

Changes the LSM303AGRDriver 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 LSM303AGRDriver.
[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 783 of file lsm303agr.h.

◆ lsm303agrCompassGetAxesNumber

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

Return the number of axes of the BaseCompass.

Parameters
[in]devppointer to LSM303AGRDriver.
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 795 of file lsm303agr.h.

◆ lsm303agrCompassReadRaw

#define lsm303agrCompassReadRaw (   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 816 of file lsm303agr.h.

◆ lsm303agrCompassReadCooked

#define lsm303agrCompassReadCooked (   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 838 of file lsm303agr.h.

◆ lsm303agrCompassSetBias

#define lsm303agrCompassSetBias (   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 855 of file lsm303agr.h.

◆ lsm303agrCompassResetBias

#define lsm303agrCompassResetBias (   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 LSM303AGRDriver.
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 870 of file lsm303agr.h.

◆ lsm303agrCompassSetSensitivity

#define lsm303agrCompassSetSensitivity (   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 LSM303AGRDriver.
[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 887 of file lsm303agr.h.

◆ lsm303agrCompassResetSensitivity

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

Reset sensitivity values for the BaseCompass.

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

Typedef Documentation

◆ LSM303AGRDriver

Structure representing a LSM303AGR driver.

Definition at line 402 of file lsm303agr.h.

Enumeration Type Documentation

◆ lsm303agr_sad_t

Accelerometer and Compass Slave Address.

Enumerator
LSM303AGR_SAD_ACC 

SAD for accelerometer.

LSM303AGR_SAD_COMP 

SAD for compass.

Definition at line 48 of file lsm303agr.c.

◆ lsm303agr_acc_fs_t

LSM303AGR accelerometer subsystem full scale.

Enumerator
LSM303AGR_ACC_FS_2G 

Full scale �2g.

LSM303AGR_ACC_FS_4G 

Full scale �4g.

LSM303AGR_ACC_FS_8G 

Full scale �8g.

LSM303AGR_ACC_FS_16G 

Full scale �16g.

Definition at line 407 of file lsm303agr.h.

◆ lsm303agr_acc_odr_t

LSM303AGR accelerometer subsystem output data rate.

Enumerator
LSM303AGR_ACC_ODR_PD 

Power down

LSM303AGR_ACC_ODR_1Hz 

ODR 1 Hz

LSM303AGR_ACC_ODR_10Hz 

ODR 10 Hz

LSM303AGR_ACC_ODR_25Hz 

ODR 25 Hz

LSM303AGR_ACC_ODR_50Hz 

ODR 50 Hz

LSM303AGR_ACC_ODR_100Hz 

ODR 100 Hz

LSM303AGR_ACC_ODR_200Hz 

ODR 200 Hz

LSM303AGR_ACC_ODR_400Hz 

ODR 400 Hz

LSM303AGR_ACC_ODR_1620Hz 

ODR 1620 Hz (LP only)

LSM303AGR_ACC_ODR_1344Hz 

ODR 1344 Hz or 5376 Hz in LP

Definition at line 417 of file lsm303agr.h.

◆ lsm303agr_acc_ae_t

LSM303AGR accelerometer subsystem axes enabling.

Enumerator
LSM303AGR_ACC_AE_DISABLED 

All axes disabled.

LSM303AGR_ACC_AE_X 

Only X-axis enabled.

LSM303AGR_ACC_AE_Y 

Only Y-axis enabled.

LSM303AGR_ACC_AE_XY 

X and Y axes enabled.

LSM303AGR_ACC_AE_Z 

Only Z-axis enabled.

LSM303AGR_ACC_AE_XZ 

X and Z axes enabled.

LSM303AGR_ACC_AE_YZ 

Y and Z axes enabled.

LSM303AGR_ACC_AE_XYZ 

All axes enabled.

Definition at line 433 of file lsm303agr.h.

◆ lsm303agr_acc_mode_t

LSM303AGR accelerometer subsystem operation mode.

Enumerator
LSM303AGR_ACC_MODE_NORM 

Normal mode.

LSM303AGR_ACC_MODE_LPOW 

Low power mode.

LSM303AGR_ACC_MODE_HRES 

High resolution mode.

Definition at line 447 of file lsm303agr.h.

◆ lsm303agr_acc_bdu_t

LSM303AGR accelerometer subsystem block data update.

Enumerator
LSM303AGR_ACC_BDU_CONT 

Continuous update

LSM303AGR_ACC_BDU_BLOCK 

Update blocked

Definition at line 456 of file lsm303agr.h.

◆ lsm303agr_acc_end_t

LSM303AGR accelerometer endianness.

Enumerator
LSM303AGR_ACC_END_LITTLE 

Little Endian

LSM303AGR_ACC_END_BIG 

Big Endian

Definition at line 464 of file lsm303agr.h.

◆ lsm303agr_comp_odr_t

LSM303AGR compass subsystem output data rate.

Enumerator
LSM303AGR_COMP_ODR_10HZ 

ODR 10 Hz

LSM303AGR_COMP_ODR_20HZ 

ODR 20 Hz

LSM303AGR_COMP_ODR_50HZ 

ODR 50 Hz

LSM303AGR_COMP_ODR_100HZ 

ODR 100 Hz

Definition at line 477 of file lsm303agr.h.

◆ lsm303agr_comp_mode_t

LSM303AGR compass subsystem working mode.

Enumerator
LSM303AGR_COMP_MODE_NORM 

Continuous-Conversion Mode

LSM303AGR_COMP_MODE_SINGLE 

Single-Conversion Mode

LSM303AGR_COMP_MODE_IDLE 

Sleep Mode

Definition at line 487 of file lsm303agr.h.

◆ lsm303agr_comp_lpow_t

LSM303AGR compass subsystem working mode.

Enumerator
LSM303AGR_COMP_LPOW_DIS 

High Resolution Mode

LSM303AGR_COMP_LPOW_EN 

Low Power Mode

Definition at line 496 of file lsm303agr.h.

◆ lsm303agr_state_t

Driver state machine possible states.

Enumerator
LSM303AGR_UNINIT 

Not initialized.

LSM303AGR_STOP 

Stopped.

LSM303AGR_READY 

Ready.

Definition at line 509 of file lsm303agr.h.

Function Documentation

◆ lsm303agrI2CReadRegister()

static msg_t lsm303agrI2CReadRegister ( I2CDriver i2cp,
lsm303agr_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 lsm303agr.c.

Referenced by acc_read_raw(), and comp_read_raw().

◆ lsm303agrI2CWriteRegister()

static msg_t lsm303agrI2CWriteRegister ( I2CDriver i2cp,
lsm303agr_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 lsm303agr.c.

◆ acc_get_axes_number()

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 lsm303agr.c.

References LSM303AGR_ACC_NUMBER_OF_AXES.

◆ acc_read_raw()

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 lsm303agr.c.

References I2C_READY, i2cAcquireBus(), i2cStart(), LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, LSM303AGR_SAD_ACC, lsm303agrI2CReadRegister(), objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_read_cooked().

Here is the call graph for this function:

◆ acc_read_cooked()

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 lsm303agr.c.

References acc_read_raw(), LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:

◆ acc_set_bias()

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 lsm303agr.c.

References LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ acc_reset_bias()

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 lsm303agr.c.

References LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ acc_set_sensivity()

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 lsm303agr.c.

References LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ acc_reset_sensivity()

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 lsm303agr.c.

References LSM303AGR_ACC_FS_2G, LSM303AGR_ACC_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ acc_set_full_scale()

static msg_t acc_set_full_scale ( LSM303AGRDriver devp,
lsm303agr_acc_fs_t  fs 
)
static

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

Definition at line 355 of file lsm303agr.c.

References I2C_READY, LSM303AGR_ACC_FS_2G, LSM303AGR_READY, osalDbgAssert, and osalDbgCheck.

◆ comp_get_axes_number()

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 445 of file lsm303agr.c.

References LSM303AGR_COMP_NUMBER_OF_AXES, and osalDbgCheck.

◆ comp_read_raw()

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 467 of file lsm303agr.c.

References I2C_READY, i2cAcquireBus(), i2cStart(), LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, LSM303AGR_SAD_COMP, lsm303agrI2CReadRegister(), objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by comp_read_cooked().

Here is the call graph for this function:

◆ comp_read_cooked()

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 521 of file lsm303agr.c.

References comp_read_raw(), LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:

◆ comp_set_bias()

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 555 of file lsm303agr.c.

References LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ comp_reset_bias()

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 584 of file lsm303agr.c.

References LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ comp_set_sensivity()

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 614 of file lsm303agr.c.

References LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ comp_reset_sensivity()

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 643 of file lsm303agr.c.

References LSM303AGR_COMP_NUMBER_OF_AXES, LSM303AGR_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ lsm303agrObjectInit()

void lsm303agrObjectInit ( LSM303AGRDriver devp)

Initializes an instance.

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

Definition at line 690 of file lsm303agr.c.

References LSM303AGRDriver::vmt.

◆ lsm303agrStart()

void lsm303agrStart ( LSM303AGRDriver devp,
const LSM303AGRConfig config 
)

Configures and activates LSM303AGR Complex Driver peripheral.

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

Definition at line 711 of file lsm303agr.c.

References LSM303AGR_READY, LSM303AGR_STOP, osalDbgAssert, and osalDbgCheck.

◆ lsm303agrStop()

void lsm303agrStop ( LSM303AGRDriver devp)

Deactivates the LSM303AGR Complex Driver peripheral.

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

Definition at line 873 of file lsm303agr.c.

References i2cAcquireBus(), i2cStart(), LSM303AGR_READY, LSM303AGR_STOP, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:
LSM303AGR_ACC_NUMBER_OF_AXES
#define LSM303AGR_ACC_NUMBER_OF_AXES
LSM303AGR accelerometer subsystem characteristics.
Definition: lsm303agr.h:72
acc_set_full_scale
static msg_t acc_set_full_scale(LIS302DLDriver *devp, lis302dl_acc_fs_t fs)
Changes the LIS302DLDriver accelerometer fullscale value.
Definition: lis302dl.c:332
LSM303AGRDriver
LSM303AGR 6-axis accelerometer/compass class.
Definition: lsm303agr.h:634
LSM303AGR_COMP_NUMBER_OF_AXES
#define LSM303AGR_COMP_NUMBER_OF_AXES
LSM303AGR compass subsystem characteristics.
Definition: lsm303agr.h:94
_base_sensor_data
#define _base_sensor_data
BaseSensor specific data.
Definition: ex_sensors.h:74
LSM303AGRConfig
LSM303AGR configuration structure.
Definition: lsm303agr.h:518