Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lsm303dlhc.h File Reference

Driver for ST LSM303DLHC 3D accelerometer and magnetometer. More...

#include "std.h"
#include "mcu_periph/i2c.h"
#include "math/pprz_algebra_int.h"
#include "peripherals/lsm303dlhc_regs.h"
+ Include dependency graph for lsm303dlhc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Lsm303dlhcAccConfig
 
struct  Lsm303dlhcMagConfig
 
struct  Lsm303dlhc
 
union  Lsm303dlhc.init_status
 
union  Lsm303dlhc.data
 
union  Lsm303dlhc.config
 

Enumerations

enum  Lsm303dlhcAccConfStatus {
  LSM_CONF_ACC_UNINIT, LSM_CONF_ACC_CTRL_REG4_A, LSM_CONF_ACC_CTRL_REG1_A, LSM_CONF_ACC_CTRL_REG3_A,
  LSM_CONF_ACC_DONE
}
 config status states More...
 
enum  Lsm303dlhcMagConfStatus {
  LSM_CONF_MAG_UNINIT, LSM_CONF_MAG_CRA_REG_M, LSM_CONF_MAG_CRB_REG_M, LSM_CONF_MAG_MR_REG_M,
  LSM_CONF_MAG_DONE
}
 config status states More...
 

Functions

void lsm303dlhc_init (struct Lsm303dlhc *lsm, struct i2c_periph *i2c_p, uint8_t addr)
 Initialize Lsm303dlhc struct and set default config options. More...
 
void lsm303dlhc_start_configure (struct Lsm303dlhc *lsm)
 
void lsm303dlhc_read (struct Lsm303dlhc *lsm)
 
void lsm303dlhc_event (struct Lsm303dlhc *lsm)
 
static void lsm303dlhc_periodic (struct Lsm303dlhc *lsm)
 convenience function: read or start configuration if not already initialized More...
 

Detailed Description

Driver for ST LSM303DLHC 3D accelerometer and magnetometer.

Definition in file lsm303dlhc.h.


Data Structure Documentation

struct Lsm303dlhcAccConfig

Definition at line 39 of file lsm303dlhc.h.

Data Fields
uint8_t hres high resolution output mode
uint8_t lp_mode Low power mode.
uint8_t rate Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
uint8_t scale full scale selection
struct Lsm303dlhcMagConfig

Definition at line 46 of file lsm303dlhc.h.

Data Fields
uint8_t gain Gain configuration (1 -> +- 1 Gauss)
uint8_t mode Measurement mode.
uint8_t rate Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
struct Lsm303dlhc

Definition at line 70 of file lsm303dlhc.h.

+ Collaboration diagram for Lsm303dlhc:
Data Fields
union Lsm303dlhc config
union Lsm303dlhc data
volatile bool_t data_available data ready flag
struct i2c_periph * i2c_p
struct i2c_transaction i2c_trans
union Lsm303dlhc init_status
bool_t initialized config done flag
union Lsm303dlhc.init_status

Definition at line 74 of file lsm303dlhc.h.

Data Fields
enum Lsm303dlhcAccConfStatus acc init status
enum Lsm303dlhcMagConfStatus mag init status
union Lsm303dlhc.data

Definition at line 79 of file lsm303dlhc.h.

Data Fields
int16_t value[3] data values accessible by channel index
struct Int16Vect3 vect data vector in acc coordinate system
union Lsm303dlhc.config

Definition at line 83 of file lsm303dlhc.h.

Data Fields
struct Lsm303dlhcAccConfig acc
struct Lsm303dlhcMagConfig mag

Enumeration Type Documentation

config status states

Enumerator
LSM_CONF_ACC_UNINIT 
LSM_CONF_ACC_CTRL_REG4_A 
LSM_CONF_ACC_CTRL_REG1_A 
LSM_CONF_ACC_CTRL_REG3_A 
LSM_CONF_ACC_DONE 

Definition at line 53 of file lsm303dlhc.h.

config status states

Enumerator
LSM_CONF_MAG_UNINIT 
LSM_CONF_MAG_CRA_REG_M 
LSM_CONF_MAG_CRB_REG_M 
LSM_CONF_MAG_MR_REG_M 
LSM_CONF_MAG_DONE 

Definition at line 62 of file lsm303dlhc.h.

Function Documentation

void lsm303dlhc_init ( struct Lsm303dlhc lsm,
struct i2c_periph i2c_p,
uint8_t  addr 
)

Initialize Lsm303dlhc struct and set default config options.

Parameters
lsmLsm303dlhc struct
i2c_pI2C peripheral to use
addrI2C address of Lsm303dlhc

Definition at line 82 of file lsm303dlhc.c.

References Lsm303dlhc::config, FALSE, Lsm303dlhc::i2c_p, Lsm303dlhc::i2c_trans, I2CTransDone, Lsm303dlhc::init_status, Lsm303dlhc::initialized, LSM303DLHC_ACC_ADDR, lsm303dlhc_acc_set_default_config(), lsm303dlhc_mag_set_default_config(), LSM_CONF_ACC_UNINIT, LSM_CONF_MAG_UNINIT, i2c_transaction::slave_addr, and i2c_transaction::status.

+ Here is the call graph for this function:

static void lsm303dlhc_periodic ( struct Lsm303dlhc lsm)
inlinestatic

convenience function: read or start configuration if not already initialized

Definition at line 100 of file lsm303dlhc.h.

References Lsm303dlhc::initialized, lsm303dlhc_read(), and lsm303dlhc_start_configure().

+ Here is the call graph for this function:

void lsm303dlhc_start_configure ( struct Lsm303dlhc lsm)

Definition at line 165 of file lsm303dlhc.c.

References Lsm303dlhc::i2c_trans, I2CTransDone, I2CTransSuccess, Lsm303dlhc::init_status, LSM303DLHC_ACC_ADDR, lsm303dlhc_send_config(), LSM_CONF_ACC_UNINIT, LSM_CONF_MAG_UNINIT, i2c_transaction::slave_addr, and i2c_transaction::status.

Referenced by lsm303dlhc_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: