Commit 9b128caf authored by Armando Visconti's avatar Armando Visconti
Browse files

sensor/stmemsc: Align stmemsc i/f to v2.3



Align stmemsc HAL i/f to v2.3

Moreover following fix has been now implemented, that will be incorporated
in next STdC version:

  - lsm6dso_STdC: fix -Wmaybe-uninitialized warning in lsm6dso_mode_set() API

Signed-off-by: default avatarArmando Visconti <armando.visconti@st.com>
parent b217e608
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ set(stmems_pids
  lsm6dsv16x
  lsm6dsv
  lsm9ds1
  sths34pf80
  stts22h
  stts751
  )
+82 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ Origin:
   https://www.st.com/en/embedded-software/c-driver-mems.html

Status:
   version v2.02
   version v2.3

Purpose:
   ST Microelectronics standard C platform-independent drivers for MEMS
@@ -47,6 +47,86 @@ Description:
       .mdelay = (stmdev_mdelay_ptr) platform_mdelay,
   };

   Driver versions in this package:

     - a3g4250d_STdC         v1.1.0
     - ais25ba_STdC          v1.1.0
     - ais2dw12_STdC         v1.1.0
     - ais2ih_STdC           v1.1.0
     - ais328dq_STdC         v1.1.0
     - ais3624dq_STdC        v1.1.0
     - asm330lhb_STdC        v1.0.0
     - asm330lhh_STdC        v2.1.0
     - asm330lhhx_STdC       v1.1.1
     - h3lis100dl_STdC       v1.1.0
     - h3lis331dl_STdC       v1.1.0
     - hts221_STdC           v1.1.0
     - i3g4250d_STdC         v1.1.0
     - iis2dh_STdC           v1.1.0
     - iis2dlpc_STdC         v1.1.0
     - iis2iclx_STdC         v1.1.0
     - iis2mdc_STdC          v1.1.0
     - iis328dq_STdC         v1.1.0
     - iis3dhhc_STdC         v1.1.0
     - iis3dwb_STdC          v1.1.1
     - ilps22qs_STdC         v2.1.1
     - ilps28qsw_STdC        v1.0.1
     - ism303dac_STdC        v1.1.0
     - ism330dhcx_STdC       v1.1.0
     - ism330dlc_STdC        v1.1.0
     - ism330is_STdC         v2.1.0
     - l20g20is_STdC         v1.1.0
     - l3gd20h_STdC          v1.1.0
     - lis25ba_STdC          v1.1.0
     - lis2de12_STdC         v1.1.0
     - lis2dh12_STdC         v1.1.0
     - lis2dh_STdC           v1.1.0
     - lis2ds12_STdC         v1.1.0
     - lis2dtw12_STdC        v1.1.0
     - lis2du12_STdC         v1.1.3
     - lis2dux12_STdC        v1.1.4
     - lis2duxs12_STdC       v1.1.5
     - lis2dw12_STdC         v1.1.0
     - lis2hh12_STdC         v1.1.0
     - lis2mdl_STdC          v1.1.0
     - lis331dlh_STdC        v1.1.0
     - lis3de_STdC           v1.1.0
     - lis3dh_STdC           v1.1.0
     - lis3dhh_STdC          v1.1.0
     - lis3dsh_STdC          v1.1.0
     - lis3mdl_STdC          v1.1.0
     - lps22ch_STdC          v1.1.0
     - lps22df_STdC          v1.1.0
     - lps22hb_STdC          v1.1.0
     - lps22hh_STdC          v1.1.0
     - lps25hb_STdC          v1.1.0
     - lps27hhtw_STdC        v1.1.0
     - lps27hhw_STdC         v1.1.0
     - lps28dfw_STdC         v1.1.0
     - lps33hw_STdC          v1.1.0
     - lps33k_STdC           v1.1.0
     - lps33w_STdC           v1.1.0
     - lsm303agr_STdC        v1.1.0
     - lsm303ah_STdC         v1.1.0
     - lsm6ds3_STdC          v1.1.1
     - lsm6ds3tr-c_STdC      v1.1.0
     - lsm6dsl_STdC          v1.1.0
     - lsm6dsm_STdC          v1.1.0
     - lsm6dso16is_STdC      v2.1.1
     - lsm6dso32_STdC        v1.1.0
     - lsm6dso32x_STdC       v1.1.0
     - lsm6dso_STdC          v2.1.0
     - lsm6dsox_STdC         v2.0.1
     - lsm6dsr_STdC          v1.1.0
     - lsm6dsrx_STdC         v1.1.0
     - lsm6dsv16bx_STdC      v2.1.2
     - lsm6dsv16x_STdC       v2.2.1
     - lsm6dsv_STdC          v1.2.1
     - lsm9ds1_STdC          v1.1.0
     - sths34pf80_STdC       v1.0.0
     - stts22h_STdC          v1.1.0
     - stts751_STdC          v1.1.0

Dependencies:
    None.

@@ -54,7 +134,7 @@ URL:
   https://www.st.com/en/embedded-software/c-driver-mems.html

