Commit b52fdbf4 authored by Armando Visconti's avatar Armando Visconti Committed by Maureen Helm
Browse files

sensor/stmemsc: Align stmemsc i/f to v1.03



Align stmemsc HAL i/f to v1.03.

Signed-off-by: default avatarArmando Visconti <armando.visconti@st.com>
parent 5b3ec3e1
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -10,11 +10,13 @@ set(stmems_pids
  ais328dq
  ais3624dq
  asm330lhh
  h3lis100dl
  h3lis331dl
  hts221
  i3g4250d
  iis2dh
  iis2dlpc
  iis2iclx
  iis2mdc
  iis328dq
  iis3dhhc
@@ -24,6 +26,7 @@ set(stmems_pids
  ism330dlc
  l20g20is
  l3gd20h
  lis25ba
  lis2de12
  lis2dh12
  lis2ds12
@@ -33,14 +36,16 @@ set(stmems_pids
  lis2mdl
  lis331dlh
  lis3de
  lis3dhh
  lis3dh
  lis3dhh
  lis3dsh
  lis3mdl
  lps22hb
  lps22hh
  lps25hb
  lps27hhw
  lps33hw
  lps33k
  lps33w
  lsm303agr
  lsm303ah
@@ -49,9 +54,12 @@ set(stmems_pids
  lsm6dsl
  lsm6dsm
  lsm6dso
  lsm6dso32
  lsm6dsox
  lsm6dsr
  lsm6dsrx
  lsm9ds1
  stts22h
  stts751
  )

+2 −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 v1.02
   version v1.03

Purpose:
   ST Microelectronics standard C platform-independent drivers for MEMS
@@ -46,7 +46,7 @@ URL:
   https://www.st.com/en/embedded-software/c-driver-mems.html

commit:
   version v1.02
   version v1.03

Maintained-by:
   ST Microelectronics
+104 −121
Original line number Diff line number Diff line
@@ -6,36 +6,18 @@
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *   1. Redistributions of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *   3. Neither the name of STMicroelectronics nor the names of its
 *      contributors may be used to endorse or promote products derived from
 *      this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */

/* Includes ------------------------------------------------------------------*/
#include <math.h>
#include "fifo_utility.h"

/**
@@ -241,7 +223,7 @@ st_fifo_status st_fifo_decompress(st_fifo_out_slot *fifo_out_slot,

    if ((has_even_parity(fifo_raw_slot[i].fifo_data_out[0]) == 0U) ||
        (is_tag_valid(tag) == 0U)){
      continue;
      return ST_FIFO_ERR;
    }

    if ((tag_counter != (tag_counter_old)) && (bdr_max != 0.0f)) {
@@ -836,7 +818,7 @@ static uint8_t has_even_parity(uint8_t x)
  uint8_t ret = 1;

  for (i = 0U; i < 8U; i++) {
    if( ( x & (b << i) ) == 0x01U){
    if( ( x & (b << i) ) != 0x00U){
      count++;
    }
  }
@@ -877,7 +859,8 @@ static void get_diff_2x(int16_t diff[6], uint8_t input[6])
  */
static void get_diff_3x(int16_t diff[9], uint8_t input[6])
{
  uint32_t decode_temp;
  uint16_t decode_temp;
  uint16_t dummy;

  for (uint8_t i = 0; i < 3U; i++) {

@@ -885,12 +868,12 @@ static void get_diff_3x(int16_t diff[9], uint8_t input[6])

    for (uint8_t j = 0; j < 3U; j++) {

      decode_temp &= ( (uint32_t)0x1FU << (5U * j) );
      decode_temp = decode_temp >> (5U * j);

      int16_t temp = (int16_t)decode_temp;

      diff[j + (3U * i)] = (temp < 16) ? temp : (temp - 32);
      dummy = decode_temp & ( (uint16_t)0x1FU << (5U * j) );
      dummy = dummy >> (5U * j);
      if (dummy >= 16U) {
        dummy -= 32U;
      }
      diff[j + (3U * i)] = (int16_t)dummy;
    }
  }
}
+8 −25
Original line number Diff line number Diff line
@@ -7,32 +7,15 @@
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
 * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *   1. Redistributions of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *   3. Neither the name of STMicroelectronics nor the names of its
 *      contributors may be used to endorse or promote products derived from
 *      this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */

/* Define to prevent recursive inclusion -------------------------------------*/
@@ -45,6 +28,7 @@ extern "C" {

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <math.h>

/** @addtogroup FIFO utility
  * @{
@@ -101,7 +85,6 @@ typedef struct {
  * @{
  *
  */

typedef union {
  int16_t data[3];       /* 3 axes mems */
  int16_t temp;          /* temperature sensor */
+21 −11
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
 * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
@@ -242,10 +242,19 @@ int32_t a3g4250d_temperature_raw_get(stmdev_ctx_t *ctx, uint8_t *buff)
  * @retval        Interface status (MANDATORY: return 0 -> no Error).
  *
  */
int32_t a3g4250d_angular_rate_raw_get(stmdev_ctx_t *ctx, uint8_t *buff)
int32_t a3g4250d_angular_rate_raw_get(stmdev_ctx_t *ctx, int16_t *val)
{
  uint8_t buff[6];
  int32_t ret;

  ret =  a3g4250d_read_reg(ctx, A3G4250D_OUT_X_L, buff, 6);
  val[0] = (int16_t)buff[1];
  val[0] = (val[0] * 256) + (int16_t)buff[0];
  val[1] = (int16_t)buff[3];
  val[1] = (val[1] * 256) + (int16_t)buff[2];
  val[2] = (int16_t)buff[5];
  val[2] = (val[2] * 256) + (int16_t)buff[4];

  return ret;
}

@@ -1247,7 +1256,7 @@ int32_t a3g4250d_int_x_treshold_set(stmdev_ctx_t *ctx, uint16_t val)
  ret = a3g4250d_read_reg(ctx, A3G4250D_INT1_TSH_XH,
                               (uint8_t*)&int1_tsh_xh, 1);
  if(ret == 0){
    int1_tsh_xh.thsx = (uint8_t)((uint16_t)val & 0x7F00U)>>8;
    int1_tsh_xh.thsx = (uint8_t)(val / 256U) & 0x7FU;
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_XH,
                             (uint8_t*)&int1_tsh_xh, 1);
  }
@@ -1256,7 +1265,7 @@ int32_t a3g4250d_int_x_treshold_set(stmdev_ctx_t *ctx, uint16_t val)
                            (uint8_t*)&int1_tsh_xl, 1);
  }
  if(ret == 0){
    int1_tsh_xl.thsx = (uint8_t)((uint16_t)val & 0x00FFU);
    int1_tsh_xl.thsx = (uint8_t)(val - (int1_tsh_xh.thsx * 256U));
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_XL,
                             (uint8_t*)&int1_tsh_xl, 1);
  }
@@ -1284,8 +1293,9 @@ int32_t a3g4250d_int_x_treshold_get(stmdev_ctx_t *ctx, uint16_t *val)
                               (uint8_t*)&int1_tsh_xl, 1);

    *val = int1_tsh_xh.thsx;
    *val = *val << 8;
    *val = *val * 256U;
    *val +=  int1_tsh_xl.thsx;

  }
  return ret;
}
@@ -1306,7 +1316,7 @@ int32_t a3g4250d_int_y_treshold_set(stmdev_ctx_t *ctx, uint16_t val)

  ret = a3g4250d_read_reg(ctx, A3G4250D_INT1_TSH_YH,
                               (uint8_t*)&int1_tsh_yh, 1);
  int1_tsh_yh.thsy = (uint8_t)((uint16_t)val & 0x7F00U)>>8;
  int1_tsh_yh.thsy = (uint8_t)(val / 256U) & 0x7FU;
  if(ret == 0){
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_YH,
                                (uint8_t*)&int1_tsh_yh, 1);
@@ -1314,7 +1324,7 @@ int32_t a3g4250d_int_y_treshold_set(stmdev_ctx_t *ctx, uint16_t val)
  if(ret == 0){
    ret = a3g4250d_read_reg(ctx, A3G4250D_INT1_TSH_YL,
                               (uint8_t*)&int1_tsh_yl, 1);
    int1_tsh_yl.thsy = (uint8_t)((uint16_t)val & 0x00FFU);
    int1_tsh_yl.thsy = (uint8_t)(val - (int1_tsh_yh.thsy * 256U));
  }
  if(ret == 0){
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_YL,
@@ -1344,7 +1354,7 @@ int32_t a3g4250d_int_y_treshold_get(stmdev_ctx_t *ctx, uint16_t *val)
                               (uint8_t*)&int1_tsh_yl, 1);

    *val = int1_tsh_yh.thsy;
    *val = *val << 8;
    *val = *val * 256U;
    *val += int1_tsh_yl.thsy;
  }
  return ret;
@@ -1366,7 +1376,7 @@ int32_t a3g4250d_int_z_treshold_set(stmdev_ctx_t *ctx, uint16_t val)

  ret = a3g4250d_read_reg(ctx, A3G4250D_INT1_TSH_ZH,
                               (uint8_t*)&int1_tsh_zh, 1);
  int1_tsh_zh.thsz = (uint8_t)((uint16_t)val & 0x7F00U)>>8;
  int1_tsh_zh.thsz = (uint8_t)(val / 256U) & 0x7FU;;
  if(ret == 0){
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_ZH,
                                (uint8_t*)&int1_tsh_zh, 1);
@@ -1374,7 +1384,7 @@ int32_t a3g4250d_int_z_treshold_set(stmdev_ctx_t *ctx, uint16_t val)
  if(ret == 0){
    ret = a3g4250d_read_reg(ctx, A3G4250D_INT1_TSH_ZL,
                               (uint8_t*)&int1_tsh_zl, 1);
    int1_tsh_zl.thsz = (uint8_t)((uint8_t)val & 0x00FFU);
    int1_tsh_zl.thsz = (uint8_t)(val - (int1_tsh_zh.thsz * 256U));
  }
  if(ret == 0){
    ret = a3g4250d_write_reg(ctx, A3G4250D_INT1_TSH_ZL,
@@ -1404,7 +1414,7 @@ int32_t a3g4250d_int_z_treshold_get(stmdev_ctx_t *ctx, uint16_t *val)
                               (uint8_t*)&int1_tsh_zl, 1);

    *val = int1_tsh_zh.thsz;
    *val = *val << 8;
    *val = *val * 256U;
    *val += int1_tsh_zl.thsz;
  }
  return ret;
Loading