Skip to content

Commit

Permalink
sensor/stmemsc: Align stmemsc i/f to v2.3
Browse files Browse the repository at this point in the history
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: Armando Visconti <armando.visconti@st.com>
  • Loading branch information
avisconti committed Aug 22, 2023
1 parent b217e60 commit 9b128ca
Show file tree
Hide file tree
Showing 30 changed files with 8,050 additions and 6,357 deletions.
1 change: 1 addition & 0 deletions sensor/stmemsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set(stmems_pids
lsm6dsv16x
lsm6dsv
lsm9ds1
sths34pf80
stts22h
stts751
)
Expand Down
84 changes: 82 additions & 2 deletions sensor/stmemsc/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,14 +47,94 @@ 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.

URL:
https://www.st.com/en/embedded-software/c-driver-mems.html

commit:
version v2.02
version v2.3

Maintained-by:
ST Microelectronics
Expand Down
43 changes: 43 additions & 0 deletions sensor/stmemsc/iis3dwb_STdC/driver/iis3dwb_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
17 changes: 17 additions & 0 deletions sensor/stmemsc/iis3dwb_STdC/driver/iis3dwb_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 7 additions & 0 deletions sensor/stmemsc/ilps22qs_STdC/driver/ilps22qs_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
* @}
*
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions sensor/stmemsc/ilps22qs_STdC/driver/ilps22qs_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ extern float_t ilps22qs_from_fs4000_to_hPa(int32_t lsb);

extern float_t ilps22qs_from_lsb_to_celsius(int16_t lsb);

extern float_t ilps22qs_from_lsb_to_mv(int32_t lsb);

typedef struct
{
uint8_t whoami;
Expand Down Expand Up @@ -616,6 +618,7 @@ int32_t ilps22qs_data_get(stmdev_ctx_t *ctx, ilps22qs_md_t *md,
ilps22qs_data_t *data);
typedef struct
{
float_t mv; /* value converted in mV */
int32_t lsb; /* 24 bit properly right aligned */
int32_t raw; /* 32 bit signed-left algned format left */
} ilps22qs_ah_qvar_data_t;
Expand Down
7 changes: 7 additions & 0 deletions sensor/stmemsc/ilps28qsw_STdC/driver/ilps28qsw_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ float_t ilps28qsw_from_lsb_to_celsius(int16_t lsb)
return ((float_t)lsb / 100.0f);
}

float_t ilps28qsw_from_lsb_to_mv(int32_t lsb)
{
return ((float_t)lsb) / 426000.0f;
}

/**
* @}
*
Expand Down Expand Up @@ -756,6 +761,8 @@ int32_t ilps28qsw_ah_qvar_data_get(stmdev_ctx_t *ctx,
data->raw = (data->raw * 256);
data->lsb = (data->raw / 256); /* shift 8bit left */

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

return ret;
}

Expand Down
3 changes: 3 additions & 0 deletions sensor/stmemsc/ilps28qsw_STdC/driver/ilps28qsw_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ extern float_t ilps28qsw_from_fs4000_to_hPa(int32_t lsb);

extern float_t ilps28qsw_from_lsb_to_celsius(int16_t lsb);

extern float_t ilps28qsw_from_lsb_to_mv(int32_t lsb);

typedef struct
{
uint8_t whoami;
Expand Down Expand Up @@ -602,6 +604,7 @@ int32_t ilps28qsw_data_get(stmdev_ctx_t *ctx, ilps28qsw_md_t *md,
ilps28qsw_data_t *data);
typedef struct
{
float_t mv; /* value converted in mV */
int32_t lsb; /* 24 bit properly right aligned */
int32_t raw; /* 32 bit signed-left algned format left */
} ilps28qsw_ah_qvar_data_t;
Expand Down

0 comments on commit 9b128ca

Please sign in to comment.