60 lsm->i2c_trans.buf[0] = reg;
61 lsm->i2c_trans.buf[1] =
val;
62 lsm->i2c_trans.len_r = 0;
63 lsm->i2c_trans.len_w = 2;
71 switch (lsm->init_status.acc) {
72 case LSM_CONF_ACC_CTRL_REG4_A:
75 (lsm->config.acc.hres & LSM303DLHC_DEFAULT_HR));
76 lsm->init_status.acc++;
78 case LSM_CONF_ACC_CTRL_REG1_A:
80 (lsm->config.acc.rate & LSM303DLHC_ODR_MASK) |
81 (lsm->config.acc.lp_mode & LSM303DLHC_LPen) |
83 lsm->init_status.acc++;
85 case LSM_CONF_ACC_CTRL_REG3_A:
87 lsm->init_status.acc++;
89 case LSM_CONF_ACC_DONE:
90 lsm->initialized =
true;
98 switch (lsm->init_status.mag) {
99 case LSM_CONF_MAG_CRA_REG_M:
101 lsm->init_status.mag++;
103 case LSM_CONF_MAG_CRB_REG_M:
105 lsm->init_status.mag++;
107 case LSM_CONF_MAG_MR_REG_M:
109 lsm->init_status.mag++;
111 case LSM_CONF_MAG_DONE:
112 lsm->initialized =
true;
125 if (lsm->init_status.acc == LSM_CONF_ACC_UNINIT) {
126 lsm->init_status.acc++;
128 lsm303dlhc_send_config(lsm);
132 if (lsm->init_status.mag == LSM_CONF_MAG_UNINIT) {
133 lsm->init_status.mag++;
146 if (!(lsm->initialized) || (lsm->initialized && lsm->i2c_trans.status ==
I2CTransDone)) {
149 lsm->i2c_trans.len_r = 6;
150 lsm->i2c_trans.len_w = 1;
154 if (lsm->initialized && lsm->i2c_trans.status ==
I2CTransDone) {
157 lsm->i2c_trans.len_r = 6;
158 lsm->i2c_trans.len_w = 1;
164 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
168 if (lsm->initialized) {
175 lsm->data_available =
true;
181 if (lsm->init_status.acc != LSM_CONF_ACC_UNINIT) {
184 lsm303dlhc_send_config(lsm);
187 lsm->init_status.acc--;
189 lsm303dlhc_send_config(lsm);
193 if (lsm->init_status.mag != LSM_CONF_MAG_UNINIT) {
196 lsm303dlhc_send_config(lsm);
199 lsm->init_status.mag--;
201 lsm303dlhc_send_config(lsm);