33 #ifndef LSM303DLHC_DEFAULT_ODR
34 #define LSM303DLHC_DEFAULT_ODR 0x90 //90 //normal 1.344khz, low power 5.376khz
37 #ifndef LSM303DLHC_DEFAULT_LP
38 #define LSM303DLHC_DEFAULT_LP 0x00 //low power disabled
41 #ifndef LSM303DLHC_DEFAULT_FS
42 #define LSM303DLHC_DEFAULT_FS 0x00 // +- 2G
45 #ifndef LSM303DLHC_DEFAULT_HR
46 #define LSM303DLHC_DEFAULT_HR 0x04 // high res enabled
49 #ifndef LSM303DLHC_DEFAULT_DO
50 #define LSM303DLHC_DEFAULT_DO (0x6 << 2) // Data Output Rate (75Hz)
53 #ifndef LSM303DLHC_DEFAULT_GN
54 #define LSM303DLHC_DEFAULT_GN (0x1 << 5) // Gain configuration (1 -> +- 1.3 Gauss)
57 #ifndef LSM303DLHC_DEFAULT_MD
58 #define LSM303DLHC_DEFAULT_MD 0x00 // Continious conversion mode
207 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
static void lsm303dlhc_acc_set_default_config(struct Lsm303dlhcAccConfig *c)
#define LSM303DLHC_REG_OUT_X_H_M
void lsm303dlhc_init(struct Lsm303dlhc *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Lsm303dlhc struct and set default config options.
#define LSM303DLHC_FS_MASK
#define LSM303DLHC_I1_DRDY1
#define Int16FromBuf(_buf, _idx)
bool_t i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
void lsm303dlhc_read(struct Lsm303dlhc *lsm)
#define LSM303DLHC_REG_MR_REG_M
static void lsm303dlhc_i2c_tx_reg(struct Lsm303dlhc *lsm, uint8_t reg, uint8_t val)
#define LSM303DLHC_ACC_ADDR
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
uint16_t len_r
Number of bytes to read/receive.
transaction successfully finished by I2C driver
#define LSM303DLHC_DEFAULT_ODR
uint8_t hres
high resolution output mode
transmit and receive transaction
#define LSM303DLHC_MD_MASK
volatile bool_t data_available
data ready flag
uint8_t lp_mode
Low power mode.
bool_t initialized
config done flag
struct i2c_periph * i2c_p
union Lsm303dlhc::@40 config
#define LSM303DLHC_GN_MASK
void lsm303dlhc_event(struct Lsm303dlhc *lsm)
#define LSM303DLHC_DEFAULT_MD
#define LSM303DLHC_DEFAULT_FS
#define LSM303DLHC_REG_CTRL_REG1_A
uint8_t len_w
Number of bytes to write/transmit.
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
#define LSM303DLHC_DEFAULT_LP
#define LSM303DLHC_REG_CRB_REG_M
transaction set to done by user level
#define LSM303DLHC_DEFAULT_HR
void lsm303dlhc_start_configure(struct Lsm303dlhc *lsm)
#define LSM303DLHC_DO0_MASK
union Lsm303dlhc::@39 data
enum I2CTransactionStatus status
Transaction status.
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
#define LSM303DLHC_REG_CTRL_REG4_A
uint8_t slave_addr
Slave address.
I2C peripheral structure.
#define LSM303DLHC_REG_OUT_X_L_A
union Lsm303dlhc::@38 init_status
static void lsm303dlhc_send_config(struct Lsm303dlhc *lsm)
Configuration function called once before normal use.
uint8_t mode
Measurement mode.
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
#define LSM303DLHC_DEFAULT_DO
struct i2c_transaction i2c_trans
transmit only transaction
static void lsm303dlhc_mag_set_default_config(struct Lsm303dlhcMagConfig *c)
#define LSM303DLHC_REG_CTRL_REG3_A
#define LSM303DLHC_ODR_MASK
uint8_t scale
full scale selection
#define LSM303DLHC_REG_CRA_REG_M
#define LSM303DLHC_DEFAULT_GN
enum I2CTransactionType type
Transaction type.
Driver for ST LSM303DLHC 3D accelerometer and magnetometer.