LSM6DSO accelerometer and gyroscope sensor library
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Diff: lsm6dso_reg.c
- Revision:
- 3:4274d9103f1d
- Parent:
- 2:4d14e9edf37e
--- a/lsm6dso_reg.c Mon Jun 03 09:16:08 2019 +0000 +++ b/lsm6dso_reg.c Wed Jul 24 14:19:35 2019 +0000 @@ -63,12 +63,12 @@ * @retval interface status (MANDATORY: return 0 -> no Error) * */ -int32_t lsm6dso_read_reg(lsm6dso_ctx_t* ctx, uint8_t reg, uint8_t* data, +int32_t lsm6dso_read_reg(lsm6dso_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len) { - int32_t ret; - ret = ctx->read_reg(ctx->handle, reg, data, len); - return ret; + int32_t ret; + ret = ctx->read_reg(ctx->handle, reg, data, len); + return ret; } /** @@ -81,12 +81,12 @@ * @retval interface status (MANDATORY: return 0 -> no Error) * */ -int32_t lsm6dso_write_reg(lsm6dso_ctx_t* ctx, uint8_t reg, uint8_t* data, +int32_t lsm6dso_write_reg(lsm6dso_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len) { - int32_t ret; - ret = ctx->write_reg(ctx->handle, reg, data, len); - return ret; + int32_t ret; + ret = ctx->write_reg(ctx->handle, reg, data, len); + return ret; } /** @@ -102,57 +102,57 @@ */ float_t lsm6dso_from_fs2_to_mg(int16_t lsb) { - return ((float_t)lsb) * 0.061f; + return ((float_t)lsb) * 0.061f; } float_t lsm6dso_from_fs4_to_mg(int16_t lsb) { - return ((float_t)lsb) * 0.122f; + return ((float_t)lsb) * 0.122f; } float_t lsm6dso_from_fs8_to_mg(int16_t lsb) { - return ((float_t)lsb) * 0.244f; + return ((float_t)lsb) * 0.244f; } float_t lsm6dso_from_fs16_to_mg(int16_t lsb) { - return ((float_t)lsb) *0.488f; + return ((float_t)lsb) * 0.488f; } float_t lsm6dso_from_fs125_to_mdps(int16_t lsb) { - return ((float_t)lsb) *4.375f; + return ((float_t)lsb) * 4.375f; } float_t lsm6dso_from_fs500_to_mdps(int16_t lsb) { - return ((float_t)lsb) *17.50f; + return ((float_t)lsb) * 17.50f; } float_t lsm6dso_from_fs250_to_mdps(int16_t lsb) { - return ((float_t)lsb) *8.750f; + return ((float_t)lsb) * 8.750f; } float_t lsm6dso_from_fs1000_to_mdps(int16_t lsb) { - return ((float_t)lsb) *35.0f; + return ((float_t)lsb) * 35.0f; } float_t lsm6dso_from_fs2000_to_mdps(int16_t lsb) { - return ((float_t)lsb) *70.0f; + return ((float_t)lsb) * 70.0f; } float_t lsm6dso_from_lsb_to_celsius(int16_t lsb) { - return (((float_t)lsb / 256.0f) + 25.0f); + return (((float_t)lsb / 256.0f) + 25.0f); } float_t lsm6dso_from_lsb_to_nsec(int16_t lsb) { - return ((float_t)lsb * 25000.0f); + return ((float_t)lsb * 25000.0f); } /** @@ -177,15 +177,15 @@ int32_t lsm6dso_xl_full_scale_set(lsm6dso_ctx_t *ctx, lsm6dso_fs_xl_t val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.fs_xl = (uint8_t) val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.fs_xl = (uint8_t) val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -197,29 +197,29 @@ */ int32_t lsm6dso_xl_full_scale_get(lsm6dso_ctx_t *ctx, lsm6dso_fs_xl_t *val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - switch (reg.fs_xl) { - case LSM6DSO_2g: - *val = LSM6DSO_2g; - break; - case LSM6DSO_16g: - *val = LSM6DSO_16g; - break; - case LSM6DSO_4g: - *val = LSM6DSO_4g; - break; - case LSM6DSO_8g: - *val = LSM6DSO_8g; - break; - default: - *val = LSM6DSO_2g; - break; - } - - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + switch (reg.fs_xl) { + case LSM6DSO_2g: + *val = LSM6DSO_2g; + break; + case LSM6DSO_16g: + *val = LSM6DSO_16g; + break; + case LSM6DSO_4g: + *val = LSM6DSO_4g; + break; + case LSM6DSO_8g: + *val = LSM6DSO_8g; + break; + default: + *val = LSM6DSO_2g; + break; + } + + return ret; } /** @@ -231,15 +231,15 @@ */ int32_t lsm6dso_xl_data_rate_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_xl_t val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.odr_xl = (uint8_t) val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.odr_xl = (uint8_t) val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -251,53 +251,53 @@ */ int32_t lsm6dso_xl_data_rate_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_xl_t *val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - - switch (reg.odr_xl) { - case LSM6DSO_XL_ODR_OFF: - *val = LSM6DSO_XL_ODR_OFF; - break; - case LSM6DSO_XL_ODR_12Hz5: - *val = LSM6DSO_XL_ODR_12Hz5; - break; - case LSM6DSO_XL_ODR_26Hz: - *val = LSM6DSO_XL_ODR_26Hz; - break; - case LSM6DSO_XL_ODR_52Hz: - *val = LSM6DSO_XL_ODR_52Hz; - break; - case LSM6DSO_XL_ODR_104Hz: - *val = LSM6DSO_XL_ODR_104Hz; - break; - case LSM6DSO_XL_ODR_208Hz: - *val = LSM6DSO_XL_ODR_208Hz; - break; - case LSM6DSO_XL_ODR_417Hz: - *val = LSM6DSO_XL_ODR_417Hz; - break; - case LSM6DSO_XL_ODR_833Hz: - *val = LSM6DSO_XL_ODR_833Hz; - break; - case LSM6DSO_XL_ODR_1667Hz: - *val = LSM6DSO_XL_ODR_1667Hz; - break; - case LSM6DSO_XL_ODR_3333Hz: - *val = LSM6DSO_XL_ODR_3333Hz; - break; - case LSM6DSO_XL_ODR_6667Hz: - *val = LSM6DSO_XL_ODR_6667Hz; - break; - case LSM6DSO_XL_ODR_6Hz5: - *val = LSM6DSO_XL_ODR_6Hz5; - break; - default: - *val = LSM6DSO_XL_ODR_OFF; - break; - } - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + + switch (reg.odr_xl) { + case LSM6DSO_XL_ODR_OFF: + *val = LSM6DSO_XL_ODR_OFF; + break; + case LSM6DSO_XL_ODR_12Hz5: + *val = LSM6DSO_XL_ODR_12Hz5; + break; + case LSM6DSO_XL_ODR_26Hz: + *val = LSM6DSO_XL_ODR_26Hz; + break; + case LSM6DSO_XL_ODR_52Hz: + *val = LSM6DSO_XL_ODR_52Hz; + break; + case LSM6DSO_XL_ODR_104Hz: + *val = LSM6DSO_XL_ODR_104Hz; + break; + case LSM6DSO_XL_ODR_208Hz: + *val = LSM6DSO_XL_ODR_208Hz; + break; + case LSM6DSO_XL_ODR_417Hz: + *val = LSM6DSO_XL_ODR_417Hz; + break; + case LSM6DSO_XL_ODR_833Hz: + *val = LSM6DSO_XL_ODR_833Hz; + break; + case LSM6DSO_XL_ODR_1667Hz: + *val = LSM6DSO_XL_ODR_1667Hz; + break; + case LSM6DSO_XL_ODR_3333Hz: + *val = LSM6DSO_XL_ODR_3333Hz; + break; + case LSM6DSO_XL_ODR_6667Hz: + *val = LSM6DSO_XL_ODR_6667Hz; + break; + case LSM6DSO_XL_ODR_6Hz5: + *val = LSM6DSO_XL_ODR_6Hz5; + break; + default: + *val = LSM6DSO_XL_ODR_OFF; + break; + } + return ret; } /** @@ -309,16 +309,16 @@ */ int32_t lsm6dso_gy_full_scale_set(lsm6dso_ctx_t *ctx, lsm6dso_fs_g_t val) { - lsm6dso_ctrl2_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.fs_g = (uint8_t) val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl2_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.fs_g = (uint8_t) val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + } + + return ret; } /** @@ -330,32 +330,32 @@ */ int32_t lsm6dso_gy_full_scale_get(lsm6dso_ctx_t *ctx, lsm6dso_fs_g_t *val) { - lsm6dso_ctrl2_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - switch (reg.fs_g) { - case LSM6DSO_250dps: - *val = LSM6DSO_250dps; - break; - case LSM6DSO_125dps: - *val = LSM6DSO_125dps; - break; - case LSM6DSO_500dps: - *val = LSM6DSO_500dps; - break; - case LSM6DSO_1000dps: - *val = LSM6DSO_1000dps; - break; - case LSM6DSO_2000dps: - *val = LSM6DSO_2000dps; - break; - default: - *val = LSM6DSO_250dps; - break; - } - - return ret; + lsm6dso_ctrl2_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + switch (reg.fs_g) { + case LSM6DSO_250dps: + *val = LSM6DSO_250dps; + break; + case LSM6DSO_125dps: + *val = LSM6DSO_125dps; + break; + case LSM6DSO_500dps: + *val = LSM6DSO_500dps; + break; + case LSM6DSO_1000dps: + *val = LSM6DSO_1000dps; + break; + case LSM6DSO_2000dps: + *val = LSM6DSO_2000dps; + break; + default: + *val = LSM6DSO_250dps; + break; + } + + return ret; } /** @@ -367,16 +367,16 @@ */ int32_t lsm6dso_gy_data_rate_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_g_t val) { - lsm6dso_ctrl2_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.odr_g = (uint8_t) val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl2_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.odr_g = (uint8_t) val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + } + + return ret; } /** @@ -388,49 +388,49 @@ */ int32_t lsm6dso_gy_data_rate_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_g_t *val) { - lsm6dso_ctrl2_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t*)®, 1); - switch (reg.odr_g) { - case LSM6DSO_GY_ODR_OFF: - *val = LSM6DSO_GY_ODR_OFF; - break; - case LSM6DSO_GY_ODR_12Hz5: - *val = LSM6DSO_GY_ODR_12Hz5; - break; - case LSM6DSO_GY_ODR_26Hz: - *val = LSM6DSO_GY_ODR_26Hz; - break; - case LSM6DSO_GY_ODR_52Hz: - *val = LSM6DSO_GY_ODR_52Hz; - break; - case LSM6DSO_GY_ODR_104Hz: - *val = LSM6DSO_GY_ODR_104Hz; - break; - case LSM6DSO_GY_ODR_208Hz: - *val = LSM6DSO_GY_ODR_208Hz; - break; - case LSM6DSO_GY_ODR_417Hz: - *val = LSM6DSO_GY_ODR_417Hz; - break; - case LSM6DSO_GY_ODR_833Hz: - *val = LSM6DSO_GY_ODR_833Hz; - break; - case LSM6DSO_GY_ODR_1667Hz: - *val = LSM6DSO_GY_ODR_1667Hz; - break; - case LSM6DSO_GY_ODR_3333Hz: - *val = LSM6DSO_GY_ODR_3333Hz; - break; - case LSM6DSO_GY_ODR_6667Hz: - *val = LSM6DSO_GY_ODR_6667Hz; - break; - default: - *val = LSM6DSO_GY_ODR_OFF; - break; - } - return ret; + lsm6dso_ctrl2_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_G, (uint8_t *)®, 1); + switch (reg.odr_g) { + case LSM6DSO_GY_ODR_OFF: + *val = LSM6DSO_GY_ODR_OFF; + break; + case LSM6DSO_GY_ODR_12Hz5: + *val = LSM6DSO_GY_ODR_12Hz5; + break; + case LSM6DSO_GY_ODR_26Hz: + *val = LSM6DSO_GY_ODR_26Hz; + break; + case LSM6DSO_GY_ODR_52Hz: + *val = LSM6DSO_GY_ODR_52Hz; + break; + case LSM6DSO_GY_ODR_104Hz: + *val = LSM6DSO_GY_ODR_104Hz; + break; + case LSM6DSO_GY_ODR_208Hz: + *val = LSM6DSO_GY_ODR_208Hz; + break; + case LSM6DSO_GY_ODR_417Hz: + *val = LSM6DSO_GY_ODR_417Hz; + break; + case LSM6DSO_GY_ODR_833Hz: + *val = LSM6DSO_GY_ODR_833Hz; + break; + case LSM6DSO_GY_ODR_1667Hz: + *val = LSM6DSO_GY_ODR_1667Hz; + break; + case LSM6DSO_GY_ODR_3333Hz: + *val = LSM6DSO_GY_ODR_3333Hz; + break; + case LSM6DSO_GY_ODR_6667Hz: + *val = LSM6DSO_GY_ODR_6667Hz; + break; + default: + *val = LSM6DSO_GY_ODR_OFF; + break; + } + return ret; } /** @@ -442,15 +442,15 @@ */ int32_t lsm6dso_block_data_update_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.bdu = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.bdu = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -462,13 +462,13 @@ */ int32_t lsm6dso_block_data_update_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - *val = reg.bdu; - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + *val = reg.bdu; + + return ret; } /** @@ -482,15 +482,15 @@ int32_t lsm6dso_xl_offset_weight_set(lsm6dso_ctx_t *ctx, lsm6dso_usr_off_w_t val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.usr_off_w = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.usr_off_w = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -504,23 +504,23 @@ int32_t lsm6dso_xl_offset_weight_get(lsm6dso_ctx_t *ctx, lsm6dso_usr_off_w_t *val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - - switch (reg.usr_off_w) { - case LSM6DSO_LSb_1mg: - *val = LSM6DSO_LSb_1mg; - break; - case LSM6DSO_LSb_16mg: - *val = LSM6DSO_LSb_16mg; - break; - default: - *val = LSM6DSO_LSb_1mg; - break; - } - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + + switch (reg.usr_off_w) { + case LSM6DSO_LSb_1mg: + *val = LSM6DSO_LSb_1mg; + break; + case LSM6DSO_LSb_16mg: + *val = LSM6DSO_LSb_16mg; + break; + default: + *val = LSM6DSO_LSb_1mg; + break; + } + return ret; } /** @@ -534,23 +534,23 @@ int32_t lsm6dso_xl_power_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_xl_hm_mode_t val) { - lsm6dso_ctrl5_c_t ctrl5_c; - lsm6dso_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*) &ctrl5_c, 1); - if (ret == 0) { - ctrl5_c.xl_ulp_en = ((uint8_t)val & 0x02U) >> 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*) &ctrl5_c, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*) &ctrl6_c, 1); - } - if (ret == 0) { - ctrl6_c.xl_hm_mode = (uint8_t)val & 0x01U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*) &ctrl6_c, 1); - } - return ret; + lsm6dso_ctrl5_c_t ctrl5_c; + lsm6dso_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *) &ctrl5_c, 1); + if (ret == 0) { + ctrl5_c.xl_ulp_en = ((uint8_t)val & 0x02U) >> 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *) &ctrl5_c, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *) &ctrl6_c, 1); + } + if (ret == 0) { + ctrl6_c.xl_hm_mode = (uint8_t)val & 0x01U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *) &ctrl6_c, 1); + } + return ret; } /** @@ -563,29 +563,29 @@ int32_t lsm6dso_xl_power_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_xl_hm_mode_t *val) { - lsm6dso_ctrl5_c_t ctrl5_c; - lsm6dso_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*) &ctrl5_c, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*) &ctrl6_c, 1); - switch ( (ctrl5_c.xl_ulp_en << 1) | ctrl6_c.xl_hm_mode) { - case LSM6DSO_HIGH_PERFORMANCE_MD: - *val = LSM6DSO_HIGH_PERFORMANCE_MD; - break; - case LSM6DSO_LOW_NORMAL_POWER_MD: - *val = LSM6DSO_LOW_NORMAL_POWER_MD; - break; - case LSM6DSO_ULTRA_LOW_POWER_MD: - *val = LSM6DSO_ULTRA_LOW_POWER_MD; - break; - default: - *val = LSM6DSO_HIGH_PERFORMANCE_MD; - break; - } - } - return ret; + lsm6dso_ctrl5_c_t ctrl5_c; + lsm6dso_ctrl6_c_t ctrl6_c; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *) &ctrl5_c, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *) &ctrl6_c, 1); + switch ((ctrl5_c.xl_ulp_en << 1) | ctrl6_c.xl_hm_mode) { + case LSM6DSO_HIGH_PERFORMANCE_MD: + *val = LSM6DSO_HIGH_PERFORMANCE_MD; + break; + case LSM6DSO_LOW_NORMAL_POWER_MD: + *val = LSM6DSO_LOW_NORMAL_POWER_MD; + break; + case LSM6DSO_ULTRA_LOW_POWER_MD: + *val = LSM6DSO_ULTRA_LOW_POWER_MD; + break; + default: + *val = LSM6DSO_HIGH_PERFORMANCE_MD; + break; + } + } + return ret; } /** @@ -598,15 +598,15 @@ int32_t lsm6dso_gy_power_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_g_hm_mode_t val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.g_hm_mode = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.g_hm_mode = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + } + return ret; } /** @@ -619,22 +619,22 @@ int32_t lsm6dso_gy_power_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_g_hm_mode_t *val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - switch (reg.g_hm_mode) { - case LSM6DSO_GY_HIGH_PERFORMANCE: - *val = LSM6DSO_GY_HIGH_PERFORMANCE; - break; - case LSM6DSO_GY_NORMAL: - *val = LSM6DSO_GY_NORMAL; - break; - default: - *val = LSM6DSO_GY_HIGH_PERFORMANCE; - break; - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + switch (reg.g_hm_mode) { + case LSM6DSO_GY_HIGH_PERFORMANCE: + *val = LSM6DSO_GY_HIGH_PERFORMANCE; + break; + case LSM6DSO_GY_NORMAL: + *val = LSM6DSO_GY_NORMAL; + break; + default: + *val = LSM6DSO_GY_HIGH_PERFORMANCE; + break; + } + return ret; } /** @@ -649,46 +649,46 @@ int32_t lsm6dso_all_sources_get(lsm6dso_ctx_t *ctx, lsm6dso_all_sources_t *val) { - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_ALL_INT_SRC, - (uint8_t*)&val->all_int_src, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_SRC, - (uint8_t*)&val->wake_up_src, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_SRC, - (uint8_t*)&val->tap_src, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_D6D_SRC, - (uint8_t*)&val->d6d_src, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, - (uint8_t*)&val->status_reg, 1); - } - if (ret == 0) { - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, - (uint8_t*)&val->emb_func_status, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_STATUS_A, - (uint8_t*)&val->fsm_status_a, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_STATUS_B, - (uint8_t*)&val->fsm_status_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_ALL_INT_SRC, + (uint8_t *)&val->all_int_src, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_SRC, + (uint8_t *)&val->wake_up_src, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_SRC, + (uint8_t *)&val->tap_src, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_D6D_SRC, + (uint8_t *)&val->d6d_src, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, + (uint8_t *)&val->status_reg, 1); + } + if (ret == 0) { + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, + (uint8_t *)&val->emb_func_status, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_STATUS_A, + (uint8_t *)&val->fsm_status_a, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_STATUS_B, + (uint8_t *)&val->fsm_status_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -700,9 +700,9 @@ */ int32_t lsm6dso_status_reg_get(lsm6dso_ctx_t *ctx, lsm6dso_status_reg_t *val) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t*) val, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t *) val, 1); + return ret; } /** @@ -714,13 +714,13 @@ */ int32_t lsm6dso_xl_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_reg_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t*)®, 1); - *val = reg.xlda; - - return ret; + lsm6dso_status_reg_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t *)®, 1); + *val = reg.xlda; + + return ret; } /** @@ -732,13 +732,13 @@ */ int32_t lsm6dso_gy_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_reg_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t*)®, 1); - *val = reg.gda; - - return ret; + lsm6dso_status_reg_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t *)®, 1); + *val = reg.gda; + + return ret; } /** @@ -750,13 +750,13 @@ */ int32_t lsm6dso_temp_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_reg_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t*)®, 1); - *val = reg.tda; - - return ret; + lsm6dso_status_reg_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_REG, (uint8_t *)®, 1); + *val = reg.tda; + + return ret; } /** @@ -770,9 +770,9 @@ */ int32_t lsm6dso_xl_usr_offset_x_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_write_reg(ctx, LSM6DSO_X_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_write_reg(ctx, LSM6DSO_X_OFS_USR, buff, 1); + return ret; } /** @@ -786,9 +786,9 @@ */ int32_t lsm6dso_xl_usr_offset_x_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_X_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_X_OFS_USR, buff, 1); + return ret; } /** @@ -802,9 +802,9 @@ */ int32_t lsm6dso_xl_usr_offset_y_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_write_reg(ctx, LSM6DSO_Y_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_write_reg(ctx, LSM6DSO_Y_OFS_USR, buff, 1); + return ret; } /** @@ -818,9 +818,9 @@ */ int32_t lsm6dso_xl_usr_offset_y_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_Y_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_Y_OFS_USR, buff, 1); + return ret; } /** @@ -834,9 +834,9 @@ */ int32_t lsm6dso_xl_usr_offset_z_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_write_reg(ctx, LSM6DSO_Z_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_write_reg(ctx, LSM6DSO_Z_OFS_USR, buff, 1); + return ret; } /** @@ -850,9 +850,9 @@ */ int32_t lsm6dso_xl_usr_offset_z_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_Z_OFS_USR, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_Z_OFS_USR, buff, 1); + return ret; } /** @@ -864,15 +864,15 @@ */ int32_t lsm6dso_xl_usr_offset_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.usr_off_on_out = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.usr_off_on_out = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + } + return ret; } /** @@ -884,13 +884,13 @@ */ int32_t lsm6dso_xl_usr_offset_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - *val = reg.usr_off_on_out; - - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + *val = reg.usr_off_on_out; + + return ret; } /** @@ -915,15 +915,15 @@ */ int32_t lsm6dso_timestamp_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl10_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.timestamp_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl10_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.timestamp_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -935,13 +935,13 @@ */ int32_t lsm6dso_timestamp_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl10_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t*)®, 1); - *val = reg.timestamp_en; - - return ret; + lsm6dso_ctrl10_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL10_C, (uint8_t *)®, 1); + *val = reg.timestamp_en; + + return ret; } /** @@ -955,9 +955,9 @@ */ int32_t lsm6dso_timestamp_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_TIMESTAMP0, buff, 4); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_TIMESTAMP0, buff, 4); + return ret; } /** @@ -983,15 +983,15 @@ int32_t lsm6dso_rounding_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_rounding_t val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.rounding = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.rounding = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1004,28 +1004,28 @@ int32_t lsm6dso_rounding_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_rounding_t *val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - switch (reg.rounding) { - case LSM6DSO_NO_ROUND: - *val = LSM6DSO_NO_ROUND; - break; - case LSM6DSO_ROUND_XL: - *val = LSM6DSO_ROUND_XL; - break; - case LSM6DSO_ROUND_GY: - *val = LSM6DSO_ROUND_GY; - break; - case LSM6DSO_ROUND_GY_XL: - *val = LSM6DSO_ROUND_GY_XL; - break; - default: - *val = LSM6DSO_NO_ROUND; - break; - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + switch (reg.rounding) { + case LSM6DSO_NO_ROUND: + *val = LSM6DSO_NO_ROUND; + break; + case LSM6DSO_ROUND_XL: + *val = LSM6DSO_ROUND_XL; + break; + case LSM6DSO_ROUND_GY: + *val = LSM6DSO_ROUND_GY; + break; + case LSM6DSO_ROUND_GY_XL: + *val = LSM6DSO_ROUND_GY_XL; + break; + default: + *val = LSM6DSO_NO_ROUND; + break; + } + return ret; } /** @@ -1039,9 +1039,9 @@ */ int32_t lsm6dso_temperature_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_OUT_TEMP_L, buff, 2); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_OUT_TEMP_L, buff, 2); + return ret; } /** @@ -1054,9 +1054,9 @@ */ int32_t lsm6dso_angular_rate_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_OUTX_L_G, buff, 6); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_OUTX_L_G, buff, 6); + return ret; } /** @@ -1069,9 +1069,9 @@ */ int32_t lsm6dso_acceleration_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_OUTX_L_A, buff, 6); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_OUTX_L_A, buff, 6); + return ret; } /** @@ -1083,9 +1083,9 @@ */ int32_t lsm6dso_fifo_out_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_DATA_OUT_X_L, buff, 6); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_DATA_OUT_X_L, buff, 6); + return ret; } /** @@ -1097,16 +1097,16 @@ */ int32_t lsm6dso_number_of_steps_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_STEP_COUNTER_L, buff, 2); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_STEP_COUNTER_L, buff, 2); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -1117,21 +1117,21 @@ */ int32_t lsm6dso_steps_reset(lsm6dso_ctx_t *ctx) { - lsm6dso_emb_func_src_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_SRC, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.pedo_rst_step = PROPERTY_ENABLE; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_SRC, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_src_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_SRC, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.pedo_rst_step = PROPERTY_ENABLE; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_SRC, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -1158,16 +1158,16 @@ */ int32_t lsm6dso_odr_cal_reg_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_internal_freq_fine_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, (uint8_t*)®, 1); - if (ret == 0) { - reg.freq_fine = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, - (uint8_t*)®, 1); - } - return ret; + lsm6dso_internal_freq_fine_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, (uint8_t *)®, 1); + if (ret == 0) { + reg.freq_fine = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, + (uint8_t *)®, 1); + } + return ret; } /** @@ -1181,13 +1181,13 @@ */ int32_t lsm6dso_odr_cal_reg_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_internal_freq_fine_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, (uint8_t*)®, 1); - *val = reg.freq_fine; - - return ret; + lsm6dso_internal_freq_fine_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE, (uint8_t *)®, 1); + *val = reg.freq_fine; + + return ret; } @@ -1202,15 +1202,15 @@ */ int32_t lsm6dso_mem_bank_set(lsm6dso_ctx_t *ctx, lsm6dso_reg_access_t val) { - lsm6dso_func_cfg_access_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t*)®, 1); - if (ret == 0) { - reg.reg_access = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_func_cfg_access_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t *)®, 1); + if (ret == 0) { + reg.reg_access = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t *)®, 1); + } + return ret; } /** @@ -1224,25 +1224,25 @@ */ int32_t lsm6dso_mem_bank_get(lsm6dso_ctx_t *ctx, lsm6dso_reg_access_t *val) { - lsm6dso_func_cfg_access_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t*)®, 1); - switch (reg.reg_access) { - case LSM6DSO_USER_BANK: - *val = LSM6DSO_USER_BANK; - break; - case LSM6DSO_SENSOR_HUB_BANK: - *val = LSM6DSO_SENSOR_HUB_BANK; - break; - case LSM6DSO_EMBEDDED_FUNC_BANK: - *val = LSM6DSO_EMBEDDED_FUNC_BANK; - break; - default: - *val = LSM6DSO_USER_BANK; - break; - } - return ret; + lsm6dso_func_cfg_access_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t *)®, 1); + switch (reg.reg_access) { + case LSM6DSO_USER_BANK: + *val = LSM6DSO_USER_BANK; + break; + case LSM6DSO_SENSOR_HUB_BANK: + *val = LSM6DSO_SENSOR_HUB_BANK; + break; + case LSM6DSO_EMBEDDED_FUNC_BANK: + *val = LSM6DSO_EMBEDDED_FUNC_BANK; + break; + default: + *val = LSM6DSO_USER_BANK; + break; + } + return ret; } /** @@ -1256,49 +1256,49 @@ int32_t lsm6dso_ln_pg_write_byte(lsm6dso_ctx_t *ctx, uint16_t address, uint8_t *val) { - lsm6dso_page_rw_t page_rw; - lsm6dso_page_sel_t page_sel; - lsm6dso_page_address_t page_address; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x02; /* page_write enable */ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - - if (ret == 0) { - page_sel.page_sel = ((uint8_t)(address >> 8) & 0x0FU); - page_sel.not_used_01 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - page_address.page_addr = (uint8_t)address & 0xFFU; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, - (uint8_t*)&page_address, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, val, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x00; /* page_write disable */ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_page_rw_t page_rw; + lsm6dso_page_sel_t page_sel; + lsm6dso_page_address_t page_address; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x02; /* page_write enable */ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + + if (ret == 0) { + page_sel.page_sel = ((uint8_t)(address >> 8) & 0x0FU); + page_sel.not_used_01 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + page_address.page_addr = (uint8_t)address & 0xFFU; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, + (uint8_t *)&page_address, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, val, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x00; /* page_write disable */ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -1313,68 +1313,68 @@ int32_t lsm6dso_ln_pg_write(lsm6dso_ctx_t *ctx, uint16_t address, uint8_t *buf, uint8_t len) { - lsm6dso_page_rw_t page_rw; - lsm6dso_page_sel_t page_sel; - lsm6dso_page_address_t page_address; - uint16_t addr_pointed; - int32_t ret; - uint8_t i ; - - addr_pointed = address; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x02; /* page_write enable*/ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU); - page_sel.not_used_01 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - page_address.page_addr = (uint8_t)(addr_pointed & 0x00FFU); - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, - (uint8_t*)&page_address, 1); - } - - if (ret == 0) { - for (i = 0; ( (i < len) && (ret == 0) ); i++) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, &buf[i], 1); - addr_pointed++; - /* Check if page wrap */ - if ( ( (addr_pointed % 0x0100U) == 0x00U ) && (ret == 0) ) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*)&page_sel, 1); - if (ret == 0) { - page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU); - page_sel.not_used_01 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, - (uint8_t*)&page_sel, 1); + lsm6dso_page_rw_t page_rw; + lsm6dso_page_sel_t page_sel; + lsm6dso_page_address_t page_address; + uint16_t addr_pointed; + int32_t ret; + uint8_t i ; + + addr_pointed = address; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x02; /* page_write enable*/ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU); + page_sel.not_used_01 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + page_address.page_addr = (uint8_t)(addr_pointed & 0x00FFU); + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, + (uint8_t *)&page_address, 1); + } + + if (ret == 0) { + for (i = 0; ((i < len) && (ret == 0)); i++) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, &buf[i], 1); + addr_pointed++; + /* Check if page wrap */ + if (((addr_pointed % 0x0100U) == 0x00U) && (ret == 0)) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *)&page_sel, 1); + if (ret == 0) { + page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU); + page_sel.not_used_01 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, + (uint8_t *)&page_sel, 1); + } + } } - } - } - page_sel.page_sel = 0; - page_sel.not_used_01 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x00; /* page_write disable */ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + page_sel.page_sel = 0; + page_sel.not_used_01 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x00; /* page_write disable */ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -1388,50 +1388,50 @@ int32_t lsm6dso_ln_pg_read_byte(lsm6dso_ctx_t *ctx, uint16_t address, uint8_t *val) { - lsm6dso_page_rw_t page_rw; - lsm6dso_page_sel_t page_sel; - lsm6dso_page_address_t page_address; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x01; /* page_read enable*/ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - page_sel.page_sel = ((uint8_t)(address >> 8) & 0x0FU); - page_sel.not_used_01 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t*) &page_sel, 1); - } - if (ret == 0) { - page_address.page_addr = (uint8_t)address & 0x00FFU; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, - (uint8_t*)&page_address, 1); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_VALUE, val, 2); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.page_rw = 0x00; /* page_read disable */ - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_page_rw_t page_rw; + lsm6dso_page_sel_t page_sel; + lsm6dso_page_address_t page_address; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x01; /* page_read enable*/ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + page_sel.page_sel = ((uint8_t)(address >> 8) & 0x0FU); + page_sel.not_used_01 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1); + } + if (ret == 0) { + page_address.page_addr = (uint8_t)address & 0x00FFU; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS, + (uint8_t *)&page_address, 1); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_VALUE, val, 2); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.page_rw = 0x00; /* page_read disable */ + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -1446,15 +1446,15 @@ int32_t lsm6dso_data_ready_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_dataready_pulsed_t val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - if (ret == 0) { - reg.dataready_pulsed = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - } - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + if (ret == 0) { + reg.dataready_pulsed = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + } + return ret; } /** @@ -1469,22 +1469,22 @@ int32_t lsm6dso_data_ready_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_dataready_pulsed_t *val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - switch (reg.dataready_pulsed) { - case LSM6DSO_DRDY_LATCHED: - *val = LSM6DSO_DRDY_LATCHED; - break; - case LSM6DSO_DRDY_PULSED: - *val = LSM6DSO_DRDY_PULSED; - break; - default: - *val = LSM6DSO_DRDY_LATCHED; - break; - } - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + switch (reg.dataready_pulsed) { + case LSM6DSO_DRDY_LATCHED: + *val = LSM6DSO_DRDY_LATCHED; + break; + case LSM6DSO_DRDY_PULSED: + *val = LSM6DSO_DRDY_PULSED; + break; + default: + *val = LSM6DSO_DRDY_LATCHED; + break; + } + return ret; } /** @@ -1496,9 +1496,9 @@ */ int32_t lsm6dso_device_id_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_WHO_AM_I, buff, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_WHO_AM_I, buff, 1); + return ret; } /** @@ -1511,16 +1511,16 @@ */ int32_t lsm6dso_reset_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.sw_reset = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.sw_reset = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + + return ret; } /** @@ -1532,13 +1532,13 @@ */ int32_t lsm6dso_reset_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - *val = reg.sw_reset; - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + *val = reg.sw_reset; + + return ret; } /** @@ -1551,15 +1551,15 @@ */ int32_t lsm6dso_auto_increment_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.if_inc = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.if_inc = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1572,13 +1572,13 @@ */ int32_t lsm6dso_auto_increment_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - *val = reg.if_inc; - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + *val = reg.if_inc; + + return ret; } /** @@ -1590,15 +1590,15 @@ */ int32_t lsm6dso_boot_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.boot = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.boot = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1610,13 +1610,13 @@ */ int32_t lsm6dso_boot_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - *val = reg.boot; - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + *val = reg.boot; + + return ret; } /** @@ -1628,15 +1628,15 @@ */ int32_t lsm6dso_xl_self_test_set(lsm6dso_ctx_t *ctx, lsm6dso_st_xl_t val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.st_xl = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.st_xl = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1648,25 +1648,25 @@ */ int32_t lsm6dso_xl_self_test_get(lsm6dso_ctx_t *ctx, lsm6dso_st_xl_t *val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - switch (reg.st_xl) { - case LSM6DSO_XL_ST_DISABLE: - *val = LSM6DSO_XL_ST_DISABLE; - break; - case LSM6DSO_XL_ST_POSITIVE: - *val = LSM6DSO_XL_ST_POSITIVE; - break; - case LSM6DSO_XL_ST_NEGATIVE: - *val = LSM6DSO_XL_ST_NEGATIVE; - break; - default: - *val = LSM6DSO_XL_ST_DISABLE; - break; - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + switch (reg.st_xl) { + case LSM6DSO_XL_ST_DISABLE: + *val = LSM6DSO_XL_ST_DISABLE; + break; + case LSM6DSO_XL_ST_POSITIVE: + *val = LSM6DSO_XL_ST_POSITIVE; + break; + case LSM6DSO_XL_ST_NEGATIVE: + *val = LSM6DSO_XL_ST_NEGATIVE; + break; + default: + *val = LSM6DSO_XL_ST_DISABLE; + break; + } + return ret; } /** @@ -1678,15 +1678,15 @@ */ int32_t lsm6dso_gy_self_test_set(lsm6dso_ctx_t *ctx, lsm6dso_st_g_t val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.st_g = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.st_g = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1698,25 +1698,25 @@ */ int32_t lsm6dso_gy_self_test_get(lsm6dso_ctx_t *ctx, lsm6dso_st_g_t *val) { - lsm6dso_ctrl5_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t*)®, 1); - switch (reg.st_g) { - case LSM6DSO_GY_ST_DISABLE: - *val = LSM6DSO_GY_ST_DISABLE; - break; - case LSM6DSO_GY_ST_POSITIVE: - *val = LSM6DSO_GY_ST_POSITIVE; - break; - case LSM6DSO_GY_ST_NEGATIVE: - *val = LSM6DSO_GY_ST_NEGATIVE; - break; - default: - *val = LSM6DSO_GY_ST_DISABLE; - break; - } - return ret; + lsm6dso_ctrl5_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL5_C, (uint8_t *)®, 1); + switch (reg.st_g) { + case LSM6DSO_GY_ST_DISABLE: + *val = LSM6DSO_GY_ST_DISABLE; + break; + case LSM6DSO_GY_ST_POSITIVE: + *val = LSM6DSO_GY_ST_POSITIVE; + break; + case LSM6DSO_GY_ST_NEGATIVE: + *val = LSM6DSO_GY_ST_NEGATIVE; + break; + default: + *val = LSM6DSO_GY_ST_DISABLE; + break; + } + return ret; } /** @@ -1741,15 +1741,15 @@ */ int32_t lsm6dso_xl_filter_lp2_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.lpf2_xl_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.lpf2_xl_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -1761,13 +1761,13 @@ */ int32_t lsm6dso_xl_filter_lp2_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl1_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t*)®, 1); - *val = reg.lpf2_xl_en; - - return ret; + lsm6dso_ctrl1_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_XL, (uint8_t *)®, 1); + *val = reg.lpf2_xl_en; + + return ret; } /** @@ -1781,15 +1781,15 @@ */ int32_t lsm6dso_gy_filter_lp1_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.lpf1_sel_g = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.lpf1_sel_g = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1803,13 +1803,13 @@ */ int32_t lsm6dso_gy_filter_lp1_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - *val = reg.lpf1_sel_g; - - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + *val = reg.lpf1_sel_g; + + return ret; } /** @@ -1822,15 +1822,15 @@ */ int32_t lsm6dso_filter_settling_mask_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.drdy_mask = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.drdy_mask = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1843,13 +1843,13 @@ */ int32_t lsm6dso_filter_settling_mask_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - *val = reg.drdy_mask; - - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + *val = reg.drdy_mask; + + return ret; } /** @@ -1861,15 +1861,15 @@ */ int32_t lsm6dso_gy_lp1_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_ftype_t val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.ftype = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.ftype = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -1881,40 +1881,40 @@ */ int32_t lsm6dso_gy_lp1_bandwidth_get(lsm6dso_ctx_t *ctx, lsm6dso_ftype_t *val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - switch (reg.ftype) { - case LSM6DSO_ULTRA_LIGHT: - *val = LSM6DSO_ULTRA_LIGHT; - break; - case LSM6DSO_VERY_LIGHT: - *val = LSM6DSO_VERY_LIGHT; - break; - case LSM6DSO_LIGHT: - *val = LSM6DSO_LIGHT; - break; - case LSM6DSO_MEDIUM: - *val = LSM6DSO_MEDIUM; - break; - case LSM6DSO_STRONG: - *val = LSM6DSO_STRONG; - break; - case LSM6DSO_VERY_STRONG: - *val = LSM6DSO_VERY_STRONG; - break; - case LSM6DSO_AGGRESSIVE: - *val = LSM6DSO_AGGRESSIVE; - break; - case LSM6DSO_XTREME: - *val = LSM6DSO_XTREME; - break; - default: - *val = LSM6DSO_ULTRA_LIGHT; - break; - } - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + switch (reg.ftype) { + case LSM6DSO_ULTRA_LIGHT: + *val = LSM6DSO_ULTRA_LIGHT; + break; + case LSM6DSO_VERY_LIGHT: + *val = LSM6DSO_VERY_LIGHT; + break; + case LSM6DSO_LIGHT: + *val = LSM6DSO_LIGHT; + break; + case LSM6DSO_MEDIUM: + *val = LSM6DSO_MEDIUM; + break; + case LSM6DSO_STRONG: + *val = LSM6DSO_STRONG; + break; + case LSM6DSO_VERY_STRONG: + *val = LSM6DSO_VERY_STRONG; + break; + case LSM6DSO_AGGRESSIVE: + *val = LSM6DSO_AGGRESSIVE; + break; + case LSM6DSO_XTREME: + *val = LSM6DSO_XTREME; + break; + default: + *val = LSM6DSO_ULTRA_LIGHT; + break; + } + return ret; } /** @@ -1926,15 +1926,15 @@ */ int32_t lsm6dso_xl_lp2_on_6d_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.low_pass_on_6d = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.low_pass_on_6d = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -1946,13 +1946,13 @@ */ int32_t lsm6dso_xl_lp2_on_6d_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - *val = reg.low_pass_on_6d; - - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + *val = reg.low_pass_on_6d; + + return ret; } /** @@ -1967,17 +1967,17 @@ int32_t lsm6dso_xl_hp_path_on_out_set(lsm6dso_ctx_t *ctx, lsm6dso_hp_slope_xl_en_t val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.hp_slope_xl_en = ((uint8_t)val & 0x10U) >> 4; - reg.hp_ref_mode_xl = ((uint8_t)val & 0x20U) >> 5; - reg.hpcf_xl = (uint8_t)val & 0x07U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.hp_slope_xl_en = ((uint8_t)val & 0x10U) >> 4; + reg.hp_ref_mode_xl = ((uint8_t)val & 0x20U) >> 5; + reg.hpcf_xl = (uint8_t)val & 0x07U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -1992,87 +1992,87 @@ int32_t lsm6dso_xl_hp_path_on_out_get(lsm6dso_ctx_t *ctx, lsm6dso_hp_slope_xl_en_t *val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - switch ((reg.hp_ref_mode_xl << 5) | (reg.hp_slope_xl_en << 4) | - reg.hpcf_xl) { - case LSM6DSO_HP_PATH_DISABLE_ON_OUT: - *val = LSM6DSO_HP_PATH_DISABLE_ON_OUT; - break; - case LSM6DSO_SLOPE_ODR_DIV_4: - *val = LSM6DSO_SLOPE_ODR_DIV_4; - break; - case LSM6DSO_HP_ODR_DIV_10: - *val = LSM6DSO_HP_ODR_DIV_10; - break; - case LSM6DSO_HP_ODR_DIV_20: - *val = LSM6DSO_HP_ODR_DIV_20; - break; - case LSM6DSO_HP_ODR_DIV_45: - *val = LSM6DSO_HP_ODR_DIV_45; - break; - case LSM6DSO_HP_ODR_DIV_100: - *val = LSM6DSO_HP_ODR_DIV_100; - break; - case LSM6DSO_HP_ODR_DIV_200: - *val = LSM6DSO_HP_ODR_DIV_200; - break; - case LSM6DSO_HP_ODR_DIV_400: - *val = LSM6DSO_HP_ODR_DIV_400; - break; - case LSM6DSO_HP_ODR_DIV_800: - *val = LSM6DSO_HP_ODR_DIV_800; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_10: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_10; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_20: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_20; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_45: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_45; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_100: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_100; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_200: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_200; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_400: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_400; - break; - case LSM6DSO_HP_REF_MD_ODR_DIV_800: - *val = LSM6DSO_HP_REF_MD_ODR_DIV_800; - break; - case LSM6DSO_LP_ODR_DIV_10: - *val = LSM6DSO_LP_ODR_DIV_10; - break; - case LSM6DSO_LP_ODR_DIV_20: - *val = LSM6DSO_LP_ODR_DIV_20; - break; - case LSM6DSO_LP_ODR_DIV_45: - *val = LSM6DSO_LP_ODR_DIV_45; - break; - case LSM6DSO_LP_ODR_DIV_100: - *val = LSM6DSO_LP_ODR_DIV_100; - break; - case LSM6DSO_LP_ODR_DIV_200: - *val = LSM6DSO_LP_ODR_DIV_200; - break; - case LSM6DSO_LP_ODR_DIV_400: - *val = LSM6DSO_LP_ODR_DIV_400; - break; - case LSM6DSO_LP_ODR_DIV_800: - *val = LSM6DSO_LP_ODR_DIV_800; - break; - default: - *val = LSM6DSO_HP_PATH_DISABLE_ON_OUT; - break; - } - - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + switch ((reg.hp_ref_mode_xl << 5) | (reg.hp_slope_xl_en << 4) | + reg.hpcf_xl) { + case LSM6DSO_HP_PATH_DISABLE_ON_OUT: + *val = LSM6DSO_HP_PATH_DISABLE_ON_OUT; + break; + case LSM6DSO_SLOPE_ODR_DIV_4: + *val = LSM6DSO_SLOPE_ODR_DIV_4; + break; + case LSM6DSO_HP_ODR_DIV_10: + *val = LSM6DSO_HP_ODR_DIV_10; + break; + case LSM6DSO_HP_ODR_DIV_20: + *val = LSM6DSO_HP_ODR_DIV_20; + break; + case LSM6DSO_HP_ODR_DIV_45: + *val = LSM6DSO_HP_ODR_DIV_45; + break; + case LSM6DSO_HP_ODR_DIV_100: + *val = LSM6DSO_HP_ODR_DIV_100; + break; + case LSM6DSO_HP_ODR_DIV_200: + *val = LSM6DSO_HP_ODR_DIV_200; + break; + case LSM6DSO_HP_ODR_DIV_400: + *val = LSM6DSO_HP_ODR_DIV_400; + break; + case LSM6DSO_HP_ODR_DIV_800: + *val = LSM6DSO_HP_ODR_DIV_800; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_10: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_10; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_20: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_20; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_45: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_45; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_100: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_100; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_200: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_200; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_400: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_400; + break; + case LSM6DSO_HP_REF_MD_ODR_DIV_800: + *val = LSM6DSO_HP_REF_MD_ODR_DIV_800; + break; + case LSM6DSO_LP_ODR_DIV_10: + *val = LSM6DSO_LP_ODR_DIV_10; + break; + case LSM6DSO_LP_ODR_DIV_20: + *val = LSM6DSO_LP_ODR_DIV_20; + break; + case LSM6DSO_LP_ODR_DIV_45: + *val = LSM6DSO_LP_ODR_DIV_45; + break; + case LSM6DSO_LP_ODR_DIV_100: + *val = LSM6DSO_LP_ODR_DIV_100; + break; + case LSM6DSO_LP_ODR_DIV_200: + *val = LSM6DSO_LP_ODR_DIV_200; + break; + case LSM6DSO_LP_ODR_DIV_400: + *val = LSM6DSO_LP_ODR_DIV_400; + break; + case LSM6DSO_LP_ODR_DIV_800: + *val = LSM6DSO_LP_ODR_DIV_800; + break; + default: + *val = LSM6DSO_HP_PATH_DISABLE_ON_OUT; + break; + } + + return ret; } /** @@ -2087,15 +2087,15 @@ */ int32_t lsm6dso_xl_fast_settling_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.fastsettl_mode_xl = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.fastsettl_mode_xl = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -2109,13 +2109,13 @@ */ int32_t lsm6dso_xl_fast_settling_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - *val = reg.fastsettl_mode_xl; - - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + *val = reg.fastsettl_mode_xl; + + return ret; } /** @@ -2129,15 +2129,15 @@ int32_t lsm6dso_xl_hp_path_internal_set(lsm6dso_ctx_t *ctx, lsm6dso_slope_fds_t val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - if (ret == 0) { - reg.slope_fds = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + if (ret == 0) { + reg.slope_fds = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + } + return ret; } /** @@ -2151,22 +2151,22 @@ int32_t lsm6dso_xl_hp_path_internal_get(lsm6dso_ctx_t *ctx, lsm6dso_slope_fds_t *val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - switch (reg.slope_fds) { - case LSM6DSO_USE_SLOPE: - *val = LSM6DSO_USE_SLOPE; - break; - case LSM6DSO_USE_HPF: - *val = LSM6DSO_USE_HPF; - break; - default: - *val = LSM6DSO_USE_SLOPE; - break; - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + switch (reg.slope_fds) { + case LSM6DSO_USE_SLOPE: + *val = LSM6DSO_USE_SLOPE; + break; + case LSM6DSO_USE_HPF: + *val = LSM6DSO_USE_HPF; + break; + default: + *val = LSM6DSO_USE_SLOPE; + break; + } + return ret; } /** @@ -2181,16 +2181,16 @@ int32_t lsm6dso_gy_hp_path_internal_set(lsm6dso_ctx_t *ctx, lsm6dso_hpm_g_t val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.hp_en_g = ((uint8_t)val & 0x80U) >> 7; - reg.hpm_g = (uint8_t)val & 0x03U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.hp_en_g = ((uint8_t)val & 0x80U) >> 7; + reg.hpm_g = (uint8_t)val & 0x03U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + } + return ret; } /** @@ -2205,31 +2205,31 @@ int32_t lsm6dso_gy_hp_path_internal_get(lsm6dso_ctx_t *ctx, lsm6dso_hpm_g_t *val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - switch ((reg.hp_en_g << 7) + reg.hpm_g) { - case LSM6DSO_HP_FILTER_NONE: - *val = LSM6DSO_HP_FILTER_NONE; - break; - case LSM6DSO_HP_FILTER_16mHz: - *val = LSM6DSO_HP_FILTER_16mHz; - break; - case LSM6DSO_HP_FILTER_65mHz: - *val = LSM6DSO_HP_FILTER_65mHz; - break; - case LSM6DSO_HP_FILTER_260mHz: - *val = LSM6DSO_HP_FILTER_260mHz; - break; - case LSM6DSO_HP_FILTER_1Hz04: - *val = LSM6DSO_HP_FILTER_1Hz04; - break; - default: - *val = LSM6DSO_HP_FILTER_NONE; - break; - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + switch ((reg.hp_en_g << 7) + reg.hpm_g) { + case LSM6DSO_HP_FILTER_NONE: + *val = LSM6DSO_HP_FILTER_NONE; + break; + case LSM6DSO_HP_FILTER_16mHz: + *val = LSM6DSO_HP_FILTER_16mHz; + break; + case LSM6DSO_HP_FILTER_65mHz: + *val = LSM6DSO_HP_FILTER_65mHz; + break; + case LSM6DSO_HP_FILTER_260mHz: + *val = LSM6DSO_HP_FILTER_260mHz; + break; + case LSM6DSO_HP_FILTER_1Hz04: + *val = LSM6DSO_HP_FILTER_1Hz04; + break; + default: + *val = LSM6DSO_HP_FILTER_NONE; + break; + } + return ret; } /** @@ -2257,15 +2257,15 @@ int32_t lsm6dso_aux_sdo_ocs_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_ois_pu_dis_t val) { - lsm6dso_pin_ctrl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - if (ret == 0) { - reg.ois_pu_dis = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_pin_ctrl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + if (ret == 0) { + reg.ois_pu_dis = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + } + return ret; } /** @@ -2279,22 +2279,22 @@ int32_t lsm6dso_aux_sdo_ocs_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_ois_pu_dis_t *val) { - lsm6dso_pin_ctrl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - switch (reg.ois_pu_dis) { - case LSM6DSO_AUX_PULL_UP_DISC: - *val = LSM6DSO_AUX_PULL_UP_DISC; - break; - case LSM6DSO_AUX_PULL_UP_CONNECT: - *val = LSM6DSO_AUX_PULL_UP_CONNECT; - break; - default: - *val = LSM6DSO_AUX_PULL_UP_DISC; - break; - } - return ret; + lsm6dso_pin_ctrl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + switch (reg.ois_pu_dis) { + case LSM6DSO_AUX_PULL_UP_DISC: + *val = LSM6DSO_AUX_PULL_UP_DISC; + break; + case LSM6DSO_AUX_PULL_UP_CONNECT: + *val = LSM6DSO_AUX_PULL_UP_CONNECT; + break; + default: + *val = LSM6DSO_AUX_PULL_UP_DISC; + break; + } + return ret; } /** @@ -2306,16 +2306,16 @@ */ int32_t lsm6dso_aux_pw_on_ctrl_set(lsm6dso_ctx_t *ctx, lsm6dso_ois_on_t val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - if (ret == 0) { - reg.ois_on_en = (uint8_t)val & 0x01U; - reg.ois_on = (uint8_t)val & 0x01U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + if (ret == 0) { + reg.ois_on_en = (uint8_t)val & 0x01U; + reg.ois_on = (uint8_t)val & 0x01U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + } + return ret; } /** @@ -2327,23 +2327,23 @@ */ int32_t lsm6dso_aux_pw_on_ctrl_get(lsm6dso_ctx_t *ctx, lsm6dso_ois_on_t *val) { - lsm6dso_ctrl7_g_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t*)®, 1); - switch (reg.ois_on) { - case LSM6DSO_AUX_ON: - *val = LSM6DSO_AUX_ON; - break; - case LSM6DSO_AUX_ON_BY_AUX_INTERFACE: - *val = LSM6DSO_AUX_ON_BY_AUX_INTERFACE; - break; - default: - *val = LSM6DSO_AUX_ON; - break; - } - - return ret; + lsm6dso_ctrl7_g_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL7_G, (uint8_t *)®, 1); + switch (reg.ois_on) { + case LSM6DSO_AUX_ON: + *val = LSM6DSO_AUX_ON; + break; + case LSM6DSO_AUX_ON_BY_AUX_INTERFACE: + *val = LSM6DSO_AUX_ON_BY_AUX_INTERFACE; + break; + default: + *val = LSM6DSO_AUX_ON; + break; + } + + return ret; } /** @@ -2362,15 +2362,15 @@ int32_t lsm6dso_aux_xl_fs_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.xl_fs_mode = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.xl_fs_mode = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + } + return ret; } /** @@ -2388,23 +2388,23 @@ int32_t lsm6dso_aux_xl_fs_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t *val) { - lsm6dso_ctrl8_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1); - switch (reg.xl_fs_mode) { - case LSM6DSO_USE_SAME_XL_FS: - *val = LSM6DSO_USE_SAME_XL_FS; - break; - case LSM6DSO_USE_DIFFERENT_XL_FS: - *val = LSM6DSO_USE_DIFFERENT_XL_FS; - break; - default: - *val = LSM6DSO_USE_SAME_XL_FS; - break; - } - - return ret; + lsm6dso_ctrl8_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1); + switch (reg.xl_fs_mode) { + case LSM6DSO_USE_SAME_XL_FS: + *val = LSM6DSO_USE_SAME_XL_FS; + break; + case LSM6DSO_USE_DIFFERENT_XL_FS: + *val = LSM6DSO_USE_DIFFERENT_XL_FS; + break; + default: + *val = LSM6DSO_USE_SAME_XL_FS; + break; + } + + return ret; } /** @@ -2417,9 +2417,9 @@ int32_t lsm6dso_aux_status_reg_get(lsm6dso_ctx_t *ctx, lsm6dso_status_spiaux_t *val) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t*) val, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t *) val, 1); + return ret; } /** @@ -2431,13 +2431,13 @@ */ int32_t lsm6dso_aux_xl_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_spiaux_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t*)®, 1); - *val = reg.xlda; - - return ret; + lsm6dso_status_spiaux_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t *)®, 1); + *val = reg.xlda; + + return ret; } /** @@ -2449,13 +2449,13 @@ */ int32_t lsm6dso_aux_gy_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_spiaux_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t*)®, 1); - *val = reg.gda; - - return ret; + lsm6dso_status_spiaux_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t *)®, 1); + *val = reg.gda; + + return ret; } /** @@ -2467,13 +2467,13 @@ */ int32_t lsm6dso_aux_gy_flag_settling_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_status_spiaux_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t*)®, 1); - *val = reg.gyro_settling; - - return ret; + lsm6dso_status_spiaux_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t *)®, 1); + *val = reg.gyro_settling; + + return ret; } /** @@ -2487,15 +2487,15 @@ int32_t lsm6dso_aux_xl_self_test_set(lsm6dso_ctx_t *ctx, lsm6dso_st_xl_ois_t val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.st_xl_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.st_xl_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2509,25 +2509,25 @@ int32_t lsm6dso_aux_xl_self_test_get(lsm6dso_ctx_t *ctx, lsm6dso_st_xl_ois_t *val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - switch (reg.st_xl_ois) { - case LSM6DSO_AUX_XL_DISABLE: - *val = LSM6DSO_AUX_XL_DISABLE; - break; - case LSM6DSO_AUX_XL_POS: - *val = LSM6DSO_AUX_XL_POS; - break; - case LSM6DSO_AUX_XL_NEG: - *val = LSM6DSO_AUX_XL_NEG; - break; - default: - *val = LSM6DSO_AUX_XL_DISABLE; - break; - } - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + switch (reg.st_xl_ois) { + case LSM6DSO_AUX_XL_DISABLE: + *val = LSM6DSO_AUX_XL_DISABLE; + break; + case LSM6DSO_AUX_XL_POS: + *val = LSM6DSO_AUX_XL_POS; + break; + case LSM6DSO_AUX_XL_NEG: + *val = LSM6DSO_AUX_XL_NEG; + break; + default: + *val = LSM6DSO_AUX_XL_DISABLE; + break; + } + return ret; } /** @@ -2541,15 +2541,15 @@ int32_t lsm6dso_aux_den_polarity_set(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_ois_t val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_lh_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_lh_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2562,22 +2562,22 @@ int32_t lsm6dso_aux_den_polarity_get(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_ois_t *val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - switch (reg.den_lh_ois) { - case LSM6DSO_AUX_DEN_ACTIVE_LOW: - *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; - break; - case LSM6DSO_AUX_DEN_ACTIVE_HIGH: - *val = LSM6DSO_AUX_DEN_ACTIVE_HIGH; - break; - default: - *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; - break; - } - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + switch (reg.den_lh_ois) { + case LSM6DSO_AUX_DEN_ACTIVE_LOW: + *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; + break; + case LSM6DSO_AUX_DEN_ACTIVE_HIGH: + *val = LSM6DSO_AUX_DEN_ACTIVE_HIGH; + break; + default: + *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; + break; + } + return ret; } /** @@ -2589,23 +2589,23 @@ */ int32_t lsm6dso_aux_den_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_lvl2_ois_t val) { - lsm6dso_ctrl1_ois_t ctrl1_ois; - lsm6dso_int_ois_t int_ois; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*) &int_ois, 1); - if (ret == 0) { - int_ois.lvl2_ois = (uint8_t)val & 0x01U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*) &int_ois, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*) &ctrl1_ois, 1); - } - if (ret == 0) { - ctrl1_ois.lvl1_ois = ((uint8_t)val & 0x02U) >> 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*) &ctrl1_ois, 1); - } - return ret; + lsm6dso_ctrl1_ois_t ctrl1_ois; + lsm6dso_int_ois_t int_ois; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *) &int_ois, 1); + if (ret == 0) { + int_ois.lvl2_ois = (uint8_t)val & 0x01U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *) &int_ois, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *) &ctrl1_ois, 1); + } + if (ret == 0) { + ctrl1_ois.lvl1_ois = ((uint8_t)val & 0x02U) >> 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *) &ctrl1_ois, 1); + } + return ret; } /** @@ -2617,29 +2617,29 @@ */ int32_t lsm6dso_aux_den_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_lvl2_ois_t *val) { - lsm6dso_ctrl1_ois_t ctrl1_ois; - lsm6dso_int_ois_t int_ois; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*) &int_ois, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*) &ctrl1_ois, 1); - switch ((ctrl1_ois.lvl1_ois << 1) + int_ois.lvl2_ois) { - case LSM6DSO_AUX_DEN_DISABLE: - *val = LSM6DSO_AUX_DEN_DISABLE; - break; - case LSM6DSO_AUX_DEN_LEVEL_LATCH: - *val = LSM6DSO_AUX_DEN_LEVEL_LATCH; - break; - case LSM6DSO_AUX_DEN_LEVEL_TRIG: - *val = LSM6DSO_AUX_DEN_LEVEL_TRIG; - break; - default: - *val = LSM6DSO_AUX_DEN_DISABLE; - break; - } - } - return ret; + lsm6dso_ctrl1_ois_t ctrl1_ois; + lsm6dso_int_ois_t int_ois; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *) &int_ois, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *) &ctrl1_ois, 1); + switch ((ctrl1_ois.lvl1_ois << 1) + int_ois.lvl2_ois) { + case LSM6DSO_AUX_DEN_DISABLE: + *val = LSM6DSO_AUX_DEN_DISABLE; + break; + case LSM6DSO_AUX_DEN_LEVEL_LATCH: + *val = LSM6DSO_AUX_DEN_LEVEL_LATCH; + break; + case LSM6DSO_AUX_DEN_LEVEL_TRIG: + *val = LSM6DSO_AUX_DEN_LEVEL_TRIG; + break; + default: + *val = LSM6DSO_AUX_DEN_DISABLE; + break; + } + } + return ret; } /** @@ -2652,15 +2652,15 @@ */ int32_t lsm6dso_aux_drdy_on_int2_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.int2_drdy_ois = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.int2_drdy_ois = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2673,13 +2673,13 @@ */ int32_t lsm6dso_aux_drdy_on_int2_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_int_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)®, 1); - *val = reg.int2_drdy_ois; - - return ret; + lsm6dso_int_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)®, 1); + *val = reg.int2_drdy_ois; + + return ret; } /** @@ -2697,16 +2697,16 @@ */ int32_t lsm6dso_aux_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_ois_en_spi2_t val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.ois_en_spi2 = (uint8_t)val & 0x01U; - reg.mode4_en = ((uint8_t)val & 0x02U) >> 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.ois_en_spi2 = (uint8_t)val & 0x01U; + reg.mode4_en = ((uint8_t)val & 0x02U) >> 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2724,25 +2724,25 @@ */ int32_t lsm6dso_aux_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_ois_en_spi2_t *val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - switch ((reg.mode4_en << 1) | reg.ois_en_spi2) { - case LSM6DSO_AUX_DISABLE: - *val = LSM6DSO_AUX_DISABLE; - break; - case LSM6DSO_MODE_3_GY: - *val = LSM6DSO_MODE_3_GY; - break; - case LSM6DSO_MODE_4_GY_XL: - *val = LSM6DSO_MODE_4_GY_XL; - break; - default: - *val = LSM6DSO_AUX_DISABLE; - break; - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + switch ((reg.mode4_en << 1) | reg.ois_en_spi2) { + case LSM6DSO_AUX_DISABLE: + *val = LSM6DSO_AUX_DISABLE; + break; + case LSM6DSO_MODE_3_GY: + *val = LSM6DSO_MODE_3_GY; + break; + case LSM6DSO_MODE_4_GY_XL: + *val = LSM6DSO_MODE_4_GY_XL; + break; + default: + *val = LSM6DSO_AUX_DISABLE; + break; + } + return ret; } /** @@ -2755,15 +2755,15 @@ int32_t lsm6dso_aux_gy_full_scale_set(lsm6dso_ctx_t *ctx, lsm6dso_fs_g_ois_t val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.fs_g_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.fs_g_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2776,31 +2776,31 @@ int32_t lsm6dso_aux_gy_full_scale_get(lsm6dso_ctx_t *ctx, lsm6dso_fs_g_ois_t *val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - switch (reg.fs_g_ois) { - case LSM6DSO_250dps_AUX: - *val = LSM6DSO_250dps_AUX; - break; - case LSM6DSO_125dps_AUX: - *val = LSM6DSO_125dps_AUX; - break; - case LSM6DSO_500dps_AUX: - *val = LSM6DSO_500dps_AUX; - break; - case LSM6DSO_1000dps_AUX: - *val = LSM6DSO_1000dps_AUX; - break; - case LSM6DSO_2000dps_AUX: - *val = LSM6DSO_2000dps_AUX; - break; - default: - *val = LSM6DSO_250dps_AUX; - break; - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + switch (reg.fs_g_ois) { + case LSM6DSO_250dps_AUX: + *val = LSM6DSO_250dps_AUX; + break; + case LSM6DSO_125dps_AUX: + *val = LSM6DSO_125dps_AUX; + break; + case LSM6DSO_500dps_AUX: + *val = LSM6DSO_500dps_AUX; + break; + case LSM6DSO_1000dps_AUX: + *val = LSM6DSO_1000dps_AUX; + break; + case LSM6DSO_2000dps_AUX: + *val = LSM6DSO_2000dps_AUX; + break; + default: + *val = LSM6DSO_250dps_AUX; + break; + } + return ret; } /** @@ -2812,15 +2812,15 @@ */ int32_t lsm6dso_aux_spi_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_sim_ois_t val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.sim_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.sim_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2832,22 +2832,22 @@ */ int32_t lsm6dso_aux_spi_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_sim_ois_t *val) { - lsm6dso_ctrl1_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t*)®, 1); - switch (reg.sim_ois) { - case LSM6DSO_AUX_SPI_4_WIRE: - *val = LSM6DSO_AUX_SPI_4_WIRE; - break; - case LSM6DSO_AUX_SPI_3_WIRE: - *val = LSM6DSO_AUX_SPI_3_WIRE; - break; - default: - *val = LSM6DSO_AUX_SPI_4_WIRE; - break; - } - return ret; + lsm6dso_ctrl1_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL1_OIS, (uint8_t *)®, 1); + switch (reg.sim_ois) { + case LSM6DSO_AUX_SPI_4_WIRE: + *val = LSM6DSO_AUX_SPI_4_WIRE; + break; + case LSM6DSO_AUX_SPI_3_WIRE: + *val = LSM6DSO_AUX_SPI_3_WIRE; + break; + default: + *val = LSM6DSO_AUX_SPI_4_WIRE; + break; + } + return ret; } /** @@ -2861,15 +2861,15 @@ int32_t lsm6dso_aux_gy_lp1_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_ftype_ois_t val) { - lsm6dso_ctrl2_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.ftype_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl2_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.ftype_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2882,28 +2882,28 @@ int32_t lsm6dso_aux_gy_lp1_bandwidth_get(lsm6dso_ctx_t *ctx, lsm6dso_ftype_ois_t *val) { - lsm6dso_ctrl2_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - switch (reg.ftype_ois) { - case LSM6DSO_351Hz39: - *val = LSM6DSO_351Hz39; - break; - case LSM6DSO_236Hz63: - *val = LSM6DSO_236Hz63; - break; - case LSM6DSO_172Hz70: - *val = LSM6DSO_172Hz70; - break; - case LSM6DSO_937Hz91: - *val = LSM6DSO_937Hz91; - break; - default: - *val = LSM6DSO_351Hz39; - break; - } - return ret; + lsm6dso_ctrl2_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + switch (reg.ftype_ois) { + case LSM6DSO_351Hz39: + *val = LSM6DSO_351Hz39; + break; + case LSM6DSO_236Hz63: + *val = LSM6DSO_236Hz63; + break; + case LSM6DSO_172Hz70: + *val = LSM6DSO_172Hz70; + break; + case LSM6DSO_937Hz91: + *val = LSM6DSO_937Hz91; + break; + default: + *val = LSM6DSO_351Hz39; + break; + } + return ret; } /** @@ -2916,16 +2916,16 @@ int32_t lsm6dso_aux_gy_hp_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_hpm_ois_t val) { - lsm6dso_ctrl2_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.hpm_ois = (uint8_t)val & 0x03U; - reg.hp_en_ois = ((uint8_t)val & 0x10U) >> 4; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl2_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.hpm_ois = (uint8_t)val & 0x03U; + reg.hp_en_ois = ((uint8_t)val & 0x10U) >> 4; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -2938,31 +2938,31 @@ int32_t lsm6dso_aux_gy_hp_bandwidth_get(lsm6dso_ctx_t *ctx, lsm6dso_hpm_ois_t *val) { - lsm6dso_ctrl2_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1); - switch ((reg.hp_en_ois << 4) | reg.hpm_ois) { - case LSM6DSO_AUX_HP_DISABLE: - *val = LSM6DSO_AUX_HP_DISABLE; - break; - case LSM6DSO_AUX_HP_Hz016: - *val = LSM6DSO_AUX_HP_Hz016; - break; - case LSM6DSO_AUX_HP_Hz065: - *val = LSM6DSO_AUX_HP_Hz065; - break; - case LSM6DSO_AUX_HP_Hz260: - *val = LSM6DSO_AUX_HP_Hz260; - break; - case LSM6DSO_AUX_HP_1Hz040: - *val = LSM6DSO_AUX_HP_1Hz040; - break; - default: - *val = LSM6DSO_AUX_HP_DISABLE; - break; - } - return ret; + lsm6dso_ctrl2_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t *)®, 1); + switch ((reg.hp_en_ois << 4) | reg.hpm_ois) { + case LSM6DSO_AUX_HP_DISABLE: + *val = LSM6DSO_AUX_HP_DISABLE; + break; + case LSM6DSO_AUX_HP_Hz016: + *val = LSM6DSO_AUX_HP_Hz016; + break; + case LSM6DSO_AUX_HP_Hz065: + *val = LSM6DSO_AUX_HP_Hz065; + break; + case LSM6DSO_AUX_HP_Hz260: + *val = LSM6DSO_AUX_HP_Hz260; + break; + case LSM6DSO_AUX_HP_1Hz040: + *val = LSM6DSO_AUX_HP_1Hz040; + break; + default: + *val = LSM6DSO_AUX_HP_DISABLE; + break; + } + return ret; } /** @@ -2980,15 +2980,15 @@ int32_t lsm6dso_aux_gy_clamp_set(lsm6dso_ctx_t *ctx, lsm6dso_st_ois_clampdis_t val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.st_ois_clampdis = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.st_ois_clampdis = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -3006,22 +3006,22 @@ int32_t lsm6dso_aux_gy_clamp_get(lsm6dso_ctx_t *ctx, lsm6dso_st_ois_clampdis_t *val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - switch (reg.st_ois_clampdis) { - case LSM6DSO_ENABLE_CLAMP: - *val = LSM6DSO_ENABLE_CLAMP; - break; - case LSM6DSO_DISABLE_CLAMP: - *val = LSM6DSO_DISABLE_CLAMP; - break; - default: - *val = LSM6DSO_ENABLE_CLAMP; - break; - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + switch (reg.st_ois_clampdis) { + case LSM6DSO_ENABLE_CLAMP: + *val = LSM6DSO_ENABLE_CLAMP; + break; + case LSM6DSO_DISABLE_CLAMP: + *val = LSM6DSO_DISABLE_CLAMP; + break; + default: + *val = LSM6DSO_ENABLE_CLAMP; + break; + } + return ret; } /** @@ -3033,15 +3033,15 @@ */ int32_t lsm6dso_aux_gy_self_test_set(lsm6dso_ctx_t *ctx, lsm6dso_st_ois_t val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.st_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.st_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -3053,25 +3053,25 @@ */ int32_t lsm6dso_aux_gy_self_test_get(lsm6dso_ctx_t *ctx, lsm6dso_st_ois_t *val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - switch (reg.st_ois) { - case LSM6DSO_AUX_GY_DISABLE: - *val = LSM6DSO_AUX_GY_DISABLE; - break; - case LSM6DSO_AUX_GY_POS: - *val = LSM6DSO_AUX_GY_POS; - break; - case LSM6DSO_AUX_GY_NEG: - *val = LSM6DSO_AUX_GY_NEG; - break; - default: - *val = LSM6DSO_AUX_GY_DISABLE; - break; - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + switch (reg.st_ois) { + case LSM6DSO_AUX_GY_DISABLE: + *val = LSM6DSO_AUX_GY_DISABLE; + break; + case LSM6DSO_AUX_GY_POS: + *val = LSM6DSO_AUX_GY_POS; + break; + case LSM6DSO_AUX_GY_NEG: + *val = LSM6DSO_AUX_GY_NEG; + break; + default: + *val = LSM6DSO_AUX_GY_DISABLE; + break; + } + return ret; } /** @@ -3085,15 +3085,15 @@ int32_t lsm6dso_aux_xl_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_filter_xl_conf_ois_t val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.filter_xl_conf_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.filter_xl_conf_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -3107,41 +3107,41 @@ int32_t lsm6dso_aux_xl_bandwidth_get(lsm6dso_ctx_t *ctx, lsm6dso_filter_xl_conf_ois_t *val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - - switch (reg.filter_xl_conf_ois) { - case LSM6DSO_289Hz: - *val = LSM6DSO_289Hz; - break; - case LSM6DSO_258Hz: - *val = LSM6DSO_258Hz; - break; - case LSM6DSO_120Hz: - *val = LSM6DSO_120Hz; - break; - case LSM6DSO_65Hz2: - *val = LSM6DSO_65Hz2; - break; - case LSM6DSO_33Hz2: - *val = LSM6DSO_33Hz2; - break; - case LSM6DSO_16Hz6: - *val = LSM6DSO_16Hz6; - break; - case LSM6DSO_8Hz30: - *val = LSM6DSO_8Hz30; - break; - case LSM6DSO_4Hz15: - *val = LSM6DSO_4Hz15; - break; - default: - *val = LSM6DSO_289Hz; - break; - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + + switch (reg.filter_xl_conf_ois) { + case LSM6DSO_289Hz: + *val = LSM6DSO_289Hz; + break; + case LSM6DSO_258Hz: + *val = LSM6DSO_258Hz; + break; + case LSM6DSO_120Hz: + *val = LSM6DSO_120Hz; + break; + case LSM6DSO_65Hz2: + *val = LSM6DSO_65Hz2; + break; + case LSM6DSO_33Hz2: + *val = LSM6DSO_33Hz2; + break; + case LSM6DSO_16Hz6: + *val = LSM6DSO_16Hz6; + break; + case LSM6DSO_8Hz30: + *val = LSM6DSO_8Hz30; + break; + case LSM6DSO_4Hz15: + *val = LSM6DSO_4Hz15; + break; + default: + *val = LSM6DSO_289Hz; + break; + } + return ret; } /** @@ -3155,15 +3155,15 @@ int32_t lsm6dso_aux_xl_full_scale_set(lsm6dso_ctx_t *ctx, lsm6dso_fs_xl_ois_t val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - if (ret == 0) { - reg.fs_xl_ois = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + if (ret == 0) { + reg.fs_xl_ois = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + } + return ret; } /** @@ -3176,28 +3176,28 @@ int32_t lsm6dso_aux_xl_full_scale_get(lsm6dso_ctx_t *ctx, lsm6dso_fs_xl_ois_t *val) { - lsm6dso_ctrl3_ois_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t*)®, 1); - switch (reg.fs_xl_ois) { - case LSM6DSO_AUX_2g: - *val = LSM6DSO_AUX_2g; - break; - case LSM6DSO_AUX_16g: - *val = LSM6DSO_AUX_16g; - break; - case LSM6DSO_AUX_4g: - *val = LSM6DSO_AUX_4g; - break; - case LSM6DSO_AUX_8g: - *val = LSM6DSO_AUX_8g; - break; - default: - *val = LSM6DSO_AUX_2g; - break; - } - return ret; + lsm6dso_ctrl3_ois_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_OIS, (uint8_t *)®, 1); + switch (reg.fs_xl_ois) { + case LSM6DSO_AUX_2g: + *val = LSM6DSO_AUX_2g; + break; + case LSM6DSO_AUX_16g: + *val = LSM6DSO_AUX_16g; + break; + case LSM6DSO_AUX_4g: + *val = LSM6DSO_AUX_4g; + break; + case LSM6DSO_AUX_8g: + *val = LSM6DSO_AUX_8g; + break; + default: + *val = LSM6DSO_AUX_2g; + break; + } + return ret; } /** @@ -3223,15 +3223,15 @@ */ int32_t lsm6dso_sdo_sa0_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_sdo_pu_en_t val) { - lsm6dso_pin_ctrl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - if (ret == 0) { - reg.sdo_pu_en = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_pin_ctrl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + if (ret == 0) { + reg.sdo_pu_en = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + } + return ret; } /** @@ -3243,22 +3243,22 @@ */ int32_t lsm6dso_sdo_sa0_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_sdo_pu_en_t *val) { - lsm6dso_pin_ctrl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t*)®, 1); - switch (reg.sdo_pu_en) { - case LSM6DSO_PULL_UP_DISC: - *val = LSM6DSO_PULL_UP_DISC; - break; - case LSM6DSO_PULL_UP_CONNECT: - *val = LSM6DSO_PULL_UP_CONNECT; - break; - default: - *val = LSM6DSO_PULL_UP_DISC; - break; - } - return ret; + lsm6dso_pin_ctrl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_PIN_CTRL, (uint8_t *)®, 1); + switch (reg.sdo_pu_en) { + case LSM6DSO_PULL_UP_DISC: + *val = LSM6DSO_PULL_UP_DISC; + break; + case LSM6DSO_PULL_UP_CONNECT: + *val = LSM6DSO_PULL_UP_CONNECT; + break; + default: + *val = LSM6DSO_PULL_UP_DISC; + break; + } + return ret; } /** @@ -3270,15 +3270,15 @@ */ int32_t lsm6dso_spi_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_sim_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.sim = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.sim = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -3290,22 +3290,22 @@ */ int32_t lsm6dso_spi_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_sim_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - switch (reg.sim) { - case LSM6DSO_SPI_4_WIRE: - *val = LSM6DSO_SPI_4_WIRE; - break; - case LSM6DSO_SPI_3_WIRE: - *val = LSM6DSO_SPI_3_WIRE; - break; - default: - *val = LSM6DSO_SPI_4_WIRE; - break; - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + switch (reg.sim) { + case LSM6DSO_SPI_4_WIRE: + *val = LSM6DSO_SPI_4_WIRE; + break; + case LSM6DSO_SPI_3_WIRE: + *val = LSM6DSO_SPI_3_WIRE; + break; + default: + *val = LSM6DSO_SPI_4_WIRE; + break; + } + return ret; } /** @@ -3319,15 +3319,15 @@ int32_t lsm6dso_i2c_interface_set(lsm6dso_ctx_t *ctx, lsm6dso_i2c_disable_t val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.i2c_disable = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.i2c_disable = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -3341,22 +3341,22 @@ int32_t lsm6dso_i2c_interface_get(lsm6dso_ctx_t *ctx, lsm6dso_i2c_disable_t *val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - switch (reg.i2c_disable) { - case LSM6DSO_I2C_ENABLE: - *val = LSM6DSO_I2C_ENABLE; - break; - case LSM6DSO_I2C_DISABLE: - *val = LSM6DSO_I2C_DISABLE; - break; - default: - *val = LSM6DSO_I2C_ENABLE; - break; - } - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + switch (reg.i2c_disable) { + case LSM6DSO_I2C_ENABLE: + *val = LSM6DSO_I2C_ENABLE; + break; + case LSM6DSO_I2C_DISABLE: + *val = LSM6DSO_I2C_DISABLE; + break; + default: + *val = LSM6DSO_I2C_ENABLE; + break; + } + return ret; } /** @@ -3369,27 +3369,27 @@ */ int32_t lsm6dso_i3c_disable_set(lsm6dso_ctx_t *ctx, lsm6dso_i3c_disable_t val) { - lsm6dso_i3c_bus_avb_t i3c_bus_avb; - lsm6dso_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - if (ret == 0) { - ctrl9_xl.i3c_disable = ((uint8_t)val & 0x80U) >> 7; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, - (uint8_t*)&i3c_bus_avb, 1); - } - if (ret == 0) { - i3c_bus_avb.i3c_bus_avb_sel = (uint8_t)val & 0x03U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_I3C_BUS_AVB, - (uint8_t*)&i3c_bus_avb, 1); - } - - return ret; + lsm6dso_i3c_bus_avb_t i3c_bus_avb; + lsm6dso_ctrl9_xl_t ctrl9_xl; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + if (ret == 0) { + ctrl9_xl.i3c_disable = ((uint8_t)val & 0x80U) >> 7; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, + (uint8_t *)&i3c_bus_avb, 1); + } + if (ret == 0) { + i3c_bus_avb.i3c_bus_avb_sel = (uint8_t)val & 0x03U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_I3C_BUS_AVB, + (uint8_t *)&i3c_bus_avb, 1); + } + + return ret; } /** @@ -3402,37 +3402,37 @@ */ int32_t lsm6dso_i3c_disable_get(lsm6dso_ctx_t *ctx, lsm6dso_i3c_disable_t *val) { - lsm6dso_ctrl9_xl_t ctrl9_xl; - lsm6dso_i3c_bus_avb_t i3c_bus_avb; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, - (uint8_t*)&i3c_bus_avb, 1); - - switch ((ctrl9_xl.i3c_disable << 7) | i3c_bus_avb.i3c_bus_avb_sel) { - case LSM6DSO_I3C_DISABLE: - *val = LSM6DSO_I3C_DISABLE; - break; - case LSM6DSO_I3C_ENABLE_T_50us: - *val = LSM6DSO_I3C_ENABLE_T_50us; - break; - case LSM6DSO_I3C_ENABLE_T_2us: - *val = LSM6DSO_I3C_ENABLE_T_2us; - break; - case LSM6DSO_I3C_ENABLE_T_1ms: - *val = LSM6DSO_I3C_ENABLE_T_1ms; - break; - case LSM6DSO_I3C_ENABLE_T_25ms: - *val = LSM6DSO_I3C_ENABLE_T_25ms; - break; - default: - *val = LSM6DSO_I3C_DISABLE; - break; - } - } - return ret; + lsm6dso_ctrl9_xl_t ctrl9_xl; + lsm6dso_i3c_bus_avb_t i3c_bus_avb; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)&ctrl9_xl, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, + (uint8_t *)&i3c_bus_avb, 1); + + switch ((ctrl9_xl.i3c_disable << 7) | i3c_bus_avb.i3c_bus_avb_sel) { + case LSM6DSO_I3C_DISABLE: + *val = LSM6DSO_I3C_DISABLE; + break; + case LSM6DSO_I3C_ENABLE_T_50us: + *val = LSM6DSO_I3C_ENABLE_T_50us; + break; + case LSM6DSO_I3C_ENABLE_T_2us: + *val = LSM6DSO_I3C_ENABLE_T_2us; + break; + case LSM6DSO_I3C_ENABLE_T_1ms: + *val = LSM6DSO_I3C_ENABLE_T_1ms; + break; + case LSM6DSO_I3C_ENABLE_T_25ms: + *val = LSM6DSO_I3C_ENABLE_T_25ms; + break; + default: + *val = LSM6DSO_I3C_DISABLE; + break; + } + } + return ret; } /** @@ -3456,15 +3456,15 @@ */ int32_t lsm6dso_int1_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_int1_pd_en_t val) { - lsm6dso_i3c_bus_avb_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t*)®, 1); - if (ret == 0) { - reg.pd_dis_int1 = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t*)®, 1); - } - return ret; + lsm6dso_i3c_bus_avb_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t *)®, 1); + if (ret == 0) { + reg.pd_dis_int1 = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t *)®, 1); + } + return ret; } /** @@ -3476,22 +3476,22 @@ */ int32_t lsm6dso_int1_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_int1_pd_en_t *val) { - lsm6dso_i3c_bus_avb_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t*)®, 1); - switch (reg.pd_dis_int1) { - case LSM6DSO_PULL_DOWN_DISC: - *val = LSM6DSO_PULL_DOWN_DISC; - break; - case LSM6DSO_PULL_DOWN_CONNECT: - *val = LSM6DSO_PULL_DOWN_CONNECT; - break; - default: - *val = LSM6DSO_PULL_DOWN_DISC; - break; - } - return ret; + lsm6dso_i3c_bus_avb_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_I3C_BUS_AVB, (uint8_t *)®, 1); + switch (reg.pd_dis_int1) { + case LSM6DSO_PULL_DOWN_DISC: + *val = LSM6DSO_PULL_DOWN_DISC; + break; + case LSM6DSO_PULL_DOWN_CONNECT: + *val = LSM6DSO_PULL_DOWN_CONNECT; + break; + default: + *val = LSM6DSO_PULL_DOWN_DISC; + break; + } + return ret; } /** @@ -3506,102 +3506,100 @@ int32_t lsm6dso_pin_int1_route_set(lsm6dso_ctx_t *ctx, lsm6dso_pin_int1_route_t *val) { - lsm6dso_pin_int2_route_t pin_int2_route; - lsm6dso_tap_cfg2_t tap_cfg2; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INT1, - (uint8_t*)&val->emb_func_int1, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT1_A, - (uint8_t*)&val->fsm_int1_a, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT1_B, - (uint8_t*)&val->fsm_int1_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - if (ret == 0) { - if ( ( val->emb_func_int1.int1_fsm_lc - | val->emb_func_int1.int1_sig_mot - | val->emb_func_int1.int1_step_detector - | val->emb_func_int1.int1_tilt - | val->fsm_int1_a.int1_fsm1 - | val->fsm_int1_a.int1_fsm2 - | val->fsm_int1_a.int1_fsm3 - | val->fsm_int1_a.int1_fsm4 - | val->fsm_int1_a.int1_fsm5 - | val->fsm_int1_a.int1_fsm6 - | val->fsm_int1_a.int1_fsm7 - | val->fsm_int1_a.int1_fsm8 - | val->fsm_int1_b.int1_fsm9 - | val->fsm_int1_b.int1_fsm10 - | val->fsm_int1_b.int1_fsm11 - | val->fsm_int1_b.int1_fsm12 - | val->fsm_int1_b.int1_fsm13 - | val->fsm_int1_b.int1_fsm14 - | val->fsm_int1_b.int1_fsm15 - | val->fsm_int1_b.int1_fsm16) != PROPERTY_DISABLE){ - val->md1_cfg.int1_emb_func = PROPERTY_ENABLE; - } - else{ - val->md1_cfg.int1_emb_func = PROPERTY_DISABLE; - } - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT1_CTRL, - (uint8_t*)&val->int1_ctrl, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_MD1_CFG, (uint8_t*)&val->md1_cfg, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*) &tap_cfg2, 1); - } - - if (ret == 0) { - ret = lsm6dso_pin_int2_route_get(ctx, &pin_int2_route); - } - if (ret == 0) { - if ( ( pin_int2_route.int2_ctrl.int2_cnt_bdr - | pin_int2_route.int2_ctrl.int2_drdy_g - | pin_int2_route.int2_ctrl.int2_drdy_temp - | pin_int2_route.int2_ctrl.int2_drdy_xl - | pin_int2_route.int2_ctrl.int2_fifo_full - | pin_int2_route.int2_ctrl.int2_fifo_ovr - | pin_int2_route.int2_ctrl.int2_fifo_th - | pin_int2_route.md2_cfg.int2_6d - | pin_int2_route.md2_cfg.int2_double_tap - | pin_int2_route.md2_cfg.int2_ff - | pin_int2_route.md2_cfg.int2_wu - | pin_int2_route.md2_cfg.int2_single_tap - | pin_int2_route.md2_cfg.int2_sleep_change - | val->int1_ctrl.den_drdy_flag - | val->int1_ctrl.int1_boot - | val->int1_ctrl.int1_cnt_bdr - | val->int1_ctrl.int1_drdy_g - | val->int1_ctrl.int1_drdy_xl - | val->int1_ctrl.int1_fifo_full - | val->int1_ctrl.int1_fifo_ovr - | val->int1_ctrl.int1_fifo_th - | val->md1_cfg.int1_6d - | val->md1_cfg.int1_double_tap - | val->md1_cfg.int1_ff - | val->md1_cfg.int1_wu - | val->md1_cfg.int1_single_tap - | val->md1_cfg.int1_sleep_change) != PROPERTY_DISABLE) { - tap_cfg2.interrupts_enable = PROPERTY_ENABLE; - } - else{ - tap_cfg2.interrupts_enable = PROPERTY_DISABLE; - } - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*) &tap_cfg2, 1); - } - return ret; + lsm6dso_pin_int2_route_t pin_int2_route; + lsm6dso_tap_cfg2_t tap_cfg2; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INT1, + (uint8_t *)&val->emb_func_int1, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT1_A, + (uint8_t *)&val->fsm_int1_a, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT1_B, + (uint8_t *)&val->fsm_int1_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + if (ret == 0) { + if ((val->emb_func_int1.int1_fsm_lc + | val->emb_func_int1.int1_sig_mot + | val->emb_func_int1.int1_step_detector + | val->emb_func_int1.int1_tilt + | val->fsm_int1_a.int1_fsm1 + | val->fsm_int1_a.int1_fsm2 + | val->fsm_int1_a.int1_fsm3 + | val->fsm_int1_a.int1_fsm4 + | val->fsm_int1_a.int1_fsm5 + | val->fsm_int1_a.int1_fsm6 + | val->fsm_int1_a.int1_fsm7 + | val->fsm_int1_a.int1_fsm8 + | val->fsm_int1_b.int1_fsm9 + | val->fsm_int1_b.int1_fsm10 + | val->fsm_int1_b.int1_fsm11 + | val->fsm_int1_b.int1_fsm12 + | val->fsm_int1_b.int1_fsm13 + | val->fsm_int1_b.int1_fsm14 + | val->fsm_int1_b.int1_fsm15 + | val->fsm_int1_b.int1_fsm16) != PROPERTY_DISABLE) { + val->md1_cfg.int1_emb_func = PROPERTY_ENABLE; + } else { + val->md1_cfg.int1_emb_func = PROPERTY_DISABLE; + } + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT1_CTRL, + (uint8_t *)&val->int1_ctrl, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_MD1_CFG, (uint8_t *)&val->md1_cfg, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *) &tap_cfg2, 1); + } + + if (ret == 0) { + ret = lsm6dso_pin_int2_route_get(ctx, &pin_int2_route); + } + if (ret == 0) { + if ((pin_int2_route.int2_ctrl.int2_cnt_bdr + | pin_int2_route.int2_ctrl.int2_drdy_g + | pin_int2_route.int2_ctrl.int2_drdy_temp + | pin_int2_route.int2_ctrl.int2_drdy_xl + | pin_int2_route.int2_ctrl.int2_fifo_full + | pin_int2_route.int2_ctrl.int2_fifo_ovr + | pin_int2_route.int2_ctrl.int2_fifo_th + | pin_int2_route.md2_cfg.int2_6d + | pin_int2_route.md2_cfg.int2_double_tap + | pin_int2_route.md2_cfg.int2_ff + | pin_int2_route.md2_cfg.int2_wu + | pin_int2_route.md2_cfg.int2_single_tap + | pin_int2_route.md2_cfg.int2_sleep_change + | val->int1_ctrl.den_drdy_flag + | val->int1_ctrl.int1_boot + | val->int1_ctrl.int1_cnt_bdr + | val->int1_ctrl.int1_drdy_g + | val->int1_ctrl.int1_drdy_xl + | val->int1_ctrl.int1_fifo_full + | val->int1_ctrl.int1_fifo_ovr + | val->int1_ctrl.int1_fifo_th + | val->md1_cfg.int1_6d + | val->md1_cfg.int1_double_tap + | val->md1_cfg.int1_ff + | val->md1_cfg.int1_wu + | val->md1_cfg.int1_single_tap + | val->md1_cfg.int1_sleep_change) != PROPERTY_DISABLE) { + tap_cfg2.interrupts_enable = PROPERTY_ENABLE; + } else { + tap_cfg2.interrupts_enable = PROPERTY_DISABLE; + } + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *) &tap_cfg2, 1); + } + return ret; } /** @@ -3615,34 +3613,34 @@ int32_t lsm6dso_pin_int1_route_get(lsm6dso_ctx_t *ctx, lsm6dso_pin_int1_route_t *val) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INT1, - (uint8_t*)&val->emb_func_int1, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT1_A, - (uint8_t*)&val->fsm_int1_a, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT1_B, - (uint8_t*)&val->fsm_int1_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT1_CTRL, - (uint8_t*)&val->int1_ctrl, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MD1_CFG, (uint8_t*)&val->md1_cfg, 1); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INT1, + (uint8_t *)&val->emb_func_int1, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT1_A, + (uint8_t *)&val->fsm_int1_a, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT1_B, + (uint8_t *)&val->fsm_int1_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT1_CTRL, + (uint8_t *)&val->int1_ctrl, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MD1_CFG, (uint8_t *)&val->md1_cfg, 1); + } + + return ret; } /** @@ -3656,103 +3654,101 @@ int32_t lsm6dso_pin_int2_route_set(lsm6dso_ctx_t *ctx, lsm6dso_pin_int2_route_t *val) { - lsm6dso_pin_int1_route_t pin_int1_route; - lsm6dso_tap_cfg2_t tap_cfg2; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INT2, - (uint8_t*)&val->emb_func_int2, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT2_A, - (uint8_t*)&val->fsm_int2_a, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT2_B, - (uint8_t*)&val->fsm_int2_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - if (ret == 0) { - if (( val->emb_func_int2.int2_fsm_lc - | val->emb_func_int2.int2_sig_mot - | val->emb_func_int2.int2_step_detector - | val->emb_func_int2.int2_tilt - | val->fsm_int2_a.int2_fsm1 - | val->fsm_int2_a.int2_fsm2 - | val->fsm_int2_a.int2_fsm3 - | val->fsm_int2_a.int2_fsm4 - | val->fsm_int2_a.int2_fsm5 - | val->fsm_int2_a.int2_fsm6 - | val->fsm_int2_a.int2_fsm7 - | val->fsm_int2_a.int2_fsm8 - | val->fsm_int2_b.int2_fsm9 - | val->fsm_int2_b.int2_fsm10 - | val->fsm_int2_b.int2_fsm11 - | val->fsm_int2_b.int2_fsm12 - | val->fsm_int2_b.int2_fsm13 - | val->fsm_int2_b.int2_fsm14 - | val->fsm_int2_b.int2_fsm15 - | val->fsm_int2_b.int2_fsm16 )!= PROPERTY_DISABLE ){ - val->md2_cfg.int2_emb_func = PROPERTY_ENABLE; - } - else{ - val->md2_cfg.int2_emb_func = PROPERTY_DISABLE; - } - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT2_CTRL, - (uint8_t*)&val->int2_ctrl, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_MD2_CFG, (uint8_t*)&val->md2_cfg, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*) &tap_cfg2, 1); - } - - if (ret == 0) { - ret = lsm6dso_pin_int1_route_get(ctx, &pin_int1_route); - } - - if (ret == 0) { - if ( ( val->int2_ctrl.int2_cnt_bdr - | val->int2_ctrl.int2_drdy_g - | val->int2_ctrl.int2_drdy_temp - | val->int2_ctrl.int2_drdy_xl - | val->int2_ctrl.int2_fifo_full - | val->int2_ctrl.int2_fifo_ovr - | val->int2_ctrl.int2_fifo_th - | val->md2_cfg.int2_6d - | val->md2_cfg.int2_double_tap - | val->md2_cfg.int2_ff - | val->md2_cfg.int2_wu - | val->md2_cfg.int2_single_tap - | val->md2_cfg.int2_sleep_change - | pin_int1_route.int1_ctrl.den_drdy_flag - | pin_int1_route.int1_ctrl.int1_boot - | pin_int1_route.int1_ctrl.int1_cnt_bdr - | pin_int1_route.int1_ctrl.int1_drdy_g - | pin_int1_route.int1_ctrl.int1_drdy_xl - | pin_int1_route.int1_ctrl.int1_fifo_full - | pin_int1_route.int1_ctrl.int1_fifo_ovr - | pin_int1_route.int1_ctrl.int1_fifo_th - | pin_int1_route.md1_cfg.int1_6d - | pin_int1_route.md1_cfg.int1_double_tap - | pin_int1_route.md1_cfg.int1_ff - | pin_int1_route.md1_cfg.int1_wu - | pin_int1_route.md1_cfg.int1_single_tap - | pin_int1_route.md1_cfg.int1_sleep_change ) != PROPERTY_DISABLE) { - tap_cfg2.interrupts_enable = PROPERTY_ENABLE; - } - else{ - tap_cfg2.interrupts_enable = PROPERTY_DISABLE; - } - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*) &tap_cfg2, 1); - } - return ret; + lsm6dso_pin_int1_route_t pin_int1_route; + lsm6dso_tap_cfg2_t tap_cfg2; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INT2, + (uint8_t *)&val->emb_func_int2, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT2_A, + (uint8_t *)&val->fsm_int2_a, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_INT2_B, + (uint8_t *)&val->fsm_int2_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + if (ret == 0) { + if ((val->emb_func_int2.int2_fsm_lc + | val->emb_func_int2.int2_sig_mot + | val->emb_func_int2.int2_step_detector + | val->emb_func_int2.int2_tilt + | val->fsm_int2_a.int2_fsm1 + | val->fsm_int2_a.int2_fsm2 + | val->fsm_int2_a.int2_fsm3 + | val->fsm_int2_a.int2_fsm4 + | val->fsm_int2_a.int2_fsm5 + | val->fsm_int2_a.int2_fsm6 + | val->fsm_int2_a.int2_fsm7 + | val->fsm_int2_a.int2_fsm8 + | val->fsm_int2_b.int2_fsm9 + | val->fsm_int2_b.int2_fsm10 + | val->fsm_int2_b.int2_fsm11 + | val->fsm_int2_b.int2_fsm12 + | val->fsm_int2_b.int2_fsm13 + | val->fsm_int2_b.int2_fsm14 + | val->fsm_int2_b.int2_fsm15 + | val->fsm_int2_b.int2_fsm16) != PROPERTY_DISABLE) { + val->md2_cfg.int2_emb_func = PROPERTY_ENABLE; + } else { + val->md2_cfg.int2_emb_func = PROPERTY_DISABLE; + } + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT2_CTRL, + (uint8_t *)&val->int2_ctrl, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_MD2_CFG, (uint8_t *)&val->md2_cfg, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *) &tap_cfg2, 1); + } + + if (ret == 0) { + ret = lsm6dso_pin_int1_route_get(ctx, &pin_int1_route); + } + + if (ret == 0) { + if ((val->int2_ctrl.int2_cnt_bdr + | val->int2_ctrl.int2_drdy_g + | val->int2_ctrl.int2_drdy_temp + | val->int2_ctrl.int2_drdy_xl + | val->int2_ctrl.int2_fifo_full + | val->int2_ctrl.int2_fifo_ovr + | val->int2_ctrl.int2_fifo_th + | val->md2_cfg.int2_6d + | val->md2_cfg.int2_double_tap + | val->md2_cfg.int2_ff + | val->md2_cfg.int2_wu + | val->md2_cfg.int2_single_tap + | val->md2_cfg.int2_sleep_change + | pin_int1_route.int1_ctrl.den_drdy_flag + | pin_int1_route.int1_ctrl.int1_boot + | pin_int1_route.int1_ctrl.int1_cnt_bdr + | pin_int1_route.int1_ctrl.int1_drdy_g + | pin_int1_route.int1_ctrl.int1_drdy_xl + | pin_int1_route.int1_ctrl.int1_fifo_full + | pin_int1_route.int1_ctrl.int1_fifo_ovr + | pin_int1_route.int1_ctrl.int1_fifo_th + | pin_int1_route.md1_cfg.int1_6d + | pin_int1_route.md1_cfg.int1_double_tap + | pin_int1_route.md1_cfg.int1_ff + | pin_int1_route.md1_cfg.int1_wu + | pin_int1_route.md1_cfg.int1_single_tap + | pin_int1_route.md1_cfg.int1_sleep_change) != PROPERTY_DISABLE) { + tap_cfg2.interrupts_enable = PROPERTY_ENABLE; + } else { + tap_cfg2.interrupts_enable = PROPERTY_DISABLE; + } + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *) &tap_cfg2, 1); + } + return ret; } /** @@ -3766,33 +3762,33 @@ int32_t lsm6dso_pin_int2_route_get(lsm6dso_ctx_t *ctx, lsm6dso_pin_int2_route_t *val) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INT2, - (uint8_t*)&val->emb_func_int2, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT2_A, - (uint8_t*)&val->fsm_int2_a, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT2_B, - (uint8_t*)&val->fsm_int2_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT2_CTRL, - (uint8_t*)&val->int2_ctrl, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MD2_CFG, (uint8_t*)&val->md2_cfg, 1); - } - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INT2, + (uint8_t *)&val->emb_func_int2, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT2_A, + (uint8_t *)&val->fsm_int2_a, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_INT2_B, + (uint8_t *)&val->fsm_int2_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT2_CTRL, + (uint8_t *)&val->int2_ctrl, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MD2_CFG, (uint8_t *)&val->md2_cfg, 1); + } + return ret; } /** @@ -3804,15 +3800,15 @@ */ int32_t lsm6dso_pin_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_pp_od_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.pp_od = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.pp_od = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -3824,23 +3820,23 @@ */ int32_t lsm6dso_pin_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_pp_od_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - - switch (reg.pp_od) { - case LSM6DSO_PUSH_PULL: - *val = LSM6DSO_PUSH_PULL; - break; - case LSM6DSO_OPEN_DRAIN: - *val = LSM6DSO_OPEN_DRAIN; - break; - default: - *val = LSM6DSO_PUSH_PULL; - break; - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + + switch (reg.pp_od) { + case LSM6DSO_PUSH_PULL: + *val = LSM6DSO_PUSH_PULL; + break; + case LSM6DSO_OPEN_DRAIN: + *val = LSM6DSO_OPEN_DRAIN; + break; + default: + *val = LSM6DSO_PUSH_PULL; + break; + } + return ret; } /** @@ -3852,16 +3848,16 @@ */ int32_t lsm6dso_pin_polarity_set(lsm6dso_ctx_t *ctx, lsm6dso_h_lactive_t val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.h_lactive = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.h_lactive = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + } + + return ret; } /** @@ -3873,23 +3869,23 @@ */ int32_t lsm6dso_pin_polarity_get(lsm6dso_ctx_t *ctx, lsm6dso_h_lactive_t *val) { - lsm6dso_ctrl3_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)®, 1); - - switch (reg.h_lactive) { - case LSM6DSO_ACTIVE_HIGH: - *val = LSM6DSO_ACTIVE_HIGH; - break; - case LSM6DSO_ACTIVE_LOW: - *val = LSM6DSO_ACTIVE_LOW; - break; - default: - *val = LSM6DSO_ACTIVE_HIGH; - break; - } - return ret; + lsm6dso_ctrl3_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t *)®, 1); + + switch (reg.h_lactive) { + case LSM6DSO_ACTIVE_HIGH: + *val = LSM6DSO_ACTIVE_HIGH; + break; + case LSM6DSO_ACTIVE_LOW: + *val = LSM6DSO_ACTIVE_LOW; + break; + default: + *val = LSM6DSO_ACTIVE_HIGH; + break; + } + return ret; } /** @@ -3901,16 +3897,16 @@ */ int32_t lsm6dso_all_on_int1_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.int2_on_int1 = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.int2_on_int1 = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + } + + return ret; } /** @@ -3922,13 +3918,13 @@ */ int32_t lsm6dso_all_on_int1_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - *val = reg.int2_on_int1; - - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + *val = reg.int2_on_int1; + + return ret; } /** @@ -3940,32 +3936,32 @@ */ int32_t lsm6dso_int_notification_set(lsm6dso_ctx_t *ctx, lsm6dso_lir_t val) { - lsm6dso_tap_cfg0_t tap_cfg0; - lsm6dso_page_rw_t page_rw; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*) &tap_cfg0, 1); - if (ret == 0) { - tap_cfg0.lir = (uint8_t)val & 0x01U; - tap_cfg0.int_clr_on_read = (uint8_t)val & 0x01U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*) &tap_cfg0, 1); - } - if (ret == 0) { - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - page_rw.emb_func_lir = ((uint8_t)val & 0x02U) >> 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_tap_cfg0_t tap_cfg0; + lsm6dso_page_rw_t page_rw; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *) &tap_cfg0, 1); + if (ret == 0) { + tap_cfg0.lir = (uint8_t)val & 0x01U; + tap_cfg0.int_clr_on_read = (uint8_t)val & 0x01U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *) &tap_cfg0, 1); + } + if (ret == 0) { + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + page_rw.emb_func_lir = ((uint8_t)val & 0x02U) >> 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -3977,50 +3973,50 @@ */ int32_t lsm6dso_int_notification_get(lsm6dso_ctx_t *ctx, lsm6dso_lir_t *val) { - lsm6dso_tap_cfg0_t tap_cfg0; - lsm6dso_page_rw_t page_rw; - int32_t ret; - - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*) &tap_cfg0, 1); - if (ret == 0) { - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - if (ret == 0) { - switch ((page_rw.emb_func_lir << 1) | tap_cfg0.lir) { - case LSM6DSO_ALL_INT_PULSED: - *val = LSM6DSO_ALL_INT_PULSED; - break; - case LSM6DSO_BASE_LATCHED_EMB_PULSED: - *val = LSM6DSO_BASE_LATCHED_EMB_PULSED; - break; - case LSM6DSO_BASE_PULSED_EMB_LATCHED: - *val = LSM6DSO_BASE_PULSED_EMB_LATCHED; - break; - case LSM6DSO_ALL_INT_LATCHED: - *val = LSM6DSO_ALL_INT_LATCHED; - break; - default: - *val = LSM6DSO_ALL_INT_PULSED; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t*) &page_rw, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_tap_cfg0_t tap_cfg0; + lsm6dso_page_rw_t page_rw; + int32_t ret; + + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *) &tap_cfg0, 1); + if (ret == 0) { + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + if (ret == 0) { + switch ((page_rw.emb_func_lir << 1) | tap_cfg0.lir) { + case LSM6DSO_ALL_INT_PULSED: + *val = LSM6DSO_ALL_INT_PULSED; + break; + case LSM6DSO_BASE_LATCHED_EMB_PULSED: + *val = LSM6DSO_BASE_LATCHED_EMB_PULSED; + break; + case LSM6DSO_BASE_PULSED_EMB_LATCHED: + *val = LSM6DSO_BASE_PULSED_EMB_LATCHED; + break; + case LSM6DSO_ALL_INT_LATCHED: + *val = LSM6DSO_ALL_INT_LATCHED; + break; + default: + *val = LSM6DSO_ALL_INT_PULSED; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -4049,15 +4045,15 @@ int32_t lsm6dso_wkup_ths_weight_set(lsm6dso_ctx_t *ctx, lsm6dso_wake_ths_w_t val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - if (ret == 0) { - reg.wake_ths_w = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + if (ret == 0) { + reg.wake_ths_w = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + } + return ret; } /** @@ -4073,23 +4069,23 @@ int32_t lsm6dso_wkup_ths_weight_get(lsm6dso_ctx_t *ctx, lsm6dso_wake_ths_w_t *val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - - switch (reg.wake_ths_w) { - case LSM6DSO_LSb_FS_DIV_64: - *val = LSM6DSO_LSb_FS_DIV_64; - break; - case LSM6DSO_LSb_FS_DIV_256: - *val = LSM6DSO_LSb_FS_DIV_256; - break; - default: - *val = LSM6DSO_LSb_FS_DIV_64; - break; - } - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + + switch (reg.wake_ths_w) { + case LSM6DSO_LSb_FS_DIV_64: + *val = LSM6DSO_LSb_FS_DIV_64; + break; + case LSM6DSO_LSb_FS_DIV_256: + *val = LSM6DSO_LSb_FS_DIV_256; + break; + default: + *val = LSM6DSO_LSb_FS_DIV_64; + break; + } + return ret; } /** @@ -4102,15 +4098,15 @@ */ int32_t lsm6dso_wkup_threshold_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - if (ret == 0) { - reg.wk_ths = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + if (ret == 0) { + reg.wk_ths = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + } + return ret; } /** @@ -4123,13 +4119,13 @@ */ int32_t lsm6dso_wkup_threshold_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - *val = reg.wk_ths; - - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + *val = reg.wk_ths; + + return ret; } /** @@ -4142,15 +4138,15 @@ */ int32_t lsm6dso_xl_usr_offset_on_wkup_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - if (ret == 0) { - reg.usr_off_on_wu = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + if (ret == 0) { + reg.usr_off_on_wu = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + } + return ret; } /** @@ -4163,13 +4159,13 @@ */ int32_t lsm6dso_xl_usr_offset_on_wkup_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - *val = reg.usr_off_on_wu; - - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + *val = reg.usr_off_on_wu; + + return ret; } /** @@ -4182,15 +4178,15 @@ */ int32_t lsm6dso_wkup_dur_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - if (ret == 0) { - reg.wake_dur = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + if (ret == 0) { + reg.wake_dur = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + } + return ret; } /** @@ -4203,13 +4199,13 @@ */ int32_t lsm6dso_wkup_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - *val = reg.wake_dur; - - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + *val = reg.wake_dur; + + return ret; } /** @@ -4234,15 +4230,15 @@ */ int32_t lsm6dso_gy_sleep_mode_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.sleep_g = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - } - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.sleep_g = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + } + return ret; } /** @@ -4254,13 +4250,13 @@ */ int32_t lsm6dso_gy_sleep_mode_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl4_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1); - *val = reg.sleep_g; - - return ret; + lsm6dso_ctrl4_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)®, 1); + *val = reg.sleep_g; + + return ret; } /** @@ -4276,15 +4272,15 @@ int32_t lsm6dso_act_pin_notification_set(lsm6dso_ctx_t *ctx, lsm6dso_sleep_status_on_int_t val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - if (ret == 0) { - reg.sleep_status_on_int = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + if (ret == 0) { + reg.sleep_status_on_int = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + } + return ret; } /** @@ -4300,22 +4296,22 @@ int32_t lsm6dso_act_pin_notification_get(lsm6dso_ctx_t *ctx, lsm6dso_sleep_status_on_int_t *val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - switch (reg.sleep_status_on_int) { - case LSM6DSO_DRIVE_SLEEP_CHG_EVENT: - *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; - break; - case LSM6DSO_DRIVE_SLEEP_STATUS: - *val = LSM6DSO_DRIVE_SLEEP_STATUS; - break; - default: - *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; - break; - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + switch (reg.sleep_status_on_int) { + case LSM6DSO_DRIVE_SLEEP_CHG_EVENT: + *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; + break; + case LSM6DSO_DRIVE_SLEEP_STATUS: + *val = LSM6DSO_DRIVE_SLEEP_STATUS; + break; + default: + *val = LSM6DSO_DRIVE_SLEEP_CHG_EVENT; + break; + } + return ret; } /** @@ -4327,15 +4323,15 @@ */ int32_t lsm6dso_act_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_inact_en_t val) { - lsm6dso_tap_cfg2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - if (ret == 0) { - reg.inact_en = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + if (ret == 0) { + reg.inact_en = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + } + return ret; } /** @@ -4347,28 +4343,28 @@ */ int32_t lsm6dso_act_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_inact_en_t *val) { - lsm6dso_tap_cfg2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - switch (reg.inact_en) { - case LSM6DSO_XL_AND_GY_NOT_AFFECTED: - *val = LSM6DSO_XL_AND_GY_NOT_AFFECTED; - break; - case LSM6DSO_XL_12Hz5_GY_NOT_AFFECTED: - *val = LSM6DSO_XL_12Hz5_GY_NOT_AFFECTED; - break; - case LSM6DSO_XL_12Hz5_GY_SLEEP: - *val = LSM6DSO_XL_12Hz5_GY_SLEEP; - break; - case LSM6DSO_XL_12Hz5_GY_PD: - *val = LSM6DSO_XL_12Hz5_GY_PD; - break; - default: - *val = LSM6DSO_XL_AND_GY_NOT_AFFECTED; - break; - } - return ret; + lsm6dso_tap_cfg2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + switch (reg.inact_en) { + case LSM6DSO_XL_AND_GY_NOT_AFFECTED: + *val = LSM6DSO_XL_AND_GY_NOT_AFFECTED; + break; + case LSM6DSO_XL_12Hz5_GY_NOT_AFFECTED: + *val = LSM6DSO_XL_12Hz5_GY_NOT_AFFECTED; + break; + case LSM6DSO_XL_12Hz5_GY_SLEEP: + *val = LSM6DSO_XL_12Hz5_GY_SLEEP; + break; + case LSM6DSO_XL_12Hz5_GY_PD: + *val = LSM6DSO_XL_12Hz5_GY_PD; + break; + default: + *val = LSM6DSO_XL_AND_GY_NOT_AFFECTED; + break; + } + return ret; } /** @@ -4381,15 +4377,15 @@ */ int32_t lsm6dso_act_sleep_dur_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - if (ret == 0) { - reg.sleep_dur = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + if (ret == 0) { + reg.sleep_dur = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + } + return ret; } /** @@ -4402,13 +4398,13 @@ */ int32_t lsm6dso_act_sleep_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_wake_up_dur_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)®, 1); - *val = reg.sleep_dur; - - return ret; + lsm6dso_wake_up_dur_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)®, 1); + *val = reg.sleep_dur; + + return ret; } /** @@ -4433,15 +4429,15 @@ */ int32_t lsm6dso_tap_detection_on_z_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_z_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_z_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + } + return ret; } /** @@ -4453,13 +4449,13 @@ */ int32_t lsm6dso_tap_detection_on_z_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - *val = reg.tap_z_en; - - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + *val = reg.tap_z_en; + + return ret; } /** @@ -4471,15 +4467,15 @@ */ int32_t lsm6dso_tap_detection_on_y_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_y_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_y_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + } + return ret; } /** @@ -4491,13 +4487,13 @@ */ int32_t lsm6dso_tap_detection_on_y_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - *val = reg.tap_y_en; - - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + *val = reg.tap_y_en; + + return ret; } /** @@ -4509,15 +4505,15 @@ */ int32_t lsm6dso_tap_detection_on_x_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_x_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_x_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + } + return ret; } /** @@ -4529,13 +4525,13 @@ */ int32_t lsm6dso_tap_detection_on_x_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_cfg0_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t*)®, 1); - *val = reg.tap_x_en; - - return ret; + lsm6dso_tap_cfg0_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG0, (uint8_t *)®, 1); + *val = reg.tap_x_en; + + return ret; } /** @@ -4547,15 +4543,15 @@ */ int32_t lsm6dso_tap_threshold_x_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_cfg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_ths_x = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_ths_x = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + } + return ret; } /** @@ -4567,13 +4563,13 @@ */ int32_t lsm6dso_tap_threshold_x_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_cfg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - *val = reg.tap_ths_x; - - return ret; + lsm6dso_tap_cfg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + *val = reg.tap_ths_x; + + return ret; } /** @@ -4587,15 +4583,15 @@ int32_t lsm6dso_tap_axis_priority_set(lsm6dso_ctx_t *ctx, lsm6dso_tap_priority_t val) { - lsm6dso_tap_cfg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_priority = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_priority = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + } + return ret; } /** @@ -4609,34 +4605,34 @@ int32_t lsm6dso_tap_axis_priority_get(lsm6dso_ctx_t *ctx, lsm6dso_tap_priority_t *val) { - lsm6dso_tap_cfg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t*)®, 1); - switch (reg.tap_priority) { - case LSM6DSO_XYZ: - *val = LSM6DSO_XYZ; - break; - case LSM6DSO_YXZ: - *val = LSM6DSO_YXZ; - break; - case LSM6DSO_XZY: - *val = LSM6DSO_XZY; - break; - case LSM6DSO_ZYX: - *val = LSM6DSO_ZYX; - break; - case LSM6DSO_YZX: - *val = LSM6DSO_YZX; - break; - case LSM6DSO_ZXY: - *val = LSM6DSO_ZXY; - break; - default: - *val = LSM6DSO_XYZ; - break; - } - return ret; + lsm6dso_tap_cfg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG1, (uint8_t *)®, 1); + switch (reg.tap_priority) { + case LSM6DSO_XYZ: + *val = LSM6DSO_XYZ; + break; + case LSM6DSO_YXZ: + *val = LSM6DSO_YXZ; + break; + case LSM6DSO_XZY: + *val = LSM6DSO_XZY; + break; + case LSM6DSO_ZYX: + *val = LSM6DSO_ZYX; + break; + case LSM6DSO_YZX: + *val = LSM6DSO_YZX; + break; + case LSM6DSO_ZXY: + *val = LSM6DSO_ZXY; + break; + default: + *val = LSM6DSO_XYZ; + break; + } + return ret; } /** @@ -4648,15 +4644,15 @@ */ int32_t lsm6dso_tap_threshold_y_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_cfg2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_ths_y = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_cfg2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_ths_y = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + } + return ret; } /** @@ -4668,13 +4664,13 @@ */ int32_t lsm6dso_tap_threshold_y_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_cfg2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t*)®, 1); - *val = reg.tap_ths_y; - - return ret; + lsm6dso_tap_cfg2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_CFG2, (uint8_t *)®, 1); + *val = reg.tap_ths_y; + + return ret; } /** @@ -4686,15 +4682,15 @@ */ int32_t lsm6dso_tap_threshold_z_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - if (ret == 0) { - reg.tap_ths_z = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + if (ret == 0) { + reg.tap_ths_z = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + } + return ret; } /** @@ -4706,13 +4702,13 @@ */ int32_t lsm6dso_tap_threshold_z_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - *val = reg.tap_ths_z; - - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + *val = reg.tap_ths_z; + + return ret; } /** @@ -4729,15 +4725,15 @@ */ int32_t lsm6dso_tap_shock_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - if (ret == 0) { - reg.shock = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + if (ret == 0) { + reg.shock = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + } + return ret; } /** @@ -4754,13 +4750,13 @@ */ int32_t lsm6dso_tap_shock_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - *val = reg.shock; - - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + *val = reg.shock; + + return ret; } /** @@ -4778,15 +4774,15 @@ */ int32_t lsm6dso_tap_quiet_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - if (ret == 0) { - reg.quiet = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + if (ret == 0) { + reg.quiet = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + } + return ret; } /** @@ -4804,13 +4800,13 @@ */ int32_t lsm6dso_tap_quiet_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - *val = reg.quiet; - - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + *val = reg.quiet; + + return ret; } /** @@ -4829,15 +4825,15 @@ */ int32_t lsm6dso_tap_dur_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - if (ret == 0) { - reg.dur = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + if (ret == 0) { + reg.dur = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + } + return ret; } /** @@ -4856,13 +4852,13 @@ */ int32_t lsm6dso_tap_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_int_dur2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1); - *val = reg.dur; - - return ret; + lsm6dso_int_dur2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)®, 1); + *val = reg.dur; + + return ret; } /** @@ -4875,15 +4871,15 @@ int32_t lsm6dso_tap_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_single_double_tap_t val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - if (ret == 0) { - reg.single_double_tap = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - } - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + if (ret == 0) { + reg.single_double_tap = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + } + return ret; } /** @@ -4896,24 +4892,24 @@ int32_t lsm6dso_tap_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_single_double_tap_t *val) { - lsm6dso_wake_up_ths_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)®, 1); - - switch (reg.single_double_tap) { - case LSM6DSO_ONLY_SINGLE: - *val = LSM6DSO_ONLY_SINGLE; - break; - case LSM6DSO_BOTH_SINGLE_DOUBLE: - *val = LSM6DSO_BOTH_SINGLE_DOUBLE; - break; - default: - *val = LSM6DSO_ONLY_SINGLE; - break; - } - - return ret; + lsm6dso_wake_up_ths_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)®, 1); + + switch (reg.single_double_tap) { + case LSM6DSO_ONLY_SINGLE: + *val = LSM6DSO_ONLY_SINGLE; + break; + case LSM6DSO_BOTH_SINGLE_DOUBLE: + *val = LSM6DSO_BOTH_SINGLE_DOUBLE; + break; + default: + *val = LSM6DSO_ONLY_SINGLE; + break; + } + + return ret; } /** @@ -4938,15 +4934,15 @@ */ int32_t lsm6dso_6d_threshold_set(lsm6dso_ctx_t *ctx, lsm6dso_sixd_ths_t val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - if (ret == 0) { - reg.sixd_ths = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + if (ret == 0) { + reg.sixd_ths = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + } + return ret; } /** @@ -4958,28 +4954,28 @@ */ int32_t lsm6dso_6d_threshold_get(lsm6dso_ctx_t *ctx, lsm6dso_sixd_ths_t *val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - switch (reg.sixd_ths) { - case LSM6DSO_DEG_80: - *val = LSM6DSO_DEG_80; - break; - case LSM6DSO_DEG_70: - *val = LSM6DSO_DEG_70; - break; - case LSM6DSO_DEG_60: - *val = LSM6DSO_DEG_60; - break; - case LSM6DSO_DEG_50: - *val = LSM6DSO_DEG_50; - break; - default: - *val = LSM6DSO_DEG_80; - break; - } - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + switch (reg.sixd_ths) { + case LSM6DSO_DEG_80: + *val = LSM6DSO_DEG_80; + break; + case LSM6DSO_DEG_70: + *val = LSM6DSO_DEG_70; + break; + case LSM6DSO_DEG_60: + *val = LSM6DSO_DEG_60; + break; + case LSM6DSO_DEG_50: + *val = LSM6DSO_DEG_50; + break; + default: + *val = LSM6DSO_DEG_80; + break; + } + return ret; } /** @@ -4991,15 +4987,15 @@ */ int32_t lsm6dso_4d_mode_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - if (ret == 0) { - reg.d4d_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - } - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + if (ret == 0) { + reg.d4d_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + } + return ret; } /** @@ -5011,13 +5007,13 @@ */ int32_t lsm6dso_4d_mode_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_tap_ths_6d_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t*)®, 1); - *val = reg.d4d_en; - - return ret; + lsm6dso_tap_ths_6d_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_TAP_THS_6D, (uint8_t *)®, 1); + *val = reg.d4d_en; + + return ret; } /** @@ -5041,15 +5037,15 @@ */ int32_t lsm6dso_ff_threshold_set(lsm6dso_ctx_t *ctx, lsm6dso_ff_ths_t val) { - lsm6dso_free_fall_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)®, 1); - if (ret == 0) { - reg.ff_ths = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)®, 1); - } - return ret; + lsm6dso_free_fall_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)®, 1); + if (ret == 0) { + reg.ff_ths = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)®, 1); + } + return ret; } /** @@ -5061,40 +5057,40 @@ */ int32_t lsm6dso_ff_threshold_get(lsm6dso_ctx_t *ctx, lsm6dso_ff_ths_t *val) { - lsm6dso_free_fall_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)®, 1); - switch (reg.ff_ths) { - case LSM6DSO_FF_TSH_156mg: - *val = LSM6DSO_FF_TSH_156mg; - break; - case LSM6DSO_FF_TSH_219mg: - *val = LSM6DSO_FF_TSH_219mg; - break; - case LSM6DSO_FF_TSH_250mg: - *val = LSM6DSO_FF_TSH_250mg; - break; - case LSM6DSO_FF_TSH_312mg: - *val = LSM6DSO_FF_TSH_312mg; - break; - case LSM6DSO_FF_TSH_344mg: - *val = LSM6DSO_FF_TSH_344mg; - break; - case LSM6DSO_FF_TSH_406mg: - *val = LSM6DSO_FF_TSH_406mg; - break; - case LSM6DSO_FF_TSH_469mg: - *val = LSM6DSO_FF_TSH_469mg; - break; - case LSM6DSO_FF_TSH_500mg: - *val = LSM6DSO_FF_TSH_500mg; - break; - default: - *val = LSM6DSO_FF_TSH_156mg; - break; - } - return ret; + lsm6dso_free_fall_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)®, 1); + switch (reg.ff_ths) { + case LSM6DSO_FF_TSH_156mg: + *val = LSM6DSO_FF_TSH_156mg; + break; + case LSM6DSO_FF_TSH_219mg: + *val = LSM6DSO_FF_TSH_219mg; + break; + case LSM6DSO_FF_TSH_250mg: + *val = LSM6DSO_FF_TSH_250mg; + break; + case LSM6DSO_FF_TSH_312mg: + *val = LSM6DSO_FF_TSH_312mg; + break; + case LSM6DSO_FF_TSH_344mg: + *val = LSM6DSO_FF_TSH_344mg; + break; + case LSM6DSO_FF_TSH_406mg: + *val = LSM6DSO_FF_TSH_406mg; + break; + case LSM6DSO_FF_TSH_469mg: + *val = LSM6DSO_FF_TSH_469mg; + break; + case LSM6DSO_FF_TSH_500mg: + *val = LSM6DSO_FF_TSH_500mg; + break; + default: + *val = LSM6DSO_FF_TSH_156mg; + break; + } + return ret; } /** @@ -5107,24 +5103,24 @@ */ int32_t lsm6dso_ff_dur_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_wake_up_dur_t wake_up_dur; - lsm6dso_free_fall_t free_fall; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)&free_fall, 1); - } - if (ret == 0) { - wake_up_dur.ff_dur = ((uint8_t)val & 0x20U) >> 5; - free_fall.ff_dur = (uint8_t)val & 0x1FU; - ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, - (uint8_t*)&wake_up_dur, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)&free_fall, 1); - } - return ret; + lsm6dso_wake_up_dur_t wake_up_dur; + lsm6dso_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)&wake_up_dur, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)&free_fall, 1); + } + if (ret == 0) { + wake_up_dur.ff_dur = ((uint8_t)val & 0x20U) >> 5; + free_fall.ff_dur = (uint8_t)val & 0x1FU; + ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_DUR, + (uint8_t *)&wake_up_dur, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)&free_fall, 1); + } + return ret; } /** @@ -5137,16 +5133,16 @@ */ int32_t lsm6dso_ff_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_wake_up_dur_t wake_up_dur; - lsm6dso_free_fall_t free_fall; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t*)&free_fall, 1); - *val = (wake_up_dur.ff_dur << 5) + free_fall.ff_dur; - } - return ret; + lsm6dso_wake_up_dur_t wake_up_dur; + lsm6dso_free_fall_t free_fall; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_DUR, (uint8_t *)&wake_up_dur, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FREE_FALL, (uint8_t *)&free_fall, 1); + *val = (wake_up_dur.ff_dur << 5) + free_fall.ff_dur; + } + return ret; } /** @@ -5170,20 +5166,20 @@ */ int32_t lsm6dso_fifo_watermark_set(lsm6dso_ctx_t *ctx, uint16_t val) { - lsm6dso_fifo_ctrl1_t fifo_ctrl1; - lsm6dso_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - if (ret == 0) { - fifo_ctrl1.wtm = 0x00FFU & (uint8_t)val; - fifo_ctrl2.wtm = (uint8_t)(( 0x0100U & val ) >> 8); - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL1, (uint8_t*)&fifo_ctrl1, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - } - return ret; + lsm6dso_fifo_ctrl1_t fifo_ctrl1; + lsm6dso_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&fifo_ctrl2, 1); + if (ret == 0) { + fifo_ctrl1.wtm = 0x00FFU & (uint8_t)val; + fifo_ctrl2.wtm = (uint8_t)((0x0100U & val) >> 8); + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL1, (uint8_t *)&fifo_ctrl1, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&fifo_ctrl2, 1); + } + return ret; } /** @@ -5195,16 +5191,16 @@ */ int32_t lsm6dso_fifo_watermark_get(lsm6dso_ctx_t *ctx, uint16_t *val) { - lsm6dso_fifo_ctrl1_t fifo_ctrl1; - lsm6dso_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL1, (uint8_t*)&fifo_ctrl1, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - *val = ((uint16_t)fifo_ctrl2.wtm << 8) + (uint16_t)fifo_ctrl1.wtm; - } - return ret; + lsm6dso_fifo_ctrl1_t fifo_ctrl1; + lsm6dso_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL1, (uint8_t *)&fifo_ctrl1, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&fifo_ctrl2, 1); + *val = ((uint16_t)fifo_ctrl2.wtm << 8) + (uint16_t)fifo_ctrl1.wtm; + } + return ret; } /** @@ -5217,22 +5213,22 @@ */ int32_t lsm6dso_compression_algo_init_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_emb_func_init_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.fifo_compr_init = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_init_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.fifo_compr_init = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -5245,19 +5241,19 @@ */ int32_t lsm6dso_compression_algo_init_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_init_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.fifo_compr_init; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_init_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.fifo_compr_init; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -5271,35 +5267,35 @@ int32_t lsm6dso_compression_algo_set(lsm6dso_ctx_t *ctx, lsm6dso_uncoptr_rate_t val) { - lsm6dso_emb_func_en_b_t emb_func_en_b; - lsm6dso_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, - (uint8_t*)&emb_func_en_b, 1); - } - if (ret == 0) { - emb_func_en_b.fifo_compr_en = ((uint8_t)val & 0x04U) >> 2; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, - (uint8_t*)&emb_func_en_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - if (ret == 0) { - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, - (uint8_t*)&fifo_ctrl2, 1); - } - if (ret == 0) { - fifo_ctrl2.fifo_compr_rt_en = ((uint8_t)val & 0x04U) >> 2; - fifo_ctrl2.uncoptr_rate = (uint8_t)val & 0x03U; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, - (uint8_t*)&fifo_ctrl2, 1); - } - return ret; + lsm6dso_emb_func_en_b_t emb_func_en_b; + lsm6dso_fifo_ctrl2_t fifo_ctrl2; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, + (uint8_t *)&emb_func_en_b, 1); + } + if (ret == 0) { + emb_func_en_b.fifo_compr_en = ((uint8_t)val & 0x04U) >> 2; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, + (uint8_t *)&emb_func_en_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + if (ret == 0) { + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + if (ret == 0) { + fifo_ctrl2.fifo_compr_rt_en = ((uint8_t)val & 0x04U) >> 2; + fifo_ctrl2.uncoptr_rate = (uint8_t)val & 0x03U; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, + (uint8_t *)&fifo_ctrl2, 1); + } + return ret; } /** @@ -5313,32 +5309,32 @@ int32_t lsm6dso_compression_algo_get(lsm6dso_ctx_t *ctx, lsm6dso_uncoptr_rate_t *val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - - switch ((reg.fifo_compr_rt_en<<2) | reg.uncoptr_rate) { - case LSM6DSO_CMP_DISABLE: - *val = LSM6DSO_CMP_DISABLE; - break; - case LSM6DSO_CMP_ALWAYS: - *val = LSM6DSO_CMP_ALWAYS; - break; - case LSM6DSO_CMP_8_TO_1: - *val = LSM6DSO_CMP_8_TO_1; - break; - case LSM6DSO_CMP_16_TO_1: - *val = LSM6DSO_CMP_16_TO_1; - break; - case LSM6DSO_CMP_32_TO_1: - *val = LSM6DSO_CMP_32_TO_1; - break; - default: - *val = LSM6DSO_CMP_DISABLE; - break; - } - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + + switch ((reg.fifo_compr_rt_en << 2) | reg.uncoptr_rate) { + case LSM6DSO_CMP_DISABLE: + *val = LSM6DSO_CMP_DISABLE; + break; + case LSM6DSO_CMP_ALWAYS: + *val = LSM6DSO_CMP_ALWAYS; + break; + case LSM6DSO_CMP_8_TO_1: + *val = LSM6DSO_CMP_8_TO_1; + break; + case LSM6DSO_CMP_16_TO_1: + *val = LSM6DSO_CMP_16_TO_1; + break; + case LSM6DSO_CMP_32_TO_1: + *val = LSM6DSO_CMP_32_TO_1; + break; + default: + *val = LSM6DSO_CMP_DISABLE; + break; + } + return ret; } /** @@ -5351,15 +5347,15 @@ int32_t lsm6dso_fifo_virtual_sens_odr_chg_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - if (ret == 0) { - reg.odrchg_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + if (ret == 0) { + reg.odrchg_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + } + return ret; } /** @@ -5372,13 +5368,13 @@ int32_t lsm6dso_fifo_virtual_sens_odr_chg_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - *val = reg.odrchg_en; - - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + *val = reg.odrchg_en; + + return ret; } /** @@ -5392,15 +5388,15 @@ int32_t lsm6dso_compression_algo_real_time_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - if (ret == 0) { - reg.fifo_compr_rt_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + if (ret == 0) { + reg.fifo_compr_rt_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + } + return ret; } /** @@ -5413,13 +5409,13 @@ int32_t lsm6dso_compression_algo_real_time_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - *val = reg.fifo_compr_rt_en; - - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + *val = reg.fifo_compr_rt_en; + + return ret; } /** @@ -5432,15 +5428,15 @@ */ int32_t lsm6dso_fifo_stop_on_wtm_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - if (ret == 0) { - reg.stop_on_wtm = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + if (ret == 0) { + reg.stop_on_wtm = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + } + return ret; } /** @@ -5453,13 +5449,13 @@ */ int32_t lsm6dso_fifo_stop_on_wtm_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_ctrl2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t*)®, 1); - *val = reg.stop_on_wtm; - - return ret; + lsm6dso_fifo_ctrl2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)®, 1); + *val = reg.stop_on_wtm; + + return ret; } /** @@ -5472,15 +5468,15 @@ */ int32_t lsm6dso_fifo_xl_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_bdr_xl_t val) { - lsm6dso_fifo_ctrl3_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - if (ret == 0) { - reg.bdr_xl = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl3_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + if (ret == 0) { + reg.bdr_xl = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + } + return ret; } /** @@ -5493,53 +5489,53 @@ */ int32_t lsm6dso_fifo_xl_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_bdr_xl_t *val) { - lsm6dso_fifo_ctrl3_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - switch (reg.bdr_xl) { - case LSM6DSO_XL_NOT_BATCHED: - *val = LSM6DSO_XL_NOT_BATCHED; - break; - case LSM6DSO_XL_BATCHED_AT_12Hz5: - *val = LSM6DSO_XL_BATCHED_AT_12Hz5; - break; - case LSM6DSO_XL_BATCHED_AT_26Hz: - *val = LSM6DSO_XL_BATCHED_AT_26Hz; - break; - case LSM6DSO_XL_BATCHED_AT_52Hz: - *val = LSM6DSO_XL_BATCHED_AT_52Hz; - break; - case LSM6DSO_XL_BATCHED_AT_104Hz: - *val = LSM6DSO_XL_BATCHED_AT_104Hz; - break; - case LSM6DSO_XL_BATCHED_AT_208Hz: - *val = LSM6DSO_XL_BATCHED_AT_208Hz; - break; - case LSM6DSO_XL_BATCHED_AT_417Hz: - *val = LSM6DSO_XL_BATCHED_AT_417Hz; - break; - case LSM6DSO_XL_BATCHED_AT_833Hz: - *val = LSM6DSO_XL_BATCHED_AT_833Hz; - break; - case LSM6DSO_XL_BATCHED_AT_1667Hz: - *val = LSM6DSO_XL_BATCHED_AT_1667Hz; - break; - case LSM6DSO_XL_BATCHED_AT_3333Hz: - *val = LSM6DSO_XL_BATCHED_AT_3333Hz; - break; - case LSM6DSO_XL_BATCHED_AT_6667Hz: - *val = LSM6DSO_XL_BATCHED_AT_6667Hz; - break; - case LSM6DSO_XL_BATCHED_AT_6Hz5: - *val = LSM6DSO_XL_BATCHED_AT_6Hz5; - break; - default: - *val = LSM6DSO_XL_NOT_BATCHED; - break; - } - - return ret; + lsm6dso_fifo_ctrl3_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + switch (reg.bdr_xl) { + case LSM6DSO_XL_NOT_BATCHED: + *val = LSM6DSO_XL_NOT_BATCHED; + break; + case LSM6DSO_XL_BATCHED_AT_12Hz5: + *val = LSM6DSO_XL_BATCHED_AT_12Hz5; + break; + case LSM6DSO_XL_BATCHED_AT_26Hz: + *val = LSM6DSO_XL_BATCHED_AT_26Hz; + break; + case LSM6DSO_XL_BATCHED_AT_52Hz: + *val = LSM6DSO_XL_BATCHED_AT_52Hz; + break; + case LSM6DSO_XL_BATCHED_AT_104Hz: + *val = LSM6DSO_XL_BATCHED_AT_104Hz; + break; + case LSM6DSO_XL_BATCHED_AT_208Hz: + *val = LSM6DSO_XL_BATCHED_AT_208Hz; + break; + case LSM6DSO_XL_BATCHED_AT_417Hz: + *val = LSM6DSO_XL_BATCHED_AT_417Hz; + break; + case LSM6DSO_XL_BATCHED_AT_833Hz: + *val = LSM6DSO_XL_BATCHED_AT_833Hz; + break; + case LSM6DSO_XL_BATCHED_AT_1667Hz: + *val = LSM6DSO_XL_BATCHED_AT_1667Hz; + break; + case LSM6DSO_XL_BATCHED_AT_3333Hz: + *val = LSM6DSO_XL_BATCHED_AT_3333Hz; + break; + case LSM6DSO_XL_BATCHED_AT_6667Hz: + *val = LSM6DSO_XL_BATCHED_AT_6667Hz; + break; + case LSM6DSO_XL_BATCHED_AT_6Hz5: + *val = LSM6DSO_XL_BATCHED_AT_6Hz5; + break; + default: + *val = LSM6DSO_XL_NOT_BATCHED; + break; + } + + return ret; } /** @@ -5552,15 +5548,15 @@ */ int32_t lsm6dso_fifo_gy_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_bdr_gy_t val) { - lsm6dso_fifo_ctrl3_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - if (ret == 0) { - reg.bdr_gy = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl3_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + if (ret == 0) { + reg.bdr_gy = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + } + return ret; } /** @@ -5573,52 +5569,52 @@ */ int32_t lsm6dso_fifo_gy_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_bdr_gy_t *val) { - lsm6dso_fifo_ctrl3_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t*)®, 1); - switch (reg.bdr_gy) { - case LSM6DSO_GY_NOT_BATCHED: - *val = LSM6DSO_GY_NOT_BATCHED; - break; - case LSM6DSO_GY_BATCHED_AT_12Hz5: - *val = LSM6DSO_GY_BATCHED_AT_12Hz5; - break; - case LSM6DSO_GY_BATCHED_AT_26Hz: - *val = LSM6DSO_GY_BATCHED_AT_26Hz; - break; - case LSM6DSO_GY_BATCHED_AT_52Hz: - *val = LSM6DSO_GY_BATCHED_AT_52Hz; - break; - case LSM6DSO_GY_BATCHED_AT_104Hz: - *val = LSM6DSO_GY_BATCHED_AT_104Hz; - break; - case LSM6DSO_GY_BATCHED_AT_208Hz: - *val = LSM6DSO_GY_BATCHED_AT_208Hz; - break; - case LSM6DSO_GY_BATCHED_AT_417Hz: - *val = LSM6DSO_GY_BATCHED_AT_417Hz; - break; - case LSM6DSO_GY_BATCHED_AT_833Hz: - *val = LSM6DSO_GY_BATCHED_AT_833Hz; - break; - case LSM6DSO_GY_BATCHED_AT_1667Hz: - *val = LSM6DSO_GY_BATCHED_AT_1667Hz; - break; - case LSM6DSO_GY_BATCHED_AT_3333Hz: - *val = LSM6DSO_GY_BATCHED_AT_3333Hz; - break; - case LSM6DSO_GY_BATCHED_AT_6667Hz: - *val = LSM6DSO_GY_BATCHED_AT_6667Hz; - break; - case LSM6DSO_GY_BATCHED_AT_6Hz5: - *val = LSM6DSO_GY_BATCHED_AT_6Hz5; - break; - default: - *val = LSM6DSO_GY_NOT_BATCHED; - break; - } - return ret; + lsm6dso_fifo_ctrl3_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL3, (uint8_t *)®, 1); + switch (reg.bdr_gy) { + case LSM6DSO_GY_NOT_BATCHED: + *val = LSM6DSO_GY_NOT_BATCHED; + break; + case LSM6DSO_GY_BATCHED_AT_12Hz5: + *val = LSM6DSO_GY_BATCHED_AT_12Hz5; + break; + case LSM6DSO_GY_BATCHED_AT_26Hz: + *val = LSM6DSO_GY_BATCHED_AT_26Hz; + break; + case LSM6DSO_GY_BATCHED_AT_52Hz: + *val = LSM6DSO_GY_BATCHED_AT_52Hz; + break; + case LSM6DSO_GY_BATCHED_AT_104Hz: + *val = LSM6DSO_GY_BATCHED_AT_104Hz; + break; + case LSM6DSO_GY_BATCHED_AT_208Hz: + *val = LSM6DSO_GY_BATCHED_AT_208Hz; + break; + case LSM6DSO_GY_BATCHED_AT_417Hz: + *val = LSM6DSO_GY_BATCHED_AT_417Hz; + break; + case LSM6DSO_GY_BATCHED_AT_833Hz: + *val = LSM6DSO_GY_BATCHED_AT_833Hz; + break; + case LSM6DSO_GY_BATCHED_AT_1667Hz: + *val = LSM6DSO_GY_BATCHED_AT_1667Hz; + break; + case LSM6DSO_GY_BATCHED_AT_3333Hz: + *val = LSM6DSO_GY_BATCHED_AT_3333Hz; + break; + case LSM6DSO_GY_BATCHED_AT_6667Hz: + *val = LSM6DSO_GY_BATCHED_AT_6667Hz; + break; + case LSM6DSO_GY_BATCHED_AT_6Hz5: + *val = LSM6DSO_GY_BATCHED_AT_6Hz5; + break; + default: + *val = LSM6DSO_GY_NOT_BATCHED; + break; + } + return ret; } /** @@ -5630,15 +5626,15 @@ */ int32_t lsm6dso_fifo_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_fifo_mode_t val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - if (ret == 0) { - reg.fifo_mode = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + if (ret == 0) { + reg.fifo_mode = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + } + return ret; } /** @@ -5650,35 +5646,35 @@ */ int32_t lsm6dso_fifo_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_fifo_mode_t *val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - - switch (reg.fifo_mode) { - case LSM6DSO_BYPASS_MODE: - *val = LSM6DSO_BYPASS_MODE; - break; - case LSM6DSO_FIFO_MODE: - *val = LSM6DSO_FIFO_MODE; - break; - case LSM6DSO_STREAM_TO_FIFO_MODE: - *val = LSM6DSO_STREAM_TO_FIFO_MODE; - break; - case LSM6DSO_BYPASS_TO_STREAM_MODE: - *val = LSM6DSO_BYPASS_TO_STREAM_MODE; - break; - case LSM6DSO_STREAM_MODE: - *val = LSM6DSO_STREAM_MODE; - break; - case LSM6DSO_BYPASS_TO_FIFO_MODE: - *val = LSM6DSO_BYPASS_TO_FIFO_MODE; - break; - default: - *val = LSM6DSO_BYPASS_MODE; - break; - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + + switch (reg.fifo_mode) { + case LSM6DSO_BYPASS_MODE: + *val = LSM6DSO_BYPASS_MODE; + break; + case LSM6DSO_FIFO_MODE: + *val = LSM6DSO_FIFO_MODE; + break; + case LSM6DSO_STREAM_TO_FIFO_MODE: + *val = LSM6DSO_STREAM_TO_FIFO_MODE; + break; + case LSM6DSO_BYPASS_TO_STREAM_MODE: + *val = LSM6DSO_BYPASS_TO_STREAM_MODE; + break; + case LSM6DSO_STREAM_MODE: + *val = LSM6DSO_STREAM_MODE; + break; + case LSM6DSO_BYPASS_TO_FIFO_MODE: + *val = LSM6DSO_BYPASS_TO_FIFO_MODE; + break; + default: + *val = LSM6DSO_BYPASS_MODE; + break; + } + return ret; } /** @@ -5692,15 +5688,15 @@ int32_t lsm6dso_fifo_temp_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_t_batch_t val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - if (ret == 0) { - reg.odr_t_batch = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + if (ret == 0) { + reg.odr_t_batch = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + } + return ret; } /** @@ -5714,29 +5710,29 @@ int32_t lsm6dso_fifo_temp_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_t_batch_t *val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - - switch (reg.odr_t_batch) { - case LSM6DSO_TEMP_NOT_BATCHED: - *val = LSM6DSO_TEMP_NOT_BATCHED; - break; - case LSM6DSO_TEMP_BATCHED_AT_1Hz6: - *val = LSM6DSO_TEMP_BATCHED_AT_1Hz6; - break; - case LSM6DSO_TEMP_BATCHED_AT_12Hz5: - *val = LSM6DSO_TEMP_BATCHED_AT_12Hz5; - break; - case LSM6DSO_TEMP_BATCHED_AT_52Hz: - *val = LSM6DSO_TEMP_BATCHED_AT_52Hz; - break; - default: - *val = LSM6DSO_TEMP_NOT_BATCHED; - break; - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + + switch (reg.odr_t_batch) { + case LSM6DSO_TEMP_NOT_BATCHED: + *val = LSM6DSO_TEMP_NOT_BATCHED; + break; + case LSM6DSO_TEMP_BATCHED_AT_1Hz6: + *val = LSM6DSO_TEMP_BATCHED_AT_1Hz6; + break; + case LSM6DSO_TEMP_BATCHED_AT_12Hz5: + *val = LSM6DSO_TEMP_BATCHED_AT_12Hz5; + break; + case LSM6DSO_TEMP_BATCHED_AT_52Hz: + *val = LSM6DSO_TEMP_BATCHED_AT_52Hz; + break; + default: + *val = LSM6DSO_TEMP_NOT_BATCHED; + break; + } + return ret; } /** @@ -5751,15 +5747,15 @@ int32_t lsm6dso_fifo_timestamp_decimation_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - if (ret == 0) { - reg.odr_ts_batch = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + if (ret == 0) { + reg.odr_ts_batch = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + } + return ret; } /** @@ -5774,28 +5770,28 @@ int32_t lsm6dso_fifo_timestamp_decimation_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t *val) { - lsm6dso_fifo_ctrl4_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1); - switch (reg.odr_ts_batch) { - case LSM6DSO_NO_DECIMATION: - *val = LSM6DSO_NO_DECIMATION; - break; - case LSM6DSO_DEC_1: - *val = LSM6DSO_DEC_1; - break; - case LSM6DSO_DEC_8: - *val = LSM6DSO_DEC_8; - break; - case LSM6DSO_DEC_32: - *val = LSM6DSO_DEC_32; - break; - default: - *val = LSM6DSO_NO_DECIMATION; - break; - } - return ret; + lsm6dso_fifo_ctrl4_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t *)®, 1); + switch (reg.odr_ts_batch) { + case LSM6DSO_NO_DECIMATION: + *val = LSM6DSO_NO_DECIMATION; + break; + case LSM6DSO_DEC_1: + *val = LSM6DSO_DEC_1; + break; + case LSM6DSO_DEC_8: + *val = LSM6DSO_DEC_8; + break; + case LSM6DSO_DEC_32: + *val = LSM6DSO_DEC_32; + break; + default: + *val = LSM6DSO_NO_DECIMATION; + break; + } + return ret; } /** @@ -5810,15 +5806,15 @@ int32_t lsm6dso_fifo_cnt_event_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_trig_counter_bdr_t val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - if (ret == 0) { - reg.trig_counter_bdr = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - } - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + if (ret == 0) { + reg.trig_counter_bdr = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + } + return ret; } /** @@ -5833,22 +5829,22 @@ int32_t lsm6dso_fifo_cnt_event_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_trig_counter_bdr_t *val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - switch (reg.trig_counter_bdr) { - case LSM6DSO_XL_BATCH_EVENT: - *val = LSM6DSO_XL_BATCH_EVENT; - break; - case LSM6DSO_GYRO_BATCH_EVENT: - *val = LSM6DSO_GYRO_BATCH_EVENT; - break; - default: - *val = LSM6DSO_XL_BATCH_EVENT; - break; - } - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + switch (reg.trig_counter_bdr) { + case LSM6DSO_XL_BATCH_EVENT: + *val = LSM6DSO_XL_BATCH_EVENT; + break; + case LSM6DSO_GYRO_BATCH_EVENT: + *val = LSM6DSO_GYRO_BATCH_EVENT; + break; + default: + *val = LSM6DSO_XL_BATCH_EVENT; + break; + } + return ret; } /** @@ -5862,15 +5858,15 @@ */ int32_t lsm6dso_rst_batch_counter_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - if (ret == 0) { - reg.rst_counter_bdr = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - } - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + if (ret == 0) { + reg.rst_counter_bdr = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + } + return ret; } /** @@ -5884,13 +5880,13 @@ */ int32_t lsm6dso_rst_batch_counter_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_counter_bdr_reg1_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1); - *val = reg.rst_counter_bdr; - - return ret; + lsm6dso_counter_bdr_reg1_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®, 1); + *val = reg.rst_counter_bdr; + + return ret; } /** @@ -5903,23 +5899,23 @@ */ int32_t lsm6dso_batch_counter_threshold_set(lsm6dso_ctx_t *ctx, uint16_t val) { - lsm6dso_counter_bdr_reg1_t counter_bdr_reg1; - lsm6dso_counter_bdr_reg2_t counter_bdr_reg2; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, - (uint8_t*)&counter_bdr_reg1, 1); - if (ret == 0) { - counter_bdr_reg2.cnt_bdr_th = 0x00FFU & (uint8_t)val; - counter_bdr_reg1.cnt_bdr_th = (uint8_t)(0x0700U & val) >> 8; - ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, - (uint8_t*)&counter_bdr_reg1, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG2, - (uint8_t*)&counter_bdr_reg2, 1); - } - return ret; + lsm6dso_counter_bdr_reg1_t counter_bdr_reg1; + lsm6dso_counter_bdr_reg2_t counter_bdr_reg2; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, + (uint8_t *)&counter_bdr_reg1, 1); + if (ret == 0) { + counter_bdr_reg2.cnt_bdr_th = 0x00FFU & (uint8_t)val; + counter_bdr_reg1.cnt_bdr_th = (uint8_t)(0x0700U & val) >> 8; + ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, + (uint8_t *)&counter_bdr_reg1, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG2, + (uint8_t *)&counter_bdr_reg2, 1); + } + return ret; } /** @@ -5932,21 +5928,21 @@ */ int32_t lsm6dso_batch_counter_threshold_get(lsm6dso_ctx_t *ctx, uint16_t *val) { - lsm6dso_counter_bdr_reg1_t counter_bdr_reg1; - lsm6dso_counter_bdr_reg2_t counter_bdr_reg2; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, - (uint8_t*)&counter_bdr_reg1, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG2, - (uint8_t*)&counter_bdr_reg2, 1); - - *val = ((uint16_t)counter_bdr_reg1.cnt_bdr_th << 8) - + (uint16_t)counter_bdr_reg2.cnt_bdr_th; - } - - return ret; + lsm6dso_counter_bdr_reg1_t counter_bdr_reg1; + lsm6dso_counter_bdr_reg2_t counter_bdr_reg2; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, + (uint8_t *)&counter_bdr_reg1, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG2, + (uint8_t *)&counter_bdr_reg2, 1); + + *val = ((uint16_t)counter_bdr_reg1.cnt_bdr_th << 8) + + (uint16_t)counter_bdr_reg2.cnt_bdr_th; + } + + return ret; } /** @@ -5958,19 +5954,19 @@ */ int32_t lsm6dso_fifo_data_level_get(lsm6dso_ctx_t *ctx, uint16_t *val) { - lsm6dso_fifo_status1_t fifo_status1; - lsm6dso_fifo_status2_t fifo_status2; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS1, - (uint8_t*)&fifo_status1, 1); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, - (uint8_t*)&fifo_status2, 1); - *val = ((uint16_t)fifo_status2.diff_fifo << 8) + - (uint16_t)fifo_status1.diff_fifo; - } - return ret; + lsm6dso_fifo_status1_t fifo_status1; + lsm6dso_fifo_status2_t fifo_status2; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS1, + (uint8_t *)&fifo_status1, 1); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, + (uint8_t *)&fifo_status2, 1); + *val = ((uint16_t)fifo_status2.diff_fifo << 8) + + (uint16_t)fifo_status1.diff_fifo; + } + return ret; } /** @@ -5983,9 +5979,9 @@ int32_t lsm6dso_fifo_status_get(lsm6dso_ctx_t *ctx, lsm6dso_fifo_status2_t *val) { - int32_t ret; - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t*) val, 1); - return ret; + int32_t ret; + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t *) val, 1); + return ret; } /** @@ -5997,13 +5993,13 @@ */ int32_t lsm6dso_fifo_full_flag_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_status2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t*)®, 1); - *val = reg.fifo_full_ia; - - return ret; + lsm6dso_fifo_status2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t *)®, 1); + *val = reg.fifo_full_ia; + + return ret; } /** @@ -6016,13 +6012,13 @@ */ int32_t lsm6dso_fifo_ovr_flag_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_status2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t*)®, 1); - *val = reg.fifo_ovr_ia; - - return ret; + lsm6dso_fifo_status2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t *)®, 1); + *val = reg.fifo_ovr_ia; + + return ret; } /** @@ -6034,13 +6030,13 @@ */ int32_t lsm6dso_fifo_wtm_flag_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_fifo_status2_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t*)®, 1); - *val = reg.fifo_wtm_ia; - - return ret; + lsm6dso_fifo_status2_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_STATUS2, (uint8_t *)®, 1); + *val = reg.fifo_wtm_ia; + + return ret; } /** @@ -6053,79 +6049,79 @@ int32_t lsm6dso_fifo_sensor_tag_get(lsm6dso_ctx_t *ctx, lsm6dso_fifo_tag_t *val) { - lsm6dso_fifo_data_out_tag_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_DATA_OUT_TAG, (uint8_t*)®, 1); - switch (reg.tag_sensor) { - case LSM6DSO_GYRO_NC_TAG: - *val = LSM6DSO_GYRO_NC_TAG; - break; - case LSM6DSO_XL_NC_TAG: - *val = LSM6DSO_XL_NC_TAG; - break; - case LSM6DSO_TEMPERATURE_TAG: - *val = LSM6DSO_TEMPERATURE_TAG; - break; - case LSM6DSO_CFG_CHANGE_TAG: - *val = LSM6DSO_CFG_CHANGE_TAG; - break; - case LSM6DSO_XL_NC_T_2_TAG: - *val = LSM6DSO_XL_NC_T_2_TAG; - break; - case LSM6DSO_XL_NC_T_1_TAG: - *val = LSM6DSO_XL_NC_T_1_TAG; - break; - case LSM6DSO_XL_2XC_TAG: - *val = LSM6DSO_XL_2XC_TAG; - break; - case LSM6DSO_XL_3XC_TAG: - *val = LSM6DSO_XL_3XC_TAG; - break; - case LSM6DSO_GYRO_NC_T_2_TAG: - *val = LSM6DSO_GYRO_NC_T_2_TAG; - break; - case LSM6DSO_GYRO_NC_T_1_TAG: - *val = LSM6DSO_GYRO_NC_T_1_TAG; - break; - case LSM6DSO_GYRO_2XC_TAG: - *val = LSM6DSO_GYRO_2XC_TAG; - break; - case LSM6DSO_GYRO_3XC_TAG: - *val = LSM6DSO_GYRO_3XC_TAG; - break; - case LSM6DSO_SENSORHUB_SLAVE0_TAG: - *val = LSM6DSO_SENSORHUB_SLAVE0_TAG; - break; - case LSM6DSO_SENSORHUB_SLAVE1_TAG: - *val = LSM6DSO_SENSORHUB_SLAVE1_TAG; - break; - case LSM6DSO_SENSORHUB_SLAVE2_TAG: - *val = LSM6DSO_SENSORHUB_SLAVE2_TAG; - break; - case LSM6DSO_SENSORHUB_SLAVE3_TAG: - *val = LSM6DSO_SENSORHUB_SLAVE3_TAG; - break; - case LSM6DSO_STEP_CPUNTER_TAG: - *val = LSM6DSO_STEP_CPUNTER_TAG; - break; - case LSM6DSO_GAME_ROTATION_TAG: - *val = LSM6DSO_GAME_ROTATION_TAG; - break; - case LSM6DSO_GEOMAG_ROTATION_TAG: - *val = LSM6DSO_GEOMAG_ROTATION_TAG; - break; - case LSM6DSO_ROTATION_TAG: - *val = LSM6DSO_ROTATION_TAG; - break; - case LSM6DSO_SENSORHUB_NACK_TAG: - *val = LSM6DSO_SENSORHUB_NACK_TAG; - break; - default: - *val = LSM6DSO_GYRO_NC_TAG; - break; - } - return ret; + lsm6dso_fifo_data_out_tag_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_DATA_OUT_TAG, (uint8_t *)®, 1); + switch (reg.tag_sensor) { + case LSM6DSO_GYRO_NC_TAG: + *val = LSM6DSO_GYRO_NC_TAG; + break; + case LSM6DSO_XL_NC_TAG: + *val = LSM6DSO_XL_NC_TAG; + break; + case LSM6DSO_TEMPERATURE_TAG: + *val = LSM6DSO_TEMPERATURE_TAG; + break; + case LSM6DSO_CFG_CHANGE_TAG: + *val = LSM6DSO_CFG_CHANGE_TAG; + break; + case LSM6DSO_XL_NC_T_2_TAG: + *val = LSM6DSO_XL_NC_T_2_TAG; + break; + case LSM6DSO_XL_NC_T_1_TAG: + *val = LSM6DSO_XL_NC_T_1_TAG; + break; + case LSM6DSO_XL_2XC_TAG: + *val = LSM6DSO_XL_2XC_TAG; + break; + case LSM6DSO_XL_3XC_TAG: + *val = LSM6DSO_XL_3XC_TAG; + break; + case LSM6DSO_GYRO_NC_T_2_TAG: + *val = LSM6DSO_GYRO_NC_T_2_TAG; + break; + case LSM6DSO_GYRO_NC_T_1_TAG: + *val = LSM6DSO_GYRO_NC_T_1_TAG; + break; + case LSM6DSO_GYRO_2XC_TAG: + *val = LSM6DSO_GYRO_2XC_TAG; + break; + case LSM6DSO_GYRO_3XC_TAG: + *val = LSM6DSO_GYRO_3XC_TAG; + break; + case LSM6DSO_SENSORHUB_SLAVE0_TAG: + *val = LSM6DSO_SENSORHUB_SLAVE0_TAG; + break; + case LSM6DSO_SENSORHUB_SLAVE1_TAG: + *val = LSM6DSO_SENSORHUB_SLAVE1_TAG; + break; + case LSM6DSO_SENSORHUB_SLAVE2_TAG: + *val = LSM6DSO_SENSORHUB_SLAVE2_TAG; + break; + case LSM6DSO_SENSORHUB_SLAVE3_TAG: + *val = LSM6DSO_SENSORHUB_SLAVE3_TAG; + break; + case LSM6DSO_STEP_CPUNTER_TAG: + *val = LSM6DSO_STEP_CPUNTER_TAG; + break; + case LSM6DSO_GAME_ROTATION_TAG: + *val = LSM6DSO_GAME_ROTATION_TAG; + break; + case LSM6DSO_GEOMAG_ROTATION_TAG: + *val = LSM6DSO_GEOMAG_ROTATION_TAG; + break; + case LSM6DSO_ROTATION_TAG: + *val = LSM6DSO_ROTATION_TAG; + break; + case LSM6DSO_SENSORHUB_NACK_TAG: + *val = LSM6DSO_SENSORHUB_NACK_TAG; + break; + default: + *val = LSM6DSO_GYRO_NC_TAG; + break; + } + return ret; } /** @@ -6139,22 +6135,22 @@ */ int32_t lsm6dso_fifo_pedo_batch_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_emb_func_fifo_cfg_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.pedo_fifo_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, - (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_fifo_cfg_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.pedo_fifo_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, + (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6167,18 +6163,18 @@ */ int32_t lsm6dso_fifo_pedo_batch_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_fifo_cfg_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.pedo_fifo_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_fifo_cfg_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.pedo_fifo_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6191,21 +6187,21 @@ */ int32_t lsm6dso_sh_batch_slave_0_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_slv0_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.batch_ext_sens_0_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv0_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.batch_ext_sens_0_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6218,18 +6214,18 @@ */ int32_t lsm6dso_sh_batch_slave_0_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_slv0_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.batch_ext_sens_0_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv0_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.batch_ext_sens_0_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6242,22 +6238,22 @@ */ int32_t lsm6dso_sh_batch_slave_1_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_slv1_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.batch_ext_sens_1_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv1_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.batch_ext_sens_1_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -6270,18 +6266,18 @@ */ int32_t lsm6dso_sh_batch_slave_1_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_slv1_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - *val = reg.batch_ext_sens_1_en; - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv1_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + *val = reg.batch_ext_sens_1_en; + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6294,22 +6290,22 @@ */ int32_t lsm6dso_sh_batch_slave_2_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_slv2_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.batch_ext_sens_2_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv2_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.batch_ext_sens_2_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6322,19 +6318,19 @@ */ int32_t lsm6dso_sh_batch_slave_2_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_slv2_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.batch_ext_sens_2_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv2_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.batch_ext_sens_2_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -6347,22 +6343,22 @@ */ int32_t lsm6dso_sh_batch_slave_3_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_slv3_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.batch_ext_sens_3_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv3_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.batch_ext_sens_3_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -6375,19 +6371,19 @@ */ int32_t lsm6dso_sh_batch_slave_3_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_slv3_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.batch_ext_sens_3_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv3_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.batch_ext_sens_3_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -6412,16 +6408,16 @@ */ int32_t lsm6dso_den_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_den_mode_t val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_mode = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_mode = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6433,32 +6429,32 @@ */ int32_t lsm6dso_den_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_den_mode_t *val) { - lsm6dso_ctrl6_c_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)®, 1); - - switch (reg.den_mode) { - case LSM6DSO_DEN_DISABLE: - *val = LSM6DSO_DEN_DISABLE; - break; - case LSM6DSO_LEVEL_FIFO: - *val = LSM6DSO_LEVEL_FIFO; - break; - case LSM6DSO_LEVEL_LETCHED: - *val = LSM6DSO_LEVEL_LETCHED; - break; - case LSM6DSO_LEVEL_TRIGGER: - *val = LSM6DSO_LEVEL_TRIGGER; - break; - case LSM6DSO_EDGE_TRIGGER: - *val = LSM6DSO_EDGE_TRIGGER; - break; - default: - *val = LSM6DSO_DEN_DISABLE; - break; - } - return ret; + lsm6dso_ctrl6_c_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1); + + switch (reg.den_mode) { + case LSM6DSO_DEN_DISABLE: + *val = LSM6DSO_DEN_DISABLE; + break; + case LSM6DSO_LEVEL_FIFO: + *val = LSM6DSO_LEVEL_FIFO; + break; + case LSM6DSO_LEVEL_LETCHED: + *val = LSM6DSO_LEVEL_LETCHED; + break; + case LSM6DSO_LEVEL_TRIGGER: + *val = LSM6DSO_LEVEL_TRIGGER; + break; + case LSM6DSO_EDGE_TRIGGER: + *val = LSM6DSO_EDGE_TRIGGER; + break; + default: + *val = LSM6DSO_DEN_DISABLE; + break; + } + return ret; } /** @@ -6470,16 +6466,16 @@ */ int32_t lsm6dso_den_polarity_set(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_t val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_lh = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_lh = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6491,23 +6487,23 @@ */ int32_t lsm6dso_den_polarity_get(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_t *val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - - switch (reg.den_lh) { - case LSM6DSO_DEN_ACT_LOW: - *val = LSM6DSO_DEN_ACT_LOW; - break; - case LSM6DSO_DEN_ACT_HIGH: - *val = LSM6DSO_DEN_ACT_HIGH; - break; - default: - *val = LSM6DSO_DEN_ACT_LOW; - break; - } - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + + switch (reg.den_lh) { + case LSM6DSO_DEN_ACT_LOW: + *val = LSM6DSO_DEN_ACT_LOW; + break; + case LSM6DSO_DEN_ACT_HIGH: + *val = LSM6DSO_DEN_ACT_HIGH; + break; + default: + *val = LSM6DSO_DEN_ACT_LOW; + break; + } + return ret; } /** @@ -6519,16 +6515,16 @@ */ int32_t lsm6dso_den_enable_set(lsm6dso_ctx_t *ctx, lsm6dso_den_xl_g_t val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_xl_g = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_xl_g = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6540,26 +6536,26 @@ */ int32_t lsm6dso_den_enable_get(lsm6dso_ctx_t *ctx, lsm6dso_den_xl_g_t *val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - - switch (reg.den_xl_g) { - case LSM6DSO_STAMP_IN_GY_DATA: - *val = LSM6DSO_STAMP_IN_GY_DATA; - break; - case LSM6DSO_STAMP_IN_XL_DATA: - *val = LSM6DSO_STAMP_IN_XL_DATA; - break; - case LSM6DSO_STAMP_IN_GY_XL_DATA: - *val = LSM6DSO_STAMP_IN_GY_XL_DATA; - break; - default: - *val = LSM6DSO_STAMP_IN_GY_DATA; - break; - } - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + + switch (reg.den_xl_g) { + case LSM6DSO_STAMP_IN_GY_DATA: + *val = LSM6DSO_STAMP_IN_GY_DATA; + break; + case LSM6DSO_STAMP_IN_XL_DATA: + *val = LSM6DSO_STAMP_IN_XL_DATA; + break; + case LSM6DSO_STAMP_IN_GY_XL_DATA: + *val = LSM6DSO_STAMP_IN_GY_XL_DATA; + break; + default: + *val = LSM6DSO_STAMP_IN_GY_DATA; + break; + } + return ret; } /** @@ -6571,16 +6567,16 @@ */ int32_t lsm6dso_den_mark_axis_x_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_z = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_z = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6592,13 +6588,13 @@ */ int32_t lsm6dso_den_mark_axis_x_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - *val = reg.den_z; - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + *val = reg.den_z; + + return ret; } /** @@ -6610,16 +6606,16 @@ */ int32_t lsm6dso_den_mark_axis_y_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_y = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_y = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6631,13 +6627,13 @@ */ int32_t lsm6dso_den_mark_axis_y_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - *val = reg.den_y; - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + *val = reg.den_y; + + return ret; } /** @@ -6649,16 +6645,16 @@ */ int32_t lsm6dso_den_mark_axis_z_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - if (ret == 0) { - reg.den_x = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - } - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + if (ret == 0) { + reg.den_x = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + } + + return ret; } /** @@ -6670,13 +6666,13 @@ */ int32_t lsm6dso_den_mark_axis_z_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_ctrl9_xl_t reg; - int32_t ret; - - ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t*)®, 1); - *val = reg.den_x; - - return ret; + lsm6dso_ctrl9_xl_t reg; + int32_t ret; + + ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL9_XL, (uint8_t *)®, 1); + *val = reg.den_x; + + return ret; } /** @@ -6700,45 +6696,45 @@ */ int32_t lsm6dso_pedo_sens_set(lsm6dso_ctx_t *ctx, lsm6dso_pedo_md_t val) { - lsm6dso_emb_func_en_a_t emb_func_en_a; - lsm6dso_emb_func_en_b_t emb_func_en_b; - lsm6dso_pedo_cmd_reg_t pedo_cmd_reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, - (uint8_t*)&pedo_cmd_reg); - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, - (uint8_t*)&emb_func_en_a, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, - (uint8_t*)&emb_func_en_b, 1); - - emb_func_en_a.pedo_en = (uint8_t)val & 0x01U; - emb_func_en_b.pedo_adv_en = ((uint8_t)val & 0x02U)>>1; - pedo_cmd_reg.fp_rejection_en = ((uint8_t)val & 0x10U)>>4; - pedo_cmd_reg.ad_det_en = ((uint8_t)val & 0x20U)>>5; - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, - (uint8_t*)&emb_func_en_a, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, - (uint8_t*)&emb_func_en_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - if (ret == 0) { - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_CMD_REG, - (uint8_t*)&pedo_cmd_reg); - } - return ret; + lsm6dso_emb_func_en_a_t emb_func_en_a; + lsm6dso_emb_func_en_b_t emb_func_en_b; + lsm6dso_pedo_cmd_reg_t pedo_cmd_reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, + (uint8_t *)&pedo_cmd_reg); + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, + (uint8_t *)&emb_func_en_a, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, + (uint8_t *)&emb_func_en_b, 1); + + emb_func_en_a.pedo_en = (uint8_t)val & 0x01U; + emb_func_en_b.pedo_adv_en = ((uint8_t)val & 0x02U) >> 1; + pedo_cmd_reg.fp_rejection_en = ((uint8_t)val & 0x10U) >> 4; + pedo_cmd_reg.ad_det_en = ((uint8_t)val & 0x20U) >> 5; + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, + (uint8_t *)&emb_func_en_a, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, + (uint8_t *)&emb_func_en_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + if (ret == 0) { + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_CMD_REG, + (uint8_t *)&pedo_cmd_reg); + } + return ret; } /** @@ -6750,49 +6746,49 @@ */ int32_t lsm6dso_pedo_sens_get(lsm6dso_ctx_t *ctx, lsm6dso_pedo_md_t *val) { - lsm6dso_emb_func_en_a_t emb_func_en_a; - lsm6dso_emb_func_en_b_t emb_func_en_b; - lsm6dso_pedo_cmd_reg_t pedo_cmd_reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, - (uint8_t*)&pedo_cmd_reg); - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, - (uint8_t*)&emb_func_en_a, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, - (uint8_t*)&emb_func_en_b, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - switch ( (pedo_cmd_reg.ad_det_en <<5) | (pedo_cmd_reg.fp_rejection_en << 4) | - (emb_func_en_b.pedo_adv_en << 1) | emb_func_en_a.pedo_en) { - case LSM6DSO_PEDO_DISABLE: - *val = LSM6DSO_PEDO_DISABLE; - break; - case LSM6DSO_PEDO_BASE_MODE: - *val = LSM6DSO_PEDO_BASE_MODE; - break; - case LSM6DSO_PEDO_ADV_MODE: - *val = LSM6DSO_PEDO_ADV_MODE; - break; - case LSM6DSO_FALSE_STEP_REJ: - *val = LSM6DSO_FALSE_STEP_REJ; - break; - case LSM6DSO_FALSE_STEP_REJ_ADV_MODE: - *val = LSM6DSO_FALSE_STEP_REJ_ADV_MODE; - break; - default: - *val = LSM6DSO_PEDO_DISABLE; - break; - } - return ret; + lsm6dso_emb_func_en_a_t emb_func_en_a; + lsm6dso_emb_func_en_b_t emb_func_en_b; + lsm6dso_pedo_cmd_reg_t pedo_cmd_reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, + (uint8_t *)&pedo_cmd_reg); + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, + (uint8_t *)&emb_func_en_a, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, + (uint8_t *)&emb_func_en_b, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + switch ((pedo_cmd_reg.ad_det_en << 5) | (pedo_cmd_reg.fp_rejection_en << 4) | + (emb_func_en_b.pedo_adv_en << 1) | emb_func_en_a.pedo_en) { + case LSM6DSO_PEDO_DISABLE: + *val = LSM6DSO_PEDO_DISABLE; + break; + case LSM6DSO_PEDO_BASE_MODE: + *val = LSM6DSO_PEDO_BASE_MODE; + break; + case LSM6DSO_PEDO_ADV_MODE: + *val = LSM6DSO_PEDO_ADV_MODE; + break; + case LSM6DSO_FALSE_STEP_REJ: + *val = LSM6DSO_FALSE_STEP_REJ; + break; + case LSM6DSO_FALSE_STEP_REJ_ADV_MODE: + *val = LSM6DSO_FALSE_STEP_REJ_ADV_MODE; + break; + default: + *val = LSM6DSO_PEDO_DISABLE; + break; + } + return ret; } /** @@ -6804,19 +6800,19 @@ */ int32_t lsm6dso_pedo_step_detect_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_status_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.is_step_det; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_status_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.is_step_det; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -6828,9 +6824,9 @@ */ int32_t lsm6dso_pedo_debounce_steps_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_DEB_STEPS_CONF, buff); - return ret; + int32_t ret; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_DEB_STEPS_CONF, buff); + return ret; } /** @@ -6842,9 +6838,9 @@ */ int32_t lsm6dso_pedo_debounce_steps_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_DEB_STEPS_CONF, buff); - return ret; + int32_t ret; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_DEB_STEPS_CONF, buff); + return ret; } /** @@ -6856,17 +6852,17 @@ */ int32_t lsm6dso_pedo_steps_period_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_H, - &buff[index]); - } - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_H, + &buff[index]); + } + return ret; } /** @@ -6878,17 +6874,17 @@ */ int32_t lsm6dso_pedo_steps_period_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_H, - &buff[index]); - } - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_SC_DELTAT_H, + &buff[index]); + } + return ret; } /** @@ -6902,16 +6898,16 @@ int32_t lsm6dso_pedo_int_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_carry_count_en_t val) { - lsm6dso_pedo_cmd_reg_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, (uint8_t*)®); - if (ret == 0) { - reg.carry_count_en = (uint8_t)val; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_CMD_REG, - (uint8_t*)®); - } - return ret; + lsm6dso_pedo_cmd_reg_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, (uint8_t *)®); + if (ret == 0) { + reg.carry_count_en = (uint8_t)val; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_PEDO_CMD_REG, + (uint8_t *)®); + } + return ret; } /** @@ -6925,22 +6921,22 @@ int32_t lsm6dso_pedo_int_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_carry_count_en_t *val) { - lsm6dso_pedo_cmd_reg_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, (uint8_t*)®); - switch (reg.carry_count_en) { - case LSM6DSO_EVERY_STEP: - *val = LSM6DSO_EVERY_STEP; - break; - case LSM6DSO_COUNT_OVERFLOW: - *val = LSM6DSO_COUNT_OVERFLOW; - break; - default: - *val = LSM6DSO_EVERY_STEP; - break; - } - return ret; + lsm6dso_pedo_cmd_reg_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_PEDO_CMD_REG, (uint8_t *)®); + switch (reg.carry_count_en) { + case LSM6DSO_EVERY_STEP: + *val = LSM6DSO_EVERY_STEP; + break; + case LSM6DSO_COUNT_OVERFLOW: + *val = LSM6DSO_COUNT_OVERFLOW; + break; + default: + *val = LSM6DSO_EVERY_STEP; + break; + } + return ret; } /** @@ -6965,21 +6961,21 @@ */ int32_t lsm6dso_motion_sens_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_emb_func_en_a_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.sign_motion_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_en_a_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.sign_motion_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -6991,18 +6987,18 @@ */ int32_t lsm6dso_motion_sens_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_en_a_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.sign_motion_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_en_a_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.sign_motion_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7014,19 +7010,19 @@ */ int32_t lsm6dso_motion_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_status_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.is_sigmot; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_status_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.is_sigmot; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7051,21 +7047,21 @@ */ int32_t lsm6dso_tilt_sens_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_emb_func_en_a_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.tilt_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_en_a_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.tilt_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7077,19 +7073,19 @@ */ int32_t lsm6dso_tilt_sens_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_en_a_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.tilt_en; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_en_a_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.tilt_en; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7101,19 +7097,19 @@ */ int32_t lsm6dso_tilt_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_status_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.is_tilt; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_status_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.is_tilt; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7138,19 +7134,19 @@ */ int32_t lsm6dso_mag_sensitivity_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SENSITIVITY_L, - &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SENSITIVITY_H, + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SENSITIVITY_L, &buff[index]); - } - - return ret; + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SENSITIVITY_H, + &buff[index]); + } + + return ret; } /** @@ -7162,19 +7158,19 @@ */ int32_t lsm6dso_mag_sensitivity_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SENSITIVITY_L, - &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SENSITIVITY_H, + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SENSITIVITY_L, &buff[index]); - } - - return ret; + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SENSITIVITY_H, + &buff[index]); + } + + return ret; } /** @@ -7186,34 +7182,34 @@ */ int32_t lsm6dso_mag_offset_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFX_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFX_H, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFZ_H, &buff[index]); - } - - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFX_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFX_H, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_OFFZ_H, &buff[index]); + } + + return ret; } /** @@ -7225,34 +7221,34 @@ */ int32_t lsm6dso_mag_offset_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFX_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFX_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFZ_H, &buff[index]); - } - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFX_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFX_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_OFFZ_H, &buff[index]); + } + return ret; } /** @@ -7270,62 +7266,62 @@ */ int32_t lsm6dso_mag_soft_iron_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XX_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XX_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XZ_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YZ_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_ZZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_ZZ_H, &buff[index]); - } - - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XX_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XX_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_XZ_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_YZ_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_ZZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_SI_ZZ_H, &buff[index]); + } + + return ret; } /** @@ -7344,62 +7340,62 @@ */ int32_t lsm6dso_mag_soft_iron_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - uint8_t index; - - index = 0x00U; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XX_L, &buff[index]); - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XX_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XZ_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YY_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YY_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YZ_H, &buff[index]); - } - if (ret == 0) { - index++; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_ZZ_L, &buff[index]); - } - if (ret == 0) { - index++; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_ZZ_H, &buff[index]); - } - - return ret; + int32_t ret; + uint8_t index; + + index = 0x00U; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XX_L, &buff[index]); + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XX_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_XZ_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YY_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YY_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_YZ_H, &buff[index]); + } + if (ret == 0) { + index++; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_ZZ_L, &buff[index]); + } + if (ret == 0) { + index++; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_SI_ZZ_H, &buff[index]); + } + + return ret; } /** @@ -7414,16 +7410,16 @@ */ int32_t lsm6dso_mag_z_orient_set(lsm6dso_ctx_t *ctx, lsm6dso_mag_z_axis_t val) { - lsm6dso_mag_cfg_a_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t*)®); - if (ret == 0) { - reg.mag_z_axis = (uint8_t) val; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t*)®); - } - - return ret; + lsm6dso_mag_cfg_a_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *)®); + if (ret == 0) { + reg.mag_z_axis = (uint8_t) val; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *)®); + } + + return ret; } /** @@ -7439,33 +7435,33 @@ int32_t lsm6dso_mag_z_orient_get(lsm6dso_ctx_t *ctx, lsm6dso_mag_z_axis_t *val) { - lsm6dso_mag_cfg_a_t reg; - int32_t ret; - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t*)®); - switch (reg.mag_z_axis) { - case LSM6DSO_Z_EQ_Y: - *val = LSM6DSO_Z_EQ_Y; - break; - case LSM6DSO_Z_EQ_MIN_Y: - *val = LSM6DSO_Z_EQ_MIN_Y; - break; - case LSM6DSO_Z_EQ_X: - *val = LSM6DSO_Z_EQ_X; - break; - case LSM6DSO_Z_EQ_MIN_X: - *val = LSM6DSO_Z_EQ_MIN_X; - break; - case LSM6DSO_Z_EQ_MIN_Z: - *val = LSM6DSO_Z_EQ_MIN_Z; - break; - case LSM6DSO_Z_EQ_Z: - *val = LSM6DSO_Z_EQ_Z; - break; - default: - *val = LSM6DSO_Z_EQ_Y; - break; - } - return ret; + lsm6dso_mag_cfg_a_t reg; + int32_t ret; + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *)®); + switch (reg.mag_z_axis) { + case LSM6DSO_Z_EQ_Y: + *val = LSM6DSO_Z_EQ_Y; + break; + case LSM6DSO_Z_EQ_MIN_Y: + *val = LSM6DSO_Z_EQ_MIN_Y; + break; + case LSM6DSO_Z_EQ_X: + *val = LSM6DSO_Z_EQ_X; + break; + case LSM6DSO_Z_EQ_MIN_X: + *val = LSM6DSO_Z_EQ_MIN_X; + break; + case LSM6DSO_Z_EQ_MIN_Z: + *val = LSM6DSO_Z_EQ_MIN_Z; + break; + case LSM6DSO_Z_EQ_Z: + *val = LSM6DSO_Z_EQ_Z; + break; + default: + *val = LSM6DSO_Z_EQ_Y; + break; + } + return ret; } /** @@ -7481,15 +7477,15 @@ int32_t lsm6dso_mag_y_orient_set(lsm6dso_ctx_t *ctx, lsm6dso_mag_y_axis_t val) { - lsm6dso_mag_cfg_a_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t*)®); - if (ret == 0) { - reg.mag_y_axis = (uint8_t)val; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_A,(uint8_t*) ®); - } - return ret; + lsm6dso_mag_cfg_a_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *)®); + if (ret == 0) { + reg.mag_y_axis = (uint8_t)val; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *) ®); + } + return ret; } /** @@ -7505,34 +7501,34 @@ int32_t lsm6dso_mag_y_orient_get(lsm6dso_ctx_t *ctx, lsm6dso_mag_y_axis_t *val) { - lsm6dso_mag_cfg_a_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t*)®); - switch (reg.mag_y_axis) { - case LSM6DSO_Y_EQ_Y: - *val = LSM6DSO_Y_EQ_Y; - break; - case LSM6DSO_Y_EQ_MIN_Y: - *val = LSM6DSO_Y_EQ_MIN_Y; - break; - case LSM6DSO_Y_EQ_X: - *val = LSM6DSO_Y_EQ_X; - break; - case LSM6DSO_Y_EQ_MIN_X: - *val = LSM6DSO_Y_EQ_MIN_X; - break; - case LSM6DSO_Y_EQ_MIN_Z: - *val = LSM6DSO_Y_EQ_MIN_Z; - break; - case LSM6DSO_Y_EQ_Z: - *val = LSM6DSO_Y_EQ_Z; - break; - default: - *val = LSM6DSO_Y_EQ_Y; - break; - } - return ret; + lsm6dso_mag_cfg_a_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_A, (uint8_t *)®); + switch (reg.mag_y_axis) { + case LSM6DSO_Y_EQ_Y: + *val = LSM6DSO_Y_EQ_Y; + break; + case LSM6DSO_Y_EQ_MIN_Y: + *val = LSM6DSO_Y_EQ_MIN_Y; + break; + case LSM6DSO_Y_EQ_X: + *val = LSM6DSO_Y_EQ_X; + break; + case LSM6DSO_Y_EQ_MIN_X: + *val = LSM6DSO_Y_EQ_MIN_X; + break; + case LSM6DSO_Y_EQ_MIN_Z: + *val = LSM6DSO_Y_EQ_MIN_Z; + break; + case LSM6DSO_Y_EQ_Z: + *val = LSM6DSO_Y_EQ_Z; + break; + default: + *val = LSM6DSO_Y_EQ_Y; + break; + } + return ret; } /** @@ -7548,15 +7544,15 @@ int32_t lsm6dso_mag_x_orient_set(lsm6dso_ctx_t *ctx, lsm6dso_mag_x_axis_t val) { - lsm6dso_mag_cfg_b_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t*)®); - if (ret == 0) { - reg.mag_x_axis = (uint8_t)val; - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t*)®); - } - return ret; + lsm6dso_mag_cfg_b_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t *)®); + if (ret == 0) { + reg.mag_x_axis = (uint8_t)val; + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t *)®); + } + return ret; } /** @@ -7572,34 +7568,34 @@ int32_t lsm6dso_mag_x_orient_get(lsm6dso_ctx_t *ctx, lsm6dso_mag_x_axis_t *val) { - lsm6dso_mag_cfg_b_t reg; - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t*)®); - switch (reg.mag_x_axis) { - case LSM6DSO_X_EQ_Y: - *val = LSM6DSO_X_EQ_Y; - break; - case LSM6DSO_X_EQ_MIN_Y: - *val = LSM6DSO_X_EQ_MIN_Y; - break; - case LSM6DSO_X_EQ_X: - *val = LSM6DSO_X_EQ_X; - break; - case LSM6DSO_X_EQ_MIN_X: - *val = LSM6DSO_X_EQ_MIN_X; - break; - case LSM6DSO_X_EQ_MIN_Z: - *val = LSM6DSO_X_EQ_MIN_Z; - break; - case LSM6DSO_X_EQ_Z: - *val = LSM6DSO_X_EQ_Z; - break; - default: - *val = LSM6DSO_X_EQ_Y; - break; - } - return ret; + lsm6dso_mag_cfg_b_t reg; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t *)®); + switch (reg.mag_x_axis) { + case LSM6DSO_X_EQ_Y: + *val = LSM6DSO_X_EQ_Y; + break; + case LSM6DSO_X_EQ_MIN_Y: + *val = LSM6DSO_X_EQ_MIN_Y; + break; + case LSM6DSO_X_EQ_X: + *val = LSM6DSO_X_EQ_X; + break; + case LSM6DSO_X_EQ_MIN_X: + *val = LSM6DSO_X_EQ_MIN_X; + break; + case LSM6DSO_X_EQ_MIN_Z: + *val = LSM6DSO_X_EQ_MIN_Z; + break; + case LSM6DSO_X_EQ_Z: + *val = LSM6DSO_X_EQ_Z; + break; + default: + *val = LSM6DSO_X_EQ_Y; + break; + } + return ret; } /** @@ -7625,18 +7621,18 @@ */ int32_t lsm6dso_long_cnt_flag_data_ready_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_status_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.is_fsm_lc; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_status_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_STATUS, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.is_fsm_lc; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7648,21 +7644,21 @@ */ int32_t lsm6dso_emb_fsm_en_set(lsm6dso_ctx_t *ctx, uint8_t val) { - int32_t ret; - lsm6dso_emb_func_en_b_t reg; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.fsm_en = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + int32_t ret; + lsm6dso_emb_func_en_b_t reg; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.fsm_en = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7674,22 +7670,22 @@ */ int32_t lsm6dso_emb_fsm_en_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - int32_t ret; - lsm6dso_emb_func_en_b_t reg; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.fsm_en; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + lsm6dso_emb_func_en_b_t reg; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.fsm_en; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7702,54 +7698,51 @@ int32_t lsm6dso_fsm_enable_set(lsm6dso_ctx_t *ctx, lsm6dso_emb_fsm_enable_t *val) { - int32_t ret; - lsm6dso_emb_func_en_b_t reg; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_ENABLE_A, - (uint8_t*)&val->fsm_enable_a, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_ENABLE_B, - (uint8_t*)&val->fsm_enable_b, 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - if ( (val->fsm_enable_a.fsm1_en | - val->fsm_enable_a.fsm2_en | - val->fsm_enable_a.fsm3_en | - val->fsm_enable_a.fsm4_en | - val->fsm_enable_a.fsm5_en | - val->fsm_enable_a.fsm6_en | - val->fsm_enable_a.fsm7_en | - val->fsm_enable_a.fsm8_en | - val->fsm_enable_b.fsm9_en | - val->fsm_enable_b.fsm10_en | - val->fsm_enable_b.fsm11_en | - val->fsm_enable_b.fsm12_en | - val->fsm_enable_b.fsm13_en | - val->fsm_enable_b.fsm14_en | - val->fsm_enable_b.fsm15_en | - val->fsm_enable_b.fsm16_en ) - != PROPERTY_DISABLE) - { - reg.fsm_en = PROPERTY_ENABLE; - } - else - { - reg.fsm_en = PROPERTY_DISABLE; - } - - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + lsm6dso_emb_func_en_b_t reg; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_ENABLE_A, + (uint8_t *)&val->fsm_enable_a, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_ENABLE_B, + (uint8_t *)&val->fsm_enable_b, 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + if ((val->fsm_enable_a.fsm1_en | + val->fsm_enable_a.fsm2_en | + val->fsm_enable_a.fsm3_en | + val->fsm_enable_a.fsm4_en | + val->fsm_enable_a.fsm5_en | + val->fsm_enable_a.fsm6_en | + val->fsm_enable_a.fsm7_en | + val->fsm_enable_a.fsm8_en | + val->fsm_enable_b.fsm9_en | + val->fsm_enable_b.fsm10_en | + val->fsm_enable_b.fsm11_en | + val->fsm_enable_b.fsm12_en | + val->fsm_enable_b.fsm13_en | + val->fsm_enable_b.fsm14_en | + val->fsm_enable_b.fsm15_en | + val->fsm_enable_b.fsm16_en) + != PROPERTY_DISABLE) { + reg.fsm_en = PROPERTY_ENABLE; + } else { + reg.fsm_en = PROPERTY_DISABLE; + } + + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7762,16 +7755,16 @@ int32_t lsm6dso_fsm_enable_get(lsm6dso_ctx_t *ctx, lsm6dso_emb_fsm_enable_t *val) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_ENABLE_A, (uint8_t*) val, 2); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_ENABLE_A, (uint8_t *) val, 2); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7784,17 +7777,17 @@ */ int32_t lsm6dso_long_cnt_set(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7807,17 +7800,17 @@ */ int32_t lsm6dso_long_cnt_get(lsm6dso_ctx_t *ctx, uint8_t *buff) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7830,23 +7823,23 @@ */ int32_t lsm6dso_long_clr_set(lsm6dso_ctx_t *ctx, lsm6dso_fsm_lc_clr_t val) { - lsm6dso_fsm_long_counter_clear_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, - (uint8_t*)®, 1); - } - if (ret == 0) { - reg. fsm_lc_clr = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, - (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_fsm_long_counter_clear_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, + (uint8_t *)®, 1); + } + if (ret == 0) { + reg. fsm_lc_clr = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, + (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7859,36 +7852,36 @@ */ int32_t lsm6dso_long_clr_get(lsm6dso_ctx_t *ctx, lsm6dso_fsm_lc_clr_t *val) { - lsm6dso_fsm_long_counter_clear_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, - (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.fsm_lc_clr) { - case LSM6DSO_LC_NORMAL: - *val = LSM6DSO_LC_NORMAL; - break; - case LSM6DSO_LC_CLEAR: - *val = LSM6DSO_LC_CLEAR; - break; - case LSM6DSO_LC_CLEAR_DONE: - *val = LSM6DSO_LC_CLEAR_DONE; - break; - default: - *val = LSM6DSO_LC_NORMAL; - break; - } - } - - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_fsm_long_counter_clear_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_CLEAR, + (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.fsm_lc_clr) { + case LSM6DSO_LC_NORMAL: + *val = LSM6DSO_LC_NORMAL; + break; + case LSM6DSO_LC_CLEAR: + *val = LSM6DSO_LC_CLEAR; + break; + case LSM6DSO_LC_CLEAR_DONE: + *val = LSM6DSO_LC_CLEAR_DONE; + break; + default: + *val = LSM6DSO_LC_NORMAL; + break; + } + } + + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7900,17 +7893,17 @@ */ int32_t lsm6dso_fsm_out_get(lsm6dso_ctx_t *ctx, lsm6dso_fsm_out_t *val) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_OUTS1, (uint8_t*)val, 16); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_OUTS1, (uint8_t *)val, 16); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7922,25 +7915,25 @@ */ int32_t lsm6dso_fsm_data_rate_set(lsm6dso_ctx_t *ctx, lsm6dso_fsm_odr_t val) { - lsm6dso_emb_func_odr_cfg_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, - (uint8_t*)®, 1); - } - if (ret == 0) { - reg.not_used_01 = 3; /* set default values */ - reg.not_used_02 = 2; /* set default values */ - reg.fsm_odr = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, - (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_odr_cfg_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, + (uint8_t *)®, 1); + } + if (ret == 0) { + reg.not_used_01 = 3; /* set default values */ + reg.not_used_02 = 2; /* set default values */ + reg.fsm_odr = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, + (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -7952,36 +7945,36 @@ */ int32_t lsm6dso_fsm_data_rate_get(lsm6dso_ctx_t *ctx, lsm6dso_fsm_odr_t *val) { - lsm6dso_emb_func_odr_cfg_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, - (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.fsm_odr) { - case LSM6DSO_ODR_FSM_12Hz5: - *val = LSM6DSO_ODR_FSM_12Hz5; - break; - case LSM6DSO_ODR_FSM_26Hz: - *val = LSM6DSO_ODR_FSM_26Hz; - break; - case LSM6DSO_ODR_FSM_52Hz: - *val = LSM6DSO_ODR_FSM_52Hz; - break; - case LSM6DSO_ODR_FSM_104Hz: - *val = LSM6DSO_ODR_FSM_104Hz; - break; - default: - *val = LSM6DSO_ODR_FSM_12Hz5; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_odr_cfg_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_ODR_CFG_B, + (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.fsm_odr) { + case LSM6DSO_ODR_FSM_12Hz5: + *val = LSM6DSO_ODR_FSM_12Hz5; + break; + case LSM6DSO_ODR_FSM_26Hz: + *val = LSM6DSO_ODR_FSM_26Hz; + break; + case LSM6DSO_ODR_FSM_52Hz: + *val = LSM6DSO_ODR_FSM_52Hz; + break; + case LSM6DSO_ODR_FSM_104Hz: + *val = LSM6DSO_ODR_FSM_104Hz; + break; + default: + *val = LSM6DSO_ODR_FSM_12Hz5; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -7993,22 +7986,22 @@ */ int32_t lsm6dso_fsm_init_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_emb_func_init_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.fsm_init = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_emb_func_init_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.fsm_init = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8020,18 +8013,18 @@ */ int32_t lsm6dso_fsm_init_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_emb_func_init_b_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.fsm_init; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_emb_func_init_b_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_INIT_B, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.fsm_init; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8046,19 +8039,19 @@ */ int32_t lsm6dso_long_cnt_int_value_set(lsm6dso_ctx_t *ctx, uint16_t val) { - int32_t ret; - uint8_t add_l; - uint8_t add_h; - - add_h = (uint8_t)( ( val & 0xFF00U ) >> 8 ); - add_l = (uint8_t)( val & 0x00FFU ); - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_L, &add_l); - if (ret == 0) { - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_H, &add_h); - } - - return ret; + int32_t ret; + uint8_t add_l; + uint8_t add_h; + + add_h = (uint8_t)((val & 0xFF00U) >> 8); + add_l = (uint8_t)(val & 0x00FFU); + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_L, &add_l); + if (ret == 0) { + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_H, &add_h); + } + + return ret; } /** @@ -8073,19 +8066,19 @@ */ int32_t lsm6dso_long_cnt_int_value_get(lsm6dso_ctx_t *ctx, uint16_t *val) { - int32_t ret; - uint8_t add_l; - uint8_t add_h; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_L, &add_l); - if (ret == 0) { - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_H, &add_h); - *val = add_h; - *val = *val << 8; - *val += add_l; - } - - return ret; + int32_t ret; + uint8_t add_l; + uint8_t add_h; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_L, &add_l); + if (ret == 0) { + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_LC_TIMEOUT_H, &add_h); + *val = add_h; + *val = *val << 8; + *val += add_l; + } + + return ret; } /** @@ -8097,11 +8090,11 @@ */ int32_t lsm6dso_fsm_number_of_programs_set(lsm6dso_ctx_t *ctx, uint8_t val) { - int32_t ret; - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_PROGRAMS, &val); - - return ret; + int32_t ret; + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_PROGRAMS, &val); + + return ret; } /** @@ -8113,11 +8106,11 @@ */ int32_t lsm6dso_fsm_number_of_programs_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - int32_t ret; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_PROGRAMS, val); - - return ret; + int32_t ret; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_PROGRAMS, val); + + return ret; } /** @@ -8130,18 +8123,18 @@ */ int32_t lsm6dso_fsm_start_address_set(lsm6dso_ctx_t *ctx, uint16_t val) { - int32_t ret; - uint8_t add_l; - uint8_t add_h; - - add_h = (uint8_t)( ( val & 0xFF00U ) >> 8 ); - add_l = (uint8_t)( val & 0x00FFU ); - - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_L, &add_l); - if (ret == 0) { - ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_H, &add_h); - } - return ret; + int32_t ret; + uint8_t add_l; + uint8_t add_h; + + add_h = (uint8_t)((val & 0xFF00U) >> 8); + add_l = (uint8_t)(val & 0x00FFU); + + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_L, &add_l); + if (ret == 0) { + ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_FSM_START_ADD_H, &add_h); + } + return ret; } /** @@ -8154,18 +8147,18 @@ */ int32_t lsm6dso_fsm_start_address_get(lsm6dso_ctx_t *ctx, uint16_t *val) { - int32_t ret; - uint8_t add_l; - uint8_t add_h; - - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_START_ADD_L, &add_l); - if (ret == 0) { - ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_START_ADD_H, &add_h); - *val = add_h; - *val = *val << 8; - *val += add_l; - } - return ret; + int32_t ret; + uint8_t add_l; + uint8_t add_h; + + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_START_ADD_L, &add_l); + if (ret == 0) { + ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_FSM_START_ADD_H, &add_h); + *val = add_h; + *val = *val << 8; + *val += add_l; + } + return ret; } /** @@ -8192,17 +8185,17 @@ int32_t lsm6dso_sh_read_data_raw_get(lsm6dso_ctx_t *ctx, uint8_t *val, uint8_t len) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SENSOR_HUB_1, (uint8_t*) val, len); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SENSOR_HUB_1, (uint8_t *) val, len); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8215,21 +8208,21 @@ int32_t lsm6dso_sh_slave_connected_set(lsm6dso_ctx_t *ctx, lsm6dso_aux_sens_on_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.aux_sens_on = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.aux_sens_on = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8242,35 +8235,35 @@ int32_t lsm6dso_sh_slave_connected_get(lsm6dso_ctx_t *ctx, lsm6dso_aux_sens_on_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.aux_sens_on) { - case LSM6DSO_SLV_0: - *val = LSM6DSO_SLV_0; - break; - case LSM6DSO_SLV_0_1: - *val = LSM6DSO_SLV_0_1; - break; - case LSM6DSO_SLV_0_1_2: - *val = LSM6DSO_SLV_0_1_2; - break; - case LSM6DSO_SLV_0_1_2_3: - *val = LSM6DSO_SLV_0_1_2_3; - break; - default: - *val = LSM6DSO_SLV_0; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.aux_sens_on) { + case LSM6DSO_SLV_0: + *val = LSM6DSO_SLV_0; + break; + case LSM6DSO_SLV_0_1: + *val = LSM6DSO_SLV_0_1; + break; + case LSM6DSO_SLV_0_1_2: + *val = LSM6DSO_SLV_0_1_2; + break; + case LSM6DSO_SLV_0_1_2_3: + *val = LSM6DSO_SLV_0_1_2_3; + break; + default: + *val = LSM6DSO_SLV_0; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8282,21 +8275,21 @@ */ int32_t lsm6dso_sh_master_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.master_on = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.master_on = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8308,19 +8301,19 @@ */ int32_t lsm6dso_sh_master_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.master_on; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.master_on; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8332,22 +8325,22 @@ */ int32_t lsm6dso_sh_pin_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_shub_pu_en_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.shub_pu_en = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.shub_pu_en = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8360,29 +8353,29 @@ int32_t lsm6dso_sh_pin_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_shub_pu_en_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.shub_pu_en) { - case LSM6DSO_EXT_PULL_UP: - *val = LSM6DSO_EXT_PULL_UP; - break; - case LSM6DSO_INTERNAL_PULL_UP: - *val = LSM6DSO_INTERNAL_PULL_UP; - break; - default: - *val = LSM6DSO_EXT_PULL_UP; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.shub_pu_en) { + case LSM6DSO_EXT_PULL_UP: + *val = LSM6DSO_EXT_PULL_UP; + break; + case LSM6DSO_INTERNAL_PULL_UP: + *val = LSM6DSO_INTERNAL_PULL_UP; + break; + default: + *val = LSM6DSO_EXT_PULL_UP; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8395,22 +8388,22 @@ */ int32_t lsm6dso_sh_pass_through_set(lsm6dso_ctx_t *ctx, uint8_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.pass_through_mode = val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.pass_through_mode = val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8423,19 +8416,19 @@ */ int32_t lsm6dso_sh_pass_through_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.pass_through_mode; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.pass_through_mode; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8448,22 +8441,22 @@ int32_t lsm6dso_sh_syncro_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_start_config_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.start_config = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.start_config = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8476,28 +8469,28 @@ int32_t lsm6dso_sh_syncro_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_start_config_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.start_config) { - case LSM6DSO_EXT_ON_INT2_PIN: - *val = LSM6DSO_EXT_ON_INT2_PIN; - break; - case LSM6DSO_XL_GY_DRDY: - *val = LSM6DSO_XL_GY_DRDY; - break; - default: - *val = LSM6DSO_EXT_ON_INT2_PIN; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.start_config) { + case LSM6DSO_EXT_ON_INT2_PIN: + *val = LSM6DSO_EXT_ON_INT2_PIN; + break; + case LSM6DSO_XL_GY_DRDY: + *val = LSM6DSO_XL_GY_DRDY; + break; + default: + *val = LSM6DSO_EXT_ON_INT2_PIN; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8511,22 +8504,22 @@ int32_t lsm6dso_sh_write_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_write_once_t val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.write_once = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.write_once = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8540,29 +8533,29 @@ int32_t lsm6dso_sh_write_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_write_once_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.write_once) { - case LSM6DSO_EACH_SH_CYCLE: - *val = LSM6DSO_EACH_SH_CYCLE; - break; - case LSM6DSO_ONLY_FIRST_CYCLE: - *val = LSM6DSO_ONLY_FIRST_CYCLE; - break; - default: - *val = LSM6DSO_EACH_SH_CYCLE; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.write_once) { + case LSM6DSO_EACH_SH_CYCLE: + *val = LSM6DSO_EACH_SH_CYCLE; + break; + case LSM6DSO_ONLY_FIRST_CYCLE: + *val = LSM6DSO_ONLY_FIRST_CYCLE; + break; + default: + *val = LSM6DSO_EACH_SH_CYCLE; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8573,26 +8566,26 @@ */ int32_t lsm6dso_sh_reset_set(lsm6dso_ctx_t *ctx) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.rst_master_regs = PROPERTY_ENABLE; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.rst_master_regs = PROPERTY_DISABLE; - ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.rst_master_regs = PROPERTY_ENABLE; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.rst_master_regs = PROPERTY_DISABLE; + ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8604,18 +8597,18 @@ */ int32_t lsm6dso_sh_reset_get(lsm6dso_ctx_t *ctx, uint8_t *val) { - lsm6dso_master_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - *val = reg.rst_master_regs; - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_master_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + *val = reg.rst_master_regs; + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8627,22 +8620,22 @@ */ int32_t lsm6dso_sh_data_rate_set(lsm6dso_ctx_t *ctx, lsm6dso_shub_odr_t val) { - lsm6dso_slv0_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - reg.shub_odr = (uint8_t)val; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv0_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + reg.shub_odr = (uint8_t)val; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8655,35 +8648,35 @@ int32_t lsm6dso_sh_data_rate_get(lsm6dso_ctx_t *ctx, lsm6dso_shub_odr_t *val) { - lsm6dso_slv0_config_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t*)®, 1); - } - if (ret == 0) { - switch (reg.shub_odr) { - case LSM6DSO_SH_ODR_104Hz: - *val = LSM6DSO_SH_ODR_104Hz; - break; - case LSM6DSO_SH_ODR_52Hz: - *val = LSM6DSO_SH_ODR_52Hz; - break; - case LSM6DSO_SH_ODR_26Hz: - *val = LSM6DSO_SH_ODR_26Hz; - break; - case LSM6DSO_SH_ODR_13Hz: - *val = LSM6DSO_SH_ODR_13Hz; - break; - default: - *val = LSM6DSO_SH_ODR_104Hz; - break; - } - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv0_config_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, (uint8_t *)®, 1); + } + if (ret == 0) { + switch (reg.shub_odr) { + case LSM6DSO_SH_ODR_104Hz: + *val = LSM6DSO_SH_ODR_104Hz; + break; + case LSM6DSO_SH_ODR_52Hz: + *val = LSM6DSO_SH_ODR_52Hz; + break; + case LSM6DSO_SH_ODR_26Hz: + *val = LSM6DSO_SH_ODR_26Hz; + break; + case LSM6DSO_SH_ODR_13Hz: + *val = LSM6DSO_SH_ODR_13Hz; + break; + default: + *val = LSM6DSO_SH_ODR_104Hz; + break; + } + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8698,27 +8691,27 @@ */ int32_t lsm6dso_sh_cfg_write(lsm6dso_ctx_t *ctx, lsm6dso_sh_cfg_write_t *val) { - lsm6dso_slv0_add_t reg; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - reg.slave0 = val->slv0_add; - reg.rw_0 = 0; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_ADD, (uint8_t*)®, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_SUBADD, - &(val->slv0_subadd), 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_DATAWRITE_SLV0, - &(val->slv0_data), 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv0_add_t reg; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + reg.slave0 = val->slv0_add; + reg.rw_0 = 0; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_ADD, (uint8_t *)®, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_SUBADD, + &(val->slv0_subadd), 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_DATAWRITE_SLV0, + &(val->slv0_data), 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8734,34 +8727,34 @@ int32_t lsm6dso_sh_slv0_cfg_read(lsm6dso_ctx_t *ctx, lsm6dso_sh_cfg_read_t *val) { - lsm6dso_slv0_add_t slv0_add; - lsm6dso_slv0_config_t slv0_config; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - slv0_add.slave0 = val->slv_add; - slv0_add.rw_0 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_ADD, (uint8_t*)&slv0_add, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_SUBADD, - &(val->slv_subadd), 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, - (uint8_t*)&slv0_config, 1); - } - if (ret == 0) { - slv0_config.slave0_numop = val->slv_len; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_CONFIG, - (uint8_t*)&slv0_config, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv0_add_t slv0_add; + lsm6dso_slv0_config_t slv0_config; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + slv0_add.slave0 = val->slv_add; + slv0_add.rw_0 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_ADD, (uint8_t *)&slv0_add, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_SUBADD, + &(val->slv_subadd), 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV0_CONFIG, + (uint8_t *)&slv0_config, 1); + } + if (ret == 0) { + slv0_config.slave0_numop = val->slv_len; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV0_CONFIG, + (uint8_t *)&slv0_config, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8777,34 +8770,34 @@ int32_t lsm6dso_sh_slv1_cfg_read(lsm6dso_ctx_t *ctx, lsm6dso_sh_cfg_read_t *val) { - lsm6dso_slv1_add_t slv1_add; - lsm6dso_slv1_config_t slv1_config; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - slv1_add.slave1_add = val->slv_add; - slv1_add.r_1 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_ADD, (uint8_t*)&slv1_add, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_SUBADD, - &(val->slv_subadd), 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, - (uint8_t*)&slv1_config, 1); - } - if (ret == 0) { - slv1_config.slave1_numop = val->slv_len; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, - (uint8_t*)&slv1_config, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + lsm6dso_slv1_add_t slv1_add; + lsm6dso_slv1_config_t slv1_config; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + slv1_add.slave1_add = val->slv_add; + slv1_add.r_1 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_ADD, (uint8_t *)&slv1_add, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_SUBADD, + &(val->slv_subadd), 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV1_CONFIG, + (uint8_t *)&slv1_config, 1); + } + if (ret == 0) { + slv1_config.slave1_numop = val->slv_len; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV1_CONFIG, + (uint8_t *)&slv1_config, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /** @@ -8820,33 +8813,33 @@ int32_t lsm6dso_sh_slv2_cfg_read(lsm6dso_ctx_t *ctx, lsm6dso_sh_cfg_read_t *val) { - lsm6dso_slv2_add_t slv2_add; - lsm6dso_slv2_config_t slv2_config; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - slv2_add.slave2_add = val->slv_add; - slv2_add.r_2 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_ADD, (uint8_t*)&slv2_add, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_SUBADD, - &(val->slv_subadd), 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, - (uint8_t*)&slv2_config, 1); - } - if (ret == 0) { - slv2_config.slave2_numop = val->slv_len; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_CONFIG, - (uint8_t*)&slv2_config, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv2_add_t slv2_add; + lsm6dso_slv2_config_t slv2_config; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + slv2_add.slave2_add = val->slv_add; + slv2_add.r_2 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_ADD, (uint8_t *)&slv2_add, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_SUBADD, + &(val->slv_subadd), 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV2_CONFIG, + (uint8_t *)&slv2_config, 1); + } + if (ret == 0) { + slv2_config.slave2_numop = val->slv_len; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV2_CONFIG, + (uint8_t *)&slv2_config, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8862,33 +8855,33 @@ int32_t lsm6dso_sh_slv3_cfg_read(lsm6dso_ctx_t *ctx, lsm6dso_sh_cfg_read_t *val) { - lsm6dso_slv3_add_t slv3_add; - lsm6dso_slv3_config_t slv3_config; - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - slv3_add.slave3_add = val->slv_add; - slv3_add.r_3 = 1; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_ADD, (uint8_t*)&slv3_add, 1); - } - if (ret == 0) { - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_SUBADD, - &(val->slv_subadd), 1); - } - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, - (uint8_t*)&slv3_config, 1); - } - if (ret == 0) { - slv3_config.slave3_numop = val->slv_len; - ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_CONFIG, - (uint8_t*)&slv3_config, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - return ret; + lsm6dso_slv3_add_t slv3_add; + lsm6dso_slv3_config_t slv3_config; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + slv3_add.slave3_add = val->slv_add; + slv3_add.r_3 = 1; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_ADD, (uint8_t *)&slv3_add, 1); + } + if (ret == 0) { + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_SUBADD, + &(val->slv_subadd), 1); + } + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_SLV3_CONFIG, + (uint8_t *)&slv3_config, 1); + } + if (ret == 0) { + slv3_config.slave3_numop = val->slv_len; + ret = lsm6dso_write_reg(ctx, LSM6DSO_SLV3_CONFIG, + (uint8_t *)&slv3_config, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + return ret; } /** @@ -8901,17 +8894,17 @@ int32_t lsm6dso_sh_status_get(lsm6dso_ctx_t *ctx, lsm6dso_status_master_t *val) { - int32_t ret; - - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); - if (ret == 0) { - ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_MASTER, (uint8_t*) val, 1); - } - if (ret == 0) { - ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); - } - - return ret; + int32_t ret; + + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); + if (ret == 0) { + ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_MASTER, (uint8_t *) val, 1); + } + if (ret == 0) { + ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); + } + + return ret; } /**