Library I2C pins modification to fit nucleo 32 pins modules
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: STM32_MagneticLight
Fork of X_NUCLEO_IKS01A1 by
Revision 3:088aa5839e0d, committed 2015-04-13
- Comitter:
- Wolfgang Betz
- Date:
- Mon Apr 13 14:44:02 2015 +0200
- Parent:
- 2:5f95b745eedb
- Child:
- 4:566f2c41dc1d
- Commit message:
- Provide first skeleton for abstract classes
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/HumTemp.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,74 @@
+/**
+ ******************************************************************************
+ * @file HumTemp.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief This file contains the abstract class describing in general
+ * the interfaces of a humidity and temperature sensor
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 from recursive inclusion --------------------------------*/
+#ifndef __HUM_TEMP_H
+#define __HUM_TEMP_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "hum_temp.h"
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for HumTemp components
+ */
+class HumTemp
+{
+ public:
+ virtual HUM_TEMP_StatusTypeDef Init(HUM_TEMP_InitTypeDef&) = 0;
+
+ virtual HUM_TEMP_StatusTypeDef PowerOFF(void) = 0;
+ virtual HUM_TEMP_StatusTypeDef ReadID(uint8_t&) = 0;
+ virtual HUM_TEMP_StatusTypeDef Reset(void) = 0;
+
+ virtual void ConfigIT(uint16_t) = 0;
+ virtual void EnableIT(uint8_t) = 0;
+ virtual void DisableIT(uint8_t) = 0;
+ virtual uint8_t ITStatus(uint16_t, uint16_t) = 0;
+ virtual void ClearIT(uint16_t, uint16_t) = 0;
+
+ virtual HUM_TEMP_StatusTypeDef GetHumidity(float&) = 0;
+ virtual HUM_TEMP_StatusTypeDef GetTemperature(float& = 0);
+
+ virtual void AttachIT(void (*fptr)(void)) = 0;
+
+ protected:
+ HumTemp(void) {};
+};
+
+#endif /* __HUM_TEMP_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/Imu6Axis.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,64 @@
+/**
+ ******************************************************************************
+ * @file Imu6Axis.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief This file contains the abstract class describing in general
+ * the interfaces of a 6-axis accelerometer and gyroscope
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 from recursive inclusion --------------------------------*/
+#ifndef __IMU_6AXIS_H
+#define __IMU_6AXIS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "imu_6axis.h"
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Imu6Axis components
+ */
+class Imu6Axis
+{
+ public:
+ virtual IMU_6AXIS_StatusTypeDef Init(IMU_6AXIS_InitTypeDef&) = 0;
+ virtual IMU_6AXIS_StatusTypeDef Read_XG_ID(uint8_t&) = 0;
+ virtual IMU_6AXIS_StatusTypeDef Get_X_Axes(int32_t&) = 0;
+ virtual IMU_6AXIS_StatusTypeDef Get_G_Axes(int32_t&) = 0;
+ virtual IMU_6AXIS_StatusTypeDef Get_X_Sensitivity(float&) = 0;
+ virtual IMU_6AXIS_StatusTypeDef Get_G_Sensitivity(float&) = 0;
+
+ protected:
+ Imu6Axis(void) {};
+};
+
+#endif /* __IMU_6AXIS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/Magneto.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,61 @@
+/**
+ ******************************************************************************
+ * @file Magneto.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief This file contains the abstract class describing in general
+ * the interfaces of a magnetometer
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 from recursive inclusion --------------------------------*/
+#ifndef __MAGNETO_CLASS_H
+#define __MAGNETO_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "magneto.h"
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Magneto components
+ */
+class Magneto
+{
+ public:
+ virtual MAGNETO_StatusTypeDef Init(MAGNETO_InitTypeDef&) = 0;
+ virtual MAGNETO_StatusTypeDef Read_M_ID(uint8_t&) = 0;
+ virtual MAGNETO_StatusTypeDef Get_M_Axes(int32_t&) = 0;
+
+ protected:
+ Magneto(void) {};
+};
+
+#endif /* __MAGNETO_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/Pressure.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,75 @@
+/**
+ ******************************************************************************
+ * @file Pressure.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief This file contains the abstract class describing in general
+ * the interfaces of a pressure sensor
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 from recursive inclusion --------------------------------*/
+#ifndef __PRESSURE_CLASS_H
+#define __PRESSURE_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "pressure.h"
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Pressure components
+ */
+class Pressure
+{
+ public:
+ virtual PRESSURE_StatusTypeDef Init(PRESSURE_InitTypeDef&) = 0;
+
+ virtual PRESSURE_StatusTypeDef PowerOff(void) = 0;
+ virtual PRESSURE_StatusTypeDef ReadID(uint8_t&) = 0;
+ virtual PRESSURE_StatusTypeDef Reset(void) = 0;
+
+ virtual void ConfigIT(uint16_t) = 0;
+ virtual void EnableIT(uint8_t) = 0;
+ virtual void DisableIT(uint8_t) = 0;
+ virtual uint8_t ITStatus(uint16_t, uint16_t) = 0;
+ virtual void ClearIT(uint16_t, uint16_t) = 0;
+
+ virtual PRESSURE_StatusTypeDef GetPressure(float&) = 0;
+ virtual PRESSURE_StatusTypeDef GetTemperature(float&) = 0;
+ virtual void SlaveAddrRemap(uint8_t) = 0;
+
+ virtual void AttachIT(void (*fptr)(void)) = 0;
+
+ protected:
+ Pressure(void) {};
+};
+
+#endif /* __PRESSURE_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/hum_temp.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,147 @@
+/**
+ ******************************************************************************
+ * @file hum_temp.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 28-January-2015
+ * @brief This header file contains the functions prototypes for the
+ * humidity and temperature driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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>
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup HUM_TEMP
+ * @{
+ */
+
+/** @defgroup HUM_TEMP_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief Humidity and temperature init structure definition
+ */
+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 status enumerator definition
+ */
+typedef enum {
+ HUM_TEMP_OK = 0,
+ HUM_TEMP_ERROR = 1,
+ HUM_TEMP_TIMEOUT = 2,
+ HUM_TEMP_NOT_IMPLEMENTED = 3
+} HUM_TEMP_StatusTypeDef;
+
+/**
+ * @brief Humidity and temperature component id enumerator definition
+ */
+typedef enum {
+ HUM_TEMP_NONE_COMPONENT = 0,
+ HUM_TEMP_HTS221_COMPONENT = 1
+} HUM_TEMP_ComponentTypeDef;
+
+/**
+ * @brief Humidity and temperature driver extended structure definition
+ */
+typedef struct {
+ HUM_TEMP_ComponentTypeDef id; /* This id must be unique for each component belonging to this class that wants to extend common class */
+ void *pData; /* This pointer is specific for each component */
+}HUM_TEMP_DrvExtTypeDef;
+
+/**
+ * @brief Humidity and temperature driver structure definition
+ */
+typedef struct
+{
+ HUM_TEMP_StatusTypeDef (*Init)(HUM_TEMP_InitTypeDef *);
+ HUM_TEMP_StatusTypeDef (*PowerOFF)(void);
+ HUM_TEMP_StatusTypeDef (*ReadID)(uint8_t *);
+ HUM_TEMP_StatusTypeDef (*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);
+ HUM_TEMP_StatusTypeDef (*GetHumidity)(float *);
+ HUM_TEMP_StatusTypeDef (*GetTemperature)(float *);
+ HUM_TEMP_DrvExtTypeDef *extData;
+}HUM_TEMP_DrvTypeDef;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HUM_TEMP_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/imu_6axis.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,146 @@
+/**
+ ******************************************************************************
+ * @file imu_6axis.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 28-January-2015
+ * @brief This header file contains the functions prototypes for the
+ * accelerometer and gyroscope driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 __IMU_6AXIS_H
+#define __IMU_6AXIS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup IMU_6AXIS
+ * @{
+ */
+
+/** @defgroup IMU_6AXIS_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief IMU_6AXIS init structure definition
+ */
+typedef struct
+{
+ uint8_t G_OutputDataRate;
+ uint8_t G_FullScale;
+ uint8_t G_X_Axis;
+ uint8_t G_Y_Axis;
+ uint8_t G_Z_Axis;
+ uint8_t X_OutputDataRate;
+ uint8_t X_FullScale;
+ uint8_t X_X_Axis;
+ uint8_t X_Y_Axis;
+ uint8_t X_Z_Axis;
+}IMU_6AXIS_InitTypeDef;
+
+/**
+ * @brief IMU_6AXIS status enumerator definition
+ */
+typedef enum {
+ IMU_6AXIS_OK = 0,
+ IMU_6AXIS_ERROR = 1,
+ IMU_6AXIS_TIMEOUT = 2,
+ IMU_6AXIS_NOT_IMPLEMENTED = 3
+} IMU_6AXIS_StatusTypeDef;
+
+/**
+ * @brief IMU_6AXIS component id enumerator definition
+ */
+typedef enum {
+ IMU_6AXIS_NONE_COMPONENT = 0,
+ IMU_6AXIS_LSM6DS0_COMPONENT = 1,
+ IMU_6AXIS_LSM6DS3_DIL24_COMPONENT = 2
+} IMU_6AXIS_ComponentTypeDef;
+
+/**
+ * @brief IMU_6AXIS driver extended structure definition
+ */
+typedef struct {
+ IMU_6AXIS_ComponentTypeDef id; /* This id must be unique for each component belonging to this class that wants to extend common class */
+ void *pData; /* This pointer is specific for each component */
+}IMU_6AXIS_DrvExtTypeDef;
+
+/**
+ * @brief IMU_6AXIS driver structure definition
+ */
+typedef struct {
+ IMU_6AXIS_StatusTypeDef (*Init)(IMU_6AXIS_InitTypeDef *);
+ IMU_6AXIS_StatusTypeDef (*Read_XG_ID)(uint8_t *);
+ IMU_6AXIS_StatusTypeDef (*Get_X_Axes)(int32_t *);
+ IMU_6AXIS_StatusTypeDef (*Get_G_Axes)(int32_t *);
+ IMU_6AXIS_StatusTypeDef (*Get_X_Sensitivity) (float *);
+ IMU_6AXIS_StatusTypeDef (*Get_G_Sensitivity) (float *);
+ IMU_6AXIS_DrvExtTypeDef *extData;
+}IMU_6AXIS_DrvTypeDef;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IMU_6AXIS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/magneto.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,137 @@
+/**
+ ******************************************************************************
+ * @file magneto.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 28-January-2015
+ * @brief This header file contains the functions prototypes for the
+ * magneto driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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 __MAGNETO_H
+#define __MAGNETO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup MAGNETO
+ * @{
+ */
+
+/** @defgroup MAGNETO_Exported_Types
+ * @{
+ */
+
+/**
+* @brief MAGNETO init structure definition
+*/
+typedef struct
+{
+ uint8_t M_OutputDataRate;
+ uint8_t M_OperatingMode;
+ uint8_t M_FullScale;
+ uint8_t M_XYOperativeMode;
+}MAGNETO_InitTypeDef;
+
+/**
+* @brief MAGNETO status enumerator definition
+*/
+typedef enum {
+ MAGNETO_OK = 0,
+ MAGNETO_ERROR = 1,
+ MAGNETO_TIMEOUT = 2,
+ MAGNETO_NOT_IMPLEMENTED = 3
+} MAGNETO_StatusTypeDef;
+
+/**
+ * @brief MAGNETO component id enumerator definition
+ */
+typedef enum {
+ MAGNETO_NONE_COMPONENT = 0,
+ MAGNETO_LIS3MDL_COMPONENT = 1
+} MAGNETO_ComponentTypeDef;
+
+/**
+ * @brief MAGNETO driver extended structure definition
+ */
+typedef struct {
+ MAGNETO_ComponentTypeDef id; /* This id must be unique for each component belonging to this class that wants to extend common class */
+ void *pData; /* This pointer is specific for each component */
+}MAGNETO_DrvExtTypeDef;
+
+/**
+* @brief MAGNETO driver structure definition
+*/
+typedef struct
+{
+ MAGNETO_StatusTypeDef (*Init)(MAGNETO_InitTypeDef *);
+ MAGNETO_StatusTypeDef (*Read_M_ID)(uint8_t *);
+ MAGNETO_StatusTypeDef (*Get_M_Axes)(int32_t *);
+ MAGNETO_DrvExtTypeDef *extData;
+}MAGNETO_DrvTypeDef;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MAGNETO_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/pressure.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,149 @@
+/**
+ ******************************************************************************
+ * @file pressure.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 28-January-2015
+ * @brief This header file contains the functions prototypes for the
+ * pressure driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 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>
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup PRESSURE
+ * @{
+ */
+
+/** @defgroup PRESSURE_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief PRESSURE init structure definition
+ */
+typedef struct
+{
+ uint8_t OutputDataRate;
+ uint8_t PressureResolution;
+ uint8_t TemperatureResolution;
+ uint8_t DiffEnable;
+ uint8_t BlockDataUpdate;
+ uint8_t SPIMode;
+} PRESSURE_InitTypeDef;
+
+/**
+ * @brief PRESSURE status enumerator definition
+ */
+typedef enum {
+ PRESSURE_OK = 0,
+ PRESSURE_ERROR = 1,
+ PRESSURE_TIMEOUT = 2,
+ PRESSURE_NOT_IMPLEMENTED = 3
+} PRESSURE_StatusTypeDef;
+
+/**
+ * @brief PRESSURE component id enumerator definition
+ */
+typedef enum {
+ PRESSURE_NONE_COMPONENT = 0,
+ PRESSURE_LPS25H_COMPONENT = 1,
+ PRESSURE_LPS25HB_DIL24_COMPONENT = 2
+} PRESSURE_ComponentTypeDef;
+
+/**
+ * @brief PRESSURE driver extended structure definition
+ */
+typedef struct {
+ PRESSURE_ComponentTypeDef id; /* This id must be unique for each component belonging to this class that wants to extend common class */
+ void *pData; /* This pointer is specific for each component */
+}PRESSURE_DrvExtTypeDef;
+
+/**
+ * @brief PRESSURE driver structure definition
+ */
+typedef struct
+{
+ PRESSURE_StatusTypeDef (*Init)(PRESSURE_InitTypeDef *);
+ PRESSURE_StatusTypeDef (*PowerOff)(void);
+ PRESSURE_StatusTypeDef (*ReadID)(uint8_t *);
+ PRESSURE_StatusTypeDef (*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);
+ PRESSURE_StatusTypeDef (*GetPressure)(float *);
+ PRESSURE_StatusTypeDef (*GetTemperature)(float *);
+ void (*SlaveAddrRemap)(uint8_t);
+ PRESSURE_DrvExtTypeDef *extData;
+}PRESSURE_DrvTypeDef;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PRESSURE_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/HTS221/hts221.cpp Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,299 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_hts221.h
-* @author AST / EST
-* @version V0.0.1
-* @date 1-December-2014
-* @brief Header file for component 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 "mbed.h"
-#include "hts221.h"
-#include "hts221_platform.h"
-
-
-/* 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;
-
-/* Methods -------------------------------------------------------------------*/
-
-/**
- * @brief Read HTS221 output register, and calculate the temperature.
- * @param pfData : Data out pointer
- * @retval None
- */
-int HTS221::GetTemperature(float* pfData)
-{
- int16_t T_out, temperature_t;
- uint8_t tempReg[2] = {0,0};
- uint8_t tmp = 0x00;
- float T_degC;
- int ret=-1;//TODO:Define Error types?
-
- if(isInitialized()==0)
- {
- return ret;
- }
-
- ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
-
- /* Output Data Rate selection */
- tmp &= (HTS221_ODR_MASK);
-
- if(tmp == 0x00){
-
- ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1);
-
- /* Serial Interface Mode selection */
- tmp &= ~(HTS221_ONE_SHOT_MASK);
- tmp |= HTS221_ONE_SHOT_START;
-
- ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1);
-
- do{
-
- ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1);
- }while(!(tmp&&0x01));
-
- }
-
- ret = dev_i2c.i2c_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((double)10,(double)TEMP_DECIMAL_DIGITS));
-
- *pfData = ((float)temperature_t)/pow((double)10,(double)TEMP_DECIMAL_DIGITS);
-
- return ret;
-}
-
-
-/**
- * @brief Read HTS221 output register, and calculate the humidity.
- * @param pfData : Data out pointer
- * @retval None
- */
-int HTS221::GetHumidity(float* pfData)
-{
- int16_t H_T_out, humidity_t;
- uint8_t tempReg[2] = {0,0};
- uint8_t tmp = 0x00;
- float H_rh;
- int ret;
-
- if(isInitialized()==0)
- {
- pfData = 0;
- return ret;
- }
-
- //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_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);
- ret = dev_i2c.i2c_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);
- ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS , HTS221_CTRL_REG2_ADDR, 1);
-
- do{
-
- //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1);
- ret = dev_i2c.i2c_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);
- ret = dev_i2c.i2c_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((double)10,(double)HUM_DECIMAL_DIGITS));
-
- *pfData = ((float)humidity_t)/pow((double)10,(double)HUM_DECIMAL_DIGITS);
-
- return ret;
-}
-
-
-/**
- * @brief Read ID address of HTS221
- * @param Device ID address
- * @retval ID name
- */
-uint8_t HTS221::ReadID(void)
-{
- uint8_t tmp;
- int ret;
-
- /* Read WHO I AM register */
- //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_WHO_AM_I_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_WHO_AM_I_ADDR, 1);
-
- /* Return the ID */
- return (uint8_t)tmp;
-}
-
-/**
- * @brief Set HTS221 Initialization.
- * @param InitStruct: it contains the configuration setting for the HTS221.
- * @retval None
- */
-void HTS221::Init() {
-
- uint8_t tmp = 0x00;
- int ret;
-
- Power_ON();
-
- HTS221_Calibration();
-
- //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
-
- /* Output Data Rate selection */
- tmp &= ~(HTS221_ODR_MASK);
- tmp |= HTS221_ODR_12_5Hz;
-
- //HUM_TEMP_IO_Write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
-
- if(ReadID() == I_AM_HTS221)
- {
- HumTempInitialized = 1;
- //ret = HUM_TEMP_OK;
- }
-
- return;
-}
-
-int HTS221::Power_ON() {
-
- uint8_t tmpReg;
-
- /* Read the register content */
- int ret;
- ret = dev_i2c.i2c_read(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
- if(ret) return ret;
-
- /* Set the power down bit */
- tmpReg |= HTS221_MODE_ACTIVE;
-
- /* Write register */
- ret = dev_i2c.i2c_write(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
- if(ret) return ret;
- return ret;
-}
-
-int HTS221::HTS221_Calibration() {
-
- if(HumTempInitialized == 1)
- {
- return 1; //TODO: Error Codes definitions
- }
-
- /* 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};
-
- int ret;
- ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T0_degC_X8_ADDR, 1);
- if(ret) return ret;
-
- T0_degC_x8_L = (uint16_t)tempReg[0];
-
- ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T1_T0_MSB_X8_ADDR, 1);
- if(ret) return ret;
- T0_degC_x8_H = (uint16_t) (tempReg[0] & 0x03);
-
- T0_degC = ((float)((T0_degC_x8_H<<8) | (T0_degC_x8_L)))/8;
-
- ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T1_degC_X8_ADDR, 1);
- T1_degC_x8_L = (uint16_t)tempReg[0];
-
- ret = dev_i2c.i2c_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;
-
- ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T0_OUT_L_ADDR + 0x80, 2);
- T0_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- ret = dev_i2c.i2c_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) */
-
- ret = dev_i2c.i2c_read(&H0_rh_x2, HTS221_ADDRESS, HTS221_H0_RH_X2_ADDR, 1);
-
- ret = dev_i2c.i2c_read(&H1_rh_x2, HTS221_ADDRESS, HTS221_H1_RH_X2_ADDR, 1);
-
- ret = dev_i2c.i2c_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]);
-
- ret = dev_i2c.i2c_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;
-
- return ret;
-}
\ No newline at end of file
--- a/Components/HTS221/hts221.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_hts221.h
-* @author AST / EST
-* @version V0.0.1
-* @date 1-December-2014
-* @brief Header file for component 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.
-*
-******************************************************************************
-*/
-
-#ifndef __X_CUBE_MEMS_HTS221_H
-#define __X_CUBE_MEMS_HTS221_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "x_cube_mems_i2c.h"
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a HTS221 sensor component
- */
-class HTS221
-{
-public:
- /** Constructor
- * @param
- */
- HTS221(DevI2C &i2c) : dev_i2c(i2c) {
- HumTempInitialized = 0;
- Init();
- };
-
- int GetTemperature(float* pfData);
- int GetHumidity(float* pfData);
- void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
- uint8_t ReadID(void);
- void RebootCmd(void);
- int Power_OFF(void);
- int Power_ON(void);
- int HTS221_Calibration();
-private:
-
- uint8_t isInitialized(void)
- {
- return HumTempInitialized;
- }
-
- DevI2C &dev_i2c;
- uint8_t HumTempInitialized;
-};
-
-#endif // __X_CUBE_MEMS_HTS221_H
--- a/Components/HTS221/hts221_platform.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,541 +0,0 @@
-/**
- ******************************************************************************
- * @file hts221.h
- * @author MEMS Application Team
- * @version V1.0.0
- * @date 30-July-2014
- * @brief This file contains definitions for the hts221.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 __HTS221_PLATFORM_H
-#define __HTS221_PLATFORM_H
-
-/** @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 Humidity sensor control register 3
- * \code
- * Read/write
- * Default value: 0x00
- * [7] DRDY_H_L: Data Ready output signal active high, low (0: active high -default;1: active low)
- * [6] PP_OD: Push-pull / Open Drain selection on pin 3 (DRDY) (0: push-pull - default; 1: open drain)
- * [5:3] Reserved
- * [2] DRDY_EN: Data Ready enable (0: Data Ready disabled - default;1: Data Ready signal available on pin 3)
- * [1:0] Reserved
- * \endcode
- */
-#define HTS221_CTRL_REG3_ADDR 0x22
-
-
- /**
- * @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)
-
-
-#endif /* __HTS221_PLATFORM_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/LIS3MDL/lis3mdl.cpp Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lis3mdl.h
-* @author AST / EST
-* @version V0.0.1
-* @date 9-December-2014
-* @brief Implementation file for component LIS3MDL
-******************************************************************************
-* @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 "mbed.h"
-#include "lis3mdl.h"
-#include "lis3mdl_platform.h"
-#include <math.h>
-
-/* Methods -------------------------------------------------------------------*/
-
-/**
- * @brief Read data from LIS3MDL Magnetic sensor and calculate Magnetic in mgauss.
- * @param float *pfData
- * @retval None.
- */
-void LIS3MDL::GetAxes(AxesRaw_TypeDef *pData)
-{
- uint8_t tempReg = 0x00;
- int16_t pDataRaw[3];
- float sensitivity = 0;
- int ret;
-
- GetAxesRaw(pDataRaw);
-
- ret = dev_i2c.i2c_read(&tempReg, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
-
- tempReg &= LIS3MDL_M_FS_MASK;
-
- switch(tempReg)
- {
- case LIS3MDL_M_FS_4:
- sensitivity = 0.14;
- break;
- case LIS3MDL_M_FS_8:
- sensitivity = 0.29;
- break;
- case LIS3MDL_M_FS_12:
- sensitivity = 0.43;
- break;
- case LIS3MDL_M_FS_16:
- sensitivity = 0.58;
- break;
- }
-
- pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
- pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
- pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
-
-}
-
-/**
- * @brief Read raw data from LIS3MDL Magnetic sensor output register.
- * @param float *pfData
- * @retval None.
- */
-void LIS3MDL::GetAxesRaw(int16_t *pData)
-{
- uint8_t tempReg[2] = {0,0};
- int ret;
-
- ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_X_L_M + 0x80, 2);
-
- pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_Y_L_M + 0x80, 2);
-
- pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_Z_L_M + 0x80, 2);
-
- pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-}
-
-/**
- * @brief Read ID address of HTS221
- * @param Device ID address
- * @retval ID name
- */
-uint8_t LIS3MDL::ReadID(void)
-{
- uint8_t tmp=0x00;
- int ret;
-
- /* Read WHO I AM register */
- ret = dev_i2c.i2c_read(&tmp, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_WHO_AM_I_ADDR, 1);
-
- /* Return the ID */
- return (uint8_t)tmp;
-}
-
-/**
- * @brief Set HTS221 Initialization.
- * @param InitStruct: it contains the configuration setting for the HTS221.
- * @retval None
- */
-void LIS3MDL::Init() {
-
- uint8_t tmp1 = 0x00;
- int ret;
-
- /****** Magnetic sensor *******/
-
- ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG3_M, 1);
-
- /* Conversion mode selection */
- tmp1 &= ~(LIS3MDL_M_MD_MASK);
- tmp1 |= LIS3MDL_M_MD_CONTINUOUS;
-
- ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG3_M, 1);
-
- ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG1_M, 1);
-
- /* Output data rate selection */
- tmp1 &= ~(LIS3MDL_M_DO_MASK);
- tmp1 |= LIS3MDL_M_DO_80;
-
- /* X and Y axes Operative mode selection */
- tmp1 &= ~(LIS3MDL_M_OM_MASK);
- tmp1 |= LIS3MDL_M_OM_HP;
-
- ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG1_M, 1);
-
- ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
-
- /* Full scale selection */
- tmp1 &= ~(LIS3MDL_M_FS_MASK);
- tmp1 |= LIS3MDL_M_FS_4;
-
- ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
-
- /******************************/
-
-
- if(ReadID() == I_AM_LIS3MDL_M)
- {
- LIS3MDLInitialized = 1;
- }
-
- return;
-}
-
-
--- a/Components/LIS3MDL/lis3mdl.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lis3mdl.h
-* @author AST / EST
-* @version V0.0.1
-* @date 9-December-2014
-* @brief Header file for component LIS3MDL
-******************************************************************************
-* @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.
-*
-******************************************************************************
-*/
-
-#ifndef __X_CUBE_MEMS_LIS3MDL_H
-#define __X_CUBE_MEMS_LIS3MDL_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "x_cube_mems_i2c.h"
-
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a HTS221 sensor component
- */
-class LIS3MDL
-{
-public:
- /** Constructor
- * @param
- */
- LIS3MDL(DevI2C &i2c) : dev_i2c(i2c) {
- LIS3MDLInitialized = 0;
- Init();
- };
-
- void GetAxes(AxesRaw_TypeDef *pData);
- void GetAxesRaw(int16_t *pData);
- void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
- uint8_t ReadID(void);
- void RebootCmd(void);
-
-private:
-
- uint8_t isInitialized(void)
- {
- return LIS3MDLInitialized;
- }
-
- DevI2C &dev_i2c;
- uint8_t LIS3MDLInitialized;
-};
-
-#endif // __X_CUBE_MEMS_LIS3MDL_H
-
--- a/Components/LIS3MDL/lis3mdl_platform.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,364 +0,0 @@
-/**
- ******************************************************************************
- * @file lis3mdl.h
- * @author MEMS Application Team
- * @version V1.0.0
- * @date 30-July-2014
- * @brief This file contains definitions for the lis3mdl.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 __LIS3MDL_H
-#define __LIS3MDL_H
-
-
-/** @addtogroup LIS3MDL
- * @{
- */
-
-/** @defgroup LIS3MDL_Exported_Constants
- * @{
- */
-
-
-
-/******************************************************************************/
-/***************** START MAGNETIC SENSOR REGISTER MAPPING ********************/
-/******************************************************************************/
-
-/**
- * @brief Device identifier register.
- * \code
- * Read
- * Default value:
- * 7:0 This read-only register contains the device identifier
- * \endcode
-*/
-#define LIS3MDL_M_WHO_AM_I_ADDR 0x0F
-
-
-/**
- * @brief Magnetic sensor Control Register 1
- * \code
- * Read/write
- * Default value: 0x10
- * [7] TEMP_COMP: Temperature compensation enable
- * [6:5] OM1-0: X and Y axes operative mode selection
- * [4:2] DO2-0: Output data rate selection
- * [1] This bit must be set to 0 for the correct operation of the device
- * [0] ST: Self-test enable
- * \endcode
- */
-#define LIS3MDL_M_CTRL_REG1_M 0x20
-
-
-/**
- * @brief Magnetic sensor Control Register 2
- * \code
- * Read/write
- * Default value: 0x00
- * [7] These bits must be set to 0 for the correct operation of the device
- * [6:5] FS1-0: Full-scale configuration
- * [4] These bits must be set to 0 for the correct operation of the device
- * [3] REBOOT: Reboot memory content
- * [2] SOFT_RST: Configuration registers and user register reset function
- * [1:0] These bits must be set to 0 for the correct operation of the device
- * \endcode
- */
-#define LIS3MDL_M_CTRL_REG2_M 0x21
-
-
-/**
- * @brief Magnetic sensor Control Register 3
- * \code
- * Read/write
- * Default value: 0x03
- * [7] I2C_DISABLE: Disable I2C interface
- * [6] These bits must be set to 0 for the correct operation of the device
- * [5] LP: Low-power mode configuration
- * [4:3] These bits must be set to 0 for the correct operation of the device
- * [2] SIM: SPI Serial Interface mode selection
- * [1:0] MD1-0: Operating mode selection
- * \endcode
- */
-#define LIS3MDL_M_CTRL_REG3_M 0x22
-
-
-/**
- * @brief Magnetic sensor data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_X_L_M 0x28
-
-
-/**
- * @brief Magnetic sensor data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_X_H_M 0x29
-
-
-/**
- * @brief Magnetic sensor data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_Y_L_M 0x2A
-
-
-/**
- * @brief Magnetic sensor data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_Y_H_M 0x2B
-
-
-/**
- * @brief Magnetic sensor data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_Z_L_M 0x2C
-
-
-/**
- * @brief Magnetic sensor data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LIS3MDL_M_OUT_Z_H_M 0x2D
-
-
-/**
- * @brief Magnetic sensor Interrupt config register
- * \code
- * Read/write
- * Default value: 0x00
- * [7] XIEN: Enable interrupt generation on X axis
- * [6] YIEN: Enable interrupt generation on Y axis
- * [5] ZIEN: Enable interrupt generation on Z axis
- * [4:3] Must be 0
- * [2] IEA: Interrupt active configuration on INT
- * [1] LIR: Latch interrupt request
- * [0] IEN: Interrupt enable on INT pin
- * \endcode
- */
-#define LIS3MDL_M_INT_CFG 0x30
-
-
-/**
- * @brief Magnetic sensor Interrupt source register
- * \code
- * Read/write
- * Default value: 0x00
- * [7] PTH_X: Value on X-axis exceeds the threshold on the positive side
- * [6] PTH_Y: Value on Y-axis exceeds the threshold on the positive side
- * [5] PTH_Z: Value on Z-axis exceeds the threshold on the positive side
- * [4] NTH_X: Value on X-axis exceeds the threshold on the negative side
- * [3] NTH_Y: Value on Y-axis exceeds the threshold on the negative side
- * [2] NTH_Z: Value on Z-axis exceeds the threshold on the negative side
- * [1] MROI: Internal measurement range overflow on magnetic value
- * [0] INT: This bit signals when interrupt event occours
- * \endcode
- */
-#define LIS3MDL_M_INT_SRC 0x31
-
-
-/**
- * @brief Magnetic sensor Interrupt threshold register low
- * \code
- * Read/write
- * Default value: 0x00
- * [7:0] THS7-0: Least 8 significant bits of interrupt threshold
- * \endcode
- */
-#define LIS3MDL_M_INT_THS_L_M 0x32
-
-
-/**
- * @brief Magnetic sensor Interrupt threshold register high
- * \code
- * Read/write
- * Default value: 0x00
- * [7] Must be 0
- * [6:0] THS14-8: Most 7 significant bits of interrupt threshold
- * \endcode
- */
-#define LIS3MDL_M_INT_THS_H_M 0x33
-
-/******************************************************************************/
-/******************* END MAGNETIC SENSOR REGISTER MAPPING ********************/
-/******************************************************************************/
-
-
-
-/**
- * @brief Device Address
- */
-
-#define LIS3MDL_M_MEMS_ADDRESS 0x3C // SAD[1] = 1
-
-/**
- * @brief Device Identifier. Default value of the WHO_AM_I register.
- */
-#define I_AM_LIS3MDL_M ((uint8_t)0x3D)
-
-
-/*********************************** MAGNETIC SENSOR REGISTERS VALUE ****************************************/
-
-/** @defgroup LIS3MDL_M Temperature compensation enable selection CTRL_REG1_M
- * @{
- */
-#define LIS3MDL_M_TEMP_COMP_DISABLE ((uint8_t)0x00) /*!< Temperature compensation: disable */
-#define LIS3MDL_M_TEMP_COMP_ENABLE ((uint8_t)0x80) /*!< Temperature compensation: enable */
-
-#define LIS3MDL_M_TEMP_COMP_MASK ((uint8_t)0x80)
-
-
-/** @defgroup LIS3MDL_M X and Y axes operative mode selection CTRL_REG1_M
- * @{
- */
-#define LIS3MDL_M_OM_LP ((uint8_t)0x00) /*!< X and Y axes operative mode: Low-power mode */
-#define LIS3MDL_M_OM_MP ((uint8_t)0x20) /*!< X and Y axes operative mode: Medium-performance mode */
-#define LIS3MDL_M_OM_HP ((uint8_t)0x40) /*!< X and Y axes operative mode: High-performance mode */
-#define LIS3MDL_M_OM_UHP ((uint8_t)0x60) /*!< X and Y axes operative mode: Ultra-high performance mode */
-
-#define LIS3MDL_M_OM_MASK ((uint8_t)0x60)
-
-
-/** @defgroup LIS3MDL_M Output data rate selection CTRL_REG1_M
- * @{
- */
-#define LIS3MDL_M_DO_0_625 ((uint8_t)0x00) /*!< Output data rate selection: 0.625 */
-#define LIS3MDL_M_DO_1_25 ((uint8_t)0x04) /*!< Output data rate selection: 1.25 */
-#define LIS3MDL_M_DO_2_5 ((uint8_t)0x08) /*!< Output data rate selection: 2.5 */
-#define LIS3MDL_M_DO_5 ((uint8_t)0x0C) /*!< Output data rate selection: 5 */
-#define LIS3MDL_M_DO_10 ((uint8_t)0x10) /*!< Output data rate selection: 10 */
-#define LIS3MDL_M_DO_20 ((uint8_t)0x14) /*!< Output data rate selection: 20 */
-#define LIS3MDL_M_DO_40 ((uint8_t)0x18) /*!< Output data rate selection: 40 */
-#define LIS3MDL_M_DO_80 ((uint8_t)0x1C) /*!< Output data rate selection: 80 */
-
-#define LIS3MDL_M_DO_MASK ((uint8_t)0x1C)
-
-
-/** @defgroup LIS3MDL_M Self-test enable selection CTRL_REG1_M
- * @{
- */
-#define LIS3MDL_M_ST_DISABLE ((uint8_t)0x00) /*!< Self-test: disable */
-#define LIS3MDL_M_ST_ENABLE ((uint8_t)0x01) /*!< Self-test: enable */
-
-#define LIS3MDL_M_ST_MASK ((uint8_t)0x01)
-
-
-/** @defgroup LIS3MDL_M Full scale selection CTRL_REG2_M
- * @{
- */
-#define LIS3MDL_M_FS_4 ((uint8_t)0x00) /*!< Full scale: +-4 guass */
-#define LIS3MDL_M_FS_8 ((uint8_t)0x20) /*!< Full scale: +-8 gauss */
-#define LIS3MDL_M_FS_12 ((uint8_t)0x40) /*!< Full scale: +-12 gauss */
-#define LIS3MDL_M_FS_16 ((uint8_t)0x60) /*!< Full scale: +-16 gauss */
-
-#define LIS3MDL_M_FS_MASK ((uint8_t)0x60)
-
-
-/** @defgroup LIS3MDL_M Reboot memory selection CTRL_REG2_M
- * @{
- */
-#define LIS3MDL_M_REBOOT_NORMAL ((uint8_t)0x00) /*!< Reboot mode: normal mode */
-#define LIS3MDL_M_REBOOT_MEM_CONTENT ((uint8_t)0x08) /*!< Reboot mode: reboot memory content */
-
-#define LIS3MDL_M_REBOOT_MASK ((uint8_t)0x08)
-
-
-/** @defgroup LIS3MDL_M Configuration registers and user register reset CTRL_REG2_M
- * @{
- */
-#define LIS3MDL_M_SOFT_RST_DEFAULT ((uint8_t)0x00) /*!< Reset function: default value */
-#define LIS3MDL_M_SOFT_RST_RESET ((uint8_t)0x04) /*!< Reset function: reset operation */
-
-#define LIS3MDL_M_SOFT_RST_MASK ((uint8_t)0x04)
-
-
-/** @defgroup LIS3MDL_M Disable I2C interface selection CTRL_REG3_M
- * @{
- */
-#define LIS3MDL_M_I2C_ENABLE ((uint8_t)0x00) /*!< I2C interface: enable */
-#define LIS3MDL_M_I2C_DISABLE ((uint8_t)0x80) /*!< I2C interface: disable */
-
-#define LIS3MDL_M_I2C_MASK ((uint8_t)0x80)
-
-
-/** @defgroup LIS3MDL_M Low-power mode selection CTRL_REG3_M
- * @{
- */
-#define LIS3MDL_M_LP_ENABLE ((uint8_t)0x00) /*!< Low-power mode: magnetic data rate is configured by
- the DO bits in the CTRL_REG1_M */
-#define LIS3MDL_M_LP_DISABLE ((uint8_t)0x20) /*!< Low-power mode: the DO bits is set to 0.625 Hz and the system performs,
- for each channel, the minimum number of averages */
-
-#define LIS3MDL_M_LP_MASK ((uint8_t)0x20)
-
-
-/** @defgroup LIS3MDL_M SPI Serial Interface mode selection CTRL_REG3_M
- * @{
- */
-#define LIS3MDL_M_SPI_R_ENABLE ((uint8_t)0x00) /*!< SPI Serial Interface mode: only write operations enabled */
-#define LIS3MDL_M_SPI_R_DISABLE ((uint8_t)0x40) /*!< SPI Serial Interface mode: read and write operations enable */
-
-#define LIS3MDL_M_SPI_R_MASK ((uint8_t)0x40)
-
-
-/** @defgroup LIS3MDL_M Operating mode selection CTRL_REG3_M
- * @{
- */
-#define LIS3MDL_M_MD_CONTINUOUS ((uint8_t)0x00) /*!< Operating mode: Continuous-conversion mode */
-#define LIS3MDL_M_MD_SINGLE ((uint8_t)0x01) /*!< Operating mode: Single-conversion mode has to be used with sampling frequency from 0.625 Hz to 80 Hz. */
-#define LIS3MDL_M_MD_PD ((uint8_t)0x02) /*!< Operating mode: Power-down mode */
-
-#define LIS3MDL_M_MD_MASK ((uint8_t)0x03)
-
-
-
-
-#endif /* __LIS3MDL_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
--- a/Components/LPS25H/lps25.cpp Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lps25.cpp
-* @author AST / EST
-* @version V0.0.1
-* @date 1-December-2014
-* @brief Implementation file for component 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 "mbed.h"
-#include "lps25h.h"
-#include "lps25h_platform.h"
-
-/* Methods -------------------------------------------------------------------*/
-
-/**
- * @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;
-
- if(isInitialized()==0)
- {
- pfData = 0;
- return;
- }
-
- 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 pressure.
- * @param uint32_t: raw_press. Pressure raw value.
- * @retval LPS25H_ERROR or LPS25H_OK.
- */
-void LPS25H::ReadRawPressure(uint32_t *raw_press)
-{
- uint8_t buffer[3], i;
- uint32_t tempVal=0;
- int ret;
-
- /* Read the register content */
- //PRESSURE_IO_Read(buffer, LPS25H_SlaveAddress, LPS25H_PRESS_POUT_XL_ADDR+0x80, 3);
- ret = dev_i2c.i2c_read(buffer, LPS25H_ADDRESS_HIGH, LPS25H_PRESS_POUT_XL_ADDR+0x80, 3);
-
- /* 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 ID address of HTS221
- * @param Device ID address
- * @retval ID name
- */
-uint8_t LPS25H::ReadID(void)
-{
- uint8_t tmp;
-
- /* Read the register content */
- int ret;
- //PRESSURE_IO_Read(&tmp, LPS25H_SlaveAddress, LPS25H_WHO_AM_I_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp, LPS25H_ADDRESS_HIGH, LPS25H_WHO_AM_I_ADDR, 1);
-
- /* Return the ID */
- return (uint8_t)tmp;
-}
-
-/**
- * @brief Set HTS221 Initialization.
- * @param InitStruct: it contains the configuration setting for the HTS221.
- * @retval None
- */
-void LPS25H::Init() {
- int ret;
- uint8_t tmp1 = 0x00;
-
- Power_ON();
-
- //PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
-
- /* Output Data Rate selection */
- tmp1 &= ~(LPS25H_ODR_MASK);
- tmp1 |= LPS25H_ODR_1Hz;
-
- /* Interrupt circuit selection */
- tmp1 &= ~(LPS25H_DIFF_EN_MASK);
- tmp1 |= LPS25H_DIFF_ENABLE;
-
- /* Block Data Update selection */
- tmp1 &= ~(LPS25H_BDU_MASK);
- tmp1 |= LPS25H_BDU_CONT;
-
- /* Serial Interface Mode selection */
- tmp1 &= ~(LPS25H_SPI_SIM_MASK);
- tmp1 |= LPS25H_SPI_SIM_3W;
-
- //PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_write(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
-
- //PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_RES_CONF_ADDR, 1);
-
- /* Pressure Res selection */
- tmp1 &= ~(LPS25H_P_RES_MASK);
- tmp1 |= LPS25H_P_RES_AVG_32;
-
- /* Temperature Res selection */
- tmp1 &= ~(LPS25H_T_RES_MASK);
- tmp1 |= LPS25H_T_RES_AVG_16;
-
- //PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1);
- ret = dev_i2c.i2c_write(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_RES_CONF_ADDR, 1);
-
- if(ReadID() == I_AM_LPS25H)
- {
- Lps25hInitialized = 1;
- //ret = HUM_TEMP_OK;
- }
-
- return;
-}
-
-int LPS25H::Power_ON() {
- uint8_t tmpreg;
- int ret;
-
- /* Read the register content */
- //PRESSURE_IO_Read(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmpreg, 0xBA, 0x20, 1);
-
- /* Set the power down bit */
- tmpreg |= LPS25H_MODE_ACTIVE;
-
- /* Write register */
- //PRESSURE_IO_Write(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
- ret = dev_i2c.i2c_write(&tmpreg, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
- return ret;
-
-}
-
-int LPS25H::LPS25H_Calibration() {
-
- int ret;
-
- if(Lps25hInitialized == 1)
- {
- return 1; //TODO: Error Codes definitions
- }
-
-
-
- return ret;
-}
--- a/Components/LPS25H/lps25h.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lps25.h
-* @author AST / EST
-* @version V0.0.1
-* @date 1-December-2014
-* @brief Header file for component 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.
-*
-******************************************************************************
-*/
-
-#ifndef __X_CUBE_MEMS_LPS25H_H
-#define __X_CUBE_MEMS_LPS25H_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "x_cube_mems_i2c.h"
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a LPS25H sensor component
- */
-class LPS25H
-{
-public:
- /** Constructor
- * @param
- */
- LPS25H(DevI2C &i2c) : dev_i2c(i2c) {
- Lps25hInitialized = 0;
- Init();
- };
-
- void GetPressure(float* pfData);
- void ReadRawPressure(uint32_t *raw_press);
- void Init();
- uint8_t ReadID(void);
- void RebootCmd(void);
- int Power_OFF(void);
- int Power_ON(void);
- int LPS25H_Calibration();
-private:
-
- uint8_t isInitialized(void)
- {
- return Lps25hInitialized;
- }
-
- DevI2C &dev_i2c;
- uint8_t Lps25hInitialized;
-};
-
-#endif // __X_CUBE_MEMS_LPS25H_H
-
--- a/Components/LPS25H/lps25h_platform.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,499 +0,0 @@
-/**
- ******************************************************************************
- * @file lps25h.h
- * @author MEMS Application Team
- * @version V1.0.0
- * @date 30-July-2014
- * @brief This file contains definitions for the 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_PLATFORM_H
-#define __LPS25H_PLATFORM_H
-
-/** @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)
-
-
-#endif /* __LPS25H_PLATFORM_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
--- a/Components/LSM6DS0/lsm6ds0.cpp Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lsm6ds0.h
-* @author AST / EST
-* @version V0.0.1
-* @date 9-December-2014
-* @brief Header file for component LSM6DS0
-******************************************************************************
-* @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 "mbed.h"
-#include "lsm6ds0.h"
-#include "lsm6ds0_platform.h"
-#include <math.h>
-
-/* Methods -------------------------------------------------------------------*/
-
-/**
- * @brief Read data from LSM6DS0 Gyroscope and calculate angular rate in mdps.
- * @param float *pfData
- * @retval None.
- */
-void LSM6DS0::Gyro_GetAxes(AxesRaw_TypeDef *pData)
-{
-
- uint8_t tempReg = 0x00;
- int16_t pDataRaw[3];
- float sensitivity = 0;
- int ret;
-
- LSM6DS0::Gyro_GetAxesRaw(pDataRaw);
-
- //IMU_6AXES_IO_Read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
- ret = dev_i2c.i2c_read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
-
- tempReg &= LSM6DS0_G_FS_MASK;
-
- switch(tempReg)
- {
- case LSM6DS0_G_FS_245:
- sensitivity = 8.75;
- break;
- case LSM6DS0_G_FS_500:
- sensitivity = 17.50;
- break;
- case LSM6DS0_G_FS_2000:
- sensitivity = 70;
- break;
- }
-
- pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
- pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
- pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
-}
-
-
-/**
- * @brief Read raw data from LSM6DS0 Gyroscope output register.
- * @param float *pfData
- * @retval None.
- */
-void LSM6DS0::Gyro_GetAxesRaw(int16_t *pData)
-{
- uint8_t tempReg[2] = {0,0};
- int ret;
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_G + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_G + 0x80, 2);
-
- pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_G + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_G + 0x80, 2);
-
- pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_G + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_G + 0x80, 2);
-
- pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-}
-
-
-/**
- * @brief Read data from LSM6DS0 Accelerometer and calculate linear acceleration in mg.
- * @param float *pfData
- * @retval None.
- */
-void LSM6DS0::Acc_GetAxes(AxesRaw_TypeDef *pData)
-{
- uint8_t tempReg = 0x00;
- int16_t pDataRaw[3];
- float sensitivity = 0;
- int ret;
-
- Acc_GetAxesRaw(pDataRaw);
-
- //IMU_6AXES_IO_Read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
- ret = dev_i2c.i2c_read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
-
- tempReg &= LSM6DS0_XL_FS_MASK;
-
- switch(tempReg)
- {
- case LSM6DS0_XL_FS_2G:
- sensitivity = 0.061;
- break;
- case LSM6DS0_XL_FS_4G:
- sensitivity = 0.122;
- break;
- case LSM6DS0_XL_FS_8G:
- sensitivity = 0.244;
- break;
- }
-
- pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
- pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
- pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
-
-}
-
-/**
- * @brief Read raw data from LSM6DS0 Accelerometer output register.
- * @param float *pfData
- * @retval None.
- */
-void LSM6DS0::Acc_GetAxesRaw(int16_t *pData)
-{
- uint8_t tempReg[2] = {0,0};
- int ret;
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_XL + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_XL + 0x80, 2);
-
- pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_XL + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_XL + 0x80, 2);
-
- pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-
- //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_XL + 0x80, 2);
- ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_XL + 0x80, 2);
-
- pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
-}
-
-/**
- * @brief Read ID address of HTS221
- * @param Device ID address
- * @retval ID name
- */
-uint8_t LSM6DS0::ReadID(void)
-{
- uint8_t tmp=0x00;
- int ret;
-
- /* Read WHO I AM register */
- //IMU_6AXES_IO_Read(&tmp, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_WHO_AM_I_ADDR, 1);
- ret = dev_i2c.i2c_read(&tmp, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_WHO_AM_I_ADDR, 1);
-
- /* Return the ID */
- return (uint8_t)tmp;
-}
-
-/**
- * @brief Set LSM6DS0 Initialization.
- * @param InitStruct: it contains the configuration setting for the LSM6DS0.
- * @retval None
- */
-void LSM6DS0::Init() {
-
- uint8_t tmp1 = 0x00;
- int ret;
-
-/******* Gyroscope init *******/
-
- //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
- ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
-
- /* Output Data Rate selection */
- tmp1 &= ~(LSM6DS0_G_ODR_MASK);
- tmp1 |= LSM6DS0_G_ODR_119HZ;
-
- /* Full scale selection */
- tmp1 &= ~(LSM6DS0_G_FS_MASK);
- tmp1 |= LSM6DS0_G_FS_2000;
-
- //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
- ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
-
- //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
- ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
-
- /* Enable X axis selection */
- tmp1 &= ~(LSM6DS0_G_XEN_MASK);
- tmp1 |= LSM6DS0_G_XEN_ENABLE;
-
- /* Enable Y axis selection */
- tmp1 &= ~(LSM6DS0_G_YEN_MASK);
- tmp1 |= LSM6DS0_G_YEN_ENABLE;
-
- /* Enable Z axis selection */
- tmp1 &= ~(LSM6DS0_G_ZEN_MASK);
- tmp1 |= LSM6DS0_G_ZEN_ENABLE;
-
- //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
- ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
-
-/******************************/
-
-/***** Accelerometer init *****/
-
- //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
- ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
-
- /* Output Data Rate selection */
- tmp1 &= ~(LSM6DS0_XL_ODR_MASK);
- tmp1 |= LSM6DS0_XL_ODR_119HZ;
-
- /* Full scale selection */
- tmp1 &= ~(LSM6DS0_XL_FS_MASK);
- tmp1 |= LSM6DS0_XL_FS_2G;
-
- //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
- ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
-
-
- //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
- ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
-
- /* Enable X axis selection */
- tmp1 &= ~(LSM6DS0_XL_XEN_MASK);
- tmp1 |= LSM6DS0_XL_XEN_ENABLE;
-
- /* Enable Y axis selection */
- tmp1 &= ~(LSM6DS0_XL_YEN_MASK);
- tmp1 |= LSM6DS0_XL_YEN_ENABLE;
-
- /* Enable Z axis selection */
- tmp1 &= ~(LSM6DS0_XL_ZEN_MASK);
- tmp1 |= LSM6DS0_XL_ZEN_ENABLE;
-
- //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
- ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
-
-/******************************/
-
- if(ReadID() == I_AM_LSM6DS0_XG)
- {
- LSM6DS0Initialized = 1;
- //ret = HUM_TEMP_OK;
- }
-
- return;
-}
-
-
--- a/Components/LSM6DS0/lsm6ds0.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_lsm6ds0.h
-* @author AST / EST
-* @version V0.0.1
-* @date 9-December-2014
-* @brief Header file for component LSM6DS0
-******************************************************************************
-* @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.
-*
-******************************************************************************
-*/
-
-#ifndef __X_CUBE_MEMS_LSM6DS0_H
-#define __X_CUBE_MEMS_LSM6DS0_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "x_cube_mems_i2c.h"
-
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a HTS221 sensor component
- */
-class LSM6DS0
-{
-public:
- /** Constructor
- * @param
- */
- LSM6DS0(DevI2C &i2c) : dev_i2c(i2c) {
- LSM6DS0Initialized = 0;
- Init();
- };
-
- void Gyro_GetAxes(AxesRaw_TypeDef *pData);
- void Gyro_GetAxesRaw(int16_t *pData);
- void Acc_GetAxes(AxesRaw_TypeDef *pData);
- void Acc_GetAxesRaw(int16_t *pData);
- void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
- uint8_t ReadID(void);
- void RebootCmd(void);
- //int Power_OFF(void);
- //int Power_ON(void);
- //int LIS3MDL_Calibration();
-private:
-
- uint8_t isInitialized(void)
- {
- return LSM6DS0Initialized;
- }
-
- DevI2C &dev_i2c;
- uint8_t LSM6DS0Initialized;
-};
-
-#endif // __X_CUBE_MEMS_LSM6DS0_H
-
--- a/Components/LSM6DS0/lsm6ds0_platform.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,486 +0,0 @@
-/**
- ******************************************************************************
- * @file lsm6ds0.h
- * @author MEMS Application Team
- * @version V1.0.0
- * @date 30-July-2014
- * @brief This file contains definitions for the lsm6ds0.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 __LSM6DS0_PLATFORM_H
-#define __LSM6DS0_PLATFORM_H
-
-
-/******************************************************************************/
-/*********** START ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
-/******************************************************************************/
-
-
-/***************************************** COMMON REGISTERS ********************************************/
-
-/**
- * @brief Interrupt config register
- * \code
- * Read/write
- * Default value: 0x00
- * [7] INT_IG_G: Gyroscope interrupt enable on INT pin
- * [6] INT_IG_XL: Accelerometer interrupt generator on INT pin
- * [5] INT_FSS5: FSS5 interrupt enable on INT pin
- * [4] INT_OVR: Overrun interrupt on INT pin
- * [3] INT_FTH: Gyroscope interrupt enable on INT pin
- * [2] INT_BOOT: Accelerometer interrupt generator on INT pin
- * [1] INT_DRDY_G: FSS5 interrupt enable on INT pin
- * [0] INT_DRDY_XL: Overrun interrupt on INT pin
- * \endcode
- */
-#define LSM6DS0_XG_INT_CTRL 0x0C
-
-
-/**
- * @brief Device identifier register.
- * \code
- * Read
- * Default value:
- * [7:0] This read-only register contains the device identifier
- * \endcode
-*/
-#define LSM6DS0_XG_WHO_AM_I_ADDR 0x0F
-
-
-/**
- * @brief Control Register 4
- * \code
- * Read/write
- * Default value: 0x38
- * [5] Zen_G: Gyroscopes Z-axis output enable
- * [4] Yen_G: Gyroscopes Y-axis output enable
- * [3] Xen_G: Gyroscopes X-axis output enable
- * \endcode
-*/
-#define LSM6DS0_XG_CTRL_REG4 0x1E
-
-
-/**
- * @brief Control Register 10
- * \code
- * Read/write
- * Default value: 0x00
- * [2] ST_G: Gyro selftest disable (0) / enable (1)
- * [0] ST_XL: Accel selftest disable (0) / enable (1)
- * \endcode
-*/
-#define LSM6DS0_XG_CTRL_REG10 0x24
-
-
-/***************************************** GYROSCOPE REGISTERS ********************************************/
-
-/**
- * @brief Angular rate sensor Control Register 1
- * \code
- * Read/write
- * Default value: 0x00
- * [7:5] ODR_G2-0: Gyroscope output data rate selection
- * [4:3] FS_G1-0: Gyroscope full-scale selection
- * [2] This bit must be set to 0 for the correct operation of the device
- * [1:0] BW_G1-0: Gyroscope bandwidth selection
- * \endcode
- */
-#define LSM6DS0_XG_CTRL_REG1_G 0x10
-
-
-/**
- * @brief Gyroscope data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_X_L_G 0x18
-
-
-/**
- * @brief Gyroscope data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_X_H_G 0x19
-
-
-/**
- * @brief Gyroscope data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Y_L_G 0x1A
-
-
-/**
- * @brief Gyroscope data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Y_H_G 0x1B
-
-
-/**
- * @brief Gyroscope data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Z_L_G 0x1C
-
-
-/**
- * @brief Gyroscope data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Z_H_G 0x1D
-
-
-
-/*************************************** ACCELEROMETER REGISTERS *******************************************/
-
-/**
- * @brief Linear acceleration sensor Control Register 6
- * \code
- * Read/write
- * Default value: 0x00
- * [7:5] ODR_XL2-0: Accelerometer Output data rate and power mode selection
- * [4:3] FS1_XL-FS0_XL: Accelerometer full-scale selection
- * [2] BW_SCAL_ODR: Bandwidth selection
- * [1:0] BW_XL1-0: Anti-aliasing filter bandwidth selection
- * \endcode
- */
-#define LSM6DS0_XG_CTRL_REG6_XL 0x20
-
-
-/**
- * @brief Linear acceleration sensor Control Register 5
- * \code
- * Read/write
- * Default value: 0x38
- * [7:6] DEC1-0: Decimation of acceleration data on OUT REG and FIFO
- * [5] Zen_XL: Accelerometers Z-axis output enable
- * [4] Yen_XL: Accelerometers Y-axis output enable
- * [3] Xen_XL: Accelerometers X-axis output enable
- * [2:0] These bits must be set to 0 for the correct operation of the device
- * \endcode
- */
-#define LSM6DS0_XG_CTRL_REG5_XL 0x1F
-
-
-/**
- * @brief Accelerometer data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_X_L_XL 0x28
-
-
-/**
- * @brief Accelerometer data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_X_H_XL 0x29
-
-
-/**
- * @brief Accelerometer data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Y_L_XL 0x2A
-
-
-/**
- * @brief Accelerometer data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Y_H_XL 0x2B
-
-
-/**
- * @brief Accelerometer data (LSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Z_L_XL 0x2C
-
-
-/**
- * @brief Accelerometer data (MSB)
- * \code
- * Read
- * \endcode
- */
-#define LSM6DS0_XG_OUT_Z_H_XL 0x2D
-
-/******************************************************************************/
-/************* END ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
-/******************************************************************************/
-
-
-
-/**
- * @brief Device Address
- */
-
-#define LSM6DS0_XG_MEMS_ADDRESS 0xD6 // SAD[0] = 1
-
-/**
- * @brief Device Identifier. Default value of the WHO_AM_I register.
- */
-#define I_AM_LSM6DS0_XG ((uint8_t)0x68)
-
-
-
-/************************************** GYROSCOPE REGISTERS VALUE *******************************************/
-
-
-/** @defgroup LSM6DS0_XG Gyroscope Output Data Rate selection CTRL_REG1_G
- * @{
- */
-#define LSM6DS0_G_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
-#define LSM6DS0_G_ODR_14_9HZ ((uint8_t)0x20) /*!< Output Data Rate: 14.9 Hz, cutoff 5Hz */
-#define LSM6DS0_G_ODR_59_5HZ ((uint8_t)0x40) /*!< Output Data Rate: 59.5 Hz, cutoff 19Hz */
-#define LSM6DS0_G_ODR_119HZ ((uint8_t)0x60) /*!< Output Data Rate: 119 Hz, cutoff 38Hz*/
-#define LSM6DS0_G_ODR_238HZ ((uint8_t)0x80) /*!< Output Data Rate: 238 Hz, cutoff 76Hz*/
-#define LSM6DS0_G_ODR_476HZ ((uint8_t)0xA0) /*!< Output Data Rate: 476 Hz, cutoff 100Hz*/
-#define LSM6DS0_G_ODR_952HZ ((uint8_t)0xC0) /*!< Output Data Rate: 952 Hz, cutoff 100Hz*/
-
-#define LSM6DS0_G_ODR_MASK ((uint8_t)0xE0)
-
-
-
-/** @defgroup LSM6DS0_XG Gyroscope Bandwidth selection CTRL_REG1_G
- * @{
- */
-#define LSM6DS0_G_BW_00 ((uint8_t)0x00) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
- - cutoff = n.a. when ODR = 14.9
- - cutoff = 16 when ODR = 59.5
- - cutoff = 14 when ODR = 119
- - cutoff = 14 when ODR = 238
- - cutoff = 21 when ODR = 476
- - cutoff = 33 when ODR = 952 */
-#define LSM6DS0_G_BW_01 ((uint8_t)0x01) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
- - cutoff = n.a. when ODR = 14.9
- - cutoff = 16 when ODR = 59.5
- - cutoff = 31 when ODR = 119
- - cutoff = 29 when ODR = 238
- - cutoff = 28 when ODR = 476
- - cutoff = 40 when ODR = 952 */
-#define LSM6DS0_G_BW_10 ((uint8_t)0x02) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
- - cutoff = n.a. when ODR = 14.9
- - cutoff = 16 when ODR = 59.5
- - cutoff = 31 when ODR = 119
- - cutoff = 63 when ODR = 238
- - cutoff = 57 when ODR = 476
- - cutoff = 58 when ODR = 952 */
-#define LSM6DS0_G_BW_11 ((uint8_t)0x03) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
- - cutoff = n.a. when ODR = 14.9
- - cutoff = 16 when ODR = 59.5
- - cutoff = 31 when ODR = 119
- - cutoff = 78 when ODR = 238
- - cutoff = 100 when ODR = 476
- - cutoff = 100 when ODR = 952 */
-
-#define LSM6DS0_G_BW_MASK ((uint8_t)0x03)
-
-
-/** @defgroup LSM6DS0_XG Gyroscope Full scale selection CTRL_REG1_G
- * @{
- */
-#define LSM6DS0_G_FS_245 ((uint8_t)0x00) /*!< Full scale: 245 dps*/
-#define LSM6DS0_G_FS_500 ((uint8_t)0x08) /*!< Full scale: 500 dps */
-#define LSM6DS0_G_FS_2000 ((uint8_t)0x18) /*!< Full scale: 2000 dps */
-
-#define LSM6DS0_G_FS_MASK ((uint8_t)0x18)
-
-
-/** @defgroup LSM6DS0_XG Gyroscopes Z-axis output enable selection CTRL_REG4
- * @{
- */
-#define LSM6DS0_G_ZEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes Z-axis output enable: disable */
-#define LSM6DS0_G_ZEN_ENABLE ((uint8_t)0x20) /*!< Gyroscopes Z-axis output enable: enable */
-
-#define LSM6DS0_G_ZEN_MASK ((uint8_t)0x20)
-
-
-/** @defgroup LSM6DS0_XG Gyroscopes Y-axis output enable selection CTRL_REG4
- * @{
- */
-#define LSM6DS0_G_YEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes Y-axis output enable: disable */
-#define LSM6DS0_G_YEN_ENABLE ((uint8_t)0x10) /*!< Gyroscopes Y-axis output enable: enable */
-
-#define LSM6DS0_G_YEN_MASK ((uint8_t)0x10)
-
-
-/** @defgroup LSM6DS0_XG Gyroscopes X-axis output enable selection CTRL_REG4
- * @{
- */
-#define LSM6DS0_G_XEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes X-axis output enable: disable */
-#define LSM6DS0_G_XEN_ENABLE ((uint8_t)0x08) /*!< Gyroscopes X-axis output enable: enable */
-
-#define LSM6DS0_G_XEN_MASK ((uint8_t)0x08)
-
-
-/** @defgroup LSM6DS0 Gyro selftest en/dis - LSM6DS0_XG_CTRL_REG10
- * @{
- */
-#define LSM6DS0_G_ST_DISABLE ((uint8_t)0x00) /*!< Gyro selftest disable */
-#define LSM6DS0_G_ST_ENABLE ((uint8_t)0x04) /*!< Gyro selftest enable */
-
-#define LSM6DS0_G_ST_MASK ((uint8_t)0x04)
-
-/**
- * @}
- */
-
-
-/************************************ ACCELEROMETER REGISTERS VALUE *****************************************/
-
-/** @defgroup LSM6DS0_XG Accelerometer Output Data Rate selection CTRL_REG6_XL
- * @{
- */
-#define LSM6DS0_XL_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
-#define LSM6DS0_XL_ODR_10HZ ((uint8_t)0x20) /*!< Output Data Rate: 10 Hz*/
-#define LSM6DS0_XL_ODR_50HZ ((uint8_t)0x40) /*!< Output Data Rate: 50 Hz */
-#define LSM6DS0_XL_ODR_119HZ ((uint8_t)0x60) /*!< Output Data Rate: 119 Hz */
-#define LSM6DS0_XL_ODR_238HZ ((uint8_t)0x80) /*!< Output Data Rate: 238 Hz */
-#define LSM6DS0_XL_ODR_476HZ ((uint8_t)0xA0) /*!< Output Data Rate: 476 Hz */
-#define LSM6DS0_XL_ODR_952HZ ((uint8_t)0xC0) /*!< Output Data Rate: 952 Hz */
-
-#define LSM6DS0_XL_ODR_MASK ((uint8_t)0xE0)
-
-
-/** @defgroup LSM6DS0_XG Accelerometer Full scale selection CTRL_REG6_XL
- * @{
- */
-#define LSM6DS0_XL_FS_2G ((uint8_t)0x00) /*!< Full scale: +- 2g */
-#define LSM6DS0_XL_FS_4G ((uint8_t)0x10) /*!< Full scale: +- 4g */
-#define LSM6DS0_XL_FS_8G ((uint8_t)0x18) /*!< Full scale: +- 8g */
-
-#define LSM6DS0_XL_FS_MASK ((uint8_t)0x18)
-
-
-/** @defgroup LSM6DS0_XG Accelerometer Bandwidth selection CTRL_REG6_XL
- * @{
- */
-#define LSM6DS0_XL_BW_SCAL_ODR ((uint8_t)0x00) /*!< Bandwidth selection: determined by ODR:
- - BW = 408Hz when ODR = 952Hz, 50Hz, 10Hz
- - BW = 211Hz when ODR = 476Hz
- - BW = 105Hz when ODR = 238Hz
- - BW = 50Hz when ODR = 119Hz */
-#define LSM6DS0_XL_BW_SCAL_BW ((uint8_t)0x04) /*!< Bandwidth selection: selected according to Anti aliasing filter bandwidth */
-
-#define LSM6DS0_XL_BW_SCAL_MASK ((uint8_t)0x04)
-
-
-/** @defgroup LSM6DS0_XG Accelerometer Anti aliasing filter bandwidth selection CTRL_REG6_XL
- * @{
- */
-#define LSM6DS0_XL_BW_408HZ ((uint8_t)0x00) /*!< Anti-aliasing filter bandwidht: 408 Hz */
-#define LSM6DS0_XL_BW_211HZ ((uint8_t)0x01) /*!< Anti-aliasing filter bandwidht: 211 Hz */
-#define LSM6DS0_XL_BW_105HZ ((uint8_t)0x02) /*!< Anti-aliasing filter bandwidht: 105 Hz */
-#define LSM6DS0_XL_BW_50HZ ((uint8_t)0x03) /*!< Anti-aliasing filter bandwidht: 50 Hz */
-
-#define LSM6DS0_XL_BW_MASK ((uint8_t)0x03)
-
-
-/** @defgroup LSM6DS0_XG Accelerometer Decimation of acceleration data selection CTRL_REG5_XL
- * @{
- */
-#define LSM6DS0_XL_DEC_NO ((uint8_t)0x00) /*!< Decimation of acceleration data: no decimation */
-#define LSM6DS0_XL_DEC_EVERY_2S ((uint8_t)0x40) /*!< Decimation of acceleration data: update every 2 samples */
-#define LSM6DS0_XL_DEC_EVERY_4S ((uint8_t)0x80) /*!< Decimation of acceleration data: update every 4 samples */
-#define LSM6DS0_XL_DEC_EVERY_8S ((uint8_t)0xC0) /*!< Decimation of acceleration data: update every 8 samples */
-
-#define LSM6DS0_XL_DEC_MASK ((uint8_t)0xC0)
-
-
-/** @defgroup LSM6DS0_XG Accelerometers Z-axis output enable selection CTRL_REG5_XL
- * @{
- */
-#define LSM6DS0_XL_ZEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers Z-axis output enable: disable */
-#define LSM6DS0_XL_ZEN_ENABLE ((uint8_t)0x20) /*!< Accelerometers Z-axis output enable: enable */
-
-#define LSM6DS0_XL_ZEN_MASK ((uint8_t)0x20)
-
-
-/** @defgroup LSM6DS0_XG Accelerometers Y-axis output enable selection CTRL_REG5_XL
- * @{
- */
-#define LSM6DS0_XL_YEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers Y-axis output enable: disable */
-#define LSM6DS0_XL_YEN_ENABLE ((uint8_t)0x10) /*!< Accelerometers Y-axis output enable: enable */
-
-#define LSM6DS0_XL_YEN_MASK ((uint8_t)0x10)
-
-
-/** @defgroup LSM6DS0_XG Accelerometers X-axis output enable selection CTRL_REG5_XL
- * @{
- */
-#define LSM6DS0_XL_XEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers X-axis output enable: disable */
-#define LSM6DS0_XL_XEN_ENABLE ((uint8_t)0x08) /*!< Accelerometers X-axis output enable: enable */
-
-#define LSM6DS0_XL_XEN_MASK ((uint8_t)0x08)
-
-/**
- * @}
- */
-
-
-/** @defgroup LSM6DS0 Accel selftest en/dis - LSM6DS0_XG_CTRL_REG10
- * @{
- */
-#define LSM6DS0_XL_ST_DISABLE ((uint8_t)0x00) /*!< Accel selftest disable */
-#define LSM6DS0_XL_ST_ENABLE ((uint8_t)0x01) /*!< Accel selftest enable */
-
-#define LSM6DS0_XL_ST_MASK ((uint8_t)0x01)
-
-
-#endif /* __LSM6DS0_PLATFORM_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/hts221/hts221.cpp Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,299 @@
+/**
+******************************************************************************
+* @file x_cube_mems_hts221.h
+* @author AST / EST
+* @version V0.0.1
+* @date 1-December-2014
+* @brief Header file for component 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 "mbed.h"
+#include "hts221.h"
+#include "hts221_platform.h"
+
+
+/* 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;
+
+/* Methods -------------------------------------------------------------------*/
+
+/**
+ * @brief Read HTS221 output register, and calculate the temperature.
+ * @param pfData : Data out pointer
+ * @retval None
+ */
+int HTS221::GetTemperature(float* pfData)
+{
+ int16_t T_out, temperature_t;
+ uint8_t tempReg[2] = {0,0};
+ uint8_t tmp = 0x00;
+ float T_degC;
+ int ret=-1;//TODO:Define Error types?
+
+ if(isInitialized()==0)
+ {
+ return ret;
+ }
+
+ ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+
+ /* Output Data Rate selection */
+ tmp &= (HTS221_ODR_MASK);
+
+ if(tmp == 0x00){
+
+ ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1);
+
+ /* Serial Interface Mode selection */
+ tmp &= ~(HTS221_ONE_SHOT_MASK);
+ tmp |= HTS221_ONE_SHOT_START;
+
+ ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG2_ADDR, 1);
+
+ do{
+
+ ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1);
+ }while(!(tmp&&0x01));
+
+ }
+
+ ret = dev_i2c.i2c_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((double)10,(double)TEMP_DECIMAL_DIGITS));
+
+ *pfData = ((float)temperature_t)/pow((double)10,(double)TEMP_DECIMAL_DIGITS);
+
+ return ret;
+}
+
+
+/**
+ * @brief Read HTS221 output register, and calculate the humidity.
+ * @param pfData : Data out pointer
+ * @retval None
+ */
+int HTS221::GetHumidity(float* pfData)
+{
+ int16_t H_T_out, humidity_t;
+ uint8_t tempReg[2] = {0,0};
+ uint8_t tmp = 0x00;
+ float H_rh;
+ int ret;
+
+ if(isInitialized()==0)
+ {
+ pfData = 0;
+ return ret;
+ }
+
+ //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_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);
+ ret = dev_i2c.i2c_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);
+ ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS , HTS221_CTRL_REG2_ADDR, 1);
+
+ do{
+
+ //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_STATUS_REG_ADDR, 1);
+ ret = dev_i2c.i2c_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);
+ ret = dev_i2c.i2c_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((double)10,(double)HUM_DECIMAL_DIGITS));
+
+ *pfData = ((float)humidity_t)/pow((double)10,(double)HUM_DECIMAL_DIGITS);
+
+ return ret;
+}
+
+
+/**
+ * @brief Read ID address of HTS221
+ * @param Device ID address
+ * @retval ID name
+ */
+uint8_t HTS221::ReadID(void)
+{
+ uint8_t tmp;
+ int ret;
+
+ /* Read WHO I AM register */
+ //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_WHO_AM_I_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_WHO_AM_I_ADDR, 1);
+
+ /* Return the ID */
+ return (uint8_t)tmp;
+}
+
+/**
+ * @brief Set HTS221 Initialization.
+ * @param InitStruct: it contains the configuration setting for the HTS221.
+ * @retval None
+ */
+void HTS221::Init() {
+
+ uint8_t tmp = 0x00;
+ int ret;
+
+ Power_ON();
+
+ HTS221_Calibration();
+
+ //HUM_TEMP_IO_Read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+
+ /* Output Data Rate selection */
+ tmp &= ~(HTS221_ODR_MASK);
+ tmp |= HTS221_ODR_12_5Hz;
+
+ //HUM_TEMP_IO_Write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_write(&tmp, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+
+ if(ReadID() == I_AM_HTS221)
+ {
+ HumTempInitialized = 1;
+ //ret = HUM_TEMP_OK;
+ }
+
+ return;
+}
+
+int HTS221::Power_ON() {
+
+ uint8_t tmpReg;
+
+ /* Read the register content */
+ int ret;
+ ret = dev_i2c.i2c_read(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+ if(ret) return ret;
+
+ /* Set the power down bit */
+ tmpReg |= HTS221_MODE_ACTIVE;
+
+ /* Write register */
+ ret = dev_i2c.i2c_write(&tmpReg, HTS221_ADDRESS, HTS221_CTRL_REG1_ADDR, 1);
+ if(ret) return ret;
+ return ret;
+}
+
+int HTS221::HTS221_Calibration() {
+
+ if(HumTempInitialized == 1)
+ {
+ return 1; //TODO: Error Codes definitions
+ }
+
+ /* 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};
+
+ int ret;
+ ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T0_degC_X8_ADDR, 1);
+ if(ret) return ret;
+
+ T0_degC_x8_L = (uint16_t)tempReg[0];
+
+ ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T1_T0_MSB_X8_ADDR, 1);
+ if(ret) return ret;
+ T0_degC_x8_H = (uint16_t) (tempReg[0] & 0x03);
+
+ T0_degC = ((float)((T0_degC_x8_H<<8) | (T0_degC_x8_L)))/8;
+
+ ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T1_degC_X8_ADDR, 1);
+ T1_degC_x8_L = (uint16_t)tempReg[0];
+
+ ret = dev_i2c.i2c_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;
+
+ ret = dev_i2c.i2c_read(tempReg, HTS221_ADDRESS, HTS221_T0_OUT_L_ADDR + 0x80, 2);
+ T0_out = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ ret = dev_i2c.i2c_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) */
+
+ ret = dev_i2c.i2c_read(&H0_rh_x2, HTS221_ADDRESS, HTS221_H0_RH_X2_ADDR, 1);
+
+ ret = dev_i2c.i2c_read(&H1_rh_x2, HTS221_ADDRESS, HTS221_H1_RH_X2_ADDR, 1);
+
+ ret = dev_i2c.i2c_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]);
+
+ ret = dev_i2c.i2c_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;
+
+ return ret;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/hts221/hts221.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,78 @@
+/**
+******************************************************************************
+* @file x_cube_mems_hts221.h
+* @author AST / EST
+* @version V0.0.1
+* @date 1-December-2014
+* @brief Header file for component 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.
+*
+******************************************************************************
+*/
+
+#ifndef __X_CUBE_MEMS_HTS221_H
+#define __X_CUBE_MEMS_HTS221_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "x_cube_mems_i2c.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a HTS221 sensor component
+ */
+class HTS221
+{
+public:
+ /** Constructor
+ * @param
+ */
+ HTS221(DevI2C &i2c) : dev_i2c(i2c) {
+ HumTempInitialized = 0;
+ Init();
+ };
+
+ int GetTemperature(float* pfData);
+ int GetHumidity(float* pfData);
+ void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
+ uint8_t ReadID(void);
+ void RebootCmd(void);
+ int Power_OFF(void);
+ int Power_ON(void);
+ int HTS221_Calibration();
+private:
+
+ uint8_t isInitialized(void)
+ {
+ return HumTempInitialized;
+ }
+
+ DevI2C &dev_i2c;
+ uint8_t HumTempInitialized;
+};
+
+#endif // __X_CUBE_MEMS_HTS221_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/hts221/hts221_platform.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,541 @@
+/**
+ ******************************************************************************
+ * @file hts221.h
+ * @author MEMS Application Team
+ * @version V1.0.0
+ * @date 30-July-2014
+ * @brief This file contains definitions for the hts221.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 __HTS221_PLATFORM_H
+#define __HTS221_PLATFORM_H
+
+/** @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 Humidity sensor control register 3
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] DRDY_H_L: Data Ready output signal active high, low (0: active high -default;1: active low)
+ * [6] PP_OD: Push-pull / Open Drain selection on pin 3 (DRDY) (0: push-pull - default; 1: open drain)
+ * [5:3] Reserved
+ * [2] DRDY_EN: Data Ready enable (0: Data Ready disabled - default;1: Data Ready signal available on pin 3)
+ * [1:0] Reserved
+ * \endcode
+ */
+#define HTS221_CTRL_REG3_ADDR 0x22
+
+
+ /**
+ * @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)
+
+
+#endif /* __HTS221_PLATFORM_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lis3mdl/lis3mdl.cpp Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,177 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lis3mdl.h
+* @author AST / EST
+* @version V0.0.1
+* @date 9-December-2014
+* @brief Implementation file for component LIS3MDL
+******************************************************************************
+* @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 "mbed.h"
+#include "lis3mdl.h"
+#include "lis3mdl_platform.h"
+#include <math.h>
+
+/* Methods -------------------------------------------------------------------*/
+
+/**
+ * @brief Read data from LIS3MDL Magnetic sensor and calculate Magnetic in mgauss.
+ * @param float *pfData
+ * @retval None.
+ */
+void LIS3MDL::GetAxes(AxesRaw_TypeDef *pData)
+{
+ uint8_t tempReg = 0x00;
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+ int ret;
+
+ GetAxesRaw(pDataRaw);
+
+ ret = dev_i2c.i2c_read(&tempReg, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
+
+ tempReg &= LIS3MDL_M_FS_MASK;
+
+ switch(tempReg)
+ {
+ case LIS3MDL_M_FS_4:
+ sensitivity = 0.14;
+ break;
+ case LIS3MDL_M_FS_8:
+ sensitivity = 0.29;
+ break;
+ case LIS3MDL_M_FS_12:
+ sensitivity = 0.43;
+ break;
+ case LIS3MDL_M_FS_16:
+ sensitivity = 0.58;
+ break;
+ }
+
+ pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
+ pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
+ pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
+
+}
+
+/**
+ * @brief Read raw data from LIS3MDL Magnetic sensor output register.
+ * @param float *pfData
+ * @retval None.
+ */
+void LIS3MDL::GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0,0};
+ int ret;
+
+ ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_X_L_M + 0x80, 2);
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_Y_L_M + 0x80, 2);
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ ret = dev_i2c.i2c_read(&tempReg[0], LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_OUT_Z_L_M + 0x80, 2);
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+}
+
+/**
+ * @brief Read ID address of HTS221
+ * @param Device ID address
+ * @retval ID name
+ */
+uint8_t LIS3MDL::ReadID(void)
+{
+ uint8_t tmp=0x00;
+ int ret;
+
+ /* Read WHO I AM register */
+ ret = dev_i2c.i2c_read(&tmp, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_WHO_AM_I_ADDR, 1);
+
+ /* Return the ID */
+ return (uint8_t)tmp;
+}
+
+/**
+ * @brief Set HTS221 Initialization.
+ * @param InitStruct: it contains the configuration setting for the HTS221.
+ * @retval None
+ */
+void LIS3MDL::Init() {
+
+ uint8_t tmp1 = 0x00;
+ int ret;
+
+ /****** Magnetic sensor *******/
+
+ ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG3_M, 1);
+
+ /* Conversion mode selection */
+ tmp1 &= ~(LIS3MDL_M_MD_MASK);
+ tmp1 |= LIS3MDL_M_MD_CONTINUOUS;
+
+ ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG3_M, 1);
+
+ ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG1_M, 1);
+
+ /* Output data rate selection */
+ tmp1 &= ~(LIS3MDL_M_DO_MASK);
+ tmp1 |= LIS3MDL_M_DO_80;
+
+ /* X and Y axes Operative mode selection */
+ tmp1 &= ~(LIS3MDL_M_OM_MASK);
+ tmp1 |= LIS3MDL_M_OM_HP;
+
+ ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG1_M, 1);
+
+ ret = dev_i2c.i2c_read(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
+
+ /* Full scale selection */
+ tmp1 &= ~(LIS3MDL_M_FS_MASK);
+ tmp1 |= LIS3MDL_M_FS_4;
+
+ ret = dev_i2c.i2c_write(&tmp1, LIS3MDL_M_MEMS_ADDRESS, LIS3MDL_M_CTRL_REG2_M, 1);
+
+ /******************************/
+
+
+ if(ReadID() == I_AM_LIS3MDL_M)
+ {
+ LIS3MDLInitialized = 1;
+ }
+
+ return;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lis3mdl/lis3mdl.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,78 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lis3mdl.h
+* @author AST / EST
+* @version V0.0.1
+* @date 9-December-2014
+* @brief Header file for component LIS3MDL
+******************************************************************************
+* @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.
+*
+******************************************************************************
+*/
+
+#ifndef __X_CUBE_MEMS_LIS3MDL_H
+#define __X_CUBE_MEMS_LIS3MDL_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "x_cube_mems_i2c.h"
+
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a HTS221 sensor component
+ */
+class LIS3MDL
+{
+public:
+ /** Constructor
+ * @param
+ */
+ LIS3MDL(DevI2C &i2c) : dev_i2c(i2c) {
+ LIS3MDLInitialized = 0;
+ Init();
+ };
+
+ void GetAxes(AxesRaw_TypeDef *pData);
+ void GetAxesRaw(int16_t *pData);
+ void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
+ uint8_t ReadID(void);
+ void RebootCmd(void);
+
+private:
+
+ uint8_t isInitialized(void)
+ {
+ return LIS3MDLInitialized;
+ }
+
+ DevI2C &dev_i2c;
+ uint8_t LIS3MDLInitialized;
+};
+
+#endif // __X_CUBE_MEMS_LIS3MDL_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lis3mdl/lis3mdl_platform.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,364 @@
+/**
+ ******************************************************************************
+ * @file lis3mdl.h
+ * @author MEMS Application Team
+ * @version V1.0.0
+ * @date 30-July-2014
+ * @brief This file contains definitions for the lis3mdl.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 __LIS3MDL_H
+#define __LIS3MDL_H
+
+
+/** @addtogroup LIS3MDL
+ * @{
+ */
+
+/** @defgroup LIS3MDL_Exported_Constants
+ * @{
+ */
+
+
+
+/******************************************************************************/
+/***************** START MAGNETIC SENSOR REGISTER MAPPING ********************/
+/******************************************************************************/
+
+/**
+ * @brief Device identifier register.
+ * \code
+ * Read
+ * Default value:
+ * 7:0 This read-only register contains the device identifier
+ * \endcode
+*/
+#define LIS3MDL_M_WHO_AM_I_ADDR 0x0F
+
+
+/**
+ * @brief Magnetic sensor Control Register 1
+ * \code
+ * Read/write
+ * Default value: 0x10
+ * [7] TEMP_COMP: Temperature compensation enable
+ * [6:5] OM1-0: X and Y axes operative mode selection
+ * [4:2] DO2-0: Output data rate selection
+ * [1] This bit must be set to 0 for the correct operation of the device
+ * [0] ST: Self-test enable
+ * \endcode
+ */
+#define LIS3MDL_M_CTRL_REG1_M 0x20
+
+
+/**
+ * @brief Magnetic sensor Control Register 2
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] These bits must be set to 0 for the correct operation of the device
+ * [6:5] FS1-0: Full-scale configuration
+ * [4] These bits must be set to 0 for the correct operation of the device
+ * [3] REBOOT: Reboot memory content
+ * [2] SOFT_RST: Configuration registers and user register reset function
+ * [1:0] These bits must be set to 0 for the correct operation of the device
+ * \endcode
+ */
+#define LIS3MDL_M_CTRL_REG2_M 0x21
+
+
+/**
+ * @brief Magnetic sensor Control Register 3
+ * \code
+ * Read/write
+ * Default value: 0x03
+ * [7] I2C_DISABLE: Disable I2C interface
+ * [6] These bits must be set to 0 for the correct operation of the device
+ * [5] LP: Low-power mode configuration
+ * [4:3] These bits must be set to 0 for the correct operation of the device
+ * [2] SIM: SPI Serial Interface mode selection
+ * [1:0] MD1-0: Operating mode selection
+ * \endcode
+ */
+#define LIS3MDL_M_CTRL_REG3_M 0x22
+
+
+/**
+ * @brief Magnetic sensor data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_X_L_M 0x28
+
+
+/**
+ * @brief Magnetic sensor data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_X_H_M 0x29
+
+
+/**
+ * @brief Magnetic sensor data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_Y_L_M 0x2A
+
+
+/**
+ * @brief Magnetic sensor data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_Y_H_M 0x2B
+
+
+/**
+ * @brief Magnetic sensor data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_Z_L_M 0x2C
+
+
+/**
+ * @brief Magnetic sensor data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LIS3MDL_M_OUT_Z_H_M 0x2D
+
+
+/**
+ * @brief Magnetic sensor Interrupt config register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] XIEN: Enable interrupt generation on X axis
+ * [6] YIEN: Enable interrupt generation on Y axis
+ * [5] ZIEN: Enable interrupt generation on Z axis
+ * [4:3] Must be 0
+ * [2] IEA: Interrupt active configuration on INT
+ * [1] LIR: Latch interrupt request
+ * [0] IEN: Interrupt enable on INT pin
+ * \endcode
+ */
+#define LIS3MDL_M_INT_CFG 0x30
+
+
+/**
+ * @brief Magnetic sensor Interrupt source register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] PTH_X: Value on X-axis exceeds the threshold on the positive side
+ * [6] PTH_Y: Value on Y-axis exceeds the threshold on the positive side
+ * [5] PTH_Z: Value on Z-axis exceeds the threshold on the positive side
+ * [4] NTH_X: Value on X-axis exceeds the threshold on the negative side
+ * [3] NTH_Y: Value on Y-axis exceeds the threshold on the negative side
+ * [2] NTH_Z: Value on Z-axis exceeds the threshold on the negative side
+ * [1] MROI: Internal measurement range overflow on magnetic value
+ * [0] INT: This bit signals when interrupt event occours
+ * \endcode
+ */
+#define LIS3MDL_M_INT_SRC 0x31
+
+
+/**
+ * @brief Magnetic sensor Interrupt threshold register low
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] THS7-0: Least 8 significant bits of interrupt threshold
+ * \endcode
+ */
+#define LIS3MDL_M_INT_THS_L_M 0x32
+
+
+/**
+ * @brief Magnetic sensor Interrupt threshold register high
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] Must be 0
+ * [6:0] THS14-8: Most 7 significant bits of interrupt threshold
+ * \endcode
+ */
+#define LIS3MDL_M_INT_THS_H_M 0x33
+
+/******************************************************************************/
+/******************* END MAGNETIC SENSOR REGISTER MAPPING ********************/
+/******************************************************************************/
+
+
+
+/**
+ * @brief Device Address
+ */
+
+#define LIS3MDL_M_MEMS_ADDRESS 0x3C // SAD[1] = 1
+
+/**
+ * @brief Device Identifier. Default value of the WHO_AM_I register.
+ */
+#define I_AM_LIS3MDL_M ((uint8_t)0x3D)
+
+
+/*********************************** MAGNETIC SENSOR REGISTERS VALUE ****************************************/
+
+/** @defgroup LIS3MDL_M Temperature compensation enable selection CTRL_REG1_M
+ * @{
+ */
+#define LIS3MDL_M_TEMP_COMP_DISABLE ((uint8_t)0x00) /*!< Temperature compensation: disable */
+#define LIS3MDL_M_TEMP_COMP_ENABLE ((uint8_t)0x80) /*!< Temperature compensation: enable */
+
+#define LIS3MDL_M_TEMP_COMP_MASK ((uint8_t)0x80)
+
+
+/** @defgroup LIS3MDL_M X and Y axes operative mode selection CTRL_REG1_M
+ * @{
+ */
+#define LIS3MDL_M_OM_LP ((uint8_t)0x00) /*!< X and Y axes operative mode: Low-power mode */
+#define LIS3MDL_M_OM_MP ((uint8_t)0x20) /*!< X and Y axes operative mode: Medium-performance mode */
+#define LIS3MDL_M_OM_HP ((uint8_t)0x40) /*!< X and Y axes operative mode: High-performance mode */
+#define LIS3MDL_M_OM_UHP ((uint8_t)0x60) /*!< X and Y axes operative mode: Ultra-high performance mode */
+
+#define LIS3MDL_M_OM_MASK ((uint8_t)0x60)
+
+
+/** @defgroup LIS3MDL_M Output data rate selection CTRL_REG1_M
+ * @{
+ */
+#define LIS3MDL_M_DO_0_625 ((uint8_t)0x00) /*!< Output data rate selection: 0.625 */
+#define LIS3MDL_M_DO_1_25 ((uint8_t)0x04) /*!< Output data rate selection: 1.25 */
+#define LIS3MDL_M_DO_2_5 ((uint8_t)0x08) /*!< Output data rate selection: 2.5 */
+#define LIS3MDL_M_DO_5 ((uint8_t)0x0C) /*!< Output data rate selection: 5 */
+#define LIS3MDL_M_DO_10 ((uint8_t)0x10) /*!< Output data rate selection: 10 */
+#define LIS3MDL_M_DO_20 ((uint8_t)0x14) /*!< Output data rate selection: 20 */
+#define LIS3MDL_M_DO_40 ((uint8_t)0x18) /*!< Output data rate selection: 40 */
+#define LIS3MDL_M_DO_80 ((uint8_t)0x1C) /*!< Output data rate selection: 80 */
+
+#define LIS3MDL_M_DO_MASK ((uint8_t)0x1C)
+
+
+/** @defgroup LIS3MDL_M Self-test enable selection CTRL_REG1_M
+ * @{
+ */
+#define LIS3MDL_M_ST_DISABLE ((uint8_t)0x00) /*!< Self-test: disable */
+#define LIS3MDL_M_ST_ENABLE ((uint8_t)0x01) /*!< Self-test: enable */
+
+#define LIS3MDL_M_ST_MASK ((uint8_t)0x01)
+
+
+/** @defgroup LIS3MDL_M Full scale selection CTRL_REG2_M
+ * @{
+ */
+#define LIS3MDL_M_FS_4 ((uint8_t)0x00) /*!< Full scale: +-4 guass */
+#define LIS3MDL_M_FS_8 ((uint8_t)0x20) /*!< Full scale: +-8 gauss */
+#define LIS3MDL_M_FS_12 ((uint8_t)0x40) /*!< Full scale: +-12 gauss */
+#define LIS3MDL_M_FS_16 ((uint8_t)0x60) /*!< Full scale: +-16 gauss */
+
+#define LIS3MDL_M_FS_MASK ((uint8_t)0x60)
+
+
+/** @defgroup LIS3MDL_M Reboot memory selection CTRL_REG2_M
+ * @{
+ */
+#define LIS3MDL_M_REBOOT_NORMAL ((uint8_t)0x00) /*!< Reboot mode: normal mode */
+#define LIS3MDL_M_REBOOT_MEM_CONTENT ((uint8_t)0x08) /*!< Reboot mode: reboot memory content */
+
+#define LIS3MDL_M_REBOOT_MASK ((uint8_t)0x08)
+
+
+/** @defgroup LIS3MDL_M Configuration registers and user register reset CTRL_REG2_M
+ * @{
+ */
+#define LIS3MDL_M_SOFT_RST_DEFAULT ((uint8_t)0x00) /*!< Reset function: default value */
+#define LIS3MDL_M_SOFT_RST_RESET ((uint8_t)0x04) /*!< Reset function: reset operation */
+
+#define LIS3MDL_M_SOFT_RST_MASK ((uint8_t)0x04)
+
+
+/** @defgroup LIS3MDL_M Disable I2C interface selection CTRL_REG3_M
+ * @{
+ */
+#define LIS3MDL_M_I2C_ENABLE ((uint8_t)0x00) /*!< I2C interface: enable */
+#define LIS3MDL_M_I2C_DISABLE ((uint8_t)0x80) /*!< I2C interface: disable */
+
+#define LIS3MDL_M_I2C_MASK ((uint8_t)0x80)
+
+
+/** @defgroup LIS3MDL_M Low-power mode selection CTRL_REG3_M
+ * @{
+ */
+#define LIS3MDL_M_LP_ENABLE ((uint8_t)0x00) /*!< Low-power mode: magnetic data rate is configured by
+ the DO bits in the CTRL_REG1_M */
+#define LIS3MDL_M_LP_DISABLE ((uint8_t)0x20) /*!< Low-power mode: the DO bits is set to 0.625 Hz and the system performs,
+ for each channel, the minimum number of averages */
+
+#define LIS3MDL_M_LP_MASK ((uint8_t)0x20)
+
+
+/** @defgroup LIS3MDL_M SPI Serial Interface mode selection CTRL_REG3_M
+ * @{
+ */
+#define LIS3MDL_M_SPI_R_ENABLE ((uint8_t)0x00) /*!< SPI Serial Interface mode: only write operations enabled */
+#define LIS3MDL_M_SPI_R_DISABLE ((uint8_t)0x40) /*!< SPI Serial Interface mode: read and write operations enable */
+
+#define LIS3MDL_M_SPI_R_MASK ((uint8_t)0x40)
+
+
+/** @defgroup LIS3MDL_M Operating mode selection CTRL_REG3_M
+ * @{
+ */
+#define LIS3MDL_M_MD_CONTINUOUS ((uint8_t)0x00) /*!< Operating mode: Continuous-conversion mode */
+#define LIS3MDL_M_MD_SINGLE ((uint8_t)0x01) /*!< Operating mode: Single-conversion mode has to be used with sampling frequency from 0.625 Hz to 80 Hz. */
+#define LIS3MDL_M_MD_PD ((uint8_t)0x02) /*!< Operating mode: Power-down mode */
+
+#define LIS3MDL_M_MD_MASK ((uint8_t)0x03)
+
+
+
+
+#endif /* __LIS3MDL_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lps25h/lps25.cpp Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,200 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lps25.cpp
+* @author AST / EST
+* @version V0.0.1
+* @date 1-December-2014
+* @brief Implementation file for component 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 "mbed.h"
+#include "lps25h.h"
+#include "lps25h_platform.h"
+
+/* Methods -------------------------------------------------------------------*/
+
+/**
+ * @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;
+
+ if(isInitialized()==0)
+ {
+ pfData = 0;
+ return;
+ }
+
+ 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 pressure.
+ * @param uint32_t: raw_press. Pressure raw value.
+ * @retval LPS25H_ERROR or LPS25H_OK.
+ */
+void LPS25H::ReadRawPressure(uint32_t *raw_press)
+{
+ uint8_t buffer[3], i;
+ uint32_t tempVal=0;
+ int ret;
+
+ /* Read the register content */
+ //PRESSURE_IO_Read(buffer, LPS25H_SlaveAddress, LPS25H_PRESS_POUT_XL_ADDR+0x80, 3);
+ ret = dev_i2c.i2c_read(buffer, LPS25H_ADDRESS_HIGH, LPS25H_PRESS_POUT_XL_ADDR+0x80, 3);
+
+ /* 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 ID address of HTS221
+ * @param Device ID address
+ * @retval ID name
+ */
+uint8_t LPS25H::ReadID(void)
+{
+ uint8_t tmp;
+
+ /* Read the register content */
+ int ret;
+ //PRESSURE_IO_Read(&tmp, LPS25H_SlaveAddress, LPS25H_WHO_AM_I_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp, LPS25H_ADDRESS_HIGH, LPS25H_WHO_AM_I_ADDR, 1);
+
+ /* Return the ID */
+ return (uint8_t)tmp;
+}
+
+/**
+ * @brief Set HTS221 Initialization.
+ * @param InitStruct: it contains the configuration setting for the HTS221.
+ * @retval None
+ */
+void LPS25H::Init() {
+ int ret;
+ uint8_t tmp1 = 0x00;
+
+ Power_ON();
+
+ //PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
+
+ /* Output Data Rate selection */
+ tmp1 &= ~(LPS25H_ODR_MASK);
+ tmp1 |= LPS25H_ODR_1Hz;
+
+ /* Interrupt circuit selection */
+ tmp1 &= ~(LPS25H_DIFF_EN_MASK);
+ tmp1 |= LPS25H_DIFF_ENABLE;
+
+ /* Block Data Update selection */
+ tmp1 &= ~(LPS25H_BDU_MASK);
+ tmp1 |= LPS25H_BDU_CONT;
+
+ /* Serial Interface Mode selection */
+ tmp1 &= ~(LPS25H_SPI_SIM_MASK);
+ tmp1 |= LPS25H_SPI_SIM_3W;
+
+ //PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
+
+ //PRESSURE_IO_Read(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_RES_CONF_ADDR, 1);
+
+ /* Pressure Res selection */
+ tmp1 &= ~(LPS25H_P_RES_MASK);
+ tmp1 |= LPS25H_P_RES_AVG_32;
+
+ /* Temperature Res selection */
+ tmp1 &= ~(LPS25H_T_RES_MASK);
+ tmp1 |= LPS25H_T_RES_AVG_16;
+
+ //PRESSURE_IO_Write(&tmp1, LPS25H_SlaveAddress, LPS25H_RES_CONF_ADDR, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LPS25H_ADDRESS_HIGH, LPS25H_RES_CONF_ADDR, 1);
+
+ if(ReadID() == I_AM_LPS25H)
+ {
+ Lps25hInitialized = 1;
+ //ret = HUM_TEMP_OK;
+ }
+
+ return;
+}
+
+int LPS25H::Power_ON() {
+ uint8_t tmpreg;
+ int ret;
+
+ /* Read the register content */
+ //PRESSURE_IO_Read(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmpreg, 0xBA, 0x20, 1);
+
+ /* Set the power down bit */
+ tmpreg |= LPS25H_MODE_ACTIVE;
+
+ /* Write register */
+ //PRESSURE_IO_Write(&tmpreg, LPS25H_SlaveAddress, LPS25H_CTRL_REG1_ADDR, 1);
+ ret = dev_i2c.i2c_write(&tmpreg, LPS25H_ADDRESS_HIGH, LPS25H_CTRL_REG1_ADDR, 1);
+ return ret;
+
+}
+
+int LPS25H::LPS25H_Calibration() {
+
+ int ret;
+
+ if(Lps25hInitialized == 1)
+ {
+ return 1; //TODO: Error Codes definitions
+ }
+
+
+
+ return ret;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lps25h/lps25h.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,79 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lps25.h
+* @author AST / EST
+* @version V0.0.1
+* @date 1-December-2014
+* @brief Header file for component 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.
+*
+******************************************************************************
+*/
+
+#ifndef __X_CUBE_MEMS_LPS25H_H
+#define __X_CUBE_MEMS_LPS25H_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "x_cube_mems_i2c.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a LPS25H sensor component
+ */
+class LPS25H
+{
+public:
+ /** Constructor
+ * @param
+ */
+ LPS25H(DevI2C &i2c) : dev_i2c(i2c) {
+ Lps25hInitialized = 0;
+ Init();
+ };
+
+ void GetPressure(float* pfData);
+ void ReadRawPressure(uint32_t *raw_press);
+ void Init();
+ uint8_t ReadID(void);
+ void RebootCmd(void);
+ int Power_OFF(void);
+ int Power_ON(void);
+ int LPS25H_Calibration();
+private:
+
+ uint8_t isInitialized(void)
+ {
+ return Lps25hInitialized;
+ }
+
+ DevI2C &dev_i2c;
+ uint8_t Lps25hInitialized;
+};
+
+#endif // __X_CUBE_MEMS_LPS25H_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lps25h/lps25h_platform.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,499 @@
+/**
+ ******************************************************************************
+ * @file lps25h.h
+ * @author MEMS Application Team
+ * @version V1.0.0
+ * @date 30-July-2014
+ * @brief This file contains definitions for the 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_PLATFORM_H
+#define __LPS25H_PLATFORM_H
+
+/** @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)
+
+
+#endif /* __LPS25H_PLATFORM_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lsm6ds0/lsm6ds0.cpp Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,286 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lsm6ds0.h
+* @author AST / EST
+* @version V0.0.1
+* @date 9-December-2014
+* @brief Header file for component LSM6DS0
+******************************************************************************
+* @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 "mbed.h"
+#include "lsm6ds0.h"
+#include "lsm6ds0_platform.h"
+#include <math.h>
+
+/* Methods -------------------------------------------------------------------*/
+
+/**
+ * @brief Read data from LSM6DS0 Gyroscope and calculate angular rate in mdps.
+ * @param float *pfData
+ * @retval None.
+ */
+void LSM6DS0::Gyro_GetAxes(AxesRaw_TypeDef *pData)
+{
+
+ uint8_t tempReg = 0x00;
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+ int ret;
+
+ LSM6DS0::Gyro_GetAxesRaw(pDataRaw);
+
+ //IMU_6AXES_IO_Read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+ ret = dev_i2c.i2c_read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+
+ tempReg &= LSM6DS0_G_FS_MASK;
+
+ switch(tempReg)
+ {
+ case LSM6DS0_G_FS_245:
+ sensitivity = 8.75;
+ break;
+ case LSM6DS0_G_FS_500:
+ sensitivity = 17.50;
+ break;
+ case LSM6DS0_G_FS_2000:
+ sensitivity = 70;
+ break;
+ }
+
+ pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
+ pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
+ pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
+}
+
+
+/**
+ * @brief Read raw data from LSM6DS0 Gyroscope output register.
+ * @param float *pfData
+ * @retval None.
+ */
+void LSM6DS0::Gyro_GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0,0};
+ int ret;
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_G + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_G + 0x80, 2);
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_G + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_G + 0x80, 2);
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_G + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_G + 0x80, 2);
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+}
+
+
+/**
+ * @brief Read data from LSM6DS0 Accelerometer and calculate linear acceleration in mg.
+ * @param float *pfData
+ * @retval None.
+ */
+void LSM6DS0::Acc_GetAxes(AxesRaw_TypeDef *pData)
+{
+ uint8_t tempReg = 0x00;
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+ int ret;
+
+ Acc_GetAxesRaw(pDataRaw);
+
+ //IMU_6AXES_IO_Read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+ ret = dev_i2c.i2c_read(&tempReg, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+
+ tempReg &= LSM6DS0_XL_FS_MASK;
+
+ switch(tempReg)
+ {
+ case LSM6DS0_XL_FS_2G:
+ sensitivity = 0.061;
+ break;
+ case LSM6DS0_XL_FS_4G:
+ sensitivity = 0.122;
+ break;
+ case LSM6DS0_XL_FS_8G:
+ sensitivity = 0.244;
+ break;
+ }
+
+ pData->AXIS_X = (int32_t)(pDataRaw[0] * sensitivity);
+ pData->AXIS_Y = (int32_t)(pDataRaw[1] * sensitivity);
+ pData->AXIS_Z = (int32_t)(pDataRaw[2] * sensitivity);
+
+}
+
+/**
+ * @brief Read raw data from LSM6DS0 Accelerometer output register.
+ * @param float *pfData
+ * @retval None.
+ */
+void LSM6DS0::Acc_GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0,0};
+ int ret;
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_XL + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_X_L_XL + 0x80, 2);
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_XL + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Y_L_XL + 0x80, 2);
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+
+ //IMU_6AXES_IO_Read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_XL + 0x80, 2);
+ ret = dev_i2c.i2c_read(&tempReg[0], LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_OUT_Z_L_XL + 0x80, 2);
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8)+(int16_t)tempReg[0]);
+}
+
+/**
+ * @brief Read ID address of HTS221
+ * @param Device ID address
+ * @retval ID name
+ */
+uint8_t LSM6DS0::ReadID(void)
+{
+ uint8_t tmp=0x00;
+ int ret;
+
+ /* Read WHO I AM register */
+ //IMU_6AXES_IO_Read(&tmp, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_WHO_AM_I_ADDR, 1);
+ ret = dev_i2c.i2c_read(&tmp, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_WHO_AM_I_ADDR, 1);
+
+ /* Return the ID */
+ return (uint8_t)tmp;
+}
+
+/**
+ * @brief Set LSM6DS0 Initialization.
+ * @param InitStruct: it contains the configuration setting for the LSM6DS0.
+ * @retval None
+ */
+void LSM6DS0::Init() {
+
+ uint8_t tmp1 = 0x00;
+ int ret;
+
+/******* Gyroscope init *******/
+
+ //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+
+ /* Output Data Rate selection */
+ tmp1 &= ~(LSM6DS0_G_ODR_MASK);
+ tmp1 |= LSM6DS0_G_ODR_119HZ;
+
+ /* Full scale selection */
+ tmp1 &= ~(LSM6DS0_G_FS_MASK);
+ tmp1 |= LSM6DS0_G_FS_2000;
+
+ //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG1_G, 1);
+
+ //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS0_G_XEN_MASK);
+ tmp1 |= LSM6DS0_G_XEN_ENABLE;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS0_G_YEN_MASK);
+ tmp1 |= LSM6DS0_G_YEN_ENABLE;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS0_G_ZEN_MASK);
+ tmp1 |= LSM6DS0_G_ZEN_ENABLE;
+
+ //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG4, 1);
+
+/******************************/
+
+/***** Accelerometer init *****/
+
+ //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+
+ /* Output Data Rate selection */
+ tmp1 &= ~(LSM6DS0_XL_ODR_MASK);
+ tmp1 |= LSM6DS0_XL_ODR_119HZ;
+
+ /* Full scale selection */
+ tmp1 &= ~(LSM6DS0_XL_FS_MASK);
+ tmp1 |= LSM6DS0_XL_FS_2G;
+
+ //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG6_XL, 1);
+
+
+ //IMU_6AXES_IO_Read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
+ ret = dev_i2c.i2c_read(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS0_XL_XEN_MASK);
+ tmp1 |= LSM6DS0_XL_XEN_ENABLE;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS0_XL_YEN_MASK);
+ tmp1 |= LSM6DS0_XL_YEN_ENABLE;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS0_XL_ZEN_MASK);
+ tmp1 |= LSM6DS0_XL_ZEN_ENABLE;
+
+ //IMU_6AXES_IO_Write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
+ ret = dev_i2c.i2c_write(&tmp1, LSM6DS0_XG_MEMS_ADDRESS, LSM6DS0_XG_CTRL_REG5_XL, 1);
+
+/******************************/
+
+ if(ReadID() == I_AM_LSM6DS0_XG)
+ {
+ LSM6DS0Initialized = 1;
+ //ret = HUM_TEMP_OK;
+ }
+
+ return;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lsm6ds0/lsm6ds0.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,82 @@
+/**
+******************************************************************************
+* @file x_cube_mems_lsm6ds0.h
+* @author AST / EST
+* @version V0.0.1
+* @date 9-December-2014
+* @brief Header file for component LSM6DS0
+******************************************************************************
+* @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.
+*
+******************************************************************************
+*/
+
+#ifndef __X_CUBE_MEMS_LSM6DS0_H
+#define __X_CUBE_MEMS_LSM6DS0_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "x_cube_mems_i2c.h"
+
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a HTS221 sensor component
+ */
+class LSM6DS0
+{
+public:
+ /** Constructor
+ * @param
+ */
+ LSM6DS0(DevI2C &i2c) : dev_i2c(i2c) {
+ LSM6DS0Initialized = 0;
+ Init();
+ };
+
+ void Gyro_GetAxes(AxesRaw_TypeDef *pData);
+ void Gyro_GetAxesRaw(int16_t *pData);
+ void Acc_GetAxes(AxesRaw_TypeDef *pData);
+ void Acc_GetAxesRaw(int16_t *pData);
+ void Init(/*HUM_TEMP_InitTypeDef *HTS221_Init*/);
+ uint8_t ReadID(void);
+ void RebootCmd(void);
+ //int Power_OFF(void);
+ //int Power_ON(void);
+ //int LIS3MDL_Calibration();
+private:
+
+ uint8_t isInitialized(void)
+ {
+ return LSM6DS0Initialized;
+ }
+
+ DevI2C &dev_i2c;
+ uint8_t LSM6DS0Initialized;
+};
+
+#endif // __X_CUBE_MEMS_LSM6DS0_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/lsm6ds0/lsm6ds0_platform.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,486 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds0.h
+ * @author MEMS Application Team
+ * @version V1.0.0
+ * @date 30-July-2014
+ * @brief This file contains definitions for the lsm6ds0.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 __LSM6DS0_PLATFORM_H
+#define __LSM6DS0_PLATFORM_H
+
+
+/******************************************************************************/
+/*********** START ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
+/******************************************************************************/
+
+
+/***************************************** COMMON REGISTERS ********************************************/
+
+/**
+ * @brief Interrupt config register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] INT_IG_G: Gyroscope interrupt enable on INT pin
+ * [6] INT_IG_XL: Accelerometer interrupt generator on INT pin
+ * [5] INT_FSS5: FSS5 interrupt enable on INT pin
+ * [4] INT_OVR: Overrun interrupt on INT pin
+ * [3] INT_FTH: Gyroscope interrupt enable on INT pin
+ * [2] INT_BOOT: Accelerometer interrupt generator on INT pin
+ * [1] INT_DRDY_G: FSS5 interrupt enable on INT pin
+ * [0] INT_DRDY_XL: Overrun interrupt on INT pin
+ * \endcode
+ */
+#define LSM6DS0_XG_INT_CTRL 0x0C
+
+
+/**
+ * @brief Device identifier register.
+ * \code
+ * Read
+ * Default value:
+ * [7:0] This read-only register contains the device identifier
+ * \endcode
+*/
+#define LSM6DS0_XG_WHO_AM_I_ADDR 0x0F
+
+
+/**
+ * @brief Control Register 4
+ * \code
+ * Read/write
+ * Default value: 0x38
+ * [5] Zen_G: Gyroscopes Z-axis output enable
+ * [4] Yen_G: Gyroscopes Y-axis output enable
+ * [3] Xen_G: Gyroscopes X-axis output enable
+ * \endcode
+*/
+#define LSM6DS0_XG_CTRL_REG4 0x1E
+
+
+/**
+ * @brief Control Register 10
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [2] ST_G: Gyro selftest disable (0) / enable (1)
+ * [0] ST_XL: Accel selftest disable (0) / enable (1)
+ * \endcode
+*/
+#define LSM6DS0_XG_CTRL_REG10 0x24
+
+
+/***************************************** GYROSCOPE REGISTERS ********************************************/
+
+/**
+ * @brief Angular rate sensor Control Register 1
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:5] ODR_G2-0: Gyroscope output data rate selection
+ * [4:3] FS_G1-0: Gyroscope full-scale selection
+ * [2] This bit must be set to 0 for the correct operation of the device
+ * [1:0] BW_G1-0: Gyroscope bandwidth selection
+ * \endcode
+ */
+#define LSM6DS0_XG_CTRL_REG1_G 0x10
+
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_X_L_G 0x18
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_X_H_G 0x19
+
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Y_L_G 0x1A
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Y_H_G 0x1B
+
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Z_L_G 0x1C
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Z_H_G 0x1D
+
+
+
+/*************************************** ACCELEROMETER REGISTERS *******************************************/
+
+/**
+ * @brief Linear acceleration sensor Control Register 6
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:5] ODR_XL2-0: Accelerometer Output data rate and power mode selection
+ * [4:3] FS1_XL-FS0_XL: Accelerometer full-scale selection
+ * [2] BW_SCAL_ODR: Bandwidth selection
+ * [1:0] BW_XL1-0: Anti-aliasing filter bandwidth selection
+ * \endcode
+ */
+#define LSM6DS0_XG_CTRL_REG6_XL 0x20
+
+
+/**
+ * @brief Linear acceleration sensor Control Register 5
+ * \code
+ * Read/write
+ * Default value: 0x38
+ * [7:6] DEC1-0: Decimation of acceleration data on OUT REG and FIFO
+ * [5] Zen_XL: Accelerometers Z-axis output enable
+ * [4] Yen_XL: Accelerometers Y-axis output enable
+ * [3] Xen_XL: Accelerometers X-axis output enable
+ * [2:0] These bits must be set to 0 for the correct operation of the device
+ * \endcode
+ */
+#define LSM6DS0_XG_CTRL_REG5_XL 0x1F
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_X_L_XL 0x28
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_X_H_XL 0x29
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Y_L_XL 0x2A
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Y_H_XL 0x2B
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Z_L_XL 0x2C
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS0_XG_OUT_Z_H_XL 0x2D
+
+/******************************************************************************/
+/************* END ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
+/******************************************************************************/
+
+
+
+/**
+ * @brief Device Address
+ */
+
+#define LSM6DS0_XG_MEMS_ADDRESS 0xD6 // SAD[0] = 1
+
+/**
+ * @brief Device Identifier. Default value of the WHO_AM_I register.
+ */
+#define I_AM_LSM6DS0_XG ((uint8_t)0x68)
+
+
+
+/************************************** GYROSCOPE REGISTERS VALUE *******************************************/
+
+
+/** @defgroup LSM6DS0_XG Gyroscope Output Data Rate selection CTRL_REG1_G
+ * @{
+ */
+#define LSM6DS0_G_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
+#define LSM6DS0_G_ODR_14_9HZ ((uint8_t)0x20) /*!< Output Data Rate: 14.9 Hz, cutoff 5Hz */
+#define LSM6DS0_G_ODR_59_5HZ ((uint8_t)0x40) /*!< Output Data Rate: 59.5 Hz, cutoff 19Hz */
+#define LSM6DS0_G_ODR_119HZ ((uint8_t)0x60) /*!< Output Data Rate: 119 Hz, cutoff 38Hz*/
+#define LSM6DS0_G_ODR_238HZ ((uint8_t)0x80) /*!< Output Data Rate: 238 Hz, cutoff 76Hz*/
+#define LSM6DS0_G_ODR_476HZ ((uint8_t)0xA0) /*!< Output Data Rate: 476 Hz, cutoff 100Hz*/
+#define LSM6DS0_G_ODR_952HZ ((uint8_t)0xC0) /*!< Output Data Rate: 952 Hz, cutoff 100Hz*/
+
+#define LSM6DS0_G_ODR_MASK ((uint8_t)0xE0)
+
+
+
+/** @defgroup LSM6DS0_XG Gyroscope Bandwidth selection CTRL_REG1_G
+ * @{
+ */
+#define LSM6DS0_G_BW_00 ((uint8_t)0x00) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
+ - cutoff = n.a. when ODR = 14.9
+ - cutoff = 16 when ODR = 59.5
+ - cutoff = 14 when ODR = 119
+ - cutoff = 14 when ODR = 238
+ - cutoff = 21 when ODR = 476
+ - cutoff = 33 when ODR = 952 */
+#define LSM6DS0_G_BW_01 ((uint8_t)0x01) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
+ - cutoff = n.a. when ODR = 14.9
+ - cutoff = 16 when ODR = 59.5
+ - cutoff = 31 when ODR = 119
+ - cutoff = 29 when ODR = 238
+ - cutoff = 28 when ODR = 476
+ - cutoff = 40 when ODR = 952 */
+#define LSM6DS0_G_BW_10 ((uint8_t)0x02) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
+ - cutoff = n.a. when ODR = 14.9
+ - cutoff = 16 when ODR = 59.5
+ - cutoff = 31 when ODR = 119
+ - cutoff = 63 when ODR = 238
+ - cutoff = 57 when ODR = 476
+ - cutoff = 58 when ODR = 952 */
+#define LSM6DS0_G_BW_11 ((uint8_t)0x03) /*!< Bandwidth selection: - cutoff = n.a. when ODR = Power-down
+ - cutoff = n.a. when ODR = 14.9
+ - cutoff = 16 when ODR = 59.5
+ - cutoff = 31 when ODR = 119
+ - cutoff = 78 when ODR = 238
+ - cutoff = 100 when ODR = 476
+ - cutoff = 100 when ODR = 952 */
+
+#define LSM6DS0_G_BW_MASK ((uint8_t)0x03)
+
+
+/** @defgroup LSM6DS0_XG Gyroscope Full scale selection CTRL_REG1_G
+ * @{
+ */
+#define LSM6DS0_G_FS_245 ((uint8_t)0x00) /*!< Full scale: 245 dps*/
+#define LSM6DS0_G_FS_500 ((uint8_t)0x08) /*!< Full scale: 500 dps */
+#define LSM6DS0_G_FS_2000 ((uint8_t)0x18) /*!< Full scale: 2000 dps */
+
+#define LSM6DS0_G_FS_MASK ((uint8_t)0x18)
+
+
+/** @defgroup LSM6DS0_XG Gyroscopes Z-axis output enable selection CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_ZEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes Z-axis output enable: disable */
+#define LSM6DS0_G_ZEN_ENABLE ((uint8_t)0x20) /*!< Gyroscopes Z-axis output enable: enable */
+
+#define LSM6DS0_G_ZEN_MASK ((uint8_t)0x20)
+
+
+/** @defgroup LSM6DS0_XG Gyroscopes Y-axis output enable selection CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_YEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes Y-axis output enable: disable */
+#define LSM6DS0_G_YEN_ENABLE ((uint8_t)0x10) /*!< Gyroscopes Y-axis output enable: enable */
+
+#define LSM6DS0_G_YEN_MASK ((uint8_t)0x10)
+
+
+/** @defgroup LSM6DS0_XG Gyroscopes X-axis output enable selection CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_XEN_DISABLE ((uint8_t)0x00) /*!< Gyroscopes X-axis output enable: disable */
+#define LSM6DS0_G_XEN_ENABLE ((uint8_t)0x08) /*!< Gyroscopes X-axis output enable: enable */
+
+#define LSM6DS0_G_XEN_MASK ((uint8_t)0x08)
+
+
+/** @defgroup LSM6DS0 Gyro selftest en/dis - LSM6DS0_XG_CTRL_REG10
+ * @{
+ */
+#define LSM6DS0_G_ST_DISABLE ((uint8_t)0x00) /*!< Gyro selftest disable */
+#define LSM6DS0_G_ST_ENABLE ((uint8_t)0x04) /*!< Gyro selftest enable */
+
+#define LSM6DS0_G_ST_MASK ((uint8_t)0x04)
+
+/**
+ * @}
+ */
+
+
+/************************************ ACCELEROMETER REGISTERS VALUE *****************************************/
+
+/** @defgroup LSM6DS0_XG Accelerometer Output Data Rate selection CTRL_REG6_XL
+ * @{
+ */
+#define LSM6DS0_XL_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
+#define LSM6DS0_XL_ODR_10HZ ((uint8_t)0x20) /*!< Output Data Rate: 10 Hz*/
+#define LSM6DS0_XL_ODR_50HZ ((uint8_t)0x40) /*!< Output Data Rate: 50 Hz */
+#define LSM6DS0_XL_ODR_119HZ ((uint8_t)0x60) /*!< Output Data Rate: 119 Hz */
+#define LSM6DS0_XL_ODR_238HZ ((uint8_t)0x80) /*!< Output Data Rate: 238 Hz */
+#define LSM6DS0_XL_ODR_476HZ ((uint8_t)0xA0) /*!< Output Data Rate: 476 Hz */
+#define LSM6DS0_XL_ODR_952HZ ((uint8_t)0xC0) /*!< Output Data Rate: 952 Hz */
+
+#define LSM6DS0_XL_ODR_MASK ((uint8_t)0xE0)
+
+
+/** @defgroup LSM6DS0_XG Accelerometer Full scale selection CTRL_REG6_XL
+ * @{
+ */
+#define LSM6DS0_XL_FS_2G ((uint8_t)0x00) /*!< Full scale: +- 2g */
+#define LSM6DS0_XL_FS_4G ((uint8_t)0x10) /*!< Full scale: +- 4g */
+#define LSM6DS0_XL_FS_8G ((uint8_t)0x18) /*!< Full scale: +- 8g */
+
+#define LSM6DS0_XL_FS_MASK ((uint8_t)0x18)
+
+
+/** @defgroup LSM6DS0_XG Accelerometer Bandwidth selection CTRL_REG6_XL
+ * @{
+ */
+#define LSM6DS0_XL_BW_SCAL_ODR ((uint8_t)0x00) /*!< Bandwidth selection: determined by ODR:
+ - BW = 408Hz when ODR = 952Hz, 50Hz, 10Hz
+ - BW = 211Hz when ODR = 476Hz
+ - BW = 105Hz when ODR = 238Hz
+ - BW = 50Hz when ODR = 119Hz */
+#define LSM6DS0_XL_BW_SCAL_BW ((uint8_t)0x04) /*!< Bandwidth selection: selected according to Anti aliasing filter bandwidth */
+
+#define LSM6DS0_XL_BW_SCAL_MASK ((uint8_t)0x04)
+
+
+/** @defgroup LSM6DS0_XG Accelerometer Anti aliasing filter bandwidth selection CTRL_REG6_XL
+ * @{
+ */
+#define LSM6DS0_XL_BW_408HZ ((uint8_t)0x00) /*!< Anti-aliasing filter bandwidht: 408 Hz */
+#define LSM6DS0_XL_BW_211HZ ((uint8_t)0x01) /*!< Anti-aliasing filter bandwidht: 211 Hz */
+#define LSM6DS0_XL_BW_105HZ ((uint8_t)0x02) /*!< Anti-aliasing filter bandwidht: 105 Hz */
+#define LSM6DS0_XL_BW_50HZ ((uint8_t)0x03) /*!< Anti-aliasing filter bandwidht: 50 Hz */
+
+#define LSM6DS0_XL_BW_MASK ((uint8_t)0x03)
+
+
+/** @defgroup LSM6DS0_XG Accelerometer Decimation of acceleration data selection CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_DEC_NO ((uint8_t)0x00) /*!< Decimation of acceleration data: no decimation */
+#define LSM6DS0_XL_DEC_EVERY_2S ((uint8_t)0x40) /*!< Decimation of acceleration data: update every 2 samples */
+#define LSM6DS0_XL_DEC_EVERY_4S ((uint8_t)0x80) /*!< Decimation of acceleration data: update every 4 samples */
+#define LSM6DS0_XL_DEC_EVERY_8S ((uint8_t)0xC0) /*!< Decimation of acceleration data: update every 8 samples */
+
+#define LSM6DS0_XL_DEC_MASK ((uint8_t)0xC0)
+
+
+/** @defgroup LSM6DS0_XG Accelerometers Z-axis output enable selection CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_ZEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers Z-axis output enable: disable */
+#define LSM6DS0_XL_ZEN_ENABLE ((uint8_t)0x20) /*!< Accelerometers Z-axis output enable: enable */
+
+#define LSM6DS0_XL_ZEN_MASK ((uint8_t)0x20)
+
+
+/** @defgroup LSM6DS0_XG Accelerometers Y-axis output enable selection CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_YEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers Y-axis output enable: disable */
+#define LSM6DS0_XL_YEN_ENABLE ((uint8_t)0x10) /*!< Accelerometers Y-axis output enable: enable */
+
+#define LSM6DS0_XL_YEN_MASK ((uint8_t)0x10)
+
+
+/** @defgroup LSM6DS0_XG Accelerometers X-axis output enable selection CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_XEN_DISABLE ((uint8_t)0x00) /*!< Accelerometers X-axis output enable: disable */
+#define LSM6DS0_XL_XEN_ENABLE ((uint8_t)0x08) /*!< Accelerometers X-axis output enable: enable */
+
+#define LSM6DS0_XL_XEN_MASK ((uint8_t)0x08)
+
+/**
+ * @}
+ */
+
+
+/** @defgroup LSM6DS0 Accel selftest en/dis - LSM6DS0_XG_CTRL_REG10
+ * @{
+ */
+#define LSM6DS0_XL_ST_DISABLE ((uint8_t)0x00) /*!< Accel selftest disable */
+#define LSM6DS0_XL_ST_ENABLE ((uint8_t)0x01) /*!< Accel selftest enable */
+
+#define LSM6DS0_XL_ST_MASK ((uint8_t)0x01)
+
+
+#endif /* __LSM6DS0_PLATFORM_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
--- a/x_cube_mems.cpp Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems.cpp
-* @author AST / EST
-* @version V0.0.1
-* @date 08-October-2014
-* @brief Implementation file for the X_CUBE_MEMS singleton class
-******************************************************************************
-* @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 "mbed.h"
-#include "x_cube_mems.h"
-
-/* Static variables ----------------------------------------------------------*/
-X_CUBE_MEMS* X_CUBE_MEMS::_instance = NULL;
-
-/* Methods -------------------------------------------------------------------*/
-/**
- * @brief Constructor
- */
-//X_CUBE_MEMS::X_CUBE_MEMS(PinName pin_sda, PinName pin_scl) : dev_i2c(pin_sda,pin_scl),
-X_CUBE_MEMS::X_CUBE_MEMS(DevI2C *ext_i2c) : dev_i2c(ext_i2c),
- hts221(*dev_i2c),
- lps25h(*dev_i2c),
- lis3mdl(*dev_i2c),
- lsm6ds0(*dev_i2c)
-{
-
-}
-
-/**
- * @brief Get singleton instance
- * @return a pointer to the singleton instance of class X_CUBE_MEMS
- */
- X_CUBE_MEMS* X_CUBE_MEMS::Instance(DevI2C *ext_i2c) {
- if(_instance == NULL) {
- if(ext_i2c == NULL)
- ext_i2c = new DevI2C(D14, D15);
- _instance = new X_CUBE_MEMS(ext_i2c);
- }
- return _instance;
-}
--- a/x_cube_mems.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/**
- ******************************************************************************
- * @file x_cube_mems.h
- * @author AST / EST
- * @version V0.0.1
- * @date 01-December-2014
- * @brief Header file for class X_CUBE_MEMS representing an MEMS expansion board
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- */
-
-
-#ifndef __X_CUBE_MEMS_H
-#define __X_CUBE_MEMS_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-
-#include "x_cube_mems_i2c.h"
-#include "Components/HTS221/hts221.h"
-#include "Components/LPS25H/lps25h.h"
-#include "Components/LIS3MDL/lis3mdl.h"
-#include "Components/LSM6DS0/lsm6ds0.h"
-
-/* Classes -------------------------------------------------------------------*/
-/** Class X_CUBE_MEMS represents the MEMS Sensor expansion board X-NUCLEO-IKS01A1
- *
- * The expansion board has the following IPs:\n
- * - HTS221 Relative Humidity and Temperature Sensor
- * - LIS3MDL 3-Axis Magnetometer
- * - LPS25H MEMS Pressure Sensor
- * - LSM6DS0 3D Acceleromenter and 3D Gyroscope
- * *
- * @code
- * // MEMS Sensors expansion board singleton instance
- * static X_CUBE_MEMS *mems_expansion_board = X_CUBE_MEMS::Instance();
- * @endcode
- */
-class X_CUBE_MEMS
-{
-protected:
- //X_CUBE_MEMS(PinName pin_sda, PinName pin_scl);
- X_CUBE_MEMS(DevI2C *ext_i2c);
-
-public:
- static X_CUBE_MEMS* Instance(DevI2C *ext_i2c=NULL);
-
- DevI2C *dev_i2c;
- HTS221 hts221;
- LPS25H lps25h;
- LIS3MDL lis3mdl;
- LSM6DS0 lsm6ds0;
-
-private:
- static X_CUBE_MEMS *_instance;
-};
-
-#endif /* __X_CUBE_MEMS_H */
--- a/x_cube_mems_i2c.h Mon Apr 13 11:49:53 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/**
-******************************************************************************
-* @file x_cube_mems_i2c.h
-* @author AST / EST
-* @version V0.0.1
-* @date 28-November-2014
-* @brief Header file for a special I2C class DevI2C which provides some
-* helper function for on-board communication
-******************************************************************************
-* @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 from recursive inclusion --------------------------------*/
-#ifndef __X_CUBE_MEMS_I2C_H
-#define __X_CUBE_MEMS_I2C_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-
-typedef struct {
- int32_t AXIS_X;
- int32_t AXIS_Y;
- int32_t AXIS_Z;
-} AxesRaw_TypeDef;
-
-/* Classes -------------------------------------------------------------------*/
-/** Helper class DevI2C providing some common functionality useful for on-board
- * communication.
- */
-class DevI2C : public I2C
-{
- public:
- /** Create a DevI2C Master interface, connected to the specified pins
- *
- * @param sda I2C data line pin
- * @param scl I2C clock line pin
- */
- DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {};
-
- /**
- * @brief Writes a buffer from the I2C peripheral device.
- * @param pBuffer pointer to data to be read.
- * @param DeviceAddr specifies the peripheral device slave address
- * (correctly masked).
- * @param RegisterAddr specifies internal address register to read from.
- * @param NumByteToWrite number of bytes to be written.
- * @retval 0 if ok, -1 if an I2C error has occured
- * @note on some devices if NumByteToWrite is greater
- * than one, the DeviceAddr must be masked correctly
- */
- int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
- uint16_t NumByteToWrite)
- {
- int ret;
- uint8_t tmp[32];
-
- //Acquire mbed mutex/semaphore/lock?
-
- /* First, send device address. Then, send data and STOP condition */
- tmp[0] = RegisterAddr;
- memcpy(tmp+1, pBuffer, NumByteToWrite);
-
- ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, 0);
-
- //Release mbed mutex/semaphore/lock?
-
- if(ret) {
- error("%s: dev = %d, reg = %d, num = %d\n",
- __func__, DeviceAddr, RegisterAddr, NumByteToWrite);
- return -1;
- }
- return 0;
- }
-
- /**
- * @brief Reads a buffer from the I2C peripheral device.
- * @param pBuffer pointer to data to be read.
- * @param DaviceAddr specifies the peripheral device slave address
- * (correctly masked)..
- * @param RegisterAddr specifies internal address register to read from.
- * @param NumByteToRead number of bytes to be read.
- * @retval 0 if ok, -1 if an I2C error has occured
- * @note on some devices if NumByteToRead is greater
- * than one, the DeviceAddr must be masked correctly
- */
- int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
- uint16_t NumByteToRead)
- {
- int ret;
-
- //Acquire mbed mutex/semaphore/lock?
-
- /* Send device address, with no STOP condition */
- ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, 1);
- if(!ret) {
- /* Read data, with STOP condition */
- ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, 0);
- }
-
- //Release mbed mutex/semaphore/lock?
-
- if(ret) {
- error("%s: dev = %d, reg = %d, num = %d\n",
- __func__, DeviceAddr, RegisterAddr, NumByteToRead);
- return -1;
- }
- return 0;
- }
-};
-
-#endif /* __X_CUBE_MEMS_I2C_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/x_nucleo_iks01a1.cpp Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,75 @@
+/**
+******************************************************************************
+* @file x_nucleo_iks01a1.cpp
+* @author AST / EST
+* @version V0.0.1
+* @date 08-October-2014
+* @brief Implementation file for the X_NUCLEO_IKS01A1 singleton class
+******************************************************************************
+* @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 "mbed.h"
+#include "x_nucleo_iks01a1.h"
+/* betzw: TO BE REVIEWED */
+
+/* Static variables ----------------------------------------------------------*/
+X_NUCLEO_IKS01A1* X_NUCLEO_IKS01A1::_instance = NULL;
+
+/* Methods -------------------------------------------------------------------*/
+/**
+ * @brief Constructor
+ */
+X_NUCLEO_IKS01A1::X_NUCLEO_IKS01A1(DevI2C *ext_i2c) : dev_i2c(ext_i2c),
+ hts221(*dev_i2c), /* betzw: TO BE REVIEWED */
+ lps25h(*dev_i2c),
+ lis3mdl(*dev_i2c),
+ lsm6ds0(*dev_i2c)
+{
+}
+
+/**
+ * @brief Get singleton instance
+ * @return a pointer to the singleton instance of class X_NUCLEO_IKS01A1
+ * @param (optional) ext_i2c pointer to instance of DevI2C to be used
+ * for communication on the expansion board.
+ * Taken into account only on the very first call of this function.
+ * If not provided a new DevI2C will be created with standard
+ * configuration parameters.
+ * The used DevI2C object gets saved in instance variable dev_i2c.
+ */
+ X_NUCLEO_IKS01A1* X_NUCLEO_IKS01A1::Instance(DevI2C *ext_i2c) {
+ if(_instance == NULL) {
+ if(ext_i2c == NULL)
+ ext_i2c = new DevI2C(IKS01A1_PIN_I2C_SDA, IKS01A1_PIN_I2C_SCL);
+ _instance = new X_NUCLEO_IKS01A1(ext_i2c);
+ }
+ return _instance;
+}
--- a/x_nucleo_iks01a1.h Mon Apr 13 11:49:53 2015 +0200 +++ b/x_nucleo_iks01a1.h Mon Apr 13 14:44:02 2015 +0200 @@ -4,12 +4,12 @@ * @author AST / EST * @version V0.0.1 * @date 13-April-2015 - * @brief Header file for class X_NUCLEO_IKS01A1 representing an X-NUCLEO-IKS01A1 + * @brief Header file for class X_NUCLEO_IKS01A1 representing a X-NUCLEO-IKS01A1 * expansion board ****************************************************************************** * @attention * - * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> + * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -44,20 +44,27 @@ #include "mbed.h" #include "x_nucleo_iks01a1_targets.h" #include "DevI2C.h" +#include "Common/HumTemp.h" +#include "Common/Pressure.h" +#include "Common/Magneto.h" +#include "Common/Imu6Axis.h" /* Classes -------------------------------------------------------------------*/ /** Class X_NUCLEO_IKS01A1 is intended to represent the <TODO> * expansion board with the same name. * - * The expansion board is featuring basically <TODO> IPs:\n - * -# <TODO>\n + * The expansion board is featuring basically four IPs:\n + * -# a HTS221 Relative Humidity and Temperature Sensor\n + * -# a LIS3MDL 3-Axis Magnetometer\n + * -# a LPS25H MEMS Pressure Sensor\n + * -# and a LSM6DS0 3D Acceleromenter and 3D Gyroscope\n * * It is intentionally implemented as a singleton because only one * X_NUCLEO_IKS01A1 at a time might be deployed in a HW component stack.\n * In order to get the singleton instance you have to call class method `Instance()`, * e.g.: * @code - * // Battery expansion board singleton instance + * // Inertial & Environmental expansion board singleton instance * static X_NUCLEO_IKS01A1 *<TODO>_expansion_board = X_NUCLEO_IKS01A1::Instance(); * @endcode */ @@ -71,6 +78,11 @@ DevI2C *dev_i2c; + HumTemp &ht_sensor; + Pressure &pressure_sensor; + Magneto &magnetometer; + Imu6Axis &gyroscope; + private: static X_NUCLEO_IKS01A1 *_instance; };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/x_nucleo_iks01a1_i2c.h Mon Apr 13 14:44:02 2015 +0200
@@ -0,0 +1,138 @@
+/**
+******************************************************************************
+* @file x_cube_mems_i2c.h
+* @author AST / EST
+* @version V0.0.1
+* @date 28-November-2014
+* @brief Header file for a special I2C class DevI2C which provides some
+* helper function for on-board communication
+******************************************************************************
+* @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 from recursive inclusion --------------------------------*/
+#ifndef __X_CUBE_MEMS_I2C_H
+#define __X_CUBE_MEMS_I2C_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+
+/* betzw - TODO: find a better place! */
+typedef struct {
+ int32_t AXIS_X;
+ int32_t AXIS_Y;
+ int32_t AXIS_Z;
+} AxesRaw_TypeDef;
+
+/* Classes -------------------------------------------------------------------*/
+/** Helper class DevI2C providing some common functionality useful for on-board
+ * communication.
+ */
+class DevI2C : public I2C
+{
+ public:
+ /** Create a DevI2C Master interface, connected to the specified pins
+ *
+ * @param sda I2C data line pin
+ * @param scl I2C clock line pin
+ */
+ DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {};
+
+ /**
+ * @brief Writes a buffer from the I2C peripheral device.
+ * @param pBuffer pointer to data to be read.
+ * @param DeviceAddr specifies the peripheral device slave address
+ * (correctly masked).
+ * @param RegisterAddr specifies internal address register to read from.
+ * @param NumByteToWrite number of bytes to be written.
+ * @retval 0 if ok, -1 if an I2C error has occured
+ * @note on some devices if NumByteToWrite is greater
+ * than one, the DeviceAddr must be masked correctly
+ */
+ int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite)
+ {
+ int ret;
+ uint8_t tmp[32];
+
+ //Acquire mbed mutex/semaphore/lock?
+
+ /* First, send device address. Then, send data and STOP condition */
+ tmp[0] = RegisterAddr;
+ memcpy(tmp+1, pBuffer, NumByteToWrite);
+
+ ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, 0);
+
+ //Release mbed mutex/semaphore/lock?
+
+ if(ret) {
+ error("%s: dev = %d, reg = %d, num = %d\n",
+ __func__, DeviceAddr, RegisterAddr, NumByteToWrite);
+ return -1;
+ }
+ return 0;
+ }
+
+ /**
+ * @brief Reads a buffer from the I2C peripheral device.
+ * @param pBuffer pointer to data to be read.
+ * @param DaviceAddr specifies the peripheral device slave address
+ * (correctly masked)..
+ * @param RegisterAddr specifies internal address register to read from.
+ * @param NumByteToRead number of bytes to be read.
+ * @retval 0 if ok, -1 if an I2C error has occured
+ * @note on some devices if NumByteToRead is greater
+ * than one, the DeviceAddr must be masked correctly
+ */
+ int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead)
+ {
+ int ret;
+
+ //Acquire mbed mutex/semaphore/lock?
+
+ /* Send device address, with no STOP condition */
+ ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, 1);
+ if(!ret) {
+ /* Read data, with STOP condition */
+ ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, 0);
+ }
+
+ //Release mbed mutex/semaphore/lock?
+
+ if(ret) {
+ error("%s: dev = %d, reg = %d, num = %d\n",
+ __func__, DeviceAddr, RegisterAddr, NumByteToRead);
+ return -1;
+ }
+ return 0;
+ }
+};
+
+#endif /* __X_CUBE_MEMS_I2C_H */
