Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HC_SR04_Ultrasonic_Library Servo mbed
Fork of FIP_REV1 by
x_nucleo_iks01a1_pressure.c
00001 /** 00002 ****************************************************************************** 00003 * @file x_nucleo_iks01a1_pressure.c 00004 * @author MEMS Application Team 00005 * @version V1.0.0 00006 * @date 30-July-2014 00007 * @brief This file provides a set of functions needed to manage the lps25h sensor. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 /* Includes ------------------------------------------------------------------*/ 00038 #include "x_nucleo_iks01a1_pressure.h" 00039 00040 /** @addtogroup BSP 00041 * @{ 00042 */ 00043 00044 /** @addtogroup X_NUCLEO_IKS01A1 00045 * @{ 00046 */ 00047 00048 /** @addtogroup X_NUCLEO_IKS01A1_PRESSURE 00049 * @{ 00050 */ 00051 00052 00053 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_TypesDefinitions 00054 * @{ 00055 */ 00056 00057 /** 00058 * @} 00059 */ 00060 00061 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_Defines 00062 * @{ 00063 */ 00064 #ifndef NULL 00065 #define NULL (void *) 0 00066 #endif 00067 /** 00068 * @} 00069 */ 00070 00071 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_Macros 00072 * @{ 00073 */ 00074 00075 /** 00076 * @} 00077 */ 00078 00079 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_Variables 00080 * @{ 00081 */ 00082 static PRESSURE_DrvTypeDef *PressureDrv; 00083 static uint8_t PressureInitialized = 0; 00084 00085 /** 00086 * @} 00087 */ 00088 00089 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_FunctionPrototypes 00090 * @{ 00091 */ 00092 00093 /** 00094 * @} 00095 */ 00096 00097 /** @defgroup X_NUCLEO_IKS01A1_PRESSURE_Private_Functions 00098 * @{ 00099 */ 00100 00101 /** 00102 * @brief Initialization pressure sensor. 00103 * @param None 00104 * @retval PRESSURE_OK if no problem during initialization 00105 */ 00106 PRESSURE_StatusTypeDef BSP_PRESSURE_Init(void) 00107 { 00108 PRESSURE_StatusTypeDef ret = PRESSURE_ERROR; 00109 PRESSURE_InitTypeDef LPS25H_InitStructure; 00110 00111 // LPS25H_SlaveAddrRemap(LPS25H_SA0_HIGH); 00112 00113 /* Initialize the uv driver structure */ 00114 PressureDrv = &LPS25HDrv; 00115 00116 /* Configure sensor */ 00117 LPS25H_InitStructure.OutputDataRate = LPS25H_ODR_1Hz; 00118 LPS25H_InitStructure.BlockDataUpdate = LPS25H_BDU_CONT; 00119 LPS25H_InitStructure.DiffEnable = LPS25H_DIFF_ENABLE; 00120 LPS25H_InitStructure.SPIMode = LPS25H_SPI_SIM_3W; 00121 LPS25H_InitStructure.PressureResolution = LPS25H_P_RES_AVG_32; 00122 LPS25H_InitStructure.TemperatureResolution = LPS25H_T_RES_AVG_16; 00123 00124 /* Pressure sensor init */ 00125 PressureDrv->Init(&LPS25H_InitStructure); 00126 00127 if(PressureDrv->ReadID() == I_AM_LPS25H) 00128 { 00129 PressureInitialized = 1; 00130 ret = PRESSURE_OK; 00131 } 00132 00133 return ret; 00134 } 00135 00136 uint8_t BSP_PRESSURE_isInitialized(void) 00137 { 00138 return PressureInitialized; 00139 } 00140 00141 /** 00142 * @brief Read ID of Uv component 00143 * @param None 00144 * @retval ID 00145 */ 00146 uint8_t BSP_PRESSURE_ReadID(void) 00147 { 00148 uint8_t id = 0x00; 00149 00150 if(PressureDrv->ReadID != NULL) 00151 { 00152 id = PressureDrv->ReadID(); 00153 } 00154 return id; 00155 } 00156 00157 00158 /** 00159 * @brief Check ID of LPS25H Pressure sensor 00160 * @param None 00161 * @retval Test status 00162 */ 00163 PRESSURE_StatusTypeDef BSP_PRESSURE_CheckID(void) { 00164 if (BSP_PRESSURE_ReadID() == I_AM_LPS25H) { 00165 return PRESSURE_OK; 00166 } else { 00167 return PRESSURE_ERROR; 00168 } 00169 } 00170 00171 00172 /** 00173 * @brief Reboot memory content of LPS25H Pressure sensor 00174 * @param None 00175 * @retval None 00176 */ 00177 void BSP_PRESSURE_Reset(void) 00178 { 00179 if(PressureDrv->Reset != NULL) 00180 { 00181 PressureDrv->Reset(); 00182 } 00183 } 00184 00185 00186 /** 00187 * @brief Get Pressure 00188 * @param pfData: pointer on floating data 00189 * @retval None 00190 */ 00191 void BSP_PRESSURE_GetPressure(float* pfData) 00192 { 00193 if(PressureDrv->GetPressure!= NULL) 00194 { 00195 PressureDrv->GetPressure(pfData); 00196 } 00197 } 00198 00199 /** 00200 * @brief Get Temperature 00201 * @param pfData: pointer on floating data 00202 * @retval None 00203 */ 00204 void BSP_PRESSURE_GetTemperature(float* pfData) 00205 { 00206 if(PressureDrv->GetTemperature!= NULL) 00207 { 00208 PressureDrv->GetTemperature(pfData); 00209 } 00210 } 00211 00212 /** 00213 * @} 00214 */ 00215 00216 /** 00217 * @} 00218 */ 00219 00220 /** 00221 * @} 00222 */ 00223 00224 /** 00225 * @} 00226 */ 00227 00228 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00229
Generated on Tue Jul 12 2022 21:42:00 by
