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...
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) |
Driver for ST LSM303DLHC 3D accelerometer and magnetometer.
Definition in file lsm303dlhc.c.
#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().
|
static |
Definition at line 61 of file lsm303dlhc.c.
References Lsm303dlhcAccConfig::hres, Lsm303dlhcAccConfig::lp_mode, LSM303DLHC_DEFAULT_FS, LSM303DLHC_DEFAULT_HR, LSM303DLHC_DEFAULT_LP, LSM303DLHC_DEFAULT_ODR, Lsm303dlhcAccConfig::rate, and Lsm303dlhcAccConfig::scale.
Referenced by lsm303dlhc_init().
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.
|
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().
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.
|
static |
Definition at line 69 of file lsm303dlhc.c.
References Lsm303dlhcMagConfig::gain, LSM303DLHC_DEFAULT_DO, LSM303DLHC_DEFAULT_GN, LSM303DLHC_DEFAULT_MD, LSM303DLHC_DO0_MASK, LSM303DLHC_GN_MASK, LSM303DLHC_MD_MASK, Lsm303dlhcMagConfig::mode, and Lsm303dlhcMagConfig::rate.
Referenced by lsm303dlhc_init().
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().
|
static |
Configuration function called once before normal use.
Definition at line 111 of file lsm303dlhc.c.
References Lsm303dlhc::config, Lsm303dlhc::i2c_trans, I2CTransDone, Lsm303dlhc::init_status, Lsm303dlhc::initialized, LSM303DLHC_ACC_ADDR, LSM303DLHC_DEFAULT_HR, LSM303DLHC_FS_MASK, LSM303DLHC_I1_DRDY1, lsm303dlhc_i2c_tx_reg(), LSM303DLHC_LPen, LSM303DLHC_ODR_MASK, lsm303dlhc_read(), LSM303DLHC_REG_CRA_REG_M, LSM303DLHC_REG_CRB_REG_M, LSM303DLHC_REG_CTRL_REG1_A, LSM303DLHC_REG_CTRL_REG3_A, LSM303DLHC_REG_CTRL_REG4_A, LSM303DLHC_REG_MR_REG_M, LSM303DLHC_Xen, LSM303DLHC_Yen, LSM303DLHC_Zen, LSM_CONF_ACC_CTRL_REG1_A, LSM_CONF_ACC_CTRL_REG3_A, LSM_CONF_ACC_CTRL_REG4_A, LSM_CONF_ACC_DONE, LSM_CONF_MAG_CRA_REG_M, LSM_CONF_MAG_CRB_REG_M, LSM_CONF_MAG_DONE, LSM_CONF_MAG_MR_REG_M, i2c_transaction::slave_addr, i2c_transaction::status, and TRUE.
Referenced by lsm303dlhc_event(), and lsm303dlhc_start_configure().
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().