Question
Question regarding implementation of LIS3DSH Standard C library.
Hi,
I was taking a look at the STMems Standard C Library for the LIS3DSH. The implementation of the function lis3dsh_status_get looks a bit weird as there are 2 calls to the lis3dsh_write_reg functions.
int32_t lis3dsh_status_get(stmdev_ctx_t *ctx, lis3dsh_status_var_t *val)
{
lis3dsh_ctrl_reg3_t ctrl_reg3;
lis3dsh_ctrl_reg6_t ctrl_reg6;
lis3dsh_stat_t stat;
int32_t ret;
ret = lis3dsh_read_reg(ctx, LIS3DSH_STAT, (uint8_t*)&stat, 1);
if (ret == 0) {
ret = lis3dsh_write_reg(ctx, LIS3DSH_CTRL_REG3, (uint8_t*)&ctrl_reg3, 1);
}
if (ret == 0) {
ret = lis3dsh_write_reg(ctx, LIS3DSH_CTRL_REG6, (uint8_t*)&ctrl_reg6, 1);
}
val->sw_reset = ctrl_reg3.strt;
val->boot = ctrl_reg6.boot;
val->drdy_xl = stat.drdy;
val->ovrn_xl = stat.dor;
return ret;
}Shouldn't lis3dsh_read_reg be called to get the values of the control reg 3 and 6? If the write reg functions are called, wouldn't it populate the ctrl reg with garbage values?
Thanks