commit:
   version v2.02
   version v2.3

Maintained-by:
   ST Microelectronics
+43 −0
Original line number Diff line number Diff line
@@ -554,6 +554,49 @@ int32_t iis3dwb_temp_flag_data_ready_get(stmdev_ctx_t *ctx,
  return ret;
}

/**
  * @brief  Enables the accelerometer user offset correction block, can be enabled 
  * by setting the USR_OFF_ON_OUT bit of the CTRL7_C register.[set]
  *
  * @param  ctx    Read / write interface definitions.(ptr)
  * @param  val    Change the values of USR_OFF_ON_OUT in reg CTRL7_C
  * @retval        Interface status (MANDATORY: return 0 -> no Error).
  *
  */
int32_t iis3dwb_usr_offset_block_set(stmdev_ctx_t *ctx, uint8_t val)
{
  iis3dwb_ctrl7_c_t ctrl7_c;

  int32_t ret = iis3dwb_read_reg(ctx, IIS3DWB_CTRL7_C, (uint8_t *)&ctrl7_c, 1);

  if (ret == 0)
  {
    ctrl7_c.usr_off_on_out = val;
    ret = iis3dwb_write_reg(ctx, IIS3DWB_CTRL7_C, (uint8_t *)&ctrl7_c, 1);
  }

  return ret;
}

/**
  * @brief  Enables the accelerometer user offset correction block, can be enabled 
  * by setting the USR_OFF_ON_OUT bit of the CTRL7_C register.[get]
  *
  * @param  ctx    Read / write interface definitions.(ptr)
  * @param  val    Change the values of USR_OFF_ON_OUT in reg CTRL7_C
  * @retval        Interface status (MANDATORY: return 0 -> no Error).
  *
  */
int32_t iis3dwb_usr_offset_block_get(stmdev_ctx_t *ctx, uint8_t *val)
{
  iis3dwb_ctrl7_c_t ctrl7_c;

  const int32_t ret = iis3dwb_read_reg(ctx, IIS3DWB_CTRL7_C, (uint8_t *)&ctrl7_c, 1);
  *val = ctrl7_c.usr_off_on_out;

  return ret;
}

/**
  * @brief  Accelerometer X-axis user offset correction expressed in two’s
  *         complement, weight depends on USR_OFF_W in CTRL6_C (15h).
+17 −0
Original line number Diff line number Diff line
@@ -410,6 +410,19 @@ typedef struct
  uint8_t xl_axis_sel              : 2;
#endif /* DRV_BYTE_ORDER */
} iis3dwb_ctrl6_c_t;
#define IIS3DWB_CTRL7_C                      0x16U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
  uint8_t not_used_01               : 1;
  uint8_t usr_off_on_out            : 1;
  uint8_t not_used_02               : 6;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
  uint8_t not_used_02               : 6;
  uint8_t usr_off_on_out            : 1;
  uint8_t not_used_01               : 1;
#endif /* DRV_BYTE_ORDER */
} iis3dwb_ctrl7_c_t;

#define IIS3DWB_CTRL8_XL                     0x17U
typedef struct
@@ -695,6 +708,7 @@ typedef union
  iis3dwb_ctrl4_c_t                       ctrl4_c;
  iis3dwb_ctrl5_c_t                       ctrl5_c;
  iis3dwb_ctrl6_c_t                       ctrl6_c;
  iis3dwb_ctrl7_c_t                       ctrl7_c;
  iis3dwb_ctrl8_xl_t                      ctrl8_xl;
  iis3dwb_ctrl10_c_t                      ctrl10_c;
  iis3dwb_all_int_src_t                   all_int_src;
@@ -817,6 +831,9 @@ int32_t iis3dwb_xl_flag_data_ready_get(stmdev_ctx_t *ctx,
int32_t iis3dwb_temp_flag_data_ready_get(stmdev_ctx_t *ctx,
                                         uint8_t *val);

int32_t iis3dwb_usr_offset_block_set(stmdev_ctx_t *ctx, uint8_t val);
int32_t iis3dwb_usr_offset_block_get(stmdev_ctx_t *ctx, uint8_t *val);

int32_t iis3dwb_xl_usr_offset_x_set(stmdev_ctx_t *ctx, uint8_t *buff);
int32_t iis3dwb_xl_usr_offset_x_get(stmdev_ctx_t *ctx, uint8_t *buff);

+7 −0
Original line number Diff line number Diff line
@@ -119,6 +119,11 @@ float_t ilps22qs_from_lsb_to_celsius(int16_t lsb)
  return ((float_t)lsb / 100.0f);
}

float_t ilps22qs_from_lsb_to_mv(int32_t lsb)
{
  return ((float_t)lsb) / 438000.0f;
}

/**
  * @}
  *
@@ -783,6 +788,8 @@ int32_t ilps22qs_ah_qvar_data_get(stmdev_ctx_t *ctx,
  data->raw = (data->raw * 256);
  data->lsb = (data->raw / 256); /* shift 8bit left */

  data->mv = ilps22qs_from_lsb_to_mv(data->lsb);

  return ret;
}

Loading