Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
|
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"
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... | |
Driver for ST LSM303DLHC 3D accelerometer and magnetometer.
Definition in file lsm303dlhc.h.
struct Lsm303dlhcAccConfig |
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.
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 |
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.
void lsm303dlhc_event | ( | struct Lsm303dlhc * | lsm | ) |
Definition at line 209 of file lsm303dlhc.c.
References i2c_transaction::buf, Lsm303dlhc::data, Lsm303dlhc::data_available, Lsm303dlhc::i2c_trans, I2CTransDone, I2CTransFailed, I2CTransSuccess, Lsm303dlhc::init_status, Lsm303dlhc::initialized, Int16FromBuf, LSM303DLHC_ACC_ADDR, lsm303dlhc_send_config(), LSM_CONF_ACC_UNINIT, LSM_CONF_MAG_UNINIT, i2c_transaction::slave_addr, i2c_transaction::status, and TRUE.
void lsm303dlhc_init | ( | struct Lsm303dlhc * | lsm, |
struct i2c_periph * | i2c_p, | ||
uint8_t | addr | ||
) |
Initialize Lsm303dlhc struct and set default config options.
lsm | Lsm303dlhc struct |
i2c_p | I2C peripheral to use |
addr | I2C 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.
|
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().
void lsm303dlhc_read | ( | struct Lsm303dlhc * | lsm | ) |
Definition at line 185 of file lsm303dlhc.c.
References i2c_transaction::buf, Lsm303dlhc::i2c_p, i2c_submit(), Lsm303dlhc::i2c_trans, I2CTransDone, I2CTransTxRx, Lsm303dlhc::initialized, i2c_transaction::len_r, i2c_transaction::len_w, LSM303DLHC_ACC_ADDR, LSM303DLHC_REG_OUT_X_H_M, LSM303DLHC_REG_OUT_X_L_A, i2c_transaction::slave_addr, i2c_transaction::status, and i2c_transaction::type.
Referenced by lsm303dlhc_periodic(), and lsm303dlhc_send_config().
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().