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

Driver for the ST LSM303Dx Compass sensor. 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  Lsm303DCfg_
 Generic LSM303D configuration. More...
 
struct  Lsm303DMagCfg_
 Magnet configuration. More...
 
struct  Lsm303DAccCfg_
 Accelerator configuration structure. More...
 

Macros

#define DRV_I2C_LSM303AGR_H_
 
#define LSM303D_MAGSCALE_2GAUSS   0x00
 
#define LSM303D_MAGSCALE_4GAUSS   0x01
 
#define LSM303D_MAGSCALE_8GAUSS   0x02
 
#define LSM303D_MAGSCALE_12GAUSS   0x03
 
#define LSM303D_MAGRATE_3HZ125   0x00
 
#define LSM303D_MAGRATE_6HZ25   0x01
 
#define LSM303D_MAGRATE_12HZ5   0x02
 
#define LSM303D_MAGRATE_25HZ   0x03
 
#define LSM303D_MAGRATE_50HZ   0x04
 
#define LSM303D_MAGRATE_100HZ   0x05
 
#define LSM303D_MAGRATE_DO_NOT_USE   0x06
 
#define LSM303D_MAGMODE_CONTINUOUS   0x00
 
#define LSM303D_MAGMODE_SINGLE   0x01
 
#define LSM303D_MAGMODE_POWERDOWN   0x02
 
#define LSM303D_ACCRATE_POWERDOWN   0x00
 
#define LSM303D_ACCRATE_3HZ125   0x01
 
#define LSM303D_ACCRATE_6HZ25   0x02
 
#define LSM303D_ACCRATE_12HZ5   0x03
 
#define LSM303D_ACCRATE_25HZ   0x04
 
#define LSM303D_ACCRATE_50HZ   0x05
 
#define LSM303D_ACCRATE_100HZ   0x06
 
#define LSM303D_ACCRATE_200HZ   0x07
 
#define LSM303D_ACCRATE_400HZ   0x08
 
#define LSM303D_ACCRATE_800HZ   0x09
 
#define LSM303D_ACCRATE_1600HZ   0x0A
 
#define LSM303D_ACCAAF_773HZ   0x00
 
#define LSM303D_ACCAAF_194HZ   0x01
 
#define LSM303D_ACCAAF_362HZ   0x02
 
#define LSM303D_ACCAAF_50HZ   0x03
 
#define LSM303D_ACCSCALE_2G   0x00
 
#define LSM303D_ACCSCALE_4G   0x01
 
#define LSM303D_ACCSCALE_6G   0x02
 
#define LSM303D_ACCSCALE_8G   0x03
 
#define LSM303D_ACCSCALE_16G   0x04
 
#define LSM303D_ACCHPF_NORMAL   0x00
 
#define LSM303D_ACCHPF_REFSIG   0x01
 
#define LSM303D_ACCHPF_AUTORESET   0x03
 
#define LSM303D_CFG_DEFAULT
 Default generic configuration. More...
 
#define LSM303D_MAGCFG_DEFAULT
 DEfault magnet configuration. More...
 
#define LSM303D_ACCCFG_DEFAULT
 Default accelerometer configuration. More...
 

Typedefs

typedef struct Lsm303DCfg_ Lsm303DCfg
 Generic LSM303D configuration.
 
typedef struct Lsm303DMagCfg_ Lsm303DMagCfg
 Magnet configuration.
 
typedef struct Lsm303DAccCfg_ Lsm303DAccCfg
 Accelerator configuration structure.
 

Functions

bool lsm303DMagnetRead (I2C_Device *dev, uint8_t addr, Lsm303Axis *result)
 Read the magnet information. More...
 
bool lsm303DMagnetCfg (I2C_Device *dev, uint8_t addr, Lsm303DMagCfg config)
 Set the Magnet configuration. More...
 
bool lsm303DTempRead (I2C_Device *dev, uint8_t addr, int16_t *result)
 Reads the temperature. More...
 
bool lsm303DAccelRead (I2C_Device *dev, uint8_t addr, Lsm303Axis *result)
 Read the accelerometer information. More...
 
bool lsm303DAccelCfg (I2C_Device *dev, uint8_t addr, Lsm303DAccCfg config)
 Set the accelerometer configuration. More...
 
bool lsm303DValid (I2C_Device *dev, uint8_t addr, bool *isLSM303)
 Checks whether or not the LSM303D is valid. More...
 
bool lsm303DCfg (I2C_Device *dev, uint8_t addr, Lsm303DCfg config)
 Sets the generic device configuration parameters. More...
 

Detailed Description

Driver for the ST LSM303Dx Compass sensor.

Definition in file lsm303d.h.

Macro Definition Documentation

#define LSM303D_ACCCFG_DEFAULT
Value:
{\
.accRate = LSM303D_ACCRATE_POWERDOWN, \
.accAAF = LSM303D_ACCAAF_773HZ, \
.accHPF = LSM303D_ACCHPF_NORMAL, \
.accScale = LSM303D_ACCSCALE_2G, \
.selfTest = false, \
.filterAcc= false}

Default accelerometer configuration.

Definition at line 128 of file lsm303d.h.

#define LSM303D_CFG_DEFAULT
Value:
{ \
.bdu = false, \
.temp = false, \
.tempOnly = false \
}

Default generic configuration.

Definition at line 89 of file lsm303d.h.

#define LSM303D_MAGCFG_DEFAULT
Value:
{\
.magScale = LSM303D_MAGSCALE_2GAUSS, \
.magRate = LSM303D_MAGRATE_DO_NOT_USE, /* oddly enough */ \
.magMode = LSM303D_MAGMODE_POWERDOWN, \
.lowPower = false, \
.hiRes = false }

DEfault magnet configuration.

Definition at line 107 of file lsm303d.h.

Function Documentation

bool lsm303DAccelCfg ( I2C_Device dev,
uint8_t  addr,
Lsm303DAccCfg  config 
)

Set the accelerometer configuration.

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

Definition at line 154 of file lsm303d.c.

bool lsm303DAccelRead ( I2C_Device dev,
uint8_t  addr,
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 118 of file lsm303d.c.

bool lsm303DCfg ( I2C_Device dev,
uint8_t  addr,
Lsm303DCfg  config 
)

Sets the generic device configuration parameters.

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

Definition at line 179 of file lsm303d.c.

bool lsm303DMagnetCfg ( I2C_Device dev,
uint8_t  addr,
Lsm303DMagCfg  config 
)

Set the Magnet configuration.

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

Definition at line 130 of file lsm303d.c.

bool lsm303DMagnetRead ( I2C_Device dev,
uint8_t  addr,
Lsm303Axis result 
)

Read the magnet information.

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

Definition at line 106 of file lsm303d.c.

bool lsm303DTempRead ( I2C_Device dev,
uint8_t  addr,
int16_t *  result 
)

Reads the temperature.

Note
Oddly the documentation does not actually specify the scaling of the sensor.
Parameters
devI2C WB device
addrI2C address
resultThe temperature.
Return values
trueProcedure was a success.
falseProcedure failed
bool lsm303DValid ( I2C_Device dev,
uint8_t  addr,
bool *  isLSM303 
)

Checks whether or not the LSM303D is valid.

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

Definition at line 92 of file lsm303d.c.