KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lsm303agr.h File Reference

Driver for the ST lsm303Agr Compass sensor, which unlike the name suggests quite incompable to the LSM303D.... More...

#include <stdint.h>
#include <stdbool.h>
#include "drv/wb/i2c.h"
#include "drv/i2c/lsm303.h"

Go to the source code of this file.

Data Structures

struct  Lsm303AgrMagCfg_
 Magnet configuration. More...
 
struct  Lsm303AgrAccCfg_
 Accelerator configuration structure. More...
 

Macros

#define LSM303AGR_ACC_PM_LOW_8BIT   0x1
 
#define LSM303AGR_ACC_PM_NORM_10BIT   0x0
 
#define LSM303AGR_ACC_PM_HIGH_12BIT   0x2
 
#define LSM303AGR_ACC_RATE_POWERDOWN   0x00
 
#define LSM303AGR_ACC_RATE_1HZ   0x01
 
#define LSM303AGR_ACC_RATE_10HZ   0x02
 
#define LSM303AGR_ACC_RATE_25HZ   0x03
 
#define LSM303AGR_ACC_RATE_50HZ   0x04
 
#define LSM303AGR_ACC_RATE_100HZ   0x05
 
#define LSM303AGR_ACC_RATE_200HZ   0x06
 
#define LSM303AGR_ACC_RATE_400HZ   0x07
 
#define LSM303AGR_ACC_RATE_LP_1620HZ   0x08
 
#define LSM303AGR_ACC_RATE_1344_LP5376HZ   0x09
 
#define LSM303AGR_ACC_FS_2G   0x00
 
#define LSM303AGR_ACC_FS_4G   0x01
 
#define LSM303AGR_ACC_FS_8G   0x02
 
#define LSM303AGR_ACC_FS_16G   0x03
 
#define LSM303AGR_MAG_RATE_10HZ   0x00
 
#define LSM303AGR_MAG_RATE_20HZ   0x01
 
#define LSM303AGR_MAG_RATE_50HZ   0x02
 
#define LSM303AGR_MAG_RATE_100HZ   0x03
 
#define LSM303AGR_MAG_MODE_CONTINUOUS   0x00
 
#define LSM303AGR_MAG_MODE_SINGLE   0x01
 
#define LSM303AGR_MAG_MODE_IDLE   0x02
 
#define LSM303AGR_ACC_HPCF_AGRESSIVE   0x0
 Highpass filter.
 
#define LSM303AGR_ACC_HPCF_STRONG   0x1
 
#define LSM303AGR_ACC_HPCF_MEDIUM   0x2
 
#define LSM303AGR_ACC_HPCF_LIGHT   0x3
 
#define LSM303AGR_MAG_CFG_DEFAULT
 DEfault magnet configuration. More...
 
#define LSM303AGR_ACC_CFG_DEFAULT
 Default accelerometer configuration. More...
 

Typedefs

typedef struct Lsm303AgrMagCfg_ Lsm303AgrMagCfg
 Magnet configuration.
 
typedef struct Lsm303AgrAccCfg_ Lsm303AgrAccCfg
 Accelerator configuration structure.
 

Functions

bool lsm303AgrMagRead (I2C_Device *dev, Lsm303Axis *result)
 Read the magnet information. More...
 
bool lsm303AgrMagCfg (I2C_Device *dev, Lsm303AgrMagCfg config)
 Set the Magnet configuration. More...
 
bool lsm303AgrTempRead (I2C_Device *dev, int16_t *result)
 Reads the temperature. More...
 
bool lsm303AgrHasTemp (I2C_Device *dev, bool *hasData)
 
bool lsm303AgrAccRead (I2C_Device *dev, Lsm303Axis *result)
 Read the accelerometer information. More...
 
bool lsm303AgrAccCfg (I2C_Device *dev, Lsm303AgrAccCfg config)
 Set the accelerometer configuration. More...
 
bool lsm303AgrValid (I2C_Device *dev, bool *isLSM303Agr)
 Checks whether or not the lsm303Agr is valid. More...
 

Detailed Description

Driver for the ST lsm303Agr Compass sensor, which unlike the name suggests quite incompable to the LSM303D....

IRQ / Fifo modes not supported.

Definition in file lsm303agr.h.

Macro Definition Documentation

#define LSM303AGR_ACC_CFG_DEFAULT
Value:
{\
.rate = LSM303AGR_ACC_RATE_POWERDOWN, \
.fs = LSM303AGR_ACC_FS_2G, \
.pm = LSM303AGR_ACC_PM_NORM_10BIT, \
.bdu = false, \
.temp = false, \
.fds= false \
}
#define LSM303AGR_ACC_HPCF_AGRESSIVE
Highpass filter.
Definition: lsm303agr.h:79

Default accelerometer configuration.

Definition at line 127 of file lsm303agr.h.

#define LSM303AGR_MAG_CFG_DEFAULT
Value:
{\
.mode = LSM303AGR_MAG_MODE_CONTINUOUS, \
.rate = LSM303AGR_MAG_RATE_10HZ, \
.tempCompEn = false, \
.lp = false, \
.offCanc = false, \
.lpf = false, \
.bdu = false \
}

DEfault magnet configuration.

Definition at line 101 of file lsm303agr.h.

Function Documentation

bool lsm303AgrAccCfg ( I2C_Device dev,
Lsm303AgrAccCfg  config 
)

Set the accelerometer configuration.

Parameters
devI2C WB device
configThe configuration structure.
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 223 of file lsm303agr.c.

bool lsm303AgrAccRead ( I2C_Device dev,
Lsm303Axis result 
)

Read the accelerometer information.

Parameters
devI2C WB device
addrI2C address
resultThe 3D accelerometer information
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 188 of file lsm303agr.c.

bool lsm303AgrMagCfg ( I2C_Device dev,
Lsm303AgrMagCfg  config 
)

Set the Magnet configuration.

Parameters
devI2C WB device
configThe configuration structure.
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 200 of file lsm303agr.c.

bool lsm303AgrMagRead ( I2C_Device dev,
Lsm303Axis result 
)

Read the magnet information.

Parameters
devI2C WB device
resultThe 3D magnet information
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 176 of file lsm303agr.c.

bool lsm303AgrTempRead ( I2C_Device dev,
int16_t *  result 
)

Reads the temperature.

Note
Oddly the documentation does not actually specify the scaling of the sensor.
The sensor uses the same pipeline as the accelerometer. So, if the accelerometer is not operational no temperature will be read.
Parameters
devI2C WB device
resultThe temperature.
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 146 of file lsm303agr.c.

bool lsm303AgrValid ( I2C_Device dev,
bool *  isLSM303Agr 
)

Checks whether or not the lsm303Agr is valid.

Parameters
devI2C WB device
isLSM303AgrPointer to boolean to be filled with true or false. true indicates the lsm303Agr was found and is valid. false indicates a device was found, but not an lsm303Agr
Return values
trueProcedure was a success.
falseProcedure failed

Definition at line 163 of file lsm303agr.c.