Environmental Shield API
Revision 0:9e645e6ed2ce, committed 2014-08-19
- Comitter:
- Deepti
- Date:
- Tue Aug 19 07:13:15 2014 +0000
- Commit message:
- Environment Shield API
Changed in this revision
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/Common/hum_temp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/Common/hum_temp.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,102 @@ +/** + ****************************************************************************** + * @file hum_temp.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 08-April-2014 + * @brief This header file contains the functions prototypes for the humidity and temperature driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __HUM_TEMP_H +#define __HUM_TEMP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include <stdint.h> + +typedef struct +{ + uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */ + uint8_t Data_Update_Mode; /* continuous update/output registers not updated until MSB and LSB reading*/ + uint8_t Reboot_Mode; /* Normal Mode/Reboot memory content */ + uint8_t Humidity_Resolutin; /* Humidity Resolution */ + uint8_t Temperature_Resolution; /* Temperature Resolution */ + uint8_t OutputDataRate; /* One-shot / 1Hz / 7 Hz / 12.5 Hz */ +}HUM_TEMP_InitTypeDef; + +/** + * @brief Humidity and temperature driver structure definition + */ +typedef struct +{ + void (*Init)(HUM_TEMP_InitTypeDef *); + void (*PowerOFF)(void); + uint8_t (*ReadID)(void); + void (*Reset)(void); + void (*ConfigIT)(uint16_t); + void (*EnableIT)(uint8_t); + void (*DisableIT)(uint8_t); +// uint8_t (*ITStatus)(uint16_t, uint16_t); +// void (*ClearIT)(uint16_t, uint16_t); + void (*GetHumidity)(float *); + void (*GetTemperature)(float *); +}HUM_TEMP_DrvTypeDef; + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __HUM_TEMP_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/Common/pressure.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/Common/pressure.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,100 @@ +/** + ****************************************************************************** + * @file pressure.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 06-March-2014 + * @brief This header file contains the functions prototypes for the pressure driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __PRESSURE_H +#define __PRESSURE_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* Includes ------------------------------------------------------------------*/ +#include <stdint.h> + + typedef struct + { + uint8_t OutputDataRate; + uint8_t PressureResolution; + uint8_t TemperatureResolution; + uint8_t DiffEnable; + uint8_t BlockDataUpdate; + uint8_t SPIMode; + }PRESSURE_InitTypeDef; + + + /** + * @brief PRESSURE driver structure definition + */ + typedef struct + { + void (*Init)(PRESSURE_InitTypeDef *); + void (*PowerOff)(void); + uint8_t (*ReadID)(void); + void (*Reset)(void); + void (*ConfigIT)(uint16_t); + void (*EnableIT)(uint8_t); + void (*DisableIT)(uint8_t); + uint8_t (*ITStatus)(uint16_t, uint16_t); + void (*ClearIT)(uint16_t, uint16_t); + void (*GetPressure)(float *); + void (*GetTemperature)(float *); + void (*SlaveAddrRemap)(uint8_t); + }PRESSURE_DrvTypeDef; + + +#ifdef __cplusplus +} +#endif + +#endif /* __PRESSURE_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/Common/uv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/Common/uv.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,98 @@ +/** + ****************************************************************************** + * @file UV.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 06-March-2014 + * @brief This header file contains the functions prototypes for the uv driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __UV_H +#define __UV_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include <stdint.h> + +typedef struct +{ + uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */ + uint8_t Output_DataRate; /* OUT data rate */ + //uint8_t Reboot_Mode; /* Normal Mode/Reboot memory content */ + //uint8_t DifferentialThreshold; /* Differential Threshold */ +}UV_InitTypeDef; + +/** + * @brief UV driver structure definition + */ +typedef struct +{ + void (*Init)(UV_InitTypeDef *); + uint8_t (*ReadID)(void); + void (*Reset)(void); + void (*ConfigIT)(uint16_t); + void (*EnableIT)(uint8_t); + void (*DisableIT)(uint8_t); + uint8_t (*ITStatus)(uint16_t, uint16_t); + void (*ClearIT)(uint16_t, uint16_t); + void (*GetIndex)(float *); +}UV_DrvTypeDef; + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UV_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/hts221/hts221.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/hts221/hts221.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,420 @@ +/** + ****************************************************************************** + * @file hts221.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 08-April-2014 + * @brief This file provides a set of functions needed to manage the hts221. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "hts221.h" +#include <math.h> + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup STM32F439_SENSITRON + * @{ + */ + +/** @addtogroup HTS221 + * @{ + */ + + +/** @defgroup HTS221_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup HTS221_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup HTS221_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup HTS221_Private_Variables + * @{ + */ + +HUM_TEMP_DrvTypeDef Hts221Drv = +{ + HTS221_Init, + HTS221_Power_OFF, + HTS221_ReadID, + HTS221_RebootCmd, + HTS221_INT1InterruptConfig, + HTS221_EnableIT, + HTS221_DisableIT, + HTS221_GetHumidity, + HTS221_GetTemperature +}; + + +/* Temperature in degree for calibration */ +float T0_degC, T1_degC; + +/* Output temperature value for calibration */ +int16_t T0_out, T1_out; + + +/* Humidity for calibration */ +float H0_rh, H1_rh; + +/* Output Humidity value for calibration */ +int16_t H0_T0_out, H1_T0_out; + + +/** + * @} + */ + +/** @defgroup HTS221_Private_FunctionPrototypes + * @{ + */ +static void HTS221_Power_On(void); + +static void HTS221_Calibration(void); +/** + * @} + */ + +/** @defgroup HTS221_Private_Functions + * @{ + */ + + + +/** + * @brief HTS221 Calibration procedure. + * @param None + * @retval None + */ +static void HTS221_Calibration(void) +{ + /* Temperature Calibration */ + /* Temperature in degree for calibration ( "/8" to obtain float) */ + uint16_t T0_degC_x8_L, T0_degC_x8_H, T1_degC_x8_L, T1_degC_x8_H; + uint8_t H0_rh_x2, H1_rh_x2; + uint8_t tempReg[2] = {0,0}; + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T0_degC_X8_ADDR, 1); + T0_degC_x8_L = (uint16_t)tempReg[0]; + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T1_T0_MSB_X8_ADDR, 1); + T0_degC_x8_H = (uint16_t) (tempReg[0] & 0x03); + + T0_degC = ((float)((T0_degC_x8_H<<8) | (T0_degC_x8_L)))/8; + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T1_degC_X8_ADDR, 1); + T1_degC_x8_L = (uint16_t)tempReg[0]; + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T1_T0_MSB_X8_ADDR, 1); + T1_degC_x8_H = (uint16_t) (tempReg[0] & 0x0C); + T1_degC_x8_H = T1_degC_x8_H >> 2; + + T1_degC = ((float)((T1_degC_x8_H<<8) | (T1_degC_x8_L)))/8; + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T0_OUT_L_ADDR + 0x80, 2); + T0_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + HUM_TEMP_IO_Read(tempReg, HTS221_ADDRESS, HTS221_T1_OUT_L_ADDR + 0x80, 2); + T1_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + /* Humidity Calibration */ + /* Humidity in degree for calibration ( "/2" to obtain float) */ + + HUM_TEMP_IO_Read(&H0_rh_x2, HTS221_ADDRESS, HTS221_H0_RH_X2_ADDR, 1); + + HUM_TEMP_IO_Read(&H1_rh_x2, HTS221_ADDRESS, HTS221_H1_RH_X2_ADDR, 1); + + HUM_TEMP_IO_Read(&tempReg[0], HTS221_ADDRESS, HTS221_H0_T0_OUT_L_ADDR + 0x80, 2); + H0_T0_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + HUM_TEMP_IO_Read(&tempReg[0], HTS221_ADDRESS, HTS221_H1_T0_OUT_L_ADDR + 0x80, 2); + H1_T0_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + H0_rh = ((float)H0_rh_x2)/2; + H1_rh = ((float)H1_rh_x2)/2; +} + + +/** + * @brief Set HTS221 Initialization. + * @param InitStruct: it contains the configuration setting for the HTS221. + * @retval None + */ +void HTS221_Init(HUM_TEMP_InitTypeDef *HTS221_Init) +{ + uint8_t tmp = 0x00; + + /* Configure the low level interface ---------------------------------------*/ + HUM_TEMP_IO_Init(); + + HTS221_Power_On(); + + HTS221_Calibration(); + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); + + /* Output Data Rate selection */ + tmp &= ~(HTS221_ODR_MASK); + tmp |= HTS221_Init->OutputDataRate; + + HUM_TEMP_IO_Write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); +} + +/** + * @brief Read ID address of HTS221 + * @param Device ID address + * @retval ID name + */ +uint8_t HTS221_ReadID(void) +{ + uint8_t tmp; + + /* Read WHO I AM register */ + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_WHO_AM_I_ADDR, 1); + + /* Return the ID */ + return (uint8_t)tmp; +} + +/** + * @brief Reboot memory content of HTS221 + * @param None + * @retval None + */ +void HTS221_RebootCmd(void) +{ + uint8_t tmpreg; + + /* Read CTRL_REG2 register */ + HUM_TEMP_IO_Read(&tmpreg, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); + + /* Enable or Disable the reboot memory */ + tmpreg |= HTS221_BOOT_REBOOTMEMORY; + + /* Write value to MEMS CTRL_REG2 regsister */ + HUM_TEMP_IO_Write(&tmpreg, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Set HTS221 Interrupt INT1 configuration + * @param HTS221_InterruptConfig_TypeDef: pointer to a HTS221_InterruptConfig_TypeDef + * structure that contains the configuration setting for the HTS221 Interrupt. + * @retval None + */ +void HTS221_INT1InterruptConfig(uint16_t Int1Config) +{ + +} + +/** + * @brief Enable INT1 + * @retval None + */ +void HTS221_EnableIT(uint8_t IntPin) +{ + +} + +/** + * @brief Disable INT1 + * @retval None + */ +void HTS221_DisableIT(uint8_t IntPin) +{ + +} + + +/** + * @brief Read HTS221 output register, and calculate the humidity. + * @param pfData : Data out pointer + * @retval None + */ +void HTS221_GetHumidity(float* pfData) +{ + int16_t H_T_out, humidity_t; + uint8_t tempReg[2] = {0,0}; + uint8_t tmp = 0x00; + float H_rh; + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); + + /* Output Data Rate selection */ + tmp &= (HTS221_ODR_MASK); + + if(tmp == 0x00){ + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); + + /* Serial Interface Mode selection */ + tmp &= ~(HTS221_ONE_SHOT_MASK); + tmp |= HTS221_ONE_SHOT_START; + + HUM_TEMP_IO_Write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); + + do{ + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1); + + }while(!(tmp&&0x02)); + + } + + + HUM_TEMP_IO_Read(&tempReg[0], HTS221_ADDRESS, HTS221_HUMIDITY_OUT_L_ADDR + 0x80, 2); + H_T_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + H_rh = ((float)(H_T_out - H0_T0_out))/(H1_T0_out - H0_T0_out) * (H1_rh - H0_rh) + H0_rh; + + humidity_t = (uint16_t)(H_rh * pow(10,HUM_DECIMAL_DIGITS)); + + *pfData = ((float)humidity_t)/pow(10,HUM_DECIMAL_DIGITS); +} + +/** + * @brief Read HTS221 output register, and calculate the temperature. + * @param pfData : Data out pointer + * @retval None + */ +void HTS221_GetTemperature(float* pfData) +{ + int16_t T_out, temperature_t; + uint8_t tempReg[2] = {0,0}; + uint8_t tmp = 0x00; + float T_degC; + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); + + /* Output Data Rate selection */ + tmp &= (HTS221_ODR_MASK); + + if(tmp == 0x00){ + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); + + /* Serial Interface Mode selection */ + tmp &= ~(HTS221_ONE_SHOT_MASK); + tmp |= HTS221_ONE_SHOT_START; + + HUM_TEMP_IO_Write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1); + + do{ + + HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1); + + }while(!(tmp&&0x01)); + + } + + HUM_TEMP_IO_Read(&tempReg[0], HTS221_ADDRESS, HTS221_TEMP_OUT_L_ADDR + 0x80, 2); + T_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]); + + T_degC = ((float)(T_out - T0_out))/(T1_out - T0_out) * (T1_degC - T0_degC) + T0_degC; + + temperature_t = (int16_t)(T_degC * pow(10,TEMP_DECIMAL_DIGITS)); + + *pfData = ((float)temperature_t)/pow(10,TEMP_DECIMAL_DIGITS); +} + + +/** + * @brief Exit the shutdown mode for HTS221. + * @retval None + */ +static void HTS221_Power_On() +{ + uint8_t tmpReg; + + /* Read the register content */ + HUM_TEMP_IO_Read(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); + + /* Set the power down bit */ + tmpReg |= HTS221_MODE_ACTIVE; + + /* Write register */ + HUM_TEMP_IO_Write(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); +} + +/** + * @brief Enter the shutdown mode for HTS221. + * @retval None + */ +void HTS221_Power_OFF() +{ + uint8_t tmpReg; + + /* Read the register content */ + HUM_TEMP_IO_Read(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); + + /* Reset the power down bit */ + tmpReg &= ~(HTS221_MODE_ACTIVE); + + /* Write register */ + HUM_TEMP_IO_Write(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/hts221/hts221.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/hts221/hts221.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,586 @@ +/** + ****************************************************************************** + * @file hts221.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 08-April-2014 + * @brief This file contains definitions hts221.h + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __HTS221_H +#define __HTS221_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "../Common/hum_temp.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup HTS221 + * @{ + */ + +/** @defgroup HTS221_Exported_Constants + * @{ + */ + +/** + * @brief Device Address + */ +#define HTS221_ADDRESS 0xBE + +/******************************************************************************/ +/*************************** START REGISTER MAPPING **************************/ +/******************************************************************************/ + + +/** + * @brief Device identification register. + * \code + * Read + * Default value: 0xBC + * 7:0 This read-only register contains the device identifier that, for HTS221, is set to BCh. + * \endcode +*/ +#define HTS221_WHO_AM_I_ADDR 0x0F + + + /** + * @brief Humidity resolution Register + * \code + * Read/write + * Default value: 0x1B + * 7:6 RFU + * 5:3 AVGT2-AVGT0: Temperature internal average. + * AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average + * ------------------------------------------------------ + * 0 | 0 | 0 | 2 + * 0 | 0 | 1 | 4 + * 0 | 1 | 0 | 8 + * 0 | 1 | 1 | 16 + * 1 | 0 | 0 | 32 + * 1 | 0 | 1 | 64 + * 1 | 1 | 0 | 128 + * 1 | 1 | 1 | 256 + * + * 2:0 AVGH2-AVGH0: Humidity internal average. + * AVGH2 | AVGH1 | AVGH0 | Nr. Internal Average + * ------------------------------------------------------ + * 0 | 0 | 0 | 4 + * 0 | 0 | 1 | 8 + * 0 | 1 | 0 | 16 + * 0 | 1 | 1 | 32 + * 1 | 0 | 0 | 64 + * 1 | 0 | 1 | 128 + * 1 | 1 | 0 | 256 + * 1 | 1 | 1 | 512 + * + * \endcode + */ +#define HTS221_RES_CONF_ADDR 0x10 + + + /** + * @brief INFO Register (LSB data) + * \code + * Read/write + * Default value: 0x00 + * 7:0 INFO7-INFO0: Lower part of the INFO reference + * used for traceability of the sample. + * \endcode + */ +#define HTS221_INFO_L_ADDR 0x1E + + + /** + * @brief INFO & Calibration Version Register (LSB data) + * \code + * Read/write + * Default value: 0x00 + * 7:6 CALVER1:CALVER0 + * 5:0 INFO13-INFO8: Higher part of the INFO reference + * used for traceability of the sample. + * \endcode + */ +#define HTS221_INFO_H_ADDR 0x1F + + + /** + * @brief Humidity sensor control register 1 + * \code + * Read/write + * Default value: 0x00 + * 7 PD: power down control. 0 - disable; 1 - enable + * 6:3 RFU + * 2 BDU: block data update. 0 - disable; 1 - enable + * 1:0 RFU + * \endcode + */ + +#define HTS221_CTRL_REG1_ADDR 0x20 + + + /** + * @brief Humidity 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 Reserved. + * 1 Reserved. + * 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset + * \endcode + */ +#define HTS221_CTRL_REG2_ADDR 0x21 + + + /** + * @brief Status Register + * \code + * Read + * Default value: 0x00 + * 7:2 RFU + * 1 H_DA: Humidity data available. 0: new data for Humidity is not yet available; 1: new data for Humidity 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 HTS221_STATUS_REG_ADDR 0x27 + + + /** + * @brief Humidity data (LSB). + * \code + * Read + * Default value: 0x00. + * POUT7 - POUT0: Humidity data LSB (2's complement) => signed 16 bits + * RAW Humidity output data: Hout(%)=(HUMIDITY_OUT_H & HUMIDITY_OUT_L). + * \endcode + */ +#define HTS221_HUMIDITY_OUT_L_ADDR 0x28 + + + /** + * @brief Humidity data (MSB). + * \code + * Read + * Default value: 0x00. + * POUT7 - POUT0: Humidity data LSB (2's complement) => signed 16 bits + * RAW Humidity output data: Hout(%)=(HUMIDITY_OUT_H & HUMIDITY_OUT_L). + * \endcode + */ +#define HTS221_HUMIDITY_OUT_H_ADDR 0x29 + + + /** + * @brief Temperature data (LSB). + * \code + * Read + * Default value: 0x00. + * TOUT7 - TOUT0: temperature data LSB (2's complement) => signed 16 bits + * RAW Temperature output data: Tout (LSB)=(TEMP_OUT_H & TEMP_OUT_L). + * \endcode + */ +#define HTS221_TEMP_OUT_L_ADDR 0x2A + + + /** + * @brief Temperature data (MSB). + * \code + * Read + * Default value: 0x00. + * TOUT15 - TOUT8: temperature data MSB (2's complement) => signed 16 bits + * RAW Temperature output data: Tout (LSB)=(TEMP_OUT_H & TEMP_OUT_L). + * \endcode + */ +#define HTS221_TEMP_OUT_H_ADDR 0x2B + + + /* + *@brief Humidity 0 Register in %RH with sensitivity=2 + *\code + * Read + * Value: (Unsigned 8 Bit)/2 + *\endcode + */ +#define HTS221_H0_RH_X2_ADDR 0x30 + + + /* + *@brief Humidity 1 Register in %RH with sensitivity=2 + *\code + * Read + * Value: (Unsigned 8 Bit)/2 + *\endcode + */ +#define HTS221_H1_RH_X2_ADDR 0x31 + + + /* + *@brief Temperature 0 Register in deg with sensitivity=8 + *\code + * Read + * Value: (Unsigned 16 Bit)/2 + *\endcode + */ +#define HTS221_T0_degC_X8_ADDR 0x32 + + + /* + *@brief Temperature 1 Register in deg with sensitivity=8 + *\code + * Read + * Value: (Unsigned 16 Bit)/2 + *\endcode + */ +#define HTS221_T1_degC_X8_ADDR 0x33 + + + /* + *@brief Temperature 1/0 MSB Register in deg with sensitivity=8 + *\code + * Read + * Value: (Unsigned 16 Bit)/2 + * 3:2 T1(9):T1(8) MSB T1_degC_X8 bits + * 1:0 T0(9):T0(8) MSB T0_degC_X8 bits + *\endcode + */ +#define HTS221_T1_T0_MSB_X8_ADDR 0x35 + + + /* + *@brief Humidity LOW CALIBRATION Register + *\code + * Read + * Default value: 0x00. + * H0_T0_TOUT7 - H0_T0_TOUT0: HUMIDITY data lSB (2's complement) => signed 16 bits + *\endcode + */ +#define HTS221_H0_T0_OUT_L_ADDR 0x36 + + + /* + *@brief Humidity LOW CALIBRATION Register + *\code + * Read + * Default value: 0x00. + * H0_T0_TOUT15 - H0_T0_TOUT8: HUMIDITY data mSB (2's complement) => signed 16 bits + *\endcode + */ +#define HTS221_H0_T0_OUT_H_ADDR 0x37 + + + /* + *@brief Humidity HIGH CALIBRATION Register + *\code + * Read + * Default value: 0x00. + * H1_T0_TOUT7 - H1_T0_TOUT0: HUMIDITY data lSB (2's complement) => signed 16 bits + *\endcode + */ +#define HTS221_H1_T0_OUT_L_ADDR 0x3A + + + /* + *@brief Humidity HIGH CALIBRATION Register + *\code + * Read + * Default value: 0x00. + * H1_T0_TOUT15 - H1_T0_TOUT8: HUMIDITY data mSB (2's complement) => signed 16 bits + *\endcode + */ +#define HTS221_H1_T0_OUT_H_ADDR 0x3B + + + /** + * @brief Low Calibration Temperature Register (LSB). + * \code + * Read + * Default value: 0x00. + * T0_OUT7 - T0_OUT0: temperature data LSB (2's complement) => signed 16 bits + * RAW LOW Calibration data: T0_OUT (LSB)=(T0_OUT_H & T0_OUT_L). + * \endcode + */ +#define HTS221_T0_OUT_L_ADDR 0x3C + + + /** + * @brief Low Calibration Temperature Register (MSB) + * \code + * Read + * Default value: 0x00. + * T0_OUT15 - T0_OUT8: temperature data MSB (2's complement) => signed 16 bits + * RAW LOW Calibration data: T0_OUT (LSB)=(T0_OUT_H & T0_OUT_L). + * \endcode + */ +#define HTS221_T0_OUT_H_ADDR 0x3D + + + /** + * @brief Low Calibration Temperature Register (LSB). + * \code + * Read + * Default value: 0x00. + * T1_OUT7 - T1_OUT0: temperature data LSB (2's complement) => signed 16 bits + * RAW LOW Calibration data: T1_OUT (LSB)=(T1_OUT_H & T1_OUT_L). + * \endcode + */ +#define HTS221_T1_OUT_L_ADDR 0x3E + + + /** + * @brief Low Calibration Temperature Register (MSB) + * \code + * Read + * Default value: 0x00. + * T1_OUT15 - T1_OUT8: temperature data MSB (2's complement) => signed 16 bits + * RAW LOW Calibration data: T1_OUT (LSB)=(T1_OUT_H & T1_OUT_L). + * \endcode + */ +#define HTS221_T1_OUT_H_ADDR 0x3F + + +/******************************************************************************/ +/**************************** END REGISTER MAPPING ***************************/ +/******************************************************************************/ + + +/** + * @brief Device Identifier. Default value of the WHO_AM_I register. + */ +#define I_AM_HTS221 ((uint8_t)0xBC) + + +/** @defgroup HTS221 Power Mode selection - CTRL_REG1 + * @{ + */ +#define HTS221_MODE_POWERDOWN ((uint8_t)0x00) +#define HTS221_MODE_ACTIVE ((uint8_t)0x80) + +#define HTS221_MODE_MASK ((uint8_t)0x80) +/** + * @} + */ + + +/** @defgroup HTS221 Block Data Update Mode selection - CTRL_REG1 + * @{ + */ +#define HTS221_BDU_CONTINUOUS ((uint8_t)0x00) +#define HTS221_BDU_NOT_UNTIL_READING ((uint8_t)0x04) + +#define HTS221_BDU_MASK ((uint8_t)0x04) +/** + * @} + */ + +/** @defgroup HTS221 Output Data Rate selection - CTRL_REG1 + * @{ + */ +#define HTS221_ODR_ONE_SHOT ((uint8_t)0x00) /*!< Output Data Rate: H - one shot, T - one shot */ +#define HTS221_ODR_1Hz ((uint8_t)0x01) /*!< Output Data Rate: H - 1Hz, T - 1Hz */ +#define HTS221_ODR_7Hz ((uint8_t)0x02) /*!< Output Data Rate: H - 7Hz, T - 7Hz */ +#define HTS221_ODR_12_5Hz ((uint8_t)0x03) /*!< Output Data Rate: H - 12.5Hz, T - 12.5Hz */ + +#define HTS221_ODR_MASK ((uint8_t)0x03) +/** +* @} +*/ + + +/** @defgroup HTS221 Boot Mode selection - CTRL_REG2 + * @{ + */ +#define HTS221_BOOT_NORMALMODE ((uint8_t)0x00) +#define HTS221_BOOT_REBOOTMEMORY ((uint8_t)0x80) + +#define HTS221_BOOT_MASK ((uint8_t)0x80) +/** + * @} + */ + + +/** @defgroup HTS221 One Shot selection - CTRL_REG2 + * @{ + */ +#define HTS221_ONE_SHOT_START ((uint8_t)0x01) + +#define HTS221_ONE_SHOT_MASK ((uint8_t)0x01) +/** + * @} + */ + + +/** @defgroup HTS221 Boot Mode selection - CTRL_REG2 + * @{ + */ +#define HTS221_BOOT_NORMALMODE ((uint8_t)0x00) +#define HTS221_BOOT_REBOOTMEMORY ((uint8_t)0x80) + +#define HTS221_BOOT_MASK ((uint8_t)0x80) +/** + * @} + */ + + +/** @defgroup HTS221 PushPull_OpenDrain selection - CTRL_REG3 + * @{ + */ +#define HTS221_PP_OD_PUSH_PULL ((uint8_t)0x00) +#define HTS221_PP_OD_OPEN_DRAIN ((uint8_t)0x40) + +#define HTS221_PP_OD_MASK ((uint8_t)0x40) +/** + * @} + */ + + +/** @defgroup HTS221 Data ready selection - CTRL_REG3 + * @{ + */ +#define HTS221_DRDY_DISABLE ((uint8_t)0x00) +#define HTS221_DRDY_AVAILABLE ((uint8_t)0x40) + +#define HTS221_DRDY_MASK ((uint8_t)0x40) +/** + * @} + */ + + +/** @defgroup HTS221 Humidity resolution selection - RES_CONF + * @{ + */ +#define HTS221_H_RES_AVG_4 ((uint8_t)0x00) +#define HTS221_H_RES_AVG_8 ((uint8_t)0x01) +#define HTS221_H_RES_AVG_16 ((uint8_t)0x02) +#define HTS221_H_RES_AVG_32 ((uint8_t)0x03) +#define HTS221_H_RES_AVG_64 ((uint8_t)0x04) +#define HTS221_H_RES_AVG_128 ((uint8_t)0x05) + +#define HTS221_H_RES_MASK ((uint8_t)0x07) +/** + * @} + */ + + +/** @defgroup HTS221 Temperature resolution - RES_CONF + * @{ + */ +#define HTS221_T_RES_AVG_2 ((uint8_t)0x00) +#define HTS221_T_RES_AVG_4 ((uint8_t)0x08) +#define HTS221_T_RES_AVG_8 ((uint8_t)0x10) +#define HTS221_T_RES_AVG_16 ((uint8_t)0x18) +#define HTS221_T_RES_AVG_32 ((uint8_t)0x20) +#define HTS221_T_RES_AVG_64 ((uint8_t)0x28) + +#define HTS221_T_RES_MASK ((uint8_t)0x38) +/** + * @} + */ + + +/** @defgroup HTS221 Temperature Humidity data available - STATUS_REG + * @{ + */ +#define HTS221_H_DATA_AVAILABLE_MASK ((uint8_t)0x02) +#define HTS221_T_DATA_AVAILABLE_MASK ((uint8_t)0x01) +/** + * @} + */ + + + +/* Data resolution */ +#define HUM_DECIMAL_DIGITS (2) +#define TEMP_DECIMAL_DIGITS (2) + + + +/** + * @} + */ + + + +/** @defgroup UVIS3_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +void HTS221_Init(HUM_TEMP_InitTypeDef *HTS221_Init); +uint8_t HTS221_ReadID(void); +void HTS221_RebootCmd(void); +void HTS221_Power_OFF(void); +void HTS221_GetHumidity(float* pfData); +void HTS221_GetTemperature(float* pfData); + +/* Interrupt Configuration Functions */ +void HTS221_INT1InterruptConfig(uint16_t Int1Config); +void HTS221_EnableIT(uint8_t IntPin); +void HTS221_DisableIT(uint8_t IntPin); + +/* HUM_TEMP sensor driver structure */ +extern HUM_TEMP_DrvTypeDef Hts221Drv; + +/* HUM_TEMP sensor IO functions */ +void HUM_TEMP_IO_Init(void); +void HUM_TEMP_IO_DeInit(void); +void HUM_TEMP_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); +void HUM_TEMP_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif + +#endif /* __HTS221_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/lps25h/lps25h.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/lps25h/lps25h.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,392 @@ +/** + ****************************************************************************** + * @file LPS25H.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 03-April-2014 + * @brief This file provides a set of functions needed to manage the lps25h. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "lps25h.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup STM32F439_SENSITRON + * @{ + */ + +/** @addtogroup LPS25H + * @{ + */ + + +/** @defgroup LPS25H_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup LPS25H_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup LPS25H_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup LPS25H_Private_Variables + * @{ + */ + +PRESSURE_DrvTypeDef LPS25HDrv = +{ + LPS25H_Init, + LPS25H_PowerOff, + LPS25H_ReadID, + LPS25H_RebootCmd, + 0,//LPS25H_INT1InterruptConfig, + 0,//LPS25H_EnableIT, + 0,//LPS25H_DisableIT, + 0, + 0, + LPS25H_GetPressure, + LPS25H_GetTemperature, + LPS25H_SlaveAddrRemap +}; + +uint8_t LPS25H_SlaveAddress = LPS25H_ADDRESS_LOW; + +/** + * @} + */ + +/** @defgroup LPS25H_Private_FunctionPrototypes + * @{ + */ + +/** + * @brief Exit the shutdown mode for LPS25H. + * @param None + * @retval None + */ +void LPS25H_PowerOn(void); + +void LPS25H_I2C_ReadRawPressure(uint32_t *raw_press); + +void LPS25H_I2C_ReadRawTemperature(int16_t *raw_data); + + +/** + * @} + */ + +/** @defgroup LPS25H_Private_Functions + * @{ + */ + + +/** + * @brief Set LPS25H Initialization. + * @param InitStruct: it contains the configuration setting for the LPS25H. + * @retval Error Code (PressureError_Enum) + */ +void LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init) +{ + uint8_t tmp1 = 0x00; + + /* Configure the low level interface ---------------------------------------*/ + PRESSURE_IO_Init(); + + LPS25H_PowerOn(); + + PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); + + /* Output Data Rate selection */ + tmp1 &= ~(LPS25H_ODR_MASK); + tmp1 |= LPS25H_Init->OutputDataRate; + + /* Interrupt circuit selection */ + tmp1 &= ~(LPS25H_DIFF_EN_MASK); + tmp1 |= LPS25H_Init->DiffEnable; + + /* Block Data Update selection */ + tmp1 &= ~(LPS25H_BDU_MASK); + tmp1 |= LPS25H_Init->BlockDataUpdate; + + /* Serial Interface Mode selection */ + tmp1 &= ~(LPS25H_SPI_SIM_MASK); + tmp1 |= LPS25H_Init->SPIMode; + + PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); + + PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1); + + /* Serial Interface Mode selection */ + tmp1 &= ~(LPS25H_P_RES_MASK); + tmp1 |= LPS25H_Init->PressureResolution; + + /* Serial Interface Mode selection */ + tmp1 &= ~(LPS25H_T_RES_MASK); + tmp1 |= LPS25H_Init->TemperatureResolution; + + PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1); +} + +/** + * @brief Read ID address of LPS25H + * @param Device ID address + * @retval ID name + */ +uint8_t LPS25H_ReadID(void) +{ + uint8_t tmp; + + /* Read WHO I AM register */ + PRESSURE_IO_Read(&tmp, LPS25H_SlaveAddress, LPS25H_WHO_AM_I_ADDR, 1); + + /* Return the ID */ + return (uint8_t)tmp; +} + +/** + * @brief Reboot memory content of LPS25H + * @param None + * @retval None + */ +void LPS25H_RebootCmd(void) +{ + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + PRESSURE_IO_Read(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG2_ADDR, 1); + + /* Enable or Disable the reboot memory */ + tmpreg |= LPS25H_RESET_MEMORY; + + /* Write value to MEMS CTRL_REG5 regsister */ + PRESSURE_IO_Write(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Set LPS25H Interrupt INT1 configuration + * @param LPS25H_InterruptConfig_TypeDef: pointer to a LPS25H_InterruptConfig_TypeDef + * structure that contains the configuration setting for the LPS25H Interrupt. + * @retval None + */ +void LPS25H_INT1InterruptConfig(uint16_t Int1Config) +{ + +} + +/** + * @brief Enable INT1 + * @retval None + */ +void LPS25H_EnableIT() +{ + +} + +/** + * @brief Disable INT1 + * @retval None + */ +void LPS25H_DisableIT() +{ + +} + + +/** + * @brief Read LPS25H output register, and calculate the raw pressure. + * @param uint32_t: raw_press. Pressure raw value. + * @retval LPS25H_ERROR or LPS25H_OK. + */ +void LPS25H_I2C_ReadRawPressure(uint32_t *raw_press) +{ + uint8_t buffer[3], i; + uint32_t tempVal=0; + + /* Read the register content */ + + PRESSURE_IO_Read(buffer, LPS25H_SlaveAddress, LPS25H_PRESS_POUT_XL_ADDR+0x80, 3); +// LPS25H_I2C_Read(LPS25H_PRESS_POUT_XL_ADDR+0x80, 3, buffer); + + /* Build the raw data */ + 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 */ + *raw_press = ((uint32_t) tempVal); +} + +/** + * @brief Read LPS25H output register, and calculate the pressure in mbar. + * @param float *pressure. Pressure value in mbar. + * @retval LPS25H_ERROR or LPS25H_OK. + */ +void LPS25H_GetPressure(float* pfData) +{ + uint32_t raw_press = 0; + + LPS25H_I2C_ReadRawPressure(&raw_press); + + /* return the built value */ + //tempInt = raw_press / 4096; + + *pfData = (float)raw_press /4096.0f; +} + +/** + * @brief Read LPS25H output register, and calculate the raw temperature. + * @param int16_t *raw_data: temperature raw value. + * @retval LPS25H_ERROR or LPS25H_OK. + */ +void LPS25H_I2C_ReadRawTemperature(int16_t *raw_data) +{ + uint8_t buffer[2]; + uint16_t tempVal=0; + + /* Read the register content */ + PRESSURE_IO_Read(buffer, LPS25H_SlaveAddress, LPS25H_TEMP_OUT_L_ADDR+0x80, 2); +// LPS25H_I2C_Read(LPS25H_TEMP_OUT_L_ADDR+0x80, 2, buffer); + + /* Build the raw value */ + tempVal = (((uint16_t)buffer[1]) << 8)+(uint16_t)buffer[0]; + + /* Return it */ + *raw_data = ((int16_t)tempVal); +} + +/** + * @brief Read LPS25H output register, and calculate the temperature. + * @param float *temperature : temperature value.. + * @retval LPS25H_ERROR or LPS25H_OK. + */ +void LPS25H_GetTemperature(float* pfData) +{ + int16_t raw_data; + + LPS25H_I2C_ReadRawTemperature(&raw_data); + + //*data_out = (int16_t)((((float)raw_data/480.0) + 42.5)*100); + *pfData = (int16_t)((((float)raw_data/480.0) + 42.5)); +} +/** + * @brief Exit the shutdown mode for LPS25H. + * @param None + * @retval LPS25H_ERROR or LPS25H_OK + */ +void LPS25H_PowerOn(void) +{ + uint8_t tmpreg; + + /* Read the register content */ +// LPS25H_I2C_Read(LPS25H_CTRL_REG1_ADDR,1,&tmpReg); + PRESSURE_IO_Read(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); + + /* Set the power down bit */ + tmpreg |= LPS25H_MODE_ACTIVE; + + /* Write register */ +// PRESSURE_IO_Write(LPS25H_CTRL_REG1_ADDR,1,&tmpReg); + PRESSURE_IO_Write(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); + +} + + +/** + * @brief Enter the shutdown mode for LPS25H. + * @param None + * @retval LPS25H_ERROR or LPS25H_OK + */ +void LPS25H_PowerOff(void) +{ + uint8_t tmpreg; + + /* Read the register content */ +// PRESSURE_IO_Read( LPS25H_CTRL_REG1_ADDR,1,&tmpReg); + PRESSURE_IO_Read(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); + + /* Reset the power down bit */ + tmpreg &= ~(LPS25H_MODE_ACTIVE); + + /* Write register */ +// PRESSURE_IO_Write( LPS25H_CTRL_REG1_ADDR,1,&tmpReg); + PRESSURE_IO_Write(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1); +} + + +/** + * @brief Set the slave address according to SA0 bit. + * @param SA0_Bit_Status: LPS25H_SA0_LOW or LPS25H_SA0_HIGH + * @retval None + */ +void LPS25H_SlaveAddrRemap(uint8_t SA0_Bit_Status) +{ + LPS25H_SlaveAddress = (SA0_Bit_Status==LPS25H_SA0_LOW?LPS25H_ADDRESS_LOW:LPS25H_ADDRESS_HIGH); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/lps25h/lps25h.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/lps25h/lps25h.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,621 @@ +/** + ****************************************************************************** + * @file lps25h.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 18-February-2014 + * @brief This file contains definitions lps25h.c + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __LPS25H_H +#define __LPS25H_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "../Common/pressure.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup LPS25H + * @{ + */ + +/** @defgroup LPS25H_Exported_Constants + * @{ + */ + +/******************************************************************************/ +/*************************** START 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 LPS25H_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 LPS25H_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 LPS25H_REF_P_H_ADDR 0x0A + +/** + * @brief Device identifier register. + * \code + * Read + * Default value: 0xBD + * 7:0 This read-only register contains the device identifier that, + for LPS25H, is set to 0xCA. + * \endcode + */ +#define LPS25H_WHO_AM_I_ADDR 0x0F + +/** + * @brief Pressure and temperature resolution mode register. + * \code + * Read + * Default value: 0x05 + * [7:4] Reserved + * [3:2] AVGP1-0: select the pressure internal average. + * [1:0] AVGT1-0: select the temperature internal average. + * \endcode + */ +#define LPS25H_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 | 7 + * 0 | 1 | 1 | 12.5 | 12.5 + * 1 | 0 | 0 | 25 | 25 + * 1 | 0 | 1 | Reserved | Reserved + * 1 | 1 | 0 | Reserved | Reserved + * 1 | 1 | 1 | Reserved | Reserved + * + * 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 + * 1 RESET_AZ: reset AutoZero. 0 - disable; 1 - enable ///////ALE REVIEW + * 0 SIM: SPI Serial Interface Mode selection. 0 - SPI 4-wire; 1 - SPI 3-wire ///////ALE REVIEW + * \endcode + */ +#define LPS25H_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 FIFO_EN: FIFO. 0: disable; 1: enable + * 5 WTM_EN: FIFO Watermark level use. 0: disable; 1: enable + * 4:3 Reserved. keep these bits at 0 + * 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 LPS25H_CTRL_REG2_ADDR 0x21 + +/** + * @brief Pressure sensor control register 3 + * \code + * Read/write + * Default value: 0x00 + * 7 INT_H_L: Interrupt. 0:active high; 1: active low. + * 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: Push-pull; 1: open drain. + * 5 Reserved + * 4:3 INT2_S2, INT2_S1: INT2 output signal selection control bits. // TO DO + * 1:0 INT1_S2, INT1_S1: data signal on INT1 pad control bits. + * INT1(2)_S2 | INT1(2)_S1 | INT1(2) pin + * ------------------------------------------------------ + * 0 | 0 | Data signal + * 0 | 1 | Pressure high (P_high) + * 1 | 0 | Pressure low (P_low) + * 1 | 1 | P_low OR P_high + + + * \endcode + */ +#define LPS25H_CTRL_REG3_ADDR 0x22 + +/** + * @brief Pressure sensor control register 4 + * \code + * Read/write + * Default value: 0x00 + * 7 P2_EMPTY: Empty Signal on INT2 pin. + * 6 P2_WTM: Watermark Signal on INT2 pin. + * 5 P2_Overrun:Overrun Signal on INT2 pin. + * 4 P2_DRDY: Data Ready Signal on INT2 pin. + * 3 P1_EMPTY: Empty Signal on INT1 pin. + * 2 P1_WTM: Watermark Signal on INT1 pin. + * 1 P1_Overrunn:Overrun Signal on INT1 pin. + * 0 P1_DRDY: Data Ready Signal on INT1 pin. + * \endcode + */ +#define LPS25H_CTRL_REG4_ADDR 0x23 + +/** + * @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 LPS25H_INT_CFG_REG_ADDR 0x24 + +/** + * @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 LPS25H_INT_SOURCE_REG_ADDR 0x25 + +/** + * @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 LPS25H_THS_P_LOW_REG_ADDR 0x30 + +/** + * @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 LPS25H_THS_P_HIGH_REG_ADDR 0x31 + +/** + * @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 LPS25H_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 LPS25H_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 LPS25H_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 LPS25H_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 LPS25H_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 LPS25H_TEMP_OUT_H_ADDR 0x2C + +/** + * @brief FIFO control register + * \code + * Read/write + * Default value: 0x00 + * 7:5 F_MODE2, F_MODE1, F_MODE0: FIFO mode selection. + * FM2 | FM1 | FM0 | FIFO MODE + * --------------------------------------------------- + * 0 | 0 | 0 | BYPASS MODE + * 0 | 0 | 1 | FIFO MODE. Stops collecting data when full + * 0 | 1 | 0 | STREAM MODE: Keep the newest measurements in the FIFO + * 0 | 1 | 1 | STREAM MODE until trigger deasserted, then change to FIFO MODE + * 1 | 0 | 0 | BYPASS MODE until trigger deasserted, then STREAM MODE + * 1 | 0 | 1 | Reserved + * 1 | 1 | 0 | FIFO_MEAN MODE: Fifo is used to generate a running average filtered pressure + * 1 | 1 | 1 | BYPASS mode until trigger deasserted, then FIFO MODE + * + * 4:0 FIFO Mean Mode Sample size + * WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | Sample Size + * ---------------------------------------------------------------------------------- + * 0 | 0 | 0 | 0 | 1 | 2 + * 0 | 0 | 0 | 1 | 1 | 4 + * 0 | 0 | 1 | 1 | 1 | 8 + * 0 | 1 | 1 | 1 | 1 | 16 + * 1 | 1 | 1 | 1 | 1 | 32 + * other values operation not guaranteed + * \endcode + */ +#define LPS25H_CTRL_FIFO_ADDR 0x2E + +/** + * @brief FIFO Status register + * \code + * Read/write + * Default value: 0x00 + * 7 WTM_FIFO: Watermark status. 0:FIFO filling is lower than watermark level; 1: FIFO is equal or higher than watermark level. + * 6 FULL_FIFO: Overrun bit status. 0 - FIFO not full; 1 -FIFO is full. + * 5 EMPTY_FIFO: Empty FIFO bit. 0 - FIFO not empty; 1 -FIFO is empty. + * 4:0 DIFF_POINT4...0: FIFOsStored data level. + * \endcode + */ +#define LPS25H_STATUS_FIFO_ADDR 0x2F + +/** + * @brief Pressure offset register + * \code + * Read/write + * Default value: 0x00 + * 7:0 RPDS15...8:Pressure Offset for 1 point calibration after soldering. + * \endcode + */ +#define LPS25H_RPDS_TRIM_L_ADDR 0x39 + +/** + * @brief Pressure offset register + * \code + * Read/write + * Default value: 0x00 + * 7:0 RPDS23...16:Pressure Offset for 1 point calibration after soldering. + * \endcode + */ +#define LPS25H_RPDS_TRIM_H_ADDR 0x3A + +/******************************************************************************/ +/**************************** END REGISTER MAPPING ***************************/ +/******************************************************************************/ + +/** + * @brief Device Address + */ +#define LPS25H_ADDRESS_LOW 0xB8 +#define LPS25H_ADDRESS_HIGH 0xBA + + +/** + * @brief Device Identifier. Default value of the WHO_AM_I register. + */ +#define I_AM_LPS25H ((uint8_t)0xBD) + +/** @defgroup Power_Mode_selection CTRL_REG1 + * @{ + */ +#define LPS25H_MODE_POWERDOWN ((uint8_t)0x00) +#define LPS25H_MODE_ACTIVE ((uint8_t)0x80) + +#define LPS25H_MODE_MASK ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup LPS25H Output Data Rate selection CTRL_REG1 + * @{ + */ +#define LPS25H_ODR_ONE_SHOT ((uint8_t)0x00) /*!< Output Data Rate: P - one shot, T - one shot */ +#define LPS25H_ODR_1Hz ((uint8_t)0x10) /*!< Output Data Rate: P - 1Hz, T - 1Hz */ +#define LPS25H_ODR_7Hz ((uint8_t)0x20) /*!< Output Data Rate: P - 7Hz, T - 7Hz */ +#define LPS25H_ODR_12_5Hz ((uint8_t)0x30) /*!< Output Data Rate: P - 12.5Hz, T - 12.5Hz */ +#define LPS25H_ODR_25Hz ((uint8_t)0x40) /*!< Output Data Rate: P - 25Hz, T - 25Hz */ + +#define LPS25H_ODR_MASK ((uint8_t)0x70) +/** + * @} + */ + +/** @defgroup LPS25H Interrupt circuit enable CTRL_REG1 + * @{ + */ +#define LPS25H_DIFF_DISABLE ((uint8_t)0x00) /*!< interrupt circuit enabled */ +#define LPS25H_DIFF_ENABLE ((uint8_t)0x08) /*!< interrupt generation disabled */ + +#define LPS25H_DIFF_EN_MASK ((uint8_t)0x08) +/** + * @} + */ + +/** @defgroup LPS25H block data update CTRL_REG1 + * @{ + */ +#define LPS25H_BDU_CONT ((uint8_t)0x00) /*!< continuous update */ +#define LPS25H_BDU_READ ((uint8_t)0x04) /*!< output registers not updated until MSB and LSB reading */ + +#define LPS25H_BDU_MASK ((uint8_t)0x04) +/** + * @} + */ + +/** @defgroup LPS25H SPI Serial Interface Mode selection CTRL_REG1 + * @{ + */ +#define LPS25H_SPI_SIM_4W ((uint8_t)0x00) /*!< 4-wire interface */ +#define LPS25H_SPI_SIM_3W ((uint8_t)0x01) /*!< 3-wire interface */ + +#define LPS25H_SPI_SIM_MASK ((uint8_t)0x01) +/** + * @} + */ + +/** @defgroup LPS25H o refresh the content of the internal registers stored in the Flash memory +block CTRL_REG2 + * @{ + */ +#define LPS25H_NORMAL_MODE ((uint8_t)0x00) +#define LPS25H_RESET_MEMORY ((uint8_t)0x80) + +#define LPS25H_RESET_MEMORY_MASK ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup LPS25H Pressure resolution selection RES_CONF + * @{ + */ +#define LPS25H_P_RES_AVG_8 ((uint8_t)0x00) +#define LPS25H_P_RES_AVG_32 ((uint8_t)0x01) +#define LPS25H_P_RES_AVG_128 ((uint8_t)0x02) +#define LPS25H_P_RES_AVG_512 ((uint8_t)0x03) + +#define LPS25H_P_RES_MASK ((uint8_t)0x03) +/** + * @} + */ + +/** @defgroup LPS25H Temperature resolution RES_CONF + * @{ + */ +#define LPS25H_T_RES_AVG_8 ((uint8_t)0x00) +#define LPS25H_T_RES_AVG_16 ((uint8_t)0x04) +#define LPS25H_T_RES_AVG_32 ((uint8_t)0x08) +#define LPS25H_T_RES_AVG_64 ((uint8_t)0x0C) + +#define LPS25H_T_RES_MASK ((uint8_t)0x0C) +/** + * @} + */ + +#define LPS25H_SA0_LOW ((uint8_t)0x00) +#define LPS25H_SA0_HIGH ((uint8_t)0x01) + +///** +// * @brief LPS25H Output Data Rate +// */ +//typedef enum { +// LPS25H_ODR_P_T_ONE_SHOT = 0x00, /*!< Output Data Rate: P - one shot, T - one shot */ +// LPS25H_ODR_P_1HZ_T_1HZ = 0x10, /*!< Output Data Rate: P - 1Hz, T - 1Hz */ +// LPS25H_ODR_P_7HZ_T_7HZ = 0x20, /*!< Output Data Rate: P - 7Hz, T - 7Hz */ +// LPS25H_ODR_P_12_5HZ_T_12_5HZ = 0x30, /*!< Output Data Rate: P - 12.5Hz, T - 12.5Hz */ +// LPS25H_ODR_P_25HZ_T_25HZ = 0x40 /*!< Output Data Rate: P - 25Hz, T - 25Hz */ +//} LPS25H_OutputDataRate; + +///** +// * @brief LPS25H Pressure resolution +// */ +//typedef enum { +// LPS25H_PRESS_AVG_8 = 0x00, /*!< Internal average on 8 sample */ +// LPS25H_PRESS_AVG_32 = 0x01, /*!< Internal average on 32 sample */ +// LPS25H_PRESS_AVG_128 = 0x02, /*!< Internal average on 128 sample */ +// LPS25H_PRESS_AVG_512 = 0x03 /*!< Internal average on 512 sample */ +//} LPS25H_PressureResolution; + +///** +// * @brief LPS25H Temperature resolution +// */ +//typedef enum { +// LPS25H_TEMP_AVG_8 = 0x00, /*!< Internal average on 8 sample */ +// LPS25H_TEMP_AVG_16 = 0x10, /*!< Internal average on 16 sample */ +// LPS25H_TEMP_AVG_32 = 0x20, /*!< Internal average on 32 sample */ +// LPS25H_TEMP_AVG_64 = 0x30 /*!< Internal average on 64 sample */ +//} LPS25H_TemperatureResolution; +// +///** +// * @addtogroup LPS25H_Structures +// * @{ +// */ +// +///** +// * @brief LPS25H Irq list +// */ +//typedef enum { +// LPS25H_DATA = 0x00, +// LPS25H_P_HIGH = 0x01, +// LPS25H_P_LOW = 0x02, +// LPS25H_P_LOW_HIGH = 0x03 +//} LPS25H_IrqList; +// +///** +// * @brief LPS25H Irq pin output configuration +// */ +//typedef enum { +// LPS25H_PP = 0x00, +// LPS25H_OD = 0x40 +//} LPS25H_OutputType; +// +///** +// * @brief LPS25H Irq configuration +// */ +//typedef enum { +// LPS25H_EMPTY = 0x08, +// LPS25H_WTM = 0x04, +// LPS25H_OVR = 0x02, +// LPS25H_DATA_READY = 0x01 +//} LPS25H_DataSignalType; + +/** + * @} + */ + +/** @defgroup LPS25H_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +void LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init); +uint8_t LPS25H_ReadID(void); +void LPS25H_RebootCmd(void); +void LPS25H_GetPressure(float* pfData); +void LPS25H_GetTemperature(float* pfData); +void LPS25H_PowerOff(void); +void LPS25H_SlaveAddrRemap(uint8_t); + +/* Interrupt Configuration Functions */ +void LPS25H_INT1InterruptConfig(uint16_t Int1Config); +void LPS25H_EnableIT(void); +void LPS25H_DisableIT(void); + +/* Pressure sensor driver structure */ +extern PRESSURE_DrvTypeDef LPS25HDrv; + +/* Pressure sensor IO functions */ +void PRESSURE_IO_Init(void); +void PRESSURE_IO_DeInit(void); +void PRESSURE_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, + uint16_t NumByteToWrite); +void PRESSURE_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, + uint8_t RegisterAddr, uint16_t NumByteToRead); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __LPS25H_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/uvis3/uvis3.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/uvis3/uvis3.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,250 @@ +/** + ****************************************************************************** + * @file uvis3.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 10-March-2014 + * @brief This file provides a set of functions needed to manage the uvis3. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "uvis3.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup STM32F439_SENSITRON + * @{ + */ + +/** @addtogroup UVIS3 + * @{ + */ + + +/** @defgroup UVIS3_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup UVIS3_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup UVIS3_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup UVIS3_Private_Variables + * @{ + */ + +UV_DrvTypeDef Uvis3Drv = +{ + UVIS3_Init, + UVIS3_ReadID, + UVIS3_RebootCmd, + 0,//UVIS3_INT1InterruptConfig, + 0,//UVIS3_EnableIT, + 0,//UVIS3_DisableIT, + 0, + 0, + UVIS3_GetIndex +}; +/** + * @} + */ + +/** @defgroup UVIS3_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup UVIS3_Private_Functions + * @{ + */ + +/** + * @brief Set UVIS3 Initialization. + * @param InitStruct: it contains the configuration setting for the UVIS3. + * @retval None + */ +void UVIS3_Init(UV_InitTypeDef *UVIS3_Init) +{ + uint8_t ctrl = 0x00; + + /* Configure the low level interface ---------------------------------------*/ + UV_IO_Init(); + + /* Read CTRL_REG1 register */ + UV_IO_Read(&ctrl, UVIS3_ADDRESS, UVIS3_CTRL_REG1_ADDR, 1); + + /* Power Mode selection */ + ctrl &= ~(UVIS3_MODE_MASK); + ctrl |= UVIS3_Init->Power_Mode; + +// if(UVIS3_Init->Power_Mode==UVIS3_MODE_POWERDOWN) { +// ctrl |= 0x80; +// } else { +// ctrl &= 0x7F; +// } + + /* Data Rate selection */ + ctrl &= ~(UVIS3_ODR_MASK); + ctrl |= UVIS3_Init->Output_DataRate; + +// if(UVIS3_Init->Output_DataRate==UVIS3_ODR_1HZ) { +// ctrl |= 0x01; +// } else { +// ctrl &= 0xFE; +// } + + /* Write value to MEMS CTRL_REG1 regsister */ + UV_IO_Write(&ctrl, UVIS3_ADDRESS, UVIS3_CTRL_REG1_ADDR, 1); + + /* Write value to MEMS CTRL_REG2 regsister ??*/ + //ctrl = (uint8_t) InitStruct>>8; + //UV_IO_Write(&ctrl, UVIS3_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Read ID address of UVIS3 + * @param Device ID address + * @retval ID name + */ +uint8_t UVIS3_ReadID(void) +{ + uint8_t tmp; + + /* Read WHO I AM register */ + UV_IO_Read(&tmp, UVIS3_ADDRESS, UVIS3_WHO_AM_I_ADDR, 1); + + /* Return the ID */ + return (uint8_t)tmp; +} + +/** + * @brief Reboot memory content of UVIS3 + * @param None + * @retval None + */ +void UVIS3_RebootCmd(void) +{ + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + UV_IO_Read(&tmpreg, UVIS3_ADDRESS, UVIS3_CTRL_REG2_ADDR, 1); + + /* Enable or Disable the reboot memory */ + tmpreg |= UVIS3_BOOT_REBOOTMEMORY; + + /* Write value to MEMS CTRL_REG5 regsister */ + UV_IO_Write(&tmpreg, UVIS3_ADDRESS, UVIS3_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Set UVIS3 Interrupt INT1 configuration + * @param UVIS3_InterruptConfig_TypeDef: pointer to a UVIS3_InterruptConfig_TypeDef + * structure that contains the configuration setting for the UVIS3 Interrupt. + * @retval None + */ +void UVIS3_INT1InterruptConfig(uint16_t Int1Config) +{ + +} + +/** + * @brief Enable INT1 + * @retval None + */ +void UVIS3_EnableIT() +{ + +} + +/** + * @brief Disable INT1 + * @retval None + */ +void UVIS3_DisableIT() +{ + +} + + +/** +* @brief Calculate the UVIS3 UV index data. +* @param pfData : Data out pointer +* @retval None +*/ +void UVIS3_GetIndex(float* pfData) +{ + uint8_t tmpreg; + /* Read UVIS3_UVDATA_OUT_ADDR register */ + UV_IO_Read(&tmpreg, UVIS3_ADDRESS, UVIS3_UVDATA_OUT_ADDR, 1); + //tmpreg=32; + *pfData=(float)tmpreg/16.0f; + +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Components/uvis3/uvis3.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Components/uvis3/uvis3.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,300 @@ +/** + ****************************************************************************** + * @file uvis3.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 18-February-2014 + * @brief This file contains definitions uvis3.c + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __UVIS3_H +#define __UVIS3_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "../Common/uv.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup UVIS3 + * @{ + */ + +/** @defgroup UVIS3_Exported_Constants + * @{ + */ + +/******************************************************************************/ +/*************************** START REGISTER MAPPING **************************/ +/******************************************************************************/ +/** + * @brief Device Address + */ +#define UVIS3_ADDRESS 0x8E + + +/** + * @brief Device identifier register. + * \code + * Read + * Default value: 0xBD + * 7:0 This read-only register contains the device identifier that, + for UVIS3, is set to 0xCA. + * \endcode + */ +#define UVIS3_WHO_AM_I_ADDR 0x0F + + + /** + * @brief UVIS3 control register 1 + * \code + * Read/write + * Default value: 0x80. + * 7 PD: power down control. 1 - disable; 0 - enable. + * 6:2 reserved. + * 1 BDU: Block Data Update. 0 - continuous update; 1 -output registers not + updated until MSB and LSB reading. //CHECK + * 0 ODR: Output Data Rate. 0 - ODR disabled (one shot mode); 1 ODR at 1 Hz. + * \endcode + */ +#define UVIS3_CTRL_REG1_ADDR 0x20 + + + /** + * @brief UVIS3 control register 2 + * \code + * Read/write + * Default value: 0x00. + * 7 BOOT: reboot memory content. 1 - reload flash content; 0 - normal mode. + * 6:5 reserved. + * 4: I2C_DIS: Disable I2C interface. 0: enable; 1: disable. + * 3 SIM: SPI Serial Interface Mode Selection. 0: 4 wires interface; + 1: 3 wires interface. + * 2:1 Reserved + * 0: One shot enable. 0: waiting for start of conversion; + 1: start for a new dataset. + * \endcode + */ +#define UVIS3_CTRL_REG2_ADDR 0x21 + + + /** + * @brief UVIS3 control register 3 + * \code + * Read/write + * Default value: 0x00. + * 7 INT_H_L: Interrupt active high, low. 0: active high; 1: active low. + * 6 PP_OD: Push-pull/open drain selection on interrupt pads. 0: push-pull; + 1: open drain. + * 5:2 Reserved + * 1:0 INT1_S2, INT1_S1: data signal on INT1 pad control bits. + Default value: 00. + * | INT1_S2 | INT1_S1 | INT1 pin | + * ------------------------------------------------- + * | 0 | 0 | Data ready | + * | 0 | 1 | UV index High | + * | 1 | 0 | UV index Low | + * | 1 | 1 | UV index High or Low | + * \endcode + */ +#define UVIS3_CTRL_REG3_ADDR 0x22 + + + /** + * @brief INT1 interrupt configuration + * \code + * Read/write + * Default value: 0x00. + * 7:4 Reserved. + * 3: DIFF_EN: interrupt logical block enable. 0: interrupt logick block + disable; 1: enable. + * 2: LIR: Latch interrupt request into INT_SOURCE register with (24h), with + the INT_SOURCE register cleared by reading INT_SOURCE reg (24h). + 0: interrupt request not latched;1: latched. + * 1: UVLE: Enable interrupt generation on differential UV low event. 0: disable + interrupt request;1: enable interrupt request + * 0: UVHE: Enable interrupt generation on differential UV high event SIM; + 0: disable interrupt request;1: enable interrupt request + * \endcode + */ +#define UVIS3_INT_CFG_ADDR 0x23 + + + + /** + * @brief Interrupt source configuration register + * \code + * Read/write + * Default value: 0x00. + * 7:3 Reserved. + * 2: IA: Interrupt Active. 0: no interrupt has been generated; + 1: one or more interrupt events have been generated. + * 1: UVL: Differential UV low. 0: no interrupt; 1: UVL event has occurred. + * 0: UVH: Differential UV high. 0: no interrupt; 1: UVH event has occurred. + * \endcode + */ +#define UVIS3_INT_SRC_ADDR 0x24 + + + + /** + * @brief Differential UV interrupt threshold + * \code + * Read/write + * Default value: 0x00. + * 7:0 Differential UV Interrupt Threshold values. + * \endcode + */ +#define UVIS3_DIFF_UV_TSH_ADDR 0x25 + + + /** + * @brief Status register + * \code + * Read/write + * Default value: 0x00. + * 7:1 Reserved. + * 0: UV_DA: UV data available. 0: UV data index not available; 1: UV data + index available. + * \endcode + */ +#define UVIS3_STATUS_REG_ADDR 0x27 + + + /** + * @brief UV index data + * \code + * Read/write + * Default value: 0x00. + * 7:0 UV index data output values. + * \endcode + */ +#define UVIS3_UVDATA_OUT_ADDR 0x28 + + +/******************************************************************************/ +/**************************** END REGISTER MAPPING ***************************/ +/******************************************************************************/ + +/** + * @brief Device Identifier. Default value of the WHO_AM_I register. + */ +#define I_AM_UVIS3 ((uint8_t)0xCA) + +/** @defgroup Power_Mode_selection CTRL_REG1 + * @{ + */ +#define UVIS3_MODE_ACTIVE ((uint8_t)0x00) +#define UVIS3_MODE_POWERDOWN ((uint8_t)0x80) + +#define UVIS3_MODE_MASK ((uint8_t)0x80) + +/** + * @} + */ + +/** @defgroup OutPut_DataRate_Selection CTRL_REG1 + * @{ + */ +#define UVIS3_ODR_ONE_SHOT ((uint8_t)0x00) +#define UVIS3_ODR_1HZ ((uint8_t)0x01) + +#define UVIS3_ODR_MASK ((uint8_t)0x01) + +/** + * @} + */ + +/** @defgroup Boot_Mode_selection CTRL_REG2 + * @{ + */ +#define UVIS3_BOOT_NORMALMODE ((uint8_t)0x00) +#define UVIS3_BOOT_REBOOTMEMORY ((uint8_t)0x80) + +#define UVIS3_BOOT_MASK ((uint8_t)0x80) + +/** + * @} + */ + + +/** @defgroup UVIS3_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +void UVIS3_Init(UV_InitTypeDef *UVIS3_Init); +uint8_t UVIS3_ReadID(void); +void UVIS3_RebootCmd(void); +void UVIS3_GetIndex(float* pfData); + +/* Interrupt Configuration Functions */ +void UVIS3_INT1InterruptConfig(uint16_t Int1Config); +void UVIS3_EnableIT(void); +void UVIS3_DisableIT(void); + +/* Uv sensor driver structure */ +extern UV_DrvTypeDef Uvis3Drv; + +/* Uv sensor IO functions */ +void UV_IO_Init(void); +void UV_IO_DeInit(void); +void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); +void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif + +#endif /* __UVIS3_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Nucleo-F401RE/nucleo-f401re.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Nucleo-F401RE/nucleo-f401re.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file nucleo-f401re.c + * @author MCD Application Team + * @version V1.0.0 + * @date 22-April-2014 + * @brief This file provides set of firmware functions to manage: + * - LEDs and push-button available on NUCLEO-F401RE Kit + * from STMicroelectronics + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "nucleo-f401re.h" +//#include "cmsis_os.h" +//#include "stm32f4xx_hal.h" +//#include "stm32f4xx_hal_i2c.h" +//#include "stm32f4xx_hal_i2c_ex.h" + + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup NUCLEO_F401RE + * @{ + */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL + * @brief This file provides set of firmware functions to manage Leds and push-button + * available on NUCLEO-F401RE Kit from STMicroelectronics. + * @{ + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Defines + * @{ + */ + +/** + * @brief STM32L0XX NUCLEO BSP Driver version number V1.0.0 + */ +#define __NUCLEO_F401RE_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ +#define __NUCLEO_F401RE_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ +#define __NUCLEO_F401RE_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ +#define __NUCLEO_F401RE_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ +#define __NUCLEO_F401RE_BSP_VERSION ((__NUCLEO_F401RE_BSP_VERSION_MAIN << 24)\ + |(__NUCLEO_F401RE_BSP_VERSION_SUB1 << 16)\ + |(__NUCLEO_F401RE_BSP_VERSION_SUB2 << 8 )\ + |(__NUCLEO_F401RE_BSP_VERSION_RC)) + +/** + * @brief LINK SD Card + */ +#define SD_DUMMY_BYTE 0xFF +#define SD_NO_RESPONSE_EXPECTED 0x80 + +/** + * @} + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Variables + * @{ + */ +GPIO_TypeDef* GPIO_PORT[LEDn] = {LED2_GPIO_PORT}; + +const uint16_t GPIO_PIN[LEDn] = {LED2_PIN}; + +GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; +const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; +const uint16_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; + +/** + * @brief BUS variables + */ + +//uint32_t SpixTimeout = NUCLEO_SPIx_TIMEOUT_MAX; /*<! Value of Timeout when SPI communication fails */ +//static SPI_HandleTypeDef hnucleo_Spi; +//static ADC_HandleTypeDef hnucleo_Adc; + +/* ADC channel configuration structure declaration */ +//static ADC_ChannelConfTypeDef sConfig; + +/** + * @} + */ + +uint32_t I2C_SHIELDS_Timeout = NUCLEO_I2C_SHIELDS_TIMEOUT_MAX; /*<! Value of Timeout when I2C communication fails */ + +static I2C_HandleTypeDef I2C_SHIELDS_Handle; + +//osMutexId I2C1_Mutex_id = 0; + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_FunctionPrototypes + * @{ + */ + +/* Link function for PRESSURE peripheral */ +void PRESSURE_IO_Init(void); +void PRESSURE_IO_ITConfig(void); +void PRESSURE_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); +void PRESSURE_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); + +/* Link function for UV peripheral */ +void UV_IO_Init(void); +void UV_IO_ITConfig(void); +void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); +void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); + +/* Link function for HUM_TEMP peripheral */ +void HUM_TEMP_IO_Init(void); +void HUM_TEMP_IO_ITConfig(void); +void HUM_TEMP_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); +void HUM_TEMP_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); + + +static void I2C_SHIELDS_MspInit(void); +static void I2C_SHIELDS_Error(uint8_t Addr); + +/** + * @} + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Functions + * @{ + */ + +/** + * @brief This method returns the STM32L0XX NUCLEO BSP Driver revision + * @param None + * @retval version : 0xXYZR (8bits for each decimal, R for RC) + */ +uint32_t BSP_GetVersion(void) +{ + return __NUCLEO_F401RE_BSP_VERSION; +} + + +/** + * @brief Configures Button GPIO and EXTI Line. + * @param Button: Specifies the Button to be configured. + * This parameter should be: BUTTON_KEY + * @param ButtonMode: Specifies Button mode. + * This parameter can be one of following parameters: + * @arg BUTTON_MODE_GPIO: Button will be used as simple IO + * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt + * generation capability + * @retval None + */ +void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /* Enable the BUTTON Clock */ + BUTTONx_GPIO_CLK_ENABLE(Button); + __SYSCFG_CLK_ENABLE(); + + if(Button_Mode == BUTTON_MODE_GPIO) + { + /* Configure Button pin as input */ + GPIO_InitStruct.Pin = BUTTON_PIN[Button]; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + + HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); + } + + if(Button_Mode == BUTTON_MODE_EXTI) + { + /* Configure Button pin as input with External interrupt */ + GPIO_InitStruct.Pin = BUTTON_PIN[Button]; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); + + /* Enable and set Button EXTI Interrupt to the lowest priority */ + NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x03); + HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); + } +} + +/** + * @brief Returns the selected Button state. + * @param Button: Specifies the Button to be checked. + * This parameter should be: BUTTON_KEY + * @retval The Button GPIO pin value. + */ +uint32_t BSP_PB_GetState(Button_TypeDef Button) +{ + return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); +} + +/******************************* I2C Routines**********************************/ +/** + * @brief Configures I2C interface. + * @param None + * @retval None + */ +static void I2C_SHIELDS_Init(void) +{ + if(HAL_I2C_GetState(&I2C_SHIELDS_Handle) == HAL_I2C_STATE_RESET) + { + /* I2C_SHIELDS peripheral configuration */ + I2C_SHIELDS_Handle.Init.ClockSpeed = NUCLEO_I2C_SHIELDS_SPEED; + I2C_SHIELDS_Handle.Init.DutyCycle = I2C_DUTYCYCLE_2; + I2C_SHIELDS_Handle.Init.OwnAddress1 = 0x33; + I2C_SHIELDS_Handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + I2C_SHIELDS_Handle.Instance = NUCLEO_I2C_SHIELDS; + + /* Init the I2C */ + I2C_SHIELDS_MspInit(); + HAL_I2C_Init(&I2C_SHIELDS_Handle); + } +} + +/** + * @brief Write a value in a register of the device through BUS. + * @param Addr: Device address on BUS Bus. + * @param Reg: The target register address to write + * @param Value: The target register value to be written + * @retval HAL status + */ + +static void I2C_SHIELDS_WriteData(uint8_t* pBuffer, uint8_t Addr, uint8_t Reg, uint16_t Size) +{ + HAL_StatusTypeDef status = HAL_OK; + + status = HAL_I2C_Mem_Write(&I2C_SHIELDS_Handle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Size, I2C_SHIELDS_Timeout); + + /* Check the communication status */ + if(status != HAL_OK) + { + /* Execute user timeout callback */ + I2C_SHIELDS_Error(Addr); + } +} + +/** + * @brief Read a register of the device through BUS + * @param Addr: Device address on BUS . + * @param Reg: The target register address to read + * @retval HAL status + */ +static void I2C_SHIELDS_ReadData(uint8_t* pBuffer, uint8_t Addr, uint8_t Reg, uint16_t Size) +{ + HAL_StatusTypeDef status = HAL_OK; + + status = HAL_I2C_Mem_Read(&I2C_SHIELDS_Handle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Size, I2C_SHIELDS_Timeout); + + /* Check the communication status */ + if(status != HAL_OK) + { + /* Execute user timeout callback */ + I2C_SHIELDS_Error(Addr); + } + +} + +/** + * @brief Manages error callback by re-initializing I2C. + * @param Addr: I2C Address + * @retval None + */ +static void I2C_SHIELDS_Error(uint8_t Addr) +{ + /* De-initialize the I2C comunication bus */ + HAL_I2C_DeInit(&I2C_SHIELDS_Handle); + + /* Re-Initiaize the I2C comunication bus */ + I2C_SHIELDS_Init(); +} + +/** + * @brief I2C MSP Initialization + * @param None + * @retval None + */ +static void I2C_SHIELDS_MspInit(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /*if(!NUCLEO_I2C_SHIELDS_MUTEX) { + NUCLEO_I2C_SHIELDS_MUTEX = osMutexCreate(0); + }*/ + /* Enable I2C GPIO clocks */ + NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_CLK_ENABLE(); + + /* I2C_SHIELDS SCL and SDA pins configuration -------------------------------------*/ + GPIO_InitStruct.Pin = NUCLEO_I2C_SHIELDS_SCL_PIN | NUCLEO_I2C_SHIELDS_SDA_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Alternate = NUCLEO_I2C_SHIELDS_SCL_SDA_AF; + HAL_GPIO_Init(NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); + + /* Enable the I2C_SHIELDS peripheral clock */ + NUCLEO_I2C_SHIELDS_CLK_ENABLE(); + + /* Force the I2C peripheral clock reset */ + NUCLEO_I2C_SHIELDS_FORCE_RESET(); + + /* Release the I2C peripheral clock reset */ + NUCLEO_I2C_SHIELDS_RELEASE_RESET(); + + /* Enable and set I2C_SHIELDS Interrupt to the highest priority */ + HAL_NVIC_SetPriority(NUCLEO_I2C_SHIELDS_EV_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(NUCLEO_I2C_SHIELDS_EV_IRQn); + + /* Enable and set I2C_SHIELDS Interrupt to the highest priority */ + HAL_NVIC_SetPriority(NUCLEO_I2C_SHIELDS_ER_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(NUCLEO_I2C_SHIELDS_ER_IRQn); +} + + +/********************************* LINK PRESSURE *****************************/ +/** + * @brief Configures Pressure I2C interface. + * @param None + * @retval None + */ +void PRESSURE_IO_Init(void) +{ + I2C_SHIELDS_Init(); +} + +/** + * @brief Writes a buffer to the Pressure sensor. + * @param pBuffer: pointer to data to be written. + * @param DeviceAddr: specifies the slave address to be programmed. + * @param RegisterAddr: specifies the Pressure register to be written. + * @param NumByteToWrite: number of bytes to be written. + * @retval None. + */ +void PRESSURE_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + +/** + * @brief Reads a buffer from the Pressure sensor. + * @param pBuffer: pointer to data to be read. + * @param DeviceAddr: specifies the address of the device. + * @param RegisterAddr: specifies the Pressure internal address register to read from. + * @param NumByteToRead: number of bytes to be read. + * @retval None. + */ +void PRESSURE_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + + + + +/********************************* LINK UVI *****************************/ +/** + * @brief Configures Uvi I2C interface. + * @param None + * @retval None + */ +void UV_IO_Init(void) +{ + I2C_SHIELDS_Init(); +} + +/** + * @brief Writes a buffer to the Uvi sensor. + * @param pBuffer: pointer to data to be written. + * @param DeviceAddr: specifies the slave address to be programmed. + * @param RegisterAddr: specifies the Pressure register to be written. + * @param NumByteToWrite: number of bytes to be written. + * @retval None. + */ +void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + +/** + * @brief Reads a buffer from the Uvi sensor. + * @param pBuffer: pointer to data to be read. + * @param DeviceAddr: specifies the address of the device. + * @param RegisterAddr: specifies the Pressure internal address register to read from. + * @param NumByteToRead: number of bytes to be read. + * @retval None. + */ +void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + + + + + +/********************************* LINK HUM_TEMP *****************************/ +/** + * @brief Configures Uvi I2C interface. + * @param None + * @retval None + */ +void HUM_TEMP_IO_Init(void) +{ + I2C_SHIELDS_Init(); +} + +/** + * @brief Writes a buffer to the Uvi sensor. + * @param pBuffer: pointer to data to be written. + * @param DeviceAddr: specifies the slave address to be programmed. + * @param RegisterAddr: specifies the Pressure register to be written. + * @param NumByteToWrite: number of bytes to be written. + * @retval None. + */ +void HUM_TEMP_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + +/** + * @brief Reads a buffer from the Uvi sensor. + * @param pBuffer: pointer to data to be read. + * @param DeviceAddr: specifies the address of the device. + * @param RegisterAddr: specifies the Pressure internal address register to read from. + * @param NumByteToRead: number of bytes to be read. + * @retval None. + */ +void HUM_TEMP_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) +{ + //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); + /* call I2C_SHIELDS Read data bus function */ + I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); + //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/Nucleo-F401RE/nucleo-f401re.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/Nucleo-F401RE/nucleo-f401re.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,324 @@ +/** + ****************************************************************************** + * @file nucleo-f401re.h + * @author MCD Application Team + * @version V1.0.0 + * @date 22-April-2014 + * @brief This file contains definitions for: + * - LEDs and push-button available on NUCLEO-F401RE Kit + * from STMicroelectronics + * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD + * shield (reference ID 802) + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __NUCLEO_F401RE_H +#define __NUCLEO_F401RE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx_hal.h" + + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup NUCLEO_F401RE + * @{ + */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL + * @{ + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Exported_Types + * @{ + */ + + +typedef enum +{ + BUTTON_KEY = 0 +} Button_TypeDef; + +typedef enum +{ + BUTTON_MODE_GPIO = 0, + BUTTON_MODE_EXTI = 1 +} ButtonMode_TypeDef; + +typedef enum +{ + JOY_NONE = 0, + JOY_SEL = 1, + JOY_DOWN = 2, + JOY_LEFT = 3, + JOY_RIGHT = 4, + JOY_UP = 5 +} JOYState_TypeDef; + +/** + * @} + */ + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Exported_Constants + * @{ + */ + +/** +* @brief Define for NUCLEO_F401RE board + */ +#if !defined (USE_NUCLEO_F401RE) + #define USE_NUCLEO_F401RE +#endif + +/** + * @} + */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL_LED + * @{ + */ +#define LEDn 1 + +#define LED2_PIN GPIO_PIN_5 +#define LED2_GPIO_PORT GPIOA +#define LED2_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() +#define LED2_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() + +#define LEDx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? LED2_GPIO_CLK_ENABLE() : 0) +#define LEDx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? LED2_GPIO_CLK_DISABLE() : 0) +/** + * @} + */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL_BUTTON + * @{ + */ +#define BUTTONn 1 + +/** + * @brief Key push-button + */ +#define KEY_BUTTON_PIN GPIO_PIN_13 +#define KEY_BUTTON_GPIO_PORT GPIOC +#define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() +#define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() +#define KEY_BUTTON_EXTI_LINE GPIO_PIN_13 +#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn +//EXTI4_15_IRQn + +#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_ENABLE() : 0) +#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_DISABLE() : 0) +/** + * @} + */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL_BUS + * @{ + */ +/*###################### SPI1 ###################################*/ +//#define NUCLEO_SPIx SPI1 +//#define NUCLEO_SPIx_CLK_ENABLE() __SPI1_CLK_ENABLE() +// +//#define NUCLEO_SPIx_SCK_AF GPIO_AF0_SPI1 +//#define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA +//#define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5 +//#define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() +//#define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() +// +//#define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF0_SPI1 +//#define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA +//#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() +//#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() +//#define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6 +//#define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7 +///* Maximum Timeout values for flags waiting loops. These timeouts are not based +// on accurate values, they just guarantee that the application will not remain +// stuck if the SPI communication is corrupted. +// You may modify these timeout values depending on CPU frequency and application +// conditions (interrupts routines ...). */ +//#define NUCLEO_SPIx_TIMEOUT_MAX 1000 + + +/** + * @brief Definition for I2C_ONBOARD_SENSORS port, connected to I2C3 + */ + +/* I2C clock speed configuration (in Hz) */ +#ifndef NUCLEO_I2C_SHIELDS_SPEED + #define NUCLEO_I2C_SHIELDS_SPEED 100000 +#endif /* I2C_ONBOARD_SENSORS_SPEED */ + +/* I2C peripheral configuration defines (control interface of the audio codec) */ +#define NUCLEO_I2C_SHIELDS I2C1 +#define NUCLEO_I2C_SHIELDS_CLK_ENABLE() __I2C1_CLK_ENABLE() +#define NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() +#define NUCLEO_I2C_SHIELDS_SCL_SDA_AF GPIO_AF4_I2C1 +#define NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_PORT GPIOB +#define NUCLEO_I2C_SHIELDS_SCL_PIN GPIO_PIN_8 +#define NUCLEO_I2C_SHIELDS_SDA_PIN GPIO_PIN_9 + +#define NUCLEO_I2C_SHIELDS_FORCE_RESET() __I2C1_FORCE_RESET() +#define NUCLEO_I2C_SHIELDS_RELEASE_RESET() __I2C1_RELEASE_RESET() + +/* I2C interrupt requests */ +#define NUCLEO_I2C_SHIELDS_EV_IRQn I2C1_EV_IRQn +#define NUCLEO_I2C_SHIELDS_ER_IRQn I2C1_ER_IRQn + +//#define NUCLEO_I2C_SHIELDS_MUTEX I2C1_Mutex_id +//#define NUCLEO_I2C_SHIELDS_MUTEX_TAKE() osMutexWait(NUCLEO_I2C_SHIELDS_MUTEX, 0) +//#define NUCLEO_I2C_SHIELDS_MUTEX_RELEASE() osMutexRelease(NUCLEO_I2C_SHIELDS_MUTEX) + +/* Maximum Timeout values for flags waiting loops. These timeouts are not based + on accurate values, they just guarantee that the application will not remain + stuck if the SPI communication is corrupted. + You may modify these timeout values depending on CPU frequency and application + conditions (interrupts routines ...). */ +#define NUCLEO_I2C_SHIELDS_TIMEOUT_MAX 0x1000 /*<! The value of the maximal timeout for BUS waiting loops */ + +/** @addtogroup NUCLEO_F401RE_LOW_LEVEL_COMPONENT + * @{ + */ + +/** + * @brief SD Control Lines management + */ +#define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET) +#define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET) + +/** + * @brief LCD Control Lines management + */ +#define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET) +#define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET) +#define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET) +#define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET) + +/** + * @brief SD Control Interface pins + */ +#define SD_CS_PIN GPIO_PIN_5 +#define SD_CS_GPIO_PORT GPIOB +#define SD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() +#define SD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE() + +/** + * @brief LCD Control Interface pins + */ +#define LCD_CS_PIN GPIO_PIN_6 +#define LCD_CS_GPIO_PORT GPIOB +#define LCD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() +#define LCD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE() + +/** + * @brief LCD Data/Command Interface pins + */ +#define LCD_DC_PIN GPIO_PIN_9 +#define LCD_DC_GPIO_PORT GPIOA +#define LCD_DC_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() +#define LCD_DC_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() + +/*##################### ADC1 ###################################*/ +/** + * @brief ADC Interface pins + * used to detect motion of Joystick available on Adafruit 1.8" TFT shield + */ +#define NUCLEO_ADCx ADC1 +#define NUCLEO_ADCx_CLK_ENABLE() __ADC1_CLK_ENABLE() + +#define NUCLEO_ADCx_GPIO_PORT GPIOB +#define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_0 +#define NUCLEO_ADCx_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() +#define NUCLEO_ADCx_GPIO_CLK_DISABLE() __GPIOB_CLK_ENABLE() + + +/* User can use this section to tailor USARTx/UARTx instance used and associated + resources */ +/* Definition for USARTx clock resources */ +#define USARTx USART2 +#define USARTx_CLK_ENABLE() __USART2_CLK_ENABLE(); +#define DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE() +#define USARTx_RX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() +#define USARTx_TX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() + +#define USARTx_FORCE_RESET() __USART2_FORCE_RESET() +#define USARTx_RELEASE_RESET() __USART2_RELEASE_RESET() + +/* Definition for USARTx Pins */ +#define USARTx_TX_PIN GPIO_PIN_2 +#define USARTx_TX_GPIO_PORT GPIOA +#define USARTx_TX_AF GPIO_AF7_USART2 +#define USARTx_RX_PIN GPIO_PIN_3 +#define USARTx_RX_GPIO_PORT GPIOA +#define USARTx_RX_AF GPIO_AF7_USART2 + +/* Definition for USARTx's DMA */ +#define USARTx_TX_DMA_CHANNEL DMA_CHANNEL_4 +#define USARTx_TX_DMA_STREAM DMA1_Stream6 +#define USARTx_RX_DMA_CHANNEL DMA_CHANNEL_4 +#define USARTx_RX_DMA_STREAM DMA1_Stream5 + +/** @defgroup NUCLEO_F401RE_LOW_LEVEL_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __NUCLEO_F401RE_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_hum_temp.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_hum_temp.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,276 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_hum_temp.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 08-April-2014 + * @brief This file provides a set of functions needed to manage the hts221 sensor. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "x_nucleo_ike01x1_hum_temp.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_HUM_TEMP + * @{ + */ + + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_TypesDefinitions X_NUCLEO_IKE01X1_UV_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_Defines X_NUCLEO_IKE01X1_HUM_TEMP_Private_Defines + * @{ + */ +#ifndef NULL + #define NULL (void *) 0 +#endif +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_Macros X_NUCLEO_IKE01X1_HUM_TEMP_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_Variables X_NUCLEO_IKE01X1_HUM_TEMP_Private_Variables + * @{ + */ +static HUM_TEMP_DrvTypeDef *Hum_tempDrv; +static uint8_t HumTempInitialized = 0; +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_FunctionPrototypes X_NUCLEO_IKE01X1_HUM_TEMP_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Private_Functions X_NUCLEO_IKE01X1_HUM_TEMP_Private_Functions + * @{ + */ + +/** + * @brief Set HUM_TEMP Initialization. + * @param None + * @retval HUM_TEMP_OK if no problem during initialization + */ +uint8_t BSP_HUM_TEMP_Init(void) +{ + uint8_t ret = HUM_TEMP_ERROR; +// uint16_t ctrl = 0x0000; + HUM_TEMP_InitTypeDef HTS221_InitStructure; + + /* Initialize the hum_temp driver structure */ + Hum_tempDrv = &Hts221Drv; + + /* Configure sensor */ + HTS221_InitStructure.OutputDataRate = HTS221_ODR_12_5Hz; + + /* Hts221 Init */ + Hum_tempDrv->Init(&HTS221_InitStructure); + + if(Hum_tempDrv->ReadID() == I_AM_HTS221) + { + HumTempInitialized = 1; + ret = HUM_TEMP_OK; + } + + return ret; +} + +uint8_t BSP_HUM_TEMP_isInitialized(void) +{ + return HumTempInitialized; +} + +/** + * @brief Read ID of hum_temp component + * @param None + * @retval ID + */ +uint8_t BSP_HUM_TEMP_ReadID(void) +{ + uint8_t id = 0x00; + + if(Hum_tempDrv->ReadID != NULL) + { + id = Hum_tempDrv->ReadID(); + } + return id; +} + +/** + * @brief Reboot memory content of hum_temp + * @param None + * @retval None + */ +void BSP_HUM_TEMP_Reset(void) +{ + if(Hum_tempDrv->Reset != NULL) + { + Hum_tempDrv->Reset(); + } +} + + +/** + * @brief Configure INT1 interrupt + * @param pIntConfig: pointer to a HUM_TEMP_InterruptConfig_TypeDef + * structure that contains the configuration setting for the HTS221 Interrupt. + * @retval None + */ +void BSP_HUM_TEMP_ITConfig(void/*HUM_TEMP_InterruptConfigTypeDef *pIntConfig*/) +{ + // uint16_t interruptconfig = 0x0000; + + // if(Hum_tempDrv->ConfigIT != NULL) + // { + // /* Configure latch Interrupt request and axe interrupts */ + // interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ + // pIntConfig->Interrupt_Axes) << 8); + + // interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); + + // Hum_tempDrv->ConfigIT(interruptconfig); + // } +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg HTS221_INT1 + * @arg HTS221_INT2 + * @retval None + */ +void BSP_HUM_TEMP_EnableIT(uint8_t IntPin) +{ + if(Hum_tempDrv->EnableIT != NULL) + { + Hum_tempDrv->EnableIT(IntPin); + } +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg HTS221_INT1 + * @arg HTS221_INT2 + * @retval None + */ +void BSP_HUM_TEMP_DisableIT(uint8_t IntPin) +{ + if(Hum_tempDrv->DisableIT != NULL) + { + Hum_tempDrv->DisableIT(IntPin); + } +} + + +/** + * @brief Power OFF HUM_TEMP sensor. + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_HUM_TEMP_PowerOFF() +{ + if(Hum_tempDrv->PowerOFF!= NULL) + { + Hum_tempDrv->PowerOFF(); + } +} + + +/** + * @brief Get Humidity value + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_HUM_TEMP_GetHumidity(float* pfData) +{ + if(Hum_tempDrv->GetHumidity!= NULL) + { + Hum_tempDrv->GetHumidity(pfData); + } +} + +/** + * @brief Get Temperature value + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_HUM_TEMP_GetTemperature(float* pfData) +{ + if(Hum_tempDrv->GetTemperature!= NULL) + { + Hum_tempDrv->GetTemperature(pfData); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_hum_temp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_hum_temp.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,138 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_hum_temp.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 08-April-2014 + * @brief This file contains definitions for x_nucleo_ike01x1_hum_temp.c + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __X_NUCLEO_IKE01X1_HUM_TEMP_H +#define __X_NUCLEO_IKE01X1_HUM_TEMP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +//#include "x_nucleo_ike01x1.h" +/* Include HUM_TEMP sensor component driver */ +#include "../Components/hts221/hts221.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_HUM_TEMP + * @{ + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Types X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Types + * @{ + */ +typedef enum +{ + HUM_TEMP_OK = 0, + HUM_TEMP_ERROR = 1, + HUM_TEMP_TIMEOUT = 2 +} +HUM_TEMP_StatusTypeDef; + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Constants X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Constants + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Macros X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Functions X_NUCLEO_IKE01X1_HUM_TEMP_Exported_Functions + * @{ + */ + +/* Sensor Configuration Functions */ +uint8_t BSP_HUM_TEMP_Init(void); +uint8_t BSP_HUM_TEMP_isInitialized(void); +void BSP_HUM_TEMP_PowerOFF(void); +uint8_t BSP_HUM_TEMP_ReadID(void); +void BSP_HUM_TEMP_Reset(void); +void BSP_HUM_TEMP_ITConfig(void/*HUM_TEMP_InterruptConfigTypeDef *pIntConfigStruct*/); +void BSP_HUM_TEMP_EnableIT(uint8_t IntPin); +void BSP_HUM_TEMP_DisableIT(uint8_t IntPin); +void BSP_HUM_TEMP_GetHumidity(float* pfData); +void BSP_HUM_TEMP_GetTemperature(float* pfData); + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif + +#endif /* __X_NUCLEO_IKE01X1_HUM_TEMP_H */ + + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_pressure.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_pressure.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,268 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_pressure.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 9-April-2014 + * @brief This file provides a set of functions needed to manage the uvis3 sensor. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "x_nucleo_ike01x1_pressure.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_PRESSURE + * @{ + */ + + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_TypesDefinitions X_NUCLEO_IKE01X1_PRESSURE_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_Defines X_NUCLEO_IKE01X1_PRESSURE_Private_Defines + * @{ + */ +#ifndef NULL + #define NULL (void *) 0 +#endif +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_Macros X_NUCLEO_IKE01X1_PRESSURE_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_Variables X_NUCLEO_IKE01X1_PRESSURE_Private_Variables + * @{ + */ +static PRESSURE_DrvTypeDef *PressureDrv; +static uint8_t PressureInitialized = 0; + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_FunctionPrototypes X_NUCLEO_IKE01X1_PRESSURE_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Private_Functions X_NUCLEO_IKE01X1_PRESSURE_Private_Functions + * @{ + */ + +/** + * @brief Initialization pressure sensor. + * @param None + * @retval PRESSURE_OK if no problem during initialization + */ +uint8_t BSP_PRESSURE_Init(void) +{ + uint8_t ret = PRESSURE_ERROR; + PRESSURE_InitTypeDef LPS25H_InitStructure; + + LPS25H_SlaveAddrRemap(LPS25H_SA0_HIGH); + + /* Initialize the uv driver structure */ + PressureDrv = &LPS25HDrv; + + /* Configure sensor */ + LPS25H_InitStructure.OutputDataRate = LPS25H_ODR_1Hz; + LPS25H_InitStructure.BlockDataUpdate = LPS25H_BDU_CONT; + LPS25H_InitStructure.DiffEnable = LPS25H_DIFF_ENABLE; + LPS25H_InitStructure.SPIMode = LPS25H_SPI_SIM_3W; + LPS25H_InitStructure.PressureResolution = LPS25H_P_RES_AVG_32; + LPS25H_InitStructure.TemperatureResolution = LPS25H_T_RES_AVG_16; + + /* Pressure sensor init */ + PressureDrv->Init(&LPS25H_InitStructure); + + if(PressureDrv->ReadID() == I_AM_LPS25H) + { + PressureInitialized = 1; + ret = PRESSURE_OK; + } + + return ret; +} + +uint8_t BSP_PRESSURE_isInitialized(void) +{ + return PressureInitialized; +} + +/** + * @brief Read ID of Uv component + * @param None + * @retval ID + */ +uint8_t BSP_PRESSURE_ReadID(void) +{ + uint8_t id = 0x00; + + if(PressureDrv->ReadID != NULL) + { + id = PressureDrv->ReadID(); + } + return id; +} + +/** + * @brief Reboot memory content of UV + * @param None + * @retval None + */ +void BSP_PRESSURE_Reset(void) +{ + if(PressureDrv->Reset != NULL) + { + PressureDrv->Reset(); + } +} + + +/** + * @brief Configure INT1 interrupt + * @param pIntConfig: pointer to a PRESSURE_InterruptConfig_TypeDef + * structure that contains the configuration setting for the PRESSURE Interrupt. + * @retval None + */ +void BSP_PRESSURE_ITConfig(void/*PRESSURE_InterruptConfigTypeDef *pIntConfig*/) +{ + // uint16_t interruptconfig = 0x0000; + + // if(UvDrv->ConfigIT != NULL) + // { + // /* Configure latch Interrupt request and axe interrupts */ + // interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ + // pIntConfig->Interrupt_Axes) << 8); + + // interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); + + // UvDrv->ConfigIT(interruptconfig); + // } +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg PRESSURE_INT1 + * @arg PRESSURE_INT2 + * @retval None + */ +void BSP_PRESSURE_EnableIT(uint8_t IntPin) +{ + if(PressureDrv->EnableIT != NULL) + { + PressureDrv->EnableIT(IntPin); + } +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg PRESSURE_INT1 + * @arg PRESSURE_INT2 + * @retval None + */ +void BSP_PRESSURE_DisableIT(uint8_t IntPin) +{ + if(PressureDrv->DisableIT != NULL) + { + PressureDrv->DisableIT(IntPin); + } +} + +/** + * @brief Get Pressure + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_PRESSURE_GetPressure(float* pfData) +{ + if(PressureDrv->GetPressure!= NULL) + { + PressureDrv->GetPressure(pfData); + } +} + +/** + * @brief Get Temperature + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_PRESSURE_GetTemperature(float* pfData) +{ + if(PressureDrv->GetTemperature!= NULL) + { + PressureDrv->GetTemperature(pfData); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_pressure.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_pressure.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,143 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_pressure.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 9-April-2014 + * @brief This file contains definitions for x_nucleo_ike01x1_pressure.c + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __X_NUCLEO_IKE01X1_PRESSURE_H +#define __X_NUCLEO_IKE01X1_PRESSURE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +//#include "x_nucleo_ike01x1.h" +/* Include UV sensor component driver */ +#include "../Components/lps25h/lps25h.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_PRESSURE + * @{ + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Exported_Types X_NUCLEO_IKE01X1_PRESSURE_Exported_Types + * @{ + */ +typedef enum { + PRESSURE_OK = 0, + PRESSURE_ERROR = 1, + PRESSURE_TIMEOUT = 2 +} PRESSURE_StatusTypeDef; + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Exported_Constants X_NUCLEO_IKE01X1_PRESSURE_Exported_Constants + * @{ + */ + +/** + * @addtogroup LPS25H_CS_Define + * @{ + */ +#define LPS25H_CS_Port GPIOH +#define LPS25H_CS_Pin GPIO_PIN_5 +#define LPS25H_CS_GPIO_CLK_ENABLE() __GPIOH_CLK_ENABLE() + +/** +*@} +*/ /* end of group LPS25H_CS_Define */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Exported_Macros X_NUCLEO_IKE01X1_PRESSURE_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_PRESSURE_Exported_Functions X_NUCLEO_IKE01X1_PRESSURE_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +uint8_t BSP_PRESSURE_Init(void); +uint8_t BSP_PRESSURE_isInitialized(void); +void BSP_PRESSURE_Reset(void); +uint8_t BSP_PRESSURE_ReadID(void); +void BSP_PRESSURE_ITConfig( + void/*PRESSURE_InterruptConfigTypeDef *pIntConfigStruct*/); +void BSP_PRESSURE_EnableIT(uint8_t IntPin); +void BSP_PRESSURE_DisableIT(uint8_t IntPin); +void BSP_PRESSURE_GetPressure(float* pfData); +void BSP_PRESSURE_GetTemperature(float* pfData); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __X_NUCLEO_IKE01X1_PRESSURE_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_uv.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_uv.c Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,250 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_uv.c + * @author AST Robotics Team + * @version V0.0.1 + * @date 10-March-2014 + * @brief This file provides a set of functions needed to manage the uvis3 sensor. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "x_nucleo_ike01x1_uv.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_UV + * @{ + */ + + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_TypesDefinitions X_NUCLEO_IKE01X1_UV_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_Defines X_NUCLEO_IKE01X1_UV_Private_Defines + * @{ + */ +#ifndef NULL + #define NULL (void *) 0 +#endif +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_Macros X_NUCLEO_IKE01X1_UV_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_Variables X_NUCLEO_IKE01X1_UV_Private_Variables + * @{ + */ +static UV_DrvTypeDef *UvDrv; +static uint8_t UvInitialized = 0; + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_FunctionPrototypes X_NUCLEO_IKE01X1_UV_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Private_Functions X_NUCLEO_IKE01X1_UV_Private_Functions + * @{ + */ + +/** + * @brief Set UV Initialization. + * @param None + * @retval UV_OK if no problem during initialization + */ +uint8_t BSP_UV_Init(void) +{ + uint8_t ret = UV_ERROR; + UV_InitTypeDef UVIS3_InitStructure; + //UV_FilterConfigTypeDef UVIS3_FilterStructure={0,0}; + + /* Initialize the uv driver structure */ + UvDrv = &Uvis3Drv; + + /* Configure sensor */ + UVIS3_InitStructure.Power_Mode = UVIS3_MODE_ACTIVE; + UVIS3_InitStructure.Output_DataRate = UVIS3_ODR_1HZ; + + /* Uvis3 Init */ + UvDrv->Init(&UVIS3_InitStructure); + + if(UvDrv->ReadID() == I_AM_UVIS3) + { + UvInitialized = 1; + ret = UV_OK; + } + + return ret; +} + +uint8_t BSP_UV_isInitialized(void) +{ + return UvInitialized; +} + +/** + * @brief Read ID of Uv component + * @param None + * @retval ID + */ +uint8_t BSP_UV_ReadID(void) +{ + uint8_t id = 0x00; + + if(UvDrv->ReadID != NULL) + { + id = UvDrv->ReadID(); + } + return id; +} + +/** + * @brief Reboot memory content of UV + * @param None + * @retval None + */ +void BSP_UV_Reset(void) +{ + if(UvDrv->Reset != NULL) + { + UvDrv->Reset(); + } +} + + +/** + * @brief Configure INT1 interrupt + * @param pIntConfig: pointer to a UVIS3_InterruptConfig_TypeDef + * structure that contains the configuration setting for the UVIS3 Interrupt. + * @retval None + */ +void BSP_UV_ITConfig(void/*UV_InterruptConfigTypeDef *pIntConfig*/) +{ + // uint16_t interruptconfig = 0x0000; + + // if(UvDrv->ConfigIT != NULL) + // { + // /* Configure latch Interrupt request and axe interrupts */ + // interruptconfig |= ((uint8_t)(pIntConfig->Latch_Request| \ + // pIntConfig->Interrupt_Axes) << 8); + + // interruptconfig |= (uint8_t)(pIntConfig->Interrupt_ActiveEdge); + + // UvDrv->ConfigIT(interruptconfig); + // } +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void BSP_UV_EnableIT(uint8_t IntPin) +{ + if(UvDrv->EnableIT != NULL) + { + UvDrv->EnableIT(IntPin); + } +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void BSP_UV_DisableIT(uint8_t IntPin) +{ + if(UvDrv->DisableIT != NULL) + { + UvDrv->DisableIT(IntPin); + } +} + +/** + * @brief Get Index UV + * @param pfData: pointer on floating data + * @retval None + */ +void BSP_UV_GetIndex(float* pfData) +{ + if(UvDrv->GetIndex!= NULL) + { + UvDrv->GetIndex(pfData); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_uv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP/X-NUCLEO-IKE01x1/x_nucleo_ike01x1_uv.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,134 @@ +/** + ****************************************************************************** + * @file x_nucleo_ike01x1_uv.h + * @author AST Robotics Team + * @version V0.0.1 + * @date 10-March-2014 + * @brief This file contains definitions for x_nucleo_ike01x1_uv.c + * firmware driver. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 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. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __X_NUCLEO_IKE01X1_UV_H +#define __X_NUCLEO_IKE01X1_UV_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +//#include "x_nucleo_ike01x1.h" +/* Include UV sensor component driver */ +#include "../Components/uvis3/uvis3.h" + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1 + * @{ + */ + +/** @addtogroup X_NUCLEO_IKE01X1_UV + * @{ + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Exported_Types X_NUCLEO_IKE01X1_UV_Exported_Types + * @{ + */ +typedef enum +{ + UV_OK = 0, + UV_ERROR = 1, + UV_TIMEOUT = 2 +} +UV_StatusTypeDef; + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Exported_Constants X_NUCLEO_IKE01X1_UV_Exported_Constants + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Exported_Macros X_NUCLEO_IKE01X1_UV_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup X_NUCLEO_IKE01X1_UV_Exported_Functions X_NUCLEO_IKE01X1_UV_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +uint8_t BSP_UV_Init(void); +uint8_t BSP_UV_isInitialized(void); +void BSP_UV_Reset(void); +uint8_t BSP_UV_ReadID(void); +void BSP_UV_ITConfig(void/*UV_InterruptConfigTypeDef *pIntConfigStruct*/); +void BSP_UV_EnableIT(uint8_t IntPin); +void BSP_UV_DisableIT(uint8_t IntPin); +void BSP_UV_GetIndex(float* pfData); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif + +#endif /* __X_NUCLEO_IKE01X1_UV_H */ + + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +
diff -r 000000000000 -r 9e645e6ed2ce Envt_Shield_F4_API.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Envt_Shield_F4_API.cpp Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,191 @@ +#include "nucleo-f401re.h" +#include "Envt_Shield_F4_API.h" +/*#include "x_nucleo_ike01x1_hum_temp.h" +#include "x_nucleo_ike01x1_pressure.h" +#include "x_nucleo_ike01x1_uv.h"*/ + + +uint8_t Envt_Shield_API::Pressure_Init(void) +{ + uint8_t ret= BSP_PRESSURE_Init(); + return ret; +} + +uint8_t Envt_Shield_API::Pressure_isInitialized(void) +{ + uint8_t PressureInitialised=BSP_PRESSURE_isInitialized(); + return PressureInitialised; +} + +void Envt_Shield_API::Pressure_Reset(void) +{ + BSP_PRESSURE_Reset(); +} + +uint8_t Envt_Shield_API::Pressure_ReadID(void) +{ + uint8_t id = BSP_PRESSURE_ReadID(); + return id; +} + +void Envt_Shield_API::Pressure_ITConfig( + void/*PRESSURE_InterruptConfigTypeDef *pIntConfigStruct*/) +{ + BSP_PRESSURE_ITConfig(); +} + +void Envt_Shield_API::Pressure_EnableIT(uint8_t IntPin) +{ + BSP_PRESSURE_EnableIT(IntPin); +} + +void Envt_Shield_API::Pressure_DisableIT(uint8_t IntPin) +{ + BSP_PRESSURE_DisableIT(IntPin); +} + +void Envt_Shield_API::Pressure_GetPressure(float* pfData) +{ + BSP_PRESSURE_GetPressure(pfData); +} + +void Envt_Shield_API::Pressure_GetTemperature(float* pfData) +{ + BSP_PRESSURE_GetTemperature(pfData); +} + + +uint8_t Envt_Shield_API::Hum_Temp_Init(void) +{ + uint8_t ret = BSP_HUM_TEMP_Init(); + return ret; +} + +uint8_t Envt_Shield_API::Hum_Temp_isInitialized(void) +{ + uint8_t HumpTempInitialised=BSP_HUM_TEMP_isInitialized(); + return HumpTempInitialised; +} + +void Envt_Shield_API::Hum_Temp_Reset(void) +{ + BSP_HUM_TEMP_Reset(); +} + +uint8_t Envt_Shield_API::Hum_Temp_ReadID(void) +{ + uint8_t id = BSP_HUM_TEMP_ReadID(); + return id; +} + +void Envt_Shield_API::Hum_Temp_ITConfig( + void/*HUM_TEMP_InterruptConfigTypeDef *pIntConfig*/) +{ + BSP_HUM_TEMP_ITConfig(); +} + +void Envt_Shield_API::Hum_Temp_EnableIT(uint8_t IntPin) +{ + BSP_HUM_TEMP_EnableIT(IntPin); +} + +void Envt_Shield_API::Hum_Temp_DisableIT(uint8_t IntPin) +{ + BSP_HUM_TEMP_DisableIT(IntPin); +} + +void Envt_Shield_API::Hum_Temp_GetHumidity(float* pfData) +{ + BSP_HUM_TEMP_GetHumidity(pfData); +} + +void Envt_Shield_API::Hum_Temp_GetTemperature(float* pfData) +{ + BSP_HUM_TEMP_GetTemperature(pfData); +} + +void Envt_Shield_API::Hum_Temp_PowerOFF() +{ + BSP_HUM_TEMP_PowerOFF(); +} + +uint8_t Envt_Shield_API::UV_Init(void) +{ + uint8_t ret = BSP_UV_Init(); + return ret; +} + +uint8_t Envt_Shield_API::UV_isInitialized(void) +{ + uint8_t UvInitialized=BSP_UV_isInitialized(); + return UvInitialized; +} + +/** + * @brief Read ID of Uv component + * @param None + * @retval ID + */ +uint8_t Envt_Shield_API::UV_ReadID(void) +{ + uint8_t id = BSP_UV_ReadID(); + return id; +} + +/** + * @brief Reboot memory content of UV + * @param None + * @retval None + */ +void Envt_Shield_API::UV_Reset(void) +{ + BSP_UV_Reset(); +} + + +/** + * @brief Configure INT1 interrupt + * @param pIntConfig: pointer to a UVIS3_InterruptConfig_TypeDef + * structure that contains the configuration setting for the UVIS3 Interrupt. + * @retval None + */ +void Envt_Shield_API::UV_ITConfig(void/*UV_InterruptConfigTypeDef *pIntConfig*/) +{ + BSP_UV_ITConfig(); +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void Envt_Shield_API::UV_EnableIT(uint8_t IntPin) +{ + BSP_UV_EnableIT(IntPin); +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void Envt_Shield_API::UV_DisableIT(uint8_t IntPin) +{ + BSP_UV_DisableIT(IntPin); +} + +/** + * @brief Get Index UV + * @param pfData: pointer on floating data + * @retval None + */ +void Envt_Shield_API::UV_GetIndex(float* pfData) +{ + BSP_UV_GetIndex(pfData); +} \ No newline at end of file
diff -r 000000000000 -r 9e645e6ed2ce Envt_Shield_F4_API.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Envt_Shield_F4_API.h Tue Aug 19 07:13:15 2014 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include "x_nucleo_ike01x1_hum_temp.h" +#include "x_nucleo_ike01x1_pressure.h" +#include "x_nucleo_ike01x1_uv.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + +class Envt_Shield_API +{ + public: + + uint8_t Pressure_Init(void); + uint8_t Pressure_isInitialized(void); + void Pressure_Reset(void); + uint8_t Pressure_ReadID(void); + void Pressure_ITConfig(void/*PRESSURE_InterruptConfigTypeDef *pIntConfigStruct*/); + void Pressure_EnableIT(uint8_t IntPin); + void Pressure_DisableIT(uint8_t IntPin); + void Pressure_GetPressure(float* pfData); + void Pressure_GetTemperature(float* pfData); + uint8_t Hum_Temp_Init(void); + uint8_t Hum_Temp_isInitialized(void); + void Hum_Temp_Reset(void); + uint8_t Hum_Temp_ReadID(void); + void Hum_Temp_ITConfig(void/*HUM_TEMP_InterruptConfigTypeDef *pIntConfig*/); + void Hum_Temp_EnableIT(uint8_t IntPin); + void Hum_Temp_DisableIT(uint8_t IntPin); + void Hum_Temp_GetHumidity(float* pfData); + void Hum_Temp_GetTemperature(float* pfData); + void Hum_Temp_PowerOFF(); + uint8_t UV_Init(void); + uint8_t UV_isInitialized(void); + uint8_t UV_ReadID(void); + void UV_Reset(void); + void UV_ITConfig(void/*UV_InterruptConfigTypeDef *pIntConfig*/); + void UV_EnableIT(uint8_t IntPin); + void UV_DisableIT(uint8_t IntPin); + void UV_GetIndex(float* pfData); +}; + +#ifdef __cplusplus +} +#endif \ No newline at end of file