From c9d3b3dee88098d800b9c773df40269f915f4ddd Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Sat, 19 Oct 2013 16:46:35 +0000 Subject: [PATCH] Remove pressure sensor git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@123 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- lib/LPS331AP/inc/LPS331AP.h | 639 ------------------------------------ lib/LPS331AP/src/LPS331AP.c | 606 ---------------------------------- 2 files changed, 1245 deletions(-) delete mode 100755 lib/LPS331AP/inc/LPS331AP.h delete mode 100755 lib/LPS331AP/src/LPS331AP.c diff --git a/lib/LPS331AP/inc/LPS331AP.h b/lib/LPS331AP/inc/LPS331AP.h deleted file mode 100755 index 2add89f..0000000 --- a/lib/LPS331AP/inc/LPS331AP.h +++ /dev/null @@ -1,639 +0,0 @@ -/** - * @file LSM303DLHC.h - * @author ART Team IMS-Systems Lab - * @version V2.3.0 - * @date 12 April 2012 - * @brief Header for LPS331AP.c file - * @details - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - * THIS SOURCE CODE IS PROTECTED BY A LICENSE. - * FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED - * IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE. - * - *

© COPYRIGHT 2012 STMicroelectronics

- */ - - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __LPS331AP_H -#define __LPS331AP_H - -/* Includes ------------------------------------------------------------------*/ -#include -#include "HAL_LPS331AP.h" - -#ifdef __cplusplus - extern "C" { -#endif - -/** - * @addtogroup Sensor_Libraries Sensor Libraries - * @{ - */ - -/** - * @defgroup LPS331AP - * @brief This module contains all the functions to configure the LPS331AP pressure sensor. - * @details - * Since this code is platform independent an implementation of the SPI or I2C driver must - * be provided by the user according to the used platform. - * Every function makes use of the Lps331apBufferRead and/or Lps331apBufferWrite - * as low level functions to write bytes through the used digital interface. - * In order to link and use this code the user should define and export these functions in a header - * file called "HAL_LPS331AP.h" (included by this module). - * - * @{ - */ - -/** - * @defgroup LPS331AP_Exported_Types LPS331AP Exported Types - * @{ - */ - -/** - * @brief LPS331AP Functional state. Used to enable or disable a specific option. - */ -typedef enum -{ - LPS_DISABLE = 0, - LPS_ENABLE = !LPS_DISABLE -}LPSFunctionalState; - - -/** - * @brief Pressure Flag status. Used to set/reset the sensor flags. - */ -typedef enum -{ - LPS_RESET = 0, - LPS_SET = !LPS_RESET -}LPSFlagStatus; - - -/** - * @brief LPS331AP Output Data Rate - */ -typedef enum -{ - ODR_P_T_ONE_SHOT = 0x00, /*!< Output Data Rate: P - one shot, T - one shot */ - ODR_P_1HZ_T_1HZ = 0x10, /*!< Output Data Rate: P - 1Hz, T - 1Hz */ - ODR_P_7HZ_T_1HZ = 0x20, /*!< Output Data Rate: P - 7Hz, T - 1Hz */ - ODR_P_12_5HZ_T_1HZ = 0x30, /*!< Output Data Rate: P - 12.5Hz, T - 1Hz */ - ODR_P_25HZ_T_1HZ = 0x40, /*!< Output Data Rate: P - 25Hz, T - 1Hz */ - ODR_P_7HZ_T_7HZ = 0x50, /*!< Output Data Rate: P - 7Hz, T - 7Hz */ - ODR_P_12_5HZ_T_12_5HZ = 0x60, /*!< Output Data Rate: P - 12.5Hz, T - 12.5Hz */ - ODR_P_25HZ_T_25HZ = 0x70, /*!< Output Data Rate: P - 25Hz, T - 25Hz */ -}LPSOutputDataRate; - - -/** - * @brief LPS331AP Pressure resolution - */ -typedef enum -{ - LPS_PRESS_AVG_1 = 0x00, /*!< Internal average on 1 sample */ - LPS_PRESS_AVG_2 = 0x01, /*!< Internal average on 2 sample */ - LPS_PRESS_AVG_4 = 0x02, /*!< Internal average on 4 sample */ - LPS_PRESS_AVG_8 = 0x03, /*!< Internal average on 8 sample */ - LPS_PRESS_AVG_16 = 0x04, /*!< Internal average on 16 sample */ - LPS_PRESS_AVG_32 = 0x05, /*!< Internal average on 32 sample */ - LPS_PRESS_AVG_64 = 0x06, /*!< Internal average on 64 sample */ - LPS_PRESS_AVG_128 = 0x07, /*!< Internal average on 128 sample */ - LPS_PRESS_AVG_256 = 0x08, /*!< Internal average on 256 sample */ - LPS_PRESS_AVG_384 = 0x09, /*!< Internal average on 384 sample */ - LPS_PRESS_AVG_512 = 0x0A, /*!< Internal average on 512 sample */ -}LPSPressureResolution; - - -/** - * @brief LPS331AP Temperature resolution - */ -typedef enum -{ - LPS_TEMP_AVG_1 = 0x00, /*!< Internal average on 1 sample */ - LPS_TEMP_AVG_2 = 0x10, /*!< Internal average on 2 sample */ - LPS_TEMP_AVG_4 = 0x20, /*!< Internal average on 4 sample */ - LPS_TEMP_AVG_8 = 0x30, /*!< Internal average on 8 sample */ - LPS_TEMP_AVG_16 = 0x40, /*!< Internal average on 16 sample */ - LPS_TEMP_AVG_32 = 0x50, /*!< Internal average on 32 sample */ - LPS_TEMP_AVG_64 = 0x60, /*!< Internal average on 64 sample */ - LPS_TEMP_AVG_128 = 0x70, /*!< Internal average on 128 sample */ -}LPSTemperatureResolution; - - - -/** - * @brief LPS331AP Irq list - */ -typedef enum -{ - LPS_GND = 0x00, - LPS_P_HIGH = 0x01, - LPS_P_LOW = 0x02, - LPS_P_LOW_HIGH = 0x03, - LPS_DATA_READY = 0x04, - LPS_TRISTATE = 0x07, -}LPSIrqList; - - -/** - * @brief LPS331AP Irq pin output configuration - */ -typedef enum -{ - LPS_PP = 0x00, - LPS_OD = 0x40 -}LPSOutputType; - - -/** - * @brief Pressure sensor Irq initialization structure - */ -typedef struct -{ - LPSFunctionalState xIrqActiveLow; - LPSOutputType xOutType; - LPSIrqList xInt1List; - LPSIrqList xInt2List; - float fPressThr; - LPSFunctionalState xIrqPressLow; - LPSFunctionalState xIrqPressHigh; -}LPSIrqInit; - - -/** - * @brief Pressure sensor Init structure definition - */ -typedef struct -{ - LPSOutputDataRate xOutputDataRate; /*!< Output Data Rate */ - LPSPressureResolution xPresRes; /*!< Pressure sensor resolution */ - LPSTemperatureResolution xTempRes; /*!< Temperature sensor resolution */ - LPSFunctionalState xPressureAutoZero; /*!< Auto zero feature enabled */ - float fPressureRef; /*!< Pressure sensor reference value */ - LPSFunctionalState xBDU; /*!< Auto zero feature enabled */ -}LPS331Init; - - -/** - * @brief Pressure sensor data status structure structure - */ -typedef struct -{ - LPSFlagStatus cTempDataAvailable:1; /*!< Temperature data available bit */ - LPSFlagStatus cPressDataAvailable:1; /*!< Pressure data available bit */ - uint8_t :2; /*!< 2 bits padding */ - LPSFlagStatus cTempDataOverrun:1; /*!< Temperature data over-run bit */ - LPSFlagStatus cPressDataOverrun:1; /*!< Pressure data over-run bit */ - uint8_t :2; /*!< 2 bits padding */ -}LPS331DataStatus; - - -/** - * @} - */ - -/** - * @defgroup LPS331AP_Exported_Constants LPS331AP Exported Constants - * @{ - */ - - -/** - * @} - */ - -/** - * @defgroup LPS331AP_Exported_Macros LPS331AP Exported Macros - * @{ - */ - -/** -* @brief Read LPS331AP output register, and calculate the pressure in mbar. -* @param None. -* @retval float: pressure expressed in mbar. -*/ -#define Lps331apReadPressure() ((float)Lps331apReadRawPressure()/4096) - - -/** -* @brief Read LPS331AP output register, and calculate the temperature in C deg. -* @param None. -* @retval float: temperature expressed in C deg. -*/ -#define Lps331apReadTemperature() ((float)Lps331apReadRawTemperature()/480.0+42.5) - - -/** @defgroup LPS331AP_Communication LPS331AP Communication - * @{ - */ - -#define Lps331apByteRead(pVal,cAddress) Lps331apBufferRead(pVal,cAddress,1) -#define Lps331apByteWrite(pVal,cAddress) Lps331apBufferWrite(pVal,cAddress,1) - - -/** - * @} - */ - -/** - * @} - */ - - -/** @defgroup LPS331AP_Register_Mapping LPS331AP Register Mapping - * @{ - */ - -/** - * @brief Reference pressure (LSB data) - * \code - * Read/write - * Default value: 0x00 - * 7:0 REF7-ODR0: Lower part of the reference pressure that - * is sum to the sensor output pressure. - * \endcode - */ -#define LPS_REF_P_XL_ADDR 0x08 - - -/** - * @brief Reference pressure (middle part) - * \code - * Read/write - * Default value: 0x00 - * 7:0 REF15-ODR8: Middle part of the reference pressure that - * is sum to the sensor output pressure. - * \endcode - */ -#define LPS_REF_P_L_ADDR 0x09 - - -/** - * @brief Reference pressure (MSB part) - * \code - * Read/write - * Default value: 0x00 - * 7:0 REF15-ODR8: Higher part of the reference pressure that - * is sum to the sensor output pressure. - * \endcode - */ -#define LPS_REF_P_H_ADDR 0x0A - - -/** - * @brief Device identifier register. - * \code - * Read - * Default value: 0xBB - * 7:0 This read-only register contains the device identifier that, for LPS331AP, is set to BBh. - * \endcode - */ -#define LPS_WHO_AM_I_ADDR 0x0F - - -/** - * @brief Pressure resolution Register - * \code - * Read/write - * Default value: 0x7A - * 7 RFU - * 6:4 AVGT2-AVGT0: temperature internal average. - * AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average - * ------------------------------------------------------ - * 0 | 0 | 0 | 1 - * 0 | 0 | 1 | 2 - * 0 | 1 | 0 | 4 - * 0 | 1 | 1 | 8 - * 1 | 0 | 0 | 16 - * 1 | 0 | 1 | 32 - * 1 | 1 | 0 | 64 - * 1 | 1 | 1 | 128 - * - * 3:0 AVGP3-AVGP0: pressure internal average. - * AVGP3 | AVGP2 | AVGP1 | AVGP0 | Nr. Internal Average - * ------------------------------------------------------ - * 0 | 0 | 0 | 0 | 1 - * 0 | 0 | 0 | 1 | 2 - * 0 | 0 | 1 | 0 | 4 - * 0 | 0 | 1 | 1 | 8 - * 0 | 1 | 0 | 0 | 16 - * 0 | 1 | 0 | 1 | 32 - * 0 | 1 | 1 | 0 | 64 - * 0 | 1 | 1 | 1 | 128 - * 1 | 0 | 0 | 0 | 256 - * 1 | 0 | 0 | 1 | 384 - * 1 | 0 | 1 | 0 | 512 - * - * \endcode - */ -#define LPS_RES_CONF_ADDR 0x10 - - - - -/** - * @brief Pressure sensor control register 1 - * \code - * Read/write - * Default value: 0x00 - * 7 PD: power down control. 0 - disable; 1 - enable - * 6:4 ODR2, ODR1, ODR0: output data rate selection. - * ODR2 | ODR1 | ODR0 | Pressure output data-rate(Hz) | Temperature output data-rate(Hz) - * ---------------------------------------------------------------------------------- - * 0 | 0 | 0 | one shot | one shot - * 0 | 0 | 1 | 1 | 1 - * 0 | 1 | 0 | 7 | 1 - * 0 | 1 | 1 | 12.5 | 1 - * 1 | 0 | 0 | 25 | 1 - * 1 | 0 | 1 | 7 | 7 - * 1 | 1 | 0 | 12.5 | 12.5 - * 1 | 1 | 1 | 25 | 25 - * - * 3 DIFF_EN: Interrupt circuit. 0 - disable; 1 - enable - * 2 BDU: block data update. 0 - disable; 1 - enable - * 1 DELTA_EN: delta pressure. 0 - disable; 1 - enable - * 0 SIM: SPI Serial Interface Mode selection. 0 - disable; 1 - enable - * \endcode - */ -#define LPS_CTRL_REG1_ADDR 0x20 - - -/** - * @brief Pressure sensor control register 2 - * \code - * Read/write - * Default value: 0x00 - * 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content - * 6:3 Reserved. - * 2 SWRESET: Software reset. 0: normal mode; 1: SW reset. - * 1 AUTO_ZERO: Autozero enable. 0: normal mode; 1: autozero enable. - * 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset - * \endcode - */ -#define LPS_CTRL_REG2_ADDR 0x21 - - -/** - * @brief Pressure sensor control register 3 - * \code - * Read/write - * Default value: 0x00 - * 7 INT_H_L: Interrupt active high, low. - * 6 PP_OD: Push-pull/open drain selection on interrupt pads. - * 5:3 INT2_S3, INT2_S2, INT2_S1: data signal on INT2 pad control bits. - * 2:0 INT1_S3, INT1_S2, INT1_S1: data signal on INT1 pad control bits. - * INT1(2)_S3 | INT1(2)_S2 | INT1(2)_S1 | INT1(2) pin - * ------------------------------------------------------ - * 0 | 0 | 0 | GND - * 0 | 0 | 1 | Pressure high (P_high) - * 0 | 1 | 0 | Pressure low (P_low) - * 0 | 1 | 1 | P_low OR P_high - * 1 | 0 | 0 | Data ready - * 1 | 0 | 1 | Reserved - * 1 | 1 | 0 | Reserved - * 1 | 1 | 1 | Tri-state - - * \endcode - */ -#define LPS_CTRL_REG3_ADDR 0x22 - - -/** - * @brief Interrupt configuration Register - * \code - * Read/write - * Default value: 0x00. - * 7:3 Reserved. - * 2 LIR: Latch Interrupt request into INT_SOURCE register. 0 - disable; 1 - enable - * 1 PL_E: Enable interrupt generation on differential pressure low event. 0 - disable; 1 - enable - * 0 PH_E: Enable interrupt generation on differential pressure high event. 0 - disable; 1 - enable - * \endcode - */ -#define LPS_INT_CFG_REG_ADDR 0x23 - - -/** - * @brief Interrupt source Register - * \code - * Read - * Default value: 0x00. - * 7:3 0. - * 2 IA: Interrupt Active.0: no interrupt has been generated; 1: one or more interrupt events have been generated. - * 1 PL: Differential pressure Low. 0: no interrupt has been generated; 1: Low differential pressure event has occurred. - * 0 PH: Differential pressure High. 0: no interrupt has been generated; 1: High differential pressure event has occurred. - * \endcode - */ -#define LPS_INT_SOURCE_REG_ADDR 0x24 - - -/** - * @brief Threshold pressure (LSB) - * \code - * Read - * Default value: 0x00. - * 7:0 THS7-THS0: Low part of threshold value for pressure interrupt - * generation. The complete threshold value is given by THS_P_H & THS_P_L and is - * expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16. - * \endcode - */ -#define LPS_THS_P_LOW_REG_ADDR 0x25 - - -/** - * @brief Threshold pressure (MSB) - * \code - * Read - * Default value: 0x00. - * 7:0 THS15-THS8: High part of threshold value for pressure interrupt - * generation. The complete threshold value is given by THS_P_H & THS_P_L and is - * expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16. - * \endcode - */ -#define LPS_THS_P_HIGH_REG_ADDR 0x26 - - -/** - * @brief Status Register - * \code - * Read - * Default value: 0x00 - * 7:6 0 - * 5 P_OR: Pressure data overrun. 0: no overrun has occurred; 1: new data for pressure has overwritten the previous one. - * 4 T_OR: Temperature data overrun. 0: no overrun has occurred; 1: a new data for temperature has overwritten the previous one. - * 3:2 0 - * 1 P_DA: Pressure data available. 0: new data for pressure is not yet available; 1: new data for pressure is available. - * 0 T_DA: Temperature data available. 0: new data for temperature is not yet available; 1: new data for temperature is available. - * \endcode - */ -#define LPS_STATUS_REG_ADDR 0x27 - - -/** - * @brief Pressure data (LSB). - * \code - * Read - * Default value: 0x00. - * POUT7 - POUT0: Pressure data LSB (2's complement). - * Pressure output data: Pout(mbar)=(PRESS_OUT_H & PRESS_OUT_L & - * PRESS_OUT_XL)[dec]/4096. - * \endcode - */ -#define LPS_PRESS_POUT_XL_ADDR 0x28 - - -/** - * @brief Pressure data (Middle part). - * \code - * Read - * Default value: 0x80. - * POUT15 - POUT8: Pressure data middle part (2's complement). - * Pressure output data: Pout(mbar)=(PRESS_OUT_H & PRESS_OUT_L & - * PRESS_OUT_XL)[dec]/4096. - * \endcode - */ -#define LPS_PRESS_OUT_L_ADDR 0x29 - - -/** - * @brief Pressure data (MSB). - * \code - * Read - * Default value: 0x2F. - * POUT23 - POUT16: Pressure data MSB (2's complement). - * Pressure output data: Pout(mbar)=(PRESS_OUT_H & PRESS_OUT_L & - * PRESS_OUT_XL)[dec]/4096. - * \endcode - */ -#define LPS_PRESS_OUT_H_ADDR 0x2A - - -/** - * @brief Temperature data (LSB). - * \code - * Read - * Default value: 0x00. - * TOUT7 - TOUT0: temperature data LSB. - * T(degC) = 42.5 + (Temp_OUTH & TEMP_OUT_L)[dec]/480. - * \endcode - */ -#define LPS_TEMP_OUT_L_ADDR 0x2B - - -/** - * @brief Temperature data (MSB). - * \code - * Read - * Default value: 0x00. - * TOUT15 - TOUT8: temperature data MSB. - * T(degC) = 42.5 + (Temp_OUTH & TEMP_OUT_L)[dec]/480. - * \endcode - */ -#define LPS_TEMP_OUT_H_ADDR 0x2C - - -/** - * @brief Analog front end control - * \code - * Read/write - * Default value: 0x00 - * 7:1 Reserved. - * 0 SELMAIN: Current of operational amplifier selector. - * -‘1’ always high current - * -‘0’ high current during pressure acquisition and low current during temperature acquisition - * \endcode - */ -#define LPS_AMP_CTRL_ADDR 0x30 - - - -/** - * @brief Pressure offset (LSB). - * \code - * Read - * Default value: 0x00. - * DELTA0 - DELTA7: Delta pressure register for One Point calibration. - * \endcode - */ -#define LPS_DELTA_PRESS_XL_ADDR 0x3C - - -/** - * @brief Pressure offset (Middle part). - * \code - * Read - * Default value: 0x80. - * DELTA15-DELTA8: Delta pressure register for One Point calibration. - * \endcode - */ -#define LPS_DELTA_PRESS_L_ADDR 0x3D - - -/** - * @brief Pressure offset (MSB). - * \code - * Read - * Default value: 0x2F. - * DELTA23-DELTA16: Delta pressure register for One Point calibration. - * \endcode - */ -#define LPS_DELTA_PRESS_H_ADDR 0x3E - - -/** - * @} - */ - - - -/** @defgroup LPS331AP_Exported_Functions LPS331AP Exported Functions - * @{ - */ - -void Lps331apConfig(LPS331Init* pxLPS331InitStruct); -void Lps331apGetInfo(LPS331Init* pxLPS331InitStruct); -void Lps331apLowPowerMode(LPSFunctionalState xFunctionalState); -void Lps331apSetPressureResolution(LPSPressureResolution xPressureResolution); -void Lps331apSetTemperatureResolution(LPSTemperatureResolution xTemperatureResolution); -void Lps331apSetDataRate(LPSOutputDataRate xDataRate); -LPSOutputDataRate Lps331apGetDataRate(void); -void Lps331apRebootCmd(void); -void Lps331apEnterShutdownCmd(void); -void Lps331apExitShutdownCmd(void); -int32_t Lps331apReadRawPressure(void); -int16_t Lps331apReadRawTemperature(void); -void Lps331apIrqInit(LPSIrqInit* pxLPSIrqInit); -void Lps331apOneShot(void); -LPS331DataStatus Lps331apGetDataStatus(void); -void Lps331apSetThreshold(float fThreshold); -float Lps331apGetThreshold(void); - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif - -/******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/ - diff --git a/lib/LPS331AP/src/LPS331AP.c b/lib/LPS331AP/src/LPS331AP.c deleted file mode 100755 index 709024b..0000000 --- a/lib/LPS331AP/src/LPS331AP.c +++ /dev/null @@ -1,606 +0,0 @@ -/** - * @file LSM303DLH.c - * @author ART Team IMS-Systems Lab - * @version V2.3.0 - * @date 12 April 2012 - * @brief This file provides a set of functions needed to manage the LPS331AP slave. - * @details - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - * THIS SOURCE CODE IS PROTECTED BY A LICENSE. - * FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED - * IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE. - * - *

© COPYRIGHT 2012 STMicroelectronics

- */ - - -#include "LPS331AP.h" - - -/** - * @addtogroup Sensor_Libraries Sensor Libraries - * @{ - */ - - -/** -* @addtogroup LPS331AP -* @{ -*/ - - -/** - * @defgroup LPS331AP_Private_TypesDefinitions LPS331AP Private TypesDefinitions - * @{ - */ - - -/** - *@} - */ - - -/** - * @defgroup LPS331AP_Private_Defines LPS331AP Private Defines - * @{ - */ - -/** - *@} - */ - - -/** - * @defgroup LPS331AP_Private_Macros LPS331AP Private Macros - * @{ - */ - -/** - *@} - */ - - -/** - * @defgroup LPS331AP_Private_Variables LPS331AP Private Variables - * @{ - */ - -/** - *@} - */ - - - -/** - * @defgroup LPS331AP_Private_FunctionPrototypes LPS331AP Private FunctionPrototypes - * @{ - */ - -/** - *@} - */ - - -/** - * @defgroup LPS331AP_Private_Functions LPS331AP Private Functions - * @{ - */ - -/** -* @brief Set configuration of pressure sensor LPS331AP -* @param pxLPS331InitStruct : pointer to a LPS331Init structure that contains the configuration setting for the LPS331AP. -* @retval None. -* @details -* Example: -* @code -* LPS331Init xLps331apInit; -* -* xLps331apInit.xOutputDataRate=ODR_P_7HZ_T_1HZ; -* xLps331apInit.xPresRes=LPS_PRESS_AVG_1; -* xLps331apInit.xTempRes=LPS_TEMP_AVG_1; -* xLps331apInit.xPressureAutoZero=LPS_DISABLE; -* xLps331apInit.fPressureRef=0; -* xLps331apInit.xBDU=LPS_DISABLE; -* -* Lps331apInit(&xLps331apInit); -* @endcode -*/ -void Lps331apConfig(LPS331Init* pxLPS331InitStruct) -{ - uint8_t tempReg[3]; - uint8_t i; - - for(i=0 ; i<3 ; i++) - tempReg[i]=(uint8_t)(((uint32_t)(4096.0*pxLPS331InitStruct->fPressureRef))>>(8*i)); - - /* Write the reference value on register */ - Lps331apBufferWrite(tempReg, LPS_REF_P_XL_ADDR,3); - - /* Resolution register setting */ - tempReg[0] = (uint8_t)pxLPS331InitStruct->xPresRes | (uint8_t)pxLPS331InitStruct->xTempRes; - - /* Write the value on register */ - Lps331apByteWrite(&tempReg[0], LPS_RES_CONF_ADDR); - - /* Read the CTRL1 and 2 register content */ - Lps331apBufferRead(tempReg, LPS_CTRL_REG1_ADDR,2); - - /* Enter the SDN mode */ - tempReg[0] &= 0x7F; - Lps331apByteWrite(tempReg, LPS_CTRL_REG1_ADDR); - - /* CTRL1 register */ - tempReg[0] &= 0x8B; - tempReg[0] |= pxLPS331InitStruct->xOutputDataRate; - - if(pxLPS331InitStruct->xBDU) - tempReg[0] |= 0x04; - else - tempReg[0] &= 0xFB; - - /* CTRL2 register */ - if(pxLPS331InitStruct->xPressureAutoZero) - tempReg[1] |= 0x02; - else - tempReg[1] &= 0xFD; - - /* Write the reference value on register */ - Lps331apBufferWrite(tempReg, LPS_CTRL_REG1_ADDR,2); - - /* Exit the SDN mode */ - tempReg[0] |= 0x80; - Lps331apByteWrite(tempReg, LPS_CTRL_REG1_ADDR); - -} - - -/** -* @brief Gets the general configuration of LPS331AP. -* @param pxLPS331InitStruct : pointer to a LPS331Init structure that will -* contain the configuration setting read from the LPS331AP registers. -* @retval None -*/ -void Lps331apGetInfo(LPS331Init* pxLPS331InitStruct) -{ - uint8_t tempReg[4]; - - Lps331apBufferRead(tempReg, LPS_REF_P_XL_ADDR,3); - tempReg[3]=0; - - /* Get the reference value */ - pxLPS331InitStruct->fPressureRef = (float)(*((uint32_t*)tempReg))/4096.0; - - /* Read register */ - Lps331apByteRead(&tempReg[0], LPS_RES_CONF_ADDR); - - pxLPS331InitStruct->xPresRes=(LPSPressureResolution)(tempReg[0] & 0x0F); - pxLPS331InitStruct->xTempRes=(LPSTemperatureResolution)(tempReg[0] & 0x70); - - /* Read the CTRL1 and 2 register content */ - Lps331apBufferRead(tempReg, LPS_CTRL_REG1_ADDR,2); - - /* get info */ - if(tempReg[0] & 0x04) - pxLPS331InitStruct->xBDU = LPS_ENABLE; - else - pxLPS331InitStruct->xBDU = LPS_DISABLE; - - - if(tempReg[1] & 0x02) - pxLPS331InitStruct->xPressureAutoZero = LPS_ENABLE; - else - pxLPS331InitStruct->xPressureAutoZero = LPS_DISABLE; - - /* Get the ODR info */ - Lps331apByteRead(tempReg, LPS_CTRL_REG1_ADDR); - - pxLPS331InitStruct->xOutputDataRate = (LPSOutputDataRate)(tempReg[0] & 0x70); - -} - - -/** -* @brief Enable or disable the lowpower mode for pressure sensor LPS331AP. -* @param xFunctionalState : new state for the lowpower mode. -* This parameter can be: LPS_ENABLE or LPS_DISABLE -* @retval None -*/ -void Lps331apLowPowerMode(LPSFunctionalState xFunctionalState) -{ - uint8_t tmpreg; - - /* Read the register content */ - Lps331apByteRead(&tmpreg, LPS_AMP_CTRL_ADDR); - - /* modify the specified bit */ - if(xFunctionalState == LPS_ENABLE) - { - tmpreg |= 0x01; - } - else - { - tmpreg &= 0xFE; - } - - /* Write the computed values on register */ - Lps331apByteWrite(&tmpreg, LPS_AMP_CTRL_ADDR); -} - - -/** -* @brief Change pressure resolution for Pressure sensor LPS331AP. -* @param xPressureResolution : new pressure resolution value. -* This parameter can be one of the @ref LPSPressureResolution value. -* @retval None -*/ -void Lps331apSetPressureResolution(LPSPressureResolution xPressureResolution) -{ - uint8_t tempReg; - - /* Read the register content */ - Lps331apByteRead(&tempReg, LPS_RES_CONF_ADDR); - - /* CTRL1 register */ - tempReg &= 0xF0; - tempReg |= xPressureResolution; - - /* Write computed byte onto register */ - Lps331apByteWrite(&tempReg, LPS_RES_CONF_ADDR); -} - - -/** -* @brief Change temperature resolution for Pressure sensor LPS331AP. -* @param xTemperatureResolution : new pressure resolution value. -* This parameter can be one of the @ref LPSTemperatureResolution value. -* @retval None -*/ -void Lps331apSetTemperatureResolution(LPSTemperatureResolution xTemperatureResolution) -{ - uint8_t tempReg; - - /* Read the register content */ - Lps331apByteRead(&tempReg, LPS_RES_CONF_ADDR); - - /* CTRL1 register */ - tempReg &= 0x8F; - tempReg |= xTemperatureResolution; - - /* Write computed byte onto register */ - Lps331apByteWrite(&tempReg, LPS_RES_CONF_ADDR); -} - - -/** -* @brief Change the ODR(Output data rate) for pressure sensor LPS331AP. -* @param xDataRate : new ODR value. -* This parameter can be one of the @ref LPSOutputDataRate value. -* @retval None -*/ -void Lps331apSetDataRate(LPSOutputDataRate xDataRate) -{ - uint8_t tempReg; - - /* Read the register content */ - Lps331apByteRead(&tempReg, LPS_CTRL_REG1_ADDR); - - /* CTRL1 register */ - tempReg &= 0x8F; - tempReg |= xDataRate; - - /*Enter Power Down mode*/ - Lps331apEnterShutdownCmd(); - - /* Write computed byte onto register */ - Lps331apByteWrite(&tempReg, LPS_CTRL_REG1_ADDR); - - /*Exit from Power down mode*/ - Lps331apExitShutdownCmd(); -} - - -/** -* @brief Returns the output data rate. -* @param None. -* @retval Datarate in Hz. -* This parameter is a @ref LPSOutputDataRate. -*/ -LPSOutputDataRate Lps331apGetDataRate(void) -{ - uint8_t tmpReg; - - /* Read the register content */ - Lps331apByteRead(&tmpReg, LPS_CTRL_REG1_ADDR); - - /* ..mask it */ - tmpReg &= 0x70; - - /* return the correspondent value */ - return ((LPSOutputDataRate)tmpReg); -} - - - -/** -* @brief Reboot memory content of LPS331AP. -* @param None -* @retval None -*/ -void Lps331apRebootCmd(void) -{ - uint8_t tmpReg; - - /* Read the register content */ - Lps331apByteRead(&tmpReg, LPS_CTRL_REG2_ADDR); - - /* Set the BOOT bit */ - tmpReg |= 0x80; - - /* Write register */ - Lps331apByteWrite(&tmpReg, LPS_CTRL_REG2_ADDR); - -} - - - -/** -* @brief Enter the shutdown mode for LPS331AP. -* @param None -* @retval None -*/ -void Lps331apEnterShutdownCmd(void) -{ - uint8_t tmpReg; - - /* Read the register content */ - Lps331apByteRead(&tmpReg, LPS_CTRL_REG1_ADDR); - - /* Reset the power down bit */ - tmpReg &= 0x7F; - - /* Write register */ - Lps331apByteWrite(&tmpReg, LPS_CTRL_REG1_ADDR); - -} - - -/** -* @brief Exit the shutdown mode for LPS331AP. -* @param None -* @retval None -*/ -void Lps331apExitShutdownCmd(void) -{ - uint8_t tmpReg; - - /* Read the register content */ - Lps331apByteRead(&tmpReg, LPS_CTRL_REG1_ADDR); - - /* Set the power down bit */ - tmpReg |= 0x80; - - /* Write register */ - Lps331apByteWrite(&tmpReg, LPS_CTRL_REG1_ADDR); - -} - -/** -* @brief Read LPS331AP output register, and calculate the raw pressure. -* @param None. -* @retval int32_t: pressure raw value. -*/ -int32_t Lps331apReadRawPressure(void) -{ - uint8_t buffer[3]; - uint32_t tempVal=0; - - /* Read the register content */ - Lps331apBufferRead(buffer, LPS_PRESS_POUT_XL_ADDR, 3); - - /* Build the raw data */ - uint8_t i; - for(i=0; i<3; i++) - tempVal |= (((uint32_t)buffer[i]) << (8*i)); - - /* convert the 2's complement 24 bit to 2's complement 32 bit */ - if(tempVal & 0x00800000) - tempVal |= 0xFF000000; - - /* return the built value */ - return ((int32_t)tempVal); - -} - - -/** -* @brief Read LPS331AP output register, and calculate the raw temperature. -* @param None. -* @retval int16_t: temperature raw value. -*/ -int16_t Lps331apReadRawTemperature(void) -{ - uint8_t buffer[2]; - uint16_t tempVal=0; - - /* Read the register content */ - Lps331apBufferRead(buffer, LPS_TEMP_OUT_L_ADDR, 2); - - /* Build the raw value */ - tempVal = (((uint16_t)buffer[1]) << 8)+(uint16_t)buffer[0]; - - /* Return it */ - return ((int16_t)tempVal); - -} - - -/** -* @brief Configures the LPS331AP IRQ outout pins. -* @param pxLPSIrqInit: pointer to the LPSIrqInit structure that defines the IRQ parameters. -* @retval None. -* @details -* Example: -* @code -* LPSIrqInit xLps331apIrqInit; -* -* xLps331apIrqInit.xIrqActiveLow = LPS_DISABLE; -* xLps331apIrqInit.xOutType = LPS_PP; -* xLps331apIrqInit.xInt1List = LPS_DATA_READY; -* xLps331apIrqInit.xInt2List = LPS_P_LOW_HIGH; -* xLps331apIrqInit.fPressThr = 1006.2; -* xLps331apIrqInit.xIrqPressLow=LPS_ENABLE; -* xLps331apIrqInit.xIrqPressHigh=LPS_ENABLE; -* -* ExtiConfiguration(); // set the micro exti before init -* Lps331apIrqInit(&xLps331apIrqInit); -* @endcode -*/ -void Lps331apIrqInit(LPSIrqInit* pxLPSIrqInit) -{ - uint8_t tempReg[2]; - - /* From the structure build the value to write on CTRL3 reg */ - tempReg[0] = (((uint8_t)(pxLPSIrqInit->xIrqActiveLow))<<7) | ((uint8_t)(pxLPSIrqInit->xOutType)) | ((uint8_t)(pxLPSIrqInit->xInt2List)<<3) | ((uint8_t)(pxLPSIrqInit->xInt1List)); - - /* Read the register content */ - Lps331apByteWrite(tempReg, LPS_CTRL_REG3_ADDR); - - /* Build the threshold register values */ - tempReg[0]=(uint8_t)(16.0*pxLPSIrqInit->fPressThr); - tempReg[1]=(uint8_t)(((uint16_t)(16.0*pxLPSIrqInit->fPressThr))>>8); - - /* Read the registers content */ - Lps331apBufferWrite(tempReg, LPS_THS_P_LOW_REG_ADDR, 2); - - Lps331apByteRead(tempReg, LPS_INT_CFG_REG_ADDR); - - /* Enable or disable the high pressure interrupt */ - if(pxLPSIrqInit->xIrqPressHigh) - tempReg[0] |= 0x01; - else - tempReg[0] &= 0xFE; - - /* Enable or disable the low pressure interrupt */ - if(pxLPSIrqInit->xIrqPressLow) - tempReg[0] |= 0x02; - else - tempReg[0] &= 0xFD; - - tempReg[0]|=0x04; - - /* Write the register or disable the high pressure interrupt */ - Lps331apByteWrite(tempReg, LPS_INT_CFG_REG_ADDR); - - /* if one has been requested then enable the differential circuit */ - Lps331apByteRead(tempReg, LPS_CTRL_REG1_ADDR); - if(pxLPSIrqInit->xIrqPressHigh || pxLPSIrqInit->xIrqPressLow) - { - tempReg[0] |= 0x08; - } - else - /* else disable it */ - { - tempReg[0] &= 0xF7; - } - Lps331apByteWrite(tempReg, LPS_CTRL_REG1_ADDR); - -} - - - -/** -* @brief Sets the one-shot bit in order to start acquisition when the ONE SHOT mode has been selected by the ODR configuration. -* @param None. -* @retval None. -*/ -void Lps331apOneShot(void) -{ - uint8_t tempReg; - - /* Read the CTRL2 register */ - Lps331apByteRead(&tempReg, LPS_CTRL_REG2_ADDR); - - /* Set the one shot bit */ - tempReg |= 0x01; - - /* Write the CTRL2 register */ - Lps331apByteWrite(&tempReg, LPS_CTRL_REG2_ADDR); - -} - - -/** -* @brief Gets status for LPS331AP data. -* @param None. -* @retval LPS331DataStatus: Data status in a LPS331DataStatus bitfields structure. -*/ -LPS331DataStatus Lps331apGetDataStatus(void) -{ - uint8_t tempReg; - - /* Read the status register */ - Lps331apByteRead(&tempReg, LPS_STATUS_REG_ADDR); - - /* cast and return it */ - return(*(LPS331DataStatus*)&tempReg); - -} - - -/** -* @brief Sets the pressure threshold. -* @param fThreshold: Threshold expressed in mbar. -* This parameter is a float value. -* @retval None. -*/ -void Lps331apSetThreshold(float fThreshold) -{ - uint8_t tempReg[2]; - - /* Build the threshold register values */ - tempReg[0]=(uint8_t)(16.0*fThreshold); - tempReg[1]=(uint8_t)(((uint16_t)(16.0*fThreshold))>>8); - - /* write the register content */ - Lps331apBufferWrite(tempReg, LPS_THS_P_LOW_REG_ADDR, 2); - -} - - -/** -* @brief Gets the pressure threshold. -* @param None. -* @retval float: threshold value expressed in mbar. -*/ -float Lps331apGetThreshold(void) -{ - uint8_t tempReg[2]; - - /* read the register content */ - Lps331apBufferRead(tempReg, LPS_THS_P_LOW_REG_ADDR, 2); - - /* return the float value */ - return ((float)((((uint16_t)tempReg[1])<<8) + tempReg[0])/16); - -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/ -- 2.30.2