Skip to content

Commit

Permalink
Fixed filtering chain functions #3
Browse files Browse the repository at this point in the history
 - removed functions xl_filter_lp2_set/get
 - renamed functions _xl_hp_path_on_out_set/get in _xl_filt_path_on_out_set/get
 - renamed enum _hp_slope_xl_en_t in _filt_xl_en_t
 - renamed and fixed SLOPE_ODR_DIV_4 = 0x30 in HP_REF_MODE 0x37
  • Loading branch information
albezanc committed Jul 21, 2021
1 parent d825d34 commit e97f730
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 66 deletions.
68 changes: 11 additions & 57 deletions iis3dwb_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,50 +1253,6 @@ int32_t iis3dwb_xl_self_test_get(stmdev_ctx_t *ctx,
*
*/

/**
* @brief Accelerometer output from LPF2 filtering stage selection.[set]
*
* @param ctx Read / write interface definitions.(ptr)
* @param val Change the values of lpf2_xl_en in reg CTRL1_XL
* @retval Interface status (MANDATORY: return 0 -> no Error).
*
*/
int32_t iis3dwb_xl_filter_lp2_set(stmdev_ctx_t *ctx, uint8_t val)
{
iis3dwb_ctrl1_xl_t ctrl1_xl;
int32_t ret;

ret = iis3dwb_read_reg(ctx, IIS3DWB_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1);

if (ret == 0)
{
ctrl1_xl.lpf2_xl_en = (uint8_t)val;
ret = iis3dwb_write_reg(ctx, IIS3DWB_CTRL1_XL,
(uint8_t *)&ctrl1_xl, 1);
}

return ret;
}

/**
* @brief Accelerometer output from LPF2 filtering stage selection.[get]
*
* @param ctx Read / write interface definitions.(ptr)
* @param val Change the values of lpf2_xl_en in reg CTRL1_XL
* @retval Interface status (MANDATORY: return 0 -> no Error).
*
*/
int32_t iis3dwb_xl_filter_lp2_get(stmdev_ctx_t *ctx, uint8_t *val)
{
iis3dwb_ctrl1_xl_t ctrl1_xl;
int32_t ret;

ret = iis3dwb_read_reg(ctx, IIS3DWB_CTRL1_XL, (uint8_t *)&ctrl1_xl, 1);
*val = ctrl1_xl.lpf2_xl_en;

return ret;
}

/**
* @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends
* (XL and Gyro independently masked).[set]
Expand Down Expand Up @@ -1345,16 +1301,15 @@ int32_t iis3dwb_filter_settling_mask_get(stmdev_ctx_t *ctx,
}

/**
* @brief Accelerometer slope filter / high-pass filter selection
* on output.[set]
* @brief Accelerometer filter selection on output.[set]
*
* @param ctx Read / write interface definitions.(ptr)
* @param val Change the values of hp_slope_xl_en in reg CTRL8_XL
* @param val Change filter selection on output.
* @retval Interface status (MANDATORY: return 0 -> no Error).
*
*/
int32_t iis3dwb_xl_hp_path_on_out_set(stmdev_ctx_t *ctx,
iis3dwb_hp_slope_xl_en_t val)
int32_t iis3dwb_xl_filt_path_on_out_set(stmdev_ctx_t *ctx,
iis3dwb_filt_xl_en_t val)
{
iis3dwb_ctrl1_xl_t ctrl1_xl;
iis3dwb_ctrl8_xl_t ctrl8_xl;
Expand Down Expand Up @@ -1385,16 +1340,15 @@ int32_t iis3dwb_xl_hp_path_on_out_set(stmdev_ctx_t *ctx,
}

/**
* @brief Accelerometer slope filter / high-pass filter selection on
* output.[get]
* @brief Accelerometer filter selection on output.[get]
*
* @param ctx Read / write interface definitions.(ptr)
* @param val Get the values of hp_slope_xl_en in reg CTRL8_XL
* @param val Get filter selection on output.
* @retval Interface status (MANDATORY: return 0 -> no Error).
*
*/
int32_t iis3dwb_xl_hp_path_on_out_get(stmdev_ctx_t *ctx,
iis3dwb_hp_slope_xl_en_t *val)
int32_t iis3dwb_xl_filt_path_on_out_get(stmdev_ctx_t *ctx,
iis3dwb_filt_xl_en_t *val)
{
iis3dwb_ctrl1_xl_t ctrl1_xl;
iis3dwb_ctrl8_xl_t ctrl8_xl;
Expand All @@ -1410,8 +1364,8 @@ int32_t iis3dwb_xl_hp_path_on_out_get(stmdev_ctx_t *ctx,
switch ((ctrl1_xl.lpf2_xl_en << 7) + (ctrl8_xl.hp_ref_mode_xl << 5) +
(ctrl8_xl.fds << 4) + ctrl8_xl.hpcf_xl)
{
case IIS3DWB_SLOPE_ODR_DIV_4:
*val = IIS3DWB_SLOPE_ODR_DIV_4;
case IIS3DWB_HP_REF_MODE:
*val = IIS3DWB_HP_REF_MODE;
break;

case IIS3DWB_HP_ODR_DIV_10:
Expand Down Expand Up @@ -1479,7 +1433,7 @@ int32_t iis3dwb_xl_hp_path_on_out_get(stmdev_ctx_t *ctx,
break;

default:
*val = IIS3DWB_SLOPE_ODR_DIV_4;
*val = IIS3DWB_HP_REF_MODE;
break;
}

Expand Down
15 changes: 6 additions & 9 deletions iis3dwb_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -871,17 +871,14 @@ int32_t iis3dwb_xl_self_test_set(stmdev_ctx_t *ctx,
int32_t iis3dwb_xl_self_test_get(stmdev_ctx_t *ctx,
iis3dwb_st_xl_t *val);

int32_t iis3dwb_xl_filter_lp2_set(stmdev_ctx_t *ctx, uint8_t val);
int32_t iis3dwb_xl_filter_lp2_get(stmdev_ctx_t *ctx, uint8_t *val);

int32_t iis3dwb_filter_settling_mask_set(stmdev_ctx_t *ctx,
uint8_t val);
int32_t iis3dwb_filter_settling_mask_get(stmdev_ctx_t *ctx,
uint8_t *val);

typedef enum
{
IIS3DWB_SLOPE_ODR_DIV_4 = 0x30,
IIS3DWB_HP_REF_MODE = 0x37,
IIS3DWB_HP_ODR_DIV_10 = 0x11,
IIS3DWB_HP_ODR_DIV_20 = 0x12,
IIS3DWB_HP_ODR_DIV_45 = 0x13,
Expand All @@ -898,11 +895,11 @@ typedef enum
IIS3DWB_LP_ODR_DIV_200 = 0x85,
IIS3DWB_LP_ODR_DIV_400 = 0x86,
IIS3DWB_LP_ODR_DIV_800 = 0x87,
} iis3dwb_hp_slope_xl_en_t;
int32_t iis3dwb_xl_hp_path_on_out_set(stmdev_ctx_t *ctx,
iis3dwb_hp_slope_xl_en_t val);
int32_t iis3dwb_xl_hp_path_on_out_get(stmdev_ctx_t *ctx,
iis3dwb_hp_slope_xl_en_t *val);
} iis3dwb_filt_xl_en_t;
int32_t iis3dwb_xl_filt_path_on_out_set(stmdev_ctx_t *ctx,
iis3dwb_filt_xl_en_t val);
int32_t iis3dwb_xl_filt_path_on_out_get(stmdev_ctx_t *ctx,
iis3dwb_filt_xl_en_t *val);

int32_t iis3dwb_xl_fast_settling_set(stmdev_ctx_t *ctx, uint8_t val);
int32_t iis3dwb_xl_fast_settling_get(stmdev_ctx_t *ctx, uint8_t *val);
Expand Down

0 comments on commit e97f730

Please sign in to comment.