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.c File Reference

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

#include "peripherals/lsm303dlhc.h"
#include "std.h"
+ Include dependency graph for lsm303dlhc.c:

Go to the source code of this file.

Macros

#define LSM303DLHC_DEFAULT_ODR   0x90
 
#define LSM303DLHC_DEFAULT_LP   0x00
 
#define LSM303DLHC_DEFAULT_FS   0x00
 
#define LSM303DLHC_DEFAULT_HR   0x04
 
#define LSM303DLHC_DEFAULT_DO   (0x6 << 2)
 
#define LSM303DLHC_DEFAULT_GN   (0x1 << 5)
 
#define LSM303DLHC_DEFAULT_MD   0x00
 
#define Int16FromBuf(_buf, _idx)   ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
 

Functions

static void lsm303dlhc_acc_set_default_config (struct Lsm303dlhcAccConfig *c)
 
static void lsm303dlhc_mag_set_default_config (struct Lsm303dlhcMagConfig *c)
 
void lsm303dlhc_init (struct Lsm303dlhc *lsm, struct i2c_periph *i2c_p, uint8_t addr)
 Initialize Lsm303dlhc struct and set default config options. More...
 
static void lsm303dlhc_i2c_tx_reg (struct Lsm303dlhc *lsm, uint8_t reg, uint8_t val)
 
static void lsm303dlhc_send_config (struct Lsm303dlhc *lsm)
 Configuration function called once before normal use. More...
 
void lsm303dlhc_start_configure (struct Lsm303dlhc *lsm)
 
void lsm303dlhc_read (struct Lsm303dlhc *lsm)
 
void lsm303dlhc_event (struct Lsm303dlhc *lsm)
 

Detailed Description

Driver for ST LSM303DLHC 3D accelerometer and magnetometer.

Definition in file lsm303dlhc.c.

Macro Definition Documentation

#define Int16FromBuf (   _buf,
  _idx 
)    ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))

Definition at line 207 of file lsm303dlhc.c.

Referenced by lsm303dlhc_event().

#define LSM303DLHC_DEFAULT_DO   (0x6 << 2)

Definition at line 50 of file lsm303dlhc.c.

Referenced by lsm303dlhc_mag_set_default_config().

#define LSM303DLHC_DEFAULT_FS   0x00

Definition at line 42 of file lsm303dlhc.c.

Referenced by lsm303dlhc_acc_set_default_config().

#define LSM303DLHC_DEFAULT_GN   (0x1 << 5)

Definition at line 54 of file lsm303dlhc.c.

Referenced by lsm303dlhc_mag_set_default_config().

#define LSM303DLHC_DEFAULT_HR   0x04

Definition at line 46 of file lsm303dlhc.c.

Referenced by lsm303dlhc_acc_set_default_config(), and lsm303dlhc_send_config().

#define LSM303DLHC_DEFAULT_LP   0x00

Definition at line 38 of file lsm303dlhc.c.

Referenced by lsm303dlhc_acc_set_default_config().

#define LSM303DLHC_DEFAULT_MD   0x00

Definition at line 58 of file lsm303dlhc.c.

Referenced by lsm303dlhc_mag_set_default_config().

#define LSM303DLHC_DEFAULT_ODR   0x90

Definition at line 34 of file lsm303dlhc.c.

Referenced by lsm303dlhc_acc_set_default_config().

Function Documentation

static void lsm303dlhc_acc_set_default_config ( struct Lsm303dlhcAccConfig c)
static
static void lsm303dlhc_i2c_tx_reg ( struct Lsm303dlhc lsm,
uint8_t  reg,
uint8_t  val 
)
static

Definition at line 100 of file lsm303dlhc.c.

References i2c_transaction::buf, Lsm303dlhc::i2c_p, i2c_submit(), Lsm303dlhc::i2c_trans, I2CTransTx, i2c_transaction::len_r, i2c_transaction::len_w, i2c_transaction::type, and val.

Referenced by lsm303dlhc_send_config().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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_mag_set_default_config ( struct Lsm303dlhcMagConfig c)
static
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: