<commit_before>/*
 ******************************************************************************
 * @file    lis2de12_reg.c
 * @author  Sensors Software Solution Team
 * @brief   LIS2DE12 driver file
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2019 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
 *
 ******************************************************************************
 */

#include "lis2de12_reg.h"

/**
  * @defgroup  LIS2DE12
  * @brief     This file provides a set of functions needed to drive the
  *            lis2de12 enanced inertial module.
  * @{
  *
  */

/**
  * @defgroup  LIS2DE12_Interfaces_Functions
  * @brief     This section provide a set of functions used to read and
  *            write a generic register of the device.
  *            MANDATORY: return 0 -> no Error.
  * @{
  *
  */

/**
  * @brief  Read generic device register
  *
  * @param  ctx   read / write interface definitions(ptr)
  * @param  reg   register to read
  * @param  data  pointer to buffer that store the data read(ptr)
  * @param  len   number of consecutive register to read
  * @retval          interface status (MANDATORY: return 0 -> no Error)
  *
  */
int32_t lis2de12_read_reg(stmdev_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;
}

/**
  * @brief  Write generic device register
  *
  * @param  ctx   read / write interface definitions(ptr)
  * @param  reg   register to write
  * @param  data  pointer to data to write in register reg(ptr)
  * @param  len   number of consecutive register to write
  * @retval          interface status (MANDATORY: return 0 -> no Error)
  *
  */
int32_t lis2de12_write_reg(stmdev_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;
}

/**
  * @}
  *
  */

  /**
  * @defgroup    LIS2DE12_Sensitivity
  * @brief       These functions convert raw-data into engineering units.
  * @{
  *
  */

float_t lis2de12_from_fs2_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 16.0f;
}

float_t lis2de12_from_fs4_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 32.0f;
}

float_t lis2de12_from_fs8_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 64.0f;
}

float_t lis2de12_from_fs16_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 192.0f;
}

float_t lis2de12_from_lsb_to_celsius(int16_t lsb)
{
  return ( ( (float_t)lsb / 256.0f ) * 1.0f ) + 25.0f;
}

/**
  * @}
  *
  */
<commit_msg>lis2de12: aligned sensitivity precision with DS<commit_after>/*
 ******************************************************************************
 * @file    lis2de12_reg.c
 * @author  Sensors Software Solution Team
 * @brief   LIS2DE12 driver file
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2019 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
 *
 ******************************************************************************
 */

#include "lis2de12_reg.h"

/**
  * @defgroup  LIS2DE12
  * @brief     This file provides a set of functions needed to drive the
  *            lis2de12 enanced inertial module.
  * @{
  *
  */

/**
  * @defgroup  LIS2DE12_Interfaces_Functions
  * @brief     This section provide a set of functions used to read and
  *            write a generic register of the device.
  *            MANDATORY: return 0 -> no Error.
  * @{
  *
  */

/**
  * @brief  Read generic device register
  *
  * @param  ctx   read / write interface definitions(ptr)
  * @param  reg   register to read
  * @param  data  pointer to buffer that store the data read(ptr)
  * @param  len   number of consecutive register to read
  * @retval          interface status (MANDATORY: return 0 -> no Error)
  *
  */
int32_t lis2de12_read_reg(stmdev_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;
}

/**
  * @brief  Write generic device register
  *
  * @param  ctx   read / write interface definitions(ptr)
  * @param  reg   register to write
  * @param  data  pointer to data to write in register reg(ptr)
  * @param  len   number of consecutive register to write
  * @retval          interface status (MANDATORY: return 0 -> no Error)
  *
  */
int32_t lis2de12_write_reg(stmdev_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;
}

/**
  * @}
  *
  */

  /**
  * @defgroup    LIS2DE12_Sensitivity
  * @brief       These functions convert raw-data into engineering units.
  * @{
  *
  */

float_t lis2de12_from_fs2_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 15.6f;
}

float_t lis2de12_from_fs4_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 31.2f;
}

float_t lis2de12_from_fs8_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 62.5f;
}

float_t lis2de12_from_fs16_to_mg(int16_t lsb)
{
  return ( (float_t)lsb / 256.0f ) * 187.5f;
}

float_t lis2de12_from_lsb_to_celsius(int16_t lsb)
{
  return ( ( (float_t)lsb / 256.0f ) * 1.0f ) + 25.0f;
}

/**
  * @}
  *
  */

{'fraction_non_alphanumeric': 0.1784392869155735, 'fraction_numerical': 0.04154053144971409, 'mean_word_length': 2.9176548089591567, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3813084', 'n_tokens_mistral': 2238, 'n_tokens_neox': 2059, 'n_words': 541}