a
Dependents: ELEC350_1-Referral-2018-IKS01A1-Demo
Revision 0:0e110e287017, committed 2016-05-11
- Comitter:
- antseggs
- Date:
- Wed May 11 21:03:33 2016 +0000
- Commit message:
- Set DATE and set TIME complete READ TIME needs a little tweeking to work.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/.hg_archival.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,5 @@ +repo: 14ddc33717d5b994b2398cb7b8b3af9c1e7b394e +node: 14ddc33717d5b994b2398cb7b8b3af9c1e7b394e +branch: default +latesttag: null +latesttagdistance: 1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/.hg_archival.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,5 @@ +repo: 0feaa2a2d9ff3645f2959bd478c6f096fd49b2ab +node: f255a2c75ecb6b7317ef8e29ae748d877d6cd811 +branch: default +latesttag: null +latesttagdistance: 46
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Common/hum_temp.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,151 @@
+/**
+ ******************************************************************************
+ * @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/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Common/imu_6axes.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,161 @@
+/**
+ ******************************************************************************
+ * @file imu_6axes.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_6AXES_H
+#define __IMU_6AXES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup IMU_6AXES
+ * @{
+ */
+
+/** @defgroup IMU_6AXES_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief IMU_6AXES init structure definition
+ */
+typedef struct
+{
+ float G_OutputDataRate;
+ float G_FullScale;
+ uint8_t G_X_Axis;
+ uint8_t G_Y_Axis;
+ uint8_t G_Z_Axis;
+ float X_OutputDataRate;
+ float X_FullScale;
+ uint8_t X_X_Axis;
+ uint8_t X_Y_Axis;
+ uint8_t X_Z_Axis;
+} IMU_6AXES_InitTypeDef;
+
+/**
+ * @brief IMU_6AXES status enumerator definition
+ */
+typedef enum
+{
+ IMU_6AXES_OK = 0,
+ IMU_6AXES_ERROR = 1,
+ IMU_6AXES_TIMEOUT = 2,
+ IMU_6AXES_NOT_IMPLEMENTED = 3
+} IMU_6AXES_StatusTypeDef;
+
+/**
+ * @brief IMU_6AXES component id enumerator definition
+ */
+typedef enum
+{
+ IMU_6AXES_NONE_COMPONENT = 0,
+ IMU_6AXES_LSM6DS0_COMPONENT = 1,
+ IMU_6AXES_LSM6DS3_DIL24_COMPONENT = 2
+} IMU_6AXES_ComponentTypeDef;
+
+/**
+ * @brief IMU_6AXES driver extended structure definition
+ */
+typedef struct
+{
+ IMU_6AXES_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_6AXES_DrvExtTypeDef;
+
+/**
+ * @brief IMU_6AXES driver structure definition
+ */
+typedef struct
+{
+ IMU_6AXES_StatusTypeDef (*Init)(IMU_6AXES_InitTypeDef *);
+ IMU_6AXES_StatusTypeDef (*Read_XG_ID)(uint8_t *);
+ IMU_6AXES_StatusTypeDef (*Get_X_Axes)(int32_t *);
+ IMU_6AXES_StatusTypeDef (*Get_X_AxesRaw)(int16_t *);
+ IMU_6AXES_StatusTypeDef (*Get_G_Axes)(int32_t *);
+ IMU_6AXES_StatusTypeDef (*Get_G_AxesRaw)(int16_t *);
+ IMU_6AXES_StatusTypeDef (*Get_X_ODR) (float *);
+ IMU_6AXES_StatusTypeDef (*Set_X_ODR) (float);
+ IMU_6AXES_StatusTypeDef (*Get_X_Sensitivity) (float *);
+ IMU_6AXES_StatusTypeDef (*Get_X_FS) (float *);
+ IMU_6AXES_StatusTypeDef (*Set_X_FS) (float);
+ IMU_6AXES_StatusTypeDef (*Get_G_ODR) (float *);
+ IMU_6AXES_StatusTypeDef (*Set_G_ODR) (float);
+ IMU_6AXES_StatusTypeDef (*Get_G_Sensitivity) (float *);
+ IMU_6AXES_StatusTypeDef (*Get_G_FS) (float *);
+ IMU_6AXES_StatusTypeDef (*Set_G_FS) (float);
+ IMU_6AXES_DrvExtTypeDef *extData;
+} IMU_6AXES_DrvTypeDef;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IMU_6AXES_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Common/magneto.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,142 @@
+/**
+ ******************************************************************************
+ * @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_StatusTypeDef (*Get_M_AxesRaw)(int16_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/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Common/pressure.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,153 @@
+/**
+ ******************************************************************************
+ * @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****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Common/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,15 @@ +hum_temp.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/Common/hum_temp.h: revision #385, +- X-CUBE-MEMS1/trunk: revision #416 + +imu_6axes.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/Common/imu_6axes.h: revision #385, +- X-CUBE-MEMS1/trunk: revision #416 + +magneto.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/Common/magneto.h: revision #385, +- X-CUBE-MEMS1/trunk: revision #416 + +pressure.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/Common/pressure.h: revision #385, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/GenericSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,67 @@
+/**
+ ******************************************************************************
+ * @file GenericSensor.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 generic 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 __GENERIC_SENSOR_CLASS_H
+#define __GENERIC_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Generic sensors
+ */
+class GenericSensor
+{
+ public:
+ /**
+ * @brief Initialization of sensor
+ * @param[out] ptr Pointer to device specific initalization structure
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Init(void *ptr) = 0;
+
+ /**
+ * @brief Get ID of sensor
+ * @param[out] id Pointer to where to store the ID to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int ReadID(uint8_t *id) = 0;
+};
+
+#endif /* __GENERIC_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/GyroSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,114 @@
+/**
+ ******************************************************************************
+ * @file GyroSensor.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 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 __GYRO_SENSOR_CLASS_H
+#define __GYRO_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for a Gyroscope
+ */
+class GyroSensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current gyroscope angular rate X/Y/Z-axes values
+ * in standard data units [mdps]
+ * @param[out] pData Pointer to where to store angular rates to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_G_Axes(int32_t *pData) = 0;
+
+ /**
+ * @brief Get current gyroscope raw data X/Y/Z-axes values
+ * in device sepcific LSB units
+ * @param[out] pData Pointer to where to store gyroscope raw data to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_G_AxesRaw(int16_t *pData) = 0;
+
+ /**
+ * @brief Get gyroscope's current sensitivity [mdps/LSB]
+ * @param[out] pfData Pointer to where the gyroscope's sensitivity is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_G_Sensitivity(float *pfData) = 0;
+
+ /**
+ * @brief Get gyroscope's current output data rate [Hz]
+ * @param[out] pfData Pointer to where the gyroscope output data rate is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_G_ODR(float *pfData) = 0;
+
+ /**
+ * @brief Set gyroscope's output data rate
+ * @param[in] odr New value for gyroscope's output data rate in [Hz]
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Set_G_ODR(float odr) = 0;
+
+ /**
+ * @brief Get gyroscope's full scale value
+ * i.e.\ min/max measurable value [dps]
+ * @param[out] pfData Pointer to where the gyroscope full scale value is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_G_FS(float *pfData) = 0;
+
+ /**
+ * @brief Set gyroscope's full scale value
+ * i.e.\ min/max measurable value
+ * @param[in] fs New full scale value for gyroscope in [dps]
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Set_G_FS(float fs) = 0;
+};
+
+#endif /* __GYRO_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/HumiditySensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ * @file HumiditySensor.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 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 __HUMIDITY_SENSOR_CLASS_H
+#define __HUMIDITY_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Humidity sensors
+ */
+class HumiditySensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current humidity [%]
+ * @param[out] pfData Pointer to where to store humidity to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int GetHumidity(float *pfData) = 0;
+};
+
+#endif /* __HUMIDITY_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/MagneticSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,77 @@
+/**
+ ******************************************************************************
+ * @file MagneticSensor.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 __MAGNETIC_SENSOR_CLASS_H
+#define __MAGNETIC_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for a magnetometer
+ */
+class MagneticSensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current magnetometer magnetic X/Y/Z-axes values
+ * in standard data units [mgauss]
+ * @param[out] pData Pointer to where to store magnetic values to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_M_Axes(int32_t *pData) = 0;
+
+ /**
+ * @brief Get current magnetometer raw data X/Y/Z-axes values
+ * in device sepcific LSB units
+ * @param[out] pData Pointer to where to store magnetometer raw data to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_M_AxesRaw(int16_t *pData) = 0;
+};
+
+#endif /* __MAGNETIC_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/MotionSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,114 @@
+/**
+ ******************************************************************************
+ * @file MotionSensor.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 an accelerometer
+ ******************************************************************************
+ * @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 __MOTION_SENSOR_CLASS_H
+#define __MOTION_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for an Accelerometer
+ */
+class MotionSensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current accelerometer linear acceleration X/Y/Z-axes values
+ * in standard data units [mg]
+ * @param[out] pData Pointer to where to store linear accelerations to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_X_Axes(int32_t *pData) = 0;
+
+ /**
+ * @brief Get current accelerometer raw data X/Y/Z-axes values
+ * in device sepcific LSB units
+ * @param[out] pData Pointer to where to store accelerometer raw data to.
+ * pData must point to an array of (at least) three elements, where:
+ * pData[0] corresponds to X-axis,
+ * pData[1] corresponds to Y-axis, and
+ * pData[2] corresponds to Z-axis.
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_X_AxesRaw(int16_t *pData) = 0;
+
+ /**
+ * @brief Get accelerometer's current sensitivity [mg/LSB]
+ * @param[out] pfData Pointer to where the accelerometer's sensitivity is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_X_Sensitivity(float *pfData) = 0;
+
+ /**
+ * @brief Get accelerometer's current output data rate [Hz]
+ * @param[out] pfData Pointer to where the accelerometer output data rate is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_X_ODR(float *pfData) = 0;
+
+ /**
+ * @brief Set accelerometer's output data rate
+ * @param[in] odr New value for accelerometer's output data rate in [Hz]
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Set_X_ODR(float odr) = 0;
+
+ /**
+ * @brief Get accelerometer's full scale value
+ * i.e.\ min/max measurable value [g]
+ * @param[out] pfData Pointer to where the accelerometer full scale value is stored to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Get_X_FS(float *pfData) = 0;
+
+ /**
+ * @brief Set accelerometer's full scale value
+ * i.e.\ min/max measurable value
+ * @param[in] fs New full scale value for accelerometer in [g]
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Set_X_FS(float fs) = 0;
+};
+
+#endif /* __MOTION_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/PressureSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,60 @@
+/**
+ ******************************************************************************
+ * @file PressureSensor.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_SENSOR_CLASS_H
+#define __PRESSURE_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for a Pressure Sensor
+ */
+class PressureSensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current pressure [mbar]
+ * @param[out] pfData Pointer to where to store pressure to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int GetPressure(float *pfData) = 0;
+};
+
+#endif /* __PRESSURE_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/Interfaces/TempSensor.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,76 @@
+/**
+ ******************************************************************************
+ * @file TempSensor.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 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 __TEMP_SENSOR_CLASS_H
+#define __TEMP_SENSOR_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include <GenericSensor.h>
+
+/* Classes ------------------------------------------------------------------*/
+/** An abstract class for Temperature sensors
+ */
+class TempSensor : public GenericSensor
+{
+ public:
+ /**
+ * @brief Get current temperature in degrees Celsius [°C]
+ * @param[out] pfData Pointer to where to store temperature to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int GetTemperature(float *pfData) = 0;
+
+ /**
+ * @brief Get current temperature in degrees Fahrenheit [°F]
+ * @param[out] pfData Pointer to where to store temperature to
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int GetFahrenheit(float *pfData) {
+ float celsius;
+ int ret;
+
+ ret = GetTemperature(&celsius);
+ if(ret) return ret;
+
+ *pfData = ((celsius * 1.8f) + 32.0f);
+ return 0;
+ }
+};
+
+#endif /* __TEMP_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/hts221/hts221.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,599 @@
+/**
+ ******************************************************************************
+ * @file hts221.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 11-February-2015
+ * @brief This file contains definitions for the hts221.c
+ * firmware 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 __HTS221_H
+#define __HTS221_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "hum_temp.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup HTS221
+ * @{
+ */
+
+/** @defgroup HTS221_Exported_Defines HTS221_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+#define NULL (void *) 0
+#endif
+
+/**
+ * @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 Multiple Byte. Mask for enabling multiple byte read/write command.
+ */
+#define HTS221_I2C_MULTIPLEBYTE_CMD ((uint8_t)0x80)
+
+/**
+ * @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 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 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 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 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 HTS221_One_Shot_Selection_CTRL_REG2
+ * @{
+ */
+#define HTS221_ONE_SHOT_START ((uint8_t)0x01)
+
+#define HTS221_ONE_SHOT_MASK ((uint8_t)0x01)
+/**
+ * @}
+ */
+
+/** @defgroup HTS221_PushPull_OpenDrain_Selection_CTRL_REG3 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 HTS221_Data_Ready_Selection_CTRL_REG3
+ * @{
+ */
+#define HTS221_DRDY_DISABLE ((uint8_t)0x00)
+#define HTS221_DRDY_AVAILABLE ((uint8_t)0x04)
+
+#define HTS221_DRDY_MASK ((uint8_t)0x04)
+/**
+ * @}
+ */
+
+
+/** @defgroup HTS221_Humidity_Resolution_Selection_RES_CONF 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_Selection_RES_CONF HTS221_Temperature_Resolution_Selection_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 HTS221_Temperature_Humidity_Data_Available_STATUS_REG
+ * @{
+ */
+#define HTS221_H_DATA_AVAILABLE_MASK ((uint8_t)0x02)
+#define HTS221_T_DATA_AVAILABLE_MASK ((uint8_t)0x01)
+/**
+ * @}
+ */
+
+/* Data resolution */
+#define HUM_DECIMAL_DIGITS (2)
+#define TEMP_DECIMAL_DIGITS (2)
+
+/**
+ * @}
+ */
+
+
+/** @defgroup HTS221_Imported_Functions HTS221_Imported_Functions
+ * @{
+ */
+/* HUM_TEMP sensor IO functions */
+extern HUM_TEMP_StatusTypeDef HTS221_IO_Init(void);
+extern HUM_TEMP_StatusTypeDef HTS221_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite);
+extern HUM_TEMP_StatusTypeDef HTS221_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead);
+extern void HTS221_IO_ITConfig( void );
+
+/**
+ * @}
+ */
+
+/* ------------------------------------------------------- */
+/* Here you should declare the internal struct of */
+/* extended features of HTS221. See the example of */
+/* LSM6DS3 in lsm6ds3.h */
+/* ------------------------------------------------------- */
+
+/** @addtogroup HTS221_Exported_Variables HTS221_Exported_Variables
+ * @{
+ */
+/* HUM_TEMP sensor driver structure */
+extern HUM_TEMP_DrvTypeDef Hts221Drv;
+extern HUM_TEMP_DrvExtTypeDef Hts221Drv_ext;
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HTS221_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/hts221/hts221_class.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,415 @@
+/**
+ ******************************************************************************
+ * @file hts221_class.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Implementation file for the HTS221 driver class
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+/* Includes ------------------------------------------------------------------*/
+#include "hts221_class.h"
+#include "hts221.h"
+
+/* Methods -------------------------------------------------------------------*/
+/* betzw - based on:
+ X-CUBE-MEMS1/trunk/Drivers/BSP/Components/hts221/hts221.c: revision #410,
+ X-CUBE-MEMS1/trunk: revision #416
+*/
+
+/**
+ * @brief HTS221 Calibration procedure
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_Calibration(void)
+{
+ /* Temperature Calibration */
+ /* Temperature in degree for calibration ( "/8" to obtain float) */
+ uint16_t T0_degC_x8_L, T0_degC_x8_H, T1_degC_x8_L, T1_degC_x8_H;
+ uint8_t H0_rh_x2, H1_rh_x2;
+ uint8_t tempReg[2] = {0, 0};
+
+ if(HTS221_IO_Read(tempReg, HTS221_T0_degC_X8_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T0_degC_x8_L = (uint16_t)tempReg[0];
+
+ if(HTS221_IO_Read(tempReg, HTS221_T1_T0_MSB_X8_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T0_degC_x8_H = (uint16_t) (tempReg[0] & 0x03);
+ T0_degC = ((float)((T0_degC_x8_H << 8) | (T0_degC_x8_L))) / 8;
+
+ if(HTS221_IO_Read(tempReg, HTS221_T1_degC_X8_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T1_degC_x8_L = (uint16_t)tempReg[0];
+
+ if(HTS221_IO_Read(tempReg, HTS221_T1_T0_MSB_X8_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ 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;
+
+ if(HTS221_IO_Read(tempReg, (HTS221_T0_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD), 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T0_out = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(HTS221_IO_Read(tempReg, (HTS221_T1_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD), 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T1_out = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ /* Humidity Calibration */
+ /* Humidity in degree for calibration ( "/2" to obtain float) */
+
+ if(HTS221_IO_Read(&H0_rh_x2, HTS221_H0_RH_X2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ if(HTS221_IO_Read(&H1_rh_x2, HTS221_H1_RH_X2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ if(HTS221_IO_Read(&tempReg[0], (HTS221_H0_T0_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD),
+ 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ H0_T0_out = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(HTS221_IO_Read(&tempReg[0], (HTS221_H1_T0_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD),
+ 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ 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 HUM_TEMP_OK;
+}
+
+
+/**
+ * @brief Set HTS221 Initialization
+ * @param HTS221_Init the configuration setting for the HTS221
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_Init(HUM_TEMP_InitTypeDef *HTS221_Init)
+{
+ uint8_t tmp = 0x00;
+
+ /* Configure the low level interface ---------------------------------------*/
+ if(HTS221_IO_Init() != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ if(HTS221_Power_On() != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ if(HTS221_Calibration() != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ if(HTS221_IO_Read(&tmp, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Output Data Rate selection */
+ tmp &= ~(HTS221_ODR_MASK);
+ tmp |= HTS221_Init->OutputDataRate;
+
+ if(HTS221_IO_Write(&tmp, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ HTS221_IO_ITConfig();
+
+ return HUM_TEMP_OK;
+}
+
+/**
+ * @brief Read ID address of HTS221
+ * @param ht_id the pointer where the ID of the device is stored
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_ReadID(uint8_t *ht_id)
+{
+ if(!ht_id)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ return HTS221_IO_Read(ht_id, HTS221_WHO_AM_I_ADDR, 1);
+}
+
+/**
+ * @brief Reboot memory content of HTS221
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_RebootCmd(void)
+{
+ uint8_t tmpreg;
+
+ /* Read CTRL_REG2 register */
+ if(HTS221_IO_Read(&tmpreg, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Enable or Disable the reboot memory */
+ tmpreg |= HTS221_BOOT_REBOOTMEMORY;
+
+ /* Write value to MEMS CTRL_REG2 regsister */
+ if(HTS221_IO_Write(&tmpreg, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ return HUM_TEMP_OK;
+}
+
+
+/**
+ * @brief Read HTS221 output register, and calculate the humidity
+ * @param pfData the pointer to data output
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_GetHumidity(float* pfData)
+{
+ int16_t H_T_out, humidity_t;
+ uint8_t tempReg[2] = {0, 0};
+ uint8_t tmp = 0x00;
+ float H_rh;
+
+ if(HTS221_IO_Read(&tmp, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Output Data Rate selection */
+ tmp &= (HTS221_ODR_MASK);
+
+ if(tmp == 0x00)
+ {
+ if(HTS221_IO_Read(&tmp, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Serial Interface Mode selection */
+ tmp &= ~(HTS221_ONE_SHOT_MASK);
+ tmp |= HTS221_ONE_SHOT_START;
+
+ if(HTS221_IO_Write(&tmp, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ do
+ {
+
+ if(HTS221_IO_Read(&tmp, HTS221_STATUS_REG_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ }
+ while(!(tmp & 0x02));
+ }
+
+
+ if(HTS221_IO_Read(&tempReg[0], (HTS221_HUMIDITY_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD),
+ 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ H_T_out = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ H_rh = ( float )(((( H_T_out - H0_T0_out ) * ( H1_rh - H0_rh )) / ( H1_T0_out - H0_T0_out )) + H0_rh );
+
+ // Truncate to specific number of decimal digits
+ humidity_t = (uint16_t)(H_rh * pow(10.0f, HUM_DECIMAL_DIGITS));
+ *pfData = ((float)humidity_t) / pow(10.0f, HUM_DECIMAL_DIGITS);
+
+ // Prevent data going below 0% and above 100% due to linear interpolation
+ if ( *pfData < 0.0f ) *pfData = 0.0f;
+ if ( *pfData > 100.0f ) *pfData = 100.0f;
+
+ return HUM_TEMP_OK;
+}
+
+/**
+ * @brief Read HTS221 output register, and calculate the temperature
+ * @param pfData the pointer to data output
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_GetTemperature(float* pfData)
+{
+ int16_t T_out, temperature_t;
+ uint8_t tempReg[2] = {0, 0};
+ uint8_t tmp = 0x00;
+ float T_degC;
+
+ if(HTS221_IO_Read(&tmp, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Output Data Rate selection */
+ tmp &= (HTS221_ODR_MASK);
+
+ if(tmp == 0x00)
+ {
+ if(HTS221_IO_Read(&tmp, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Serial Interface Mode selection */
+ tmp &= ~(HTS221_ONE_SHOT_MASK);
+ tmp |= HTS221_ONE_SHOT_START;
+
+ if(HTS221_IO_Write(&tmp, HTS221_CTRL_REG2_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ do
+ {
+
+ if(HTS221_IO_Read(&tmp, HTS221_STATUS_REG_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ }
+ while(!(tmp & 0x01));
+ }
+
+ if(HTS221_IO_Read(&tempReg[0], (HTS221_TEMP_OUT_L_ADDR | HTS221_I2C_MULTIPLEBYTE_CMD),
+ 2) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ T_out = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ T_degC = ((float)(T_out - T0_out)) / (T1_out - T0_out) * (T1_degC - T0_degC) + T0_degC;
+
+ temperature_t = (int16_t)(T_degC * pow(10.0f, TEMP_DECIMAL_DIGITS));
+
+ *pfData = ((float)temperature_t) / pow(10.0f, TEMP_DECIMAL_DIGITS);
+
+ return HUM_TEMP_OK;
+}
+
+
+/**
+ * @brief Exit the shutdown mode for HTS221
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_Power_On(void)
+{
+ uint8_t tmpReg;
+
+ /* Read the register content */
+ if(HTS221_IO_Read(&tmpReg, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Set the power down bit */
+ tmpReg |= HTS221_MODE_ACTIVE;
+
+ /* Write register */
+ if(HTS221_IO_Write(&tmpReg, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ return HUM_TEMP_OK;
+}
+
+/**
+ * @brief Enter the shutdown mode for HTS221
+ * @retval HUM_TEMP_OK in case of success, an error code otherwise
+ */
+HUM_TEMP_StatusTypeDef HTS221::HTS221_Power_OFF(void)
+{
+ uint8_t tmpReg;
+
+ /* Read the register content */
+ if(HTS221_IO_Read(&tmpReg, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ /* Reset the power down bit */
+ tmpReg &= ~(HTS221_MODE_ACTIVE);
+
+ /* Write register */
+ if(HTS221_IO_Write(&tmpReg, HTS221_CTRL_REG1_ADDR, 1) != HUM_TEMP_OK)
+ {
+ return HUM_TEMP_ERROR;
+ }
+
+ return HUM_TEMP_OK;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/hts221/hts221_class.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,186 @@
+/**
+ ******************************************************************************
+ * @file hts221_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component HTS221
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+#ifndef __HTS221_CLASS_H
+#define __HTS221_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "DevI2C.h"
+#include "hts221.h"
+#include "../Interfaces/HumiditySensor.h"
+#include "../Interfaces/TempSensor.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a HTS221 sensor component
+ */
+class HTS221 : public HumiditySensor, public TempSensor {
+ public:
+ /** Constructor
+ * @param[in] i2c device I2C to be used for communication
+ */
+ HTS221(DevI2C &i2c) : HumiditySensor(), TempSensor(), dev_i2c(i2c) {
+ T0_degC = T1_degC = H0_rh = H1_rh = 0.0;
+ T0_out = T1_out = H0_T0_out = H1_T0_out = 0;
+ }
+
+ /** Destructor
+ */
+ virtual ~HTS221() {}
+
+ /*** Interface Methods ***/
+ virtual int Init(void *init_struct) {
+ return HTS221_Init((HUM_TEMP_InitTypeDef*)init_struct);
+ }
+
+ /**
+ * @brief Enter sensor shutdown mode
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int PowerOff(void) {
+ return HTS221_Power_OFF();
+ }
+
+ virtual int ReadID(uint8_t *ht_id) {
+ return HTS221_ReadID(ht_id);
+ }
+
+ /**
+ * @brief Reset sensor
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Reset(void) {
+ return HTS221_RebootCmd();
+ }
+
+ virtual int GetHumidity(float *pfData) {
+ return HTS221_GetHumidity(pfData);
+ }
+
+ virtual int GetTemperature(float *pfData) {
+ return HTS221_GetTemperature(pfData);
+ }
+
+ protected:
+ /*** Methods ***/
+ HUM_TEMP_StatusTypeDef HTS221_Init(HUM_TEMP_InitTypeDef *HTS221_Init);
+ HUM_TEMP_StatusTypeDef HTS221_Power_OFF(void);
+ HUM_TEMP_StatusTypeDef HTS221_ReadID(uint8_t *ht_id);
+ HUM_TEMP_StatusTypeDef HTS221_RebootCmd(void);
+ HUM_TEMP_StatusTypeDef HTS221_GetHumidity(float* pfData);
+ HUM_TEMP_StatusTypeDef HTS221_GetTemperature(float* pfData);
+
+ HUM_TEMP_StatusTypeDef HTS221_Power_On(void);
+ HUM_TEMP_StatusTypeDef HTS221_Calibration(void);
+
+ /**
+ * @brief Configures HTS221 interrupt lines for NUCLEO boards
+ */
+ void HTS221_IO_ITConfig(void)
+ {
+ /* To be implemented */
+ }
+
+ /**
+ * @brief Configures HTS221 I2C interface
+ * @return HUM_TEMP_OK in case of success, an error code otherwise
+ */
+ HUM_TEMP_StatusTypeDef HTS221_IO_Init(void)
+ {
+ return HUM_TEMP_OK; /* done in constructor */
+ }
+
+ /**
+ * @brief Utility function to read data from HTS221
+ * @param[out] pBuffer pointer to the byte-array to read data in to
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToRead number of bytes to be read.
+ * @retval HUM_TEMP_OK if ok,
+ * @retval HUM_TEMP_ERROR if an I2C error has occured
+ */
+ HUM_TEMP_StatusTypeDef HTS221_IO_Read(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ int ret = dev_i2c.i2c_read(pBuffer,
+ HTS221_ADDRESS,
+ RegisterAddr,
+ NumByteToRead);
+ if(ret != 0) {
+ return HUM_TEMP_ERROR;
+ }
+ return HUM_TEMP_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to HTS221
+ * @param[in] pBuffer pointer to the byte-array data to send
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToWrite number of bytes to write.
+ * @retval HUM_TEMP_OK if ok,
+ * @retval HUM_TEMP_ERROR if an I2C error has occured
+ */
+ HUM_TEMP_StatusTypeDef HTS221_IO_Write(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ int ret = dev_i2c.i2c_write(pBuffer,
+ HTS221_ADDRESS,
+ RegisterAddr,
+ NumByteToWrite);
+ if(ret != 0) {
+ return HUM_TEMP_ERROR;
+ }
+ return HUM_TEMP_OK;
+ }
+
+ /*** Instance Variables ***/
+ /* IO Device */
+ DevI2C &dev_i2c;
+
+ /* 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;
+};
+
+#endif // __HTS221_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/hts221/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,3 @@ +hts221.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/hts221/hts221.h: revision #402, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lis3mdl/lis3mdl.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,455 @@
+/**
+ ******************************************************************************
+ * @file lis3mdl.h
+ * @author MEMS Application Team
+ * @version V1.3.0
+ * @date 28-May-2015
+ * @brief This file contains definitions for the lis3mdl.c
+ * firmware 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 __LIS3MDL_H
+#define __LIS3MDL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "magneto.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup LIS3MDL
+ * @{
+ */
+
+/** @defgroup LIS3MDL_Exported_Defines LIS3MDL_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+#define NULL (void *) 0
+#endif
+
+
+/******************************************************************************/
+/***************** 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 Multiple Byte. Mask for enabling multiple byte read/write command.
+ */
+#define LIS3MDL_I2C_MULTIPLEBYTE_CMD ((uint8_t)0x80)
+
+/**
+ * @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 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 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 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 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 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 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 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 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 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 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 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)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup LIS3MDL_Imported_Functions LIS3MDL_Imported_Functions
+ * @{
+ */
+
+/* Magneto sensor IO functions */
+extern MAGNETO_StatusTypeDef LIS3MDL_IO_Init(void);
+extern MAGNETO_StatusTypeDef LIS3MDL_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite);
+extern MAGNETO_StatusTypeDef LIS3MDL_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead);
+extern void LIS3MDL_IO_ITConfig( void );
+
+/**
+ * @}
+ */
+
+/* ------------------------------------------------------- */
+/* Here you should declare the internal struct of */
+/* extended features of LSM6DS0. See the example of */
+/* LSM6DS3 in lsm6ds3.h */
+/* ------------------------------------------------------- */
+
+/** @addtogroup LIS3MDL_Exported_Variables LIS3MDL_Exported_Variables
+ * @{
+ */
+/* Magneto sensor driver structure */
+extern MAGNETO_DrvTypeDef LIS3MDLDrv;
+extern MAGNETO_DrvExtTypeDef LIS3MDLDrv_ext;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIS3MDL_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lis3mdl/lis3mdl_class.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,219 @@
+/**
+ ******************************************************************************
+ * @file lis3mdl_class.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Implementation file for the LIS3MDL driver class
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+/* Includes ------------------------------------------------------------------*/
+#include "lis3mdl_class.h"
+#include "lis3mdl.h"
+
+/* Methods -------------------------------------------------------------------*/
+/* betzw - based on:
+ X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lis3mdl/lis3mdl.c: revision #400,
+ X-CUBE-MEMS1/trunk: revision #416
+*/
+
+/**
+ * @brief Set LIS3MDL Initialization
+ * @param LIS3MDL_Init the configuration setting for the LIS3MDL
+ * @retval MAGNETO_OK in case of success, an error code otherwise
+ */
+MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_Init(MAGNETO_InitTypeDef *LIS3MDL_Init)
+{
+ uint8_t tmp1 = 0x00;
+
+ /* Configure the low level interface ---------------------------------------*/
+ if(LIS3MDL_IO_Init() != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ /****** Magnetic sensor *******/
+
+ if(LIS3MDL_IO_Read(&tmp1, LIS3MDL_M_CTRL_REG3_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ /* Conversion mode selection */
+ tmp1 &= ~(LIS3MDL_M_MD_MASK);
+ tmp1 |= LIS3MDL_Init->M_OperatingMode;
+
+ if(LIS3MDL_IO_Write(&tmp1, LIS3MDL_M_CTRL_REG3_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ if(LIS3MDL_IO_Read(&tmp1, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ /* Output data rate selection */
+ tmp1 &= ~(LIS3MDL_M_DO_MASK);
+ tmp1 |= LIS3MDL_Init->M_OutputDataRate;
+
+ /* X and Y axes Operative mode selection */
+ tmp1 &= ~(LIS3MDL_M_OM_MASK);
+ tmp1 |= LIS3MDL_Init->M_XYOperativeMode;
+
+ if(LIS3MDL_IO_Write(&tmp1, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ if(LIS3MDL_IO_Read(&tmp1, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ /* Full scale selection */
+ tmp1 &= ~(LIS3MDL_M_FS_MASK);
+ tmp1 |= LIS3MDL_Init->M_FullScale;
+
+ if(LIS3MDL_IO_Write(&tmp1, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ /* Configure interrupt lines */
+ LIS3MDL_IO_ITConfig();
+
+ return MAGNETO_OK;
+
+ /******************************/
+}
+
+
+/**
+ * @brief Read ID of LIS3MDL Magnetic sensor
+ * @param m_id the pointer where the ID of the device is stored
+ * @retval MAGNETO_OK in case of success, an error code otherwise
+ */
+MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_Read_M_ID(uint8_t *m_id)
+{
+ if(!m_id)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ return LIS3MDL_IO_Read(m_id, LIS3MDL_M_WHO_AM_I_ADDR, 1);
+}
+
+
+/**
+ * @brief Read raw data from LIS3MDL Magnetic sensor output register
+ * @param pData the pointer where the magnetometer raw data are stored
+ * @retval MAGNETO_OK in case of success, an error code otherwise
+ */
+MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0, 0};
+
+ if(LIS3MDL_IO_Read(&tempReg[0], (LIS3MDL_M_OUT_X_L_M | LIS3MDL_I2C_MULTIPLEBYTE_CMD),
+ 2) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LIS3MDL_IO_Read(&tempReg[0], (LIS3MDL_M_OUT_Y_L_M | LIS3MDL_I2C_MULTIPLEBYTE_CMD),
+ 2) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LIS3MDL_IO_Read(&tempReg[0], (LIS3MDL_M_OUT_Z_L_M | LIS3MDL_I2C_MULTIPLEBYTE_CMD),
+ 2) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ return MAGNETO_OK;
+}
+
+
+/**
+ * @brief Read data from LIS3MDL Magnetic sensor and calculate Magnetic in mgauss
+ * @param pData the pointer where the magnetometer data are stored
+ * @retval MAGNETO_OK in case of success, an error code otherwise
+ */
+MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_GetAxes(int32_t *pData)
+{
+ uint8_t tempReg = 0x00;
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+
+ if(LIS3MDL_M_GetAxesRaw(pDataRaw) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK)
+ {
+ return MAGNETO_ERROR;
+ }
+
+ 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[0] = (int32_t)(pDataRaw[0] * sensitivity);
+ pData[1] = (int32_t)(pDataRaw[1] * sensitivity);
+ pData[2] = (int32_t)(pDataRaw[2] * sensitivity);
+
+ return MAGNETO_OK;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lis3mdl/lis3mdl_class.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,150 @@
+/**
+ ******************************************************************************
+ * @file lis3mdl_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component LIS3MDL
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+#ifndef __LIS3MDL_CLASS_H
+#define __LIS3MDL_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "DevI2C.h"
+#include "lis3mdl.h"
+#include "../Interfaces/MagneticSensor.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a LIS3MDL sensor component
+ */
+class LIS3MDL : public MagneticSensor {
+ public:
+ /** Constructor
+ * @param[in] i2c device I2C to be used for communication
+ */
+ LIS3MDL(DevI2C &i2c) : MagneticSensor(), dev_i2c(i2c) {
+ }
+
+ /** Destructor
+ */
+ virtual ~LIS3MDL() {}
+
+ /*** Interface Methods ***/
+ virtual int Init(void *init_struct) {
+ return LIS3MDL_Init((MAGNETO_InitTypeDef*)init_struct);
+ }
+
+ virtual int ReadID(uint8_t *m_id) {
+ return LIS3MDL_Read_M_ID(m_id);
+ }
+
+ virtual int Get_M_Axes(int32_t *pData) {
+ return LIS3MDL_M_GetAxes(pData);
+ }
+
+ virtual int Get_M_AxesRaw(int16_t *pData) {
+ return LIS3MDL_M_GetAxesRaw(pData);
+ }
+
+ protected:
+ /*** Methods ***/
+ MAGNETO_StatusTypeDef LIS3MDL_Init(MAGNETO_InitTypeDef *LIS3MDL_Init);
+ MAGNETO_StatusTypeDef LIS3MDL_Read_M_ID(uint8_t *m_id);
+ MAGNETO_StatusTypeDef LIS3MDL_M_GetAxes(int32_t *pData);
+ MAGNETO_StatusTypeDef LIS3MDL_M_GetAxesRaw(int16_t *pData);
+
+ /**
+ * @brief Configures LIS3MDL interrupt lines for NUCLEO boards
+ */
+ void LIS3MDL_IO_ITConfig(void)
+ {
+ /* To be implemented */
+ }
+
+ /**
+ * @brief Configures LIS3MDL I2C interface
+ * @return MAGNETO_OK in case of success, an error code otherwise
+ */
+ MAGNETO_StatusTypeDef LIS3MDL_IO_Init(void)
+ {
+ return MAGNETO_OK; /* done in constructor */
+ }
+
+ /**
+ * @brief Utility function to read data from LIS3MDL
+ * @param[out] pBuffer pointer to the byte-array to read data in to
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToRead number of bytes to be read.
+ * @retval MAGNETO_OK if ok,
+ * @retval MAGNETO_ERROR if an I2C error has occured
+ */
+ MAGNETO_StatusTypeDef LIS3MDL_IO_Read(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ int ret = dev_i2c.i2c_read(pBuffer,
+ LIS3MDL_M_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToRead);
+ if(ret != 0) {
+ return MAGNETO_ERROR;
+ }
+ return MAGNETO_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to LIS3MDL
+ * @param[in] pBuffer pointer to the byte-array data to send
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToWrite number of bytes to write.
+ * @retval MAGNETO_OK if ok,
+ * @retval MAGNETO_ERROR if an I2C error has occured
+ */
+ MAGNETO_StatusTypeDef LIS3MDL_IO_Write(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ int ret = dev_i2c.i2c_write(pBuffer,
+ LIS3MDL_M_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToWrite);
+ if(ret != 0) {
+ return MAGNETO_ERROR;
+ }
+ return MAGNETO_OK;
+ }
+
+ /*** Instance Variables ***/
+ /* IO Device */
+ DevI2C &dev_i2c;
+};
+
+#endif // __LIS3MDL_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lis3mdl/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,3 @@ +lis3mdl.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lis3mdl/lis3mdl.h: revision #402, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lps25h/lps25h.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,572 @@
+/**
+ ******************************************************************************
+ * @file lps25h.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 11-February-2015
+ * @brief This file contains definitions for the lps25h.c
+ * firmware 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 __LPS25H_H
+#define __LPS25H_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "pressure.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup LPS25H
+ * @{
+ */
+
+/** @defgroup LPS25H_Exported_Defines LPS25H_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+#define NULL (void *) 0
+#endif
+
+
+/******************************************************************************/
+/*************************** 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 Multiple Byte. Mask for enabling multiple byte read/write command.
+ */
+#define LPS25H_I2C_MULTIPLEBYTE_CMD ((uint8_t)0x80)
+
+/**
+ * @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 LPS25H_Power_Mode_Selection_CTRL_REG1 LPS25H_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 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 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 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 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_Refresh_Registers_Flash_Memory_CTRL_REG2 LPS25H_Refresh_Registers_Flash_Memory_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 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_Selection_RES_CONF LPS25H_Temperature_Resolution_Selection_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)
+
+/**
+ * @}
+ */
+
+/** @defgroup LPS25H_Imported_Functions LPS25H_Imported_Functions
+ * @{
+ */
+/* Pressure sensor IO functions */
+extern PRESSURE_StatusTypeDef LPS25H_IO_Init(void);
+extern PRESSURE_StatusTypeDef LPS25H_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite);
+extern PRESSURE_StatusTypeDef LPS25H_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead);
+extern void LPS25H_IO_ITConfig( void );
+
+/**
+ * @}
+ */
+
+/* ------------------------------------------------------- */
+/* Here you should declare the internal struct of */
+/* extended features of LPS25H. See the example of */
+/* LSM6DS3 in lsm6ds3.h */
+/* ------------------------------------------------------- */
+
+/** @addtogroup LPS25H_Exported_Variables LPS25H_Exported_Variables
+ * @{
+ */
+/* Pressure sensor driver structure */
+extern PRESSURE_DrvTypeDef LPS25HDrv;
+extern PRESSURE_DrvExtTypeDef LPS25HDrv_ext;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LPS25H_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lps25h/lps25h_class.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,317 @@
+/**
+ ******************************************************************************
+ * @file lps25h_class.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Implementation file for the LPS25H driver class
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+/* Includes ------------------------------------------------------------------*/
+#include "lps25h_class.h"
+#include "lps25h.h"
+
+/* Methods -------------------------------------------------------------------*/
+/* betzw - based on:
+ X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lps25h/lps25h.c: revision #400,
+ X-CUBE-MEMS1/trunk: revision #416
+*/
+
+/**
+ * @brief Set LPS25H Initialization
+ * @param LPS25H_Init the configuration setting for the LPS25H
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init)
+{
+ uint8_t tmp1 = 0x00;
+
+ /* Configure the low level interface ---------------------------------------*/
+ if(LPS25H_IO_Init() != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ if(LPS25H_PowerOn() != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ if(LPS25H_IO_Read(&tmp1, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Output Data Rate selection */
+ tmp1 &= ~(LPS25H_ODR_MASK);
+ tmp1 |= LPS25H_Init->OutputDataRate;
+
+ /* Interrupt circuit selection */
+ tmp1 &= ~(LPS25H_DIFF_EN_MASK);
+ tmp1 |= LPS25H_Init->DiffEnable;
+
+ /* Block Data Update selection */
+ tmp1 &= ~(LPS25H_BDU_MASK);
+ tmp1 |= LPS25H_Init->BlockDataUpdate;
+
+ /* Serial Interface Mode selection */
+ tmp1 &= ~(LPS25H_SPI_SIM_MASK);
+ tmp1 |= LPS25H_Init->SPIMode;
+
+ if(LPS25H_IO_Write(&tmp1, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ if(LPS25H_IO_Read(&tmp1, LPS25H_RES_CONF_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Serial Interface Mode selection */
+ tmp1 &= ~(LPS25H_P_RES_MASK);
+ tmp1 |= LPS25H_Init->PressureResolution;
+
+ /* Serial Interface Mode selection */
+ tmp1 &= ~(LPS25H_T_RES_MASK);
+ tmp1 |= LPS25H_Init->TemperatureResolution;
+
+ if(LPS25H_IO_Write(&tmp1, LPS25H_RES_CONF_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ LPS25H_IO_ITConfig();
+
+ return PRESSURE_OK;
+}
+
+/**
+ * @brief Read ID address of LPS25H
+ * @param ht_id the pointer where the ID of the device is stored
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_ReadID(uint8_t *p_id)
+{
+ if(!p_id)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ return LPS25H_IO_Read(p_id, LPS25H_WHO_AM_I_ADDR, 1);
+}
+
+/**
+ * @brief Reboot memory content of LPS25H
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_RebootCmd(void)
+{
+ uint8_t tmpreg;
+
+ /* Read CTRL_REG5 register */
+ if(LPS25H_IO_Read(&tmpreg, LPS25H_CTRL_REG2_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Enable or Disable the reboot memory */
+ tmpreg |= LPS25H_RESET_MEMORY;
+
+ /* Write value to MEMS CTRL_REG5 regsister */
+ if(LPS25H_IO_Write(&tmpreg, LPS25H_CTRL_REG2_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ return PRESSURE_OK;
+}
+
+
+/**
+ * @brief Read LPS25H output register, and calculate the raw pressure
+ * @param raw_press the pressure raw value
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_I2C_ReadRawPressure(int32_t *raw_press)
+{
+ uint8_t buffer[3], i;
+ uint32_t tempVal = 0;
+
+ /* Read the register content */
+
+ if(LPS25H_IO_Read(buffer, (LPS25H_PRESS_POUT_XL_ADDR | LPS25H_I2C_MULTIPLEBYTE_CMD),
+ 3) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* 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 = ((int32_t) tempVal);
+
+ return PRESSURE_OK;
+}
+
+/**
+ * @brief Read LPS25H output register, and calculate the pressure in mbar
+ * @param pfData the pressure value in mbar
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_GetPressure(float* pfData)
+{
+ int32_t raw_press = 0;
+
+ if(LPS25H_I2C_ReadRawPressure(&raw_press) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ *pfData = (float)raw_press / 4096.0f;
+
+ return PRESSURE_OK;
+}
+
+/**
+ * @brief Read LPS25H output register, and calculate the raw temperature
+ * @param raw_data the temperature raw value
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_I2C_ReadRawTemperature(int16_t *raw_data)
+{
+ uint8_t buffer[2];
+ uint16_t tempVal = 0;
+
+ /* Read the register content */
+ if(LPS25H_IO_Read(buffer, (LPS25H_TEMP_OUT_L_ADDR | LPS25H_I2C_MULTIPLEBYTE_CMD),
+ 2) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Build the raw value */
+ tempVal = (((uint16_t)buffer[1]) << 8) + (uint16_t)buffer[0];
+
+ /* Return it */
+ *raw_data = ((int16_t)tempVal);
+
+ return PRESSURE_OK;
+}
+
+/**
+ * @brief Read LPS25H output register, and calculate the temperature
+ * @param pfData the temperature value
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_GetTemperature(float *pfData)
+{
+ int16_t raw_data;
+
+ if(LPS25H_I2C_ReadRawTemperature(&raw_data) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ *pfData = (float)((((float)raw_data / 480.0f) + 42.5f));
+
+ return PRESSURE_OK;
+}
+/**
+ * @brief Exit the shutdown mode for LPS25H
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_PowerOn(void)
+{
+ uint8_t tmpreg;
+
+ /* Read the register content */
+ if(LPS25H_IO_Read(&tmpreg, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Set the power down bit */
+ tmpreg |= LPS25H_MODE_ACTIVE;
+
+ /* Write register */
+ if(LPS25H_IO_Write(&tmpreg, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ return PRESSURE_OK;
+}
+
+
+/**
+ * @brief Enter the shutdown mode for LPS25H
+ * @retval PRESSURE_OK in case of success, an error code otherwise
+ */
+PRESSURE_StatusTypeDef LPS25H::LPS25H_PowerOff(void)
+{
+ uint8_t tmpreg;
+
+ /* Read the register content */
+ if(LPS25H_IO_Read(&tmpreg, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ /* Reset the power down bit */
+ tmpreg &= ~(LPS25H_MODE_ACTIVE);
+
+ /* Write register */
+ if(LPS25H_IO_Write(&tmpreg, LPS25H_CTRL_REG1_ADDR, 1) != PRESSURE_OK)
+ {
+ return PRESSURE_ERROR;
+ }
+
+ return PRESSURE_OK;
+}
+
+/**
+ * @brief Set the slave address according to SA0 bit
+ * @param SA0_Bit_Status LPS25H_SA0_LOW or LPS25H_SA0_HIGH
+ * @retval None
+ */
+void LPS25H::LPS25H_SlaveAddrRemap(uint8_t SA0_Bit_Status)
+{
+ LPS25H_SlaveAddress = (SA0_Bit_Status == LPS25H_SA0_LOW ? LPS25H_ADDRESS_LOW : LPS25H_ADDRESS_HIGH);
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lps25h/lps25h_class.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,181 @@
+/**
+ ******************************************************************************
+ * @file lps25h_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component LPS25H
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+#ifndef __LPS25H_CLASS_H
+#define __LPS25H_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "DevI2C.h"
+#include "lps25h.h"
+#include "../Interfaces/PressureSensor.h"
+#include "../Interfaces/TempSensor.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a LPS25H sensor component
+ */
+class LPS25H : public PressureSensor, public TempSensor {
+ public:
+ /** Constructor
+ * @param[in] i2c device I2C to be used for communication
+ */
+ LPS25H(DevI2C &i2c) : PressureSensor(), TempSensor(), dev_i2c(i2c) {
+ LPS25H_SlaveAddress = LPS25H_ADDRESS_HIGH;
+ }
+
+ /** Destructor
+ */
+ virtual ~LPS25H() {}
+
+ /*** Interface Methods ***/
+ virtual int Init(void *init_struct) {
+ return LPS25H_Init((PRESSURE_InitTypeDef*)init_struct);
+ }
+
+ /**
+ * @brief Enter sensor shutdown mode
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int PowerOff(void) {
+ return LPS25H_PowerOff();
+ }
+
+ virtual int ReadID(uint8_t *p_id) {
+ return LPS25H_ReadID(p_id);
+ }
+
+ /**
+ * @brief Reset sensor
+ * @return 0 in case of success, an error code otherwise
+ */
+ virtual int Reset(void) {
+ return LPS25H_RebootCmd();
+ }
+
+ virtual int GetPressure(float *pfData) {
+ return LPS25H_GetPressure(pfData);
+ }
+
+ virtual int GetTemperature(float *pfData) {
+ return LPS25H_GetTemperature(pfData);
+ }
+
+ void SlaveAddrRemap(uint8_t SA0_Bit_Status) {
+ LPS25H_SlaveAddrRemap(SA0_Bit_Status);
+ }
+
+protected:
+ /*** Methods ***/
+ PRESSURE_StatusTypeDef LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init);
+ PRESSURE_StatusTypeDef LPS25H_ReadID(uint8_t *p_id);
+ PRESSURE_StatusTypeDef LPS25H_RebootCmd(void);
+ PRESSURE_StatusTypeDef LPS25H_GetPressure(float* pfData);
+ PRESSURE_StatusTypeDef LPS25H_GetTemperature(float* pfData);
+ PRESSURE_StatusTypeDef LPS25H_PowerOff(void);
+ void LPS25H_SlaveAddrRemap(uint8_t SA0_Bit_Status);
+
+ PRESSURE_StatusTypeDef LPS25H_PowerOn(void);
+ PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawPressure(int32_t *raw_press);
+ PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawTemperature(int16_t *raw_data);
+
+ /**
+ * @brief Configures LPS25H interrupt lines for NUCLEO boards
+ */
+ void LPS25H_IO_ITConfig(void)
+ {
+ /* To be implemented */
+ }
+
+ /**
+ * @brief Configures LPS25H I2C interface
+ * @return PRESSURE_OK in case of success, an error code otherwise
+ */
+ PRESSURE_StatusTypeDef LPS25H_IO_Init(void)
+ {
+ return PRESSURE_OK; /* done in constructor */
+ }
+
+ /**
+ * @brief Utility function to read data from LPS25H
+ * @param[out] pBuffer pointer to the byte-array to read data in to
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToRead number of bytes to be read.
+ * @retval PRESSURE_OK if ok,
+ * @retval PRESSURE_ERROR if an I2C error has occured
+ */
+ PRESSURE_StatusTypeDef LPS25H_IO_Read(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ int ret = dev_i2c.i2c_read(pBuffer,
+ LPS25H_SlaveAddress,
+ RegisterAddr,
+ NumByteToRead);
+ if(ret != 0) {
+ return PRESSURE_ERROR;
+ }
+ return PRESSURE_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to LPS25H
+ * @param[in] pBuffer pointer to the byte-array data to send
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToWrite number of bytes to write.
+ * @retval PRESSURE_OK if ok,
+ * @retval PRESSURE_ERROR if an I2C error has occured
+ */
+ PRESSURE_StatusTypeDef LPS25H_IO_Write(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ int ret = dev_i2c.i2c_write(pBuffer,
+ LPS25H_SlaveAddress,
+ RegisterAddr,
+ NumByteToWrite);
+ if(ret != 0) {
+ return PRESSURE_ERROR;
+ }
+ return PRESSURE_OK;
+ }
+
+ /*** Instance Variables ***/
+ /* IO Device */
+ DevI2C &dev_i2c;
+
+ uint8_t LPS25H_SlaveAddress;
+};
+
+#endif // __LPS25H_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lps25h/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,3 @@ +lps25h.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lps25h/lps25h.h: revision #402, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds0/lsm6ds0.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,602 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds0.h
+ * @author MEMS Application Team
+ * @version V1.3.0
+ * @date 28-May-2015
+ * @brief This file contains definitions for the lsm6ds0.c
+ * firmware 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 __LSM6DS0_H
+#define __LSM6DS0_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "imu_6axes.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup LSM6DS0
+ * @{
+ */
+
+/** @defgroup LSM6DS0_Exported_Defines LSM6DS0_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+#define NULL (void *) 0
+#endif
+
+
+/******************************************************************************/
+/*********** 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: Gyroscope�s Z-axis output enable
+ * [4] Yen_G: Gyroscope�s Y-axis output enable
+ * [3] Xen_G: Gyroscope�s 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: Accelerometer�s Z-axis output enable
+ * [4] Yen_XL: Accelerometer�s Y-axis output enable
+ * [3] Xen_XL: Accelerometer�s 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 Multiple Byte. Mask for enabling multiple byte read/write command.
+ */
+#define LSM6DS0_I2C_MULTIPLEBYTE_CMD ((uint8_t)0x80)
+
+/**
+* @brief Device Address
+*/
+#define LSM6DS0_ADDRESS_LOW 0xD4 // SAD[0] = 0
+#define LSM6DS0_ADDRESS_HIGH 0xD6 // SAD[0] = 1
+#define LSM6DS0_XG_MEMS_ADDRESS LSM6DS0_ADDRESS_HIGH // 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 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 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 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_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL_REG4 LSM6DS0_XG_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_ZEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Z-axis output enable: disable */
+#define LSM6DS0_G_ZEN_ENABLE ((uint8_t)0x20) /*!< Gyroscope�s Z-axis output enable: enable */
+
+#define LSM6DS0_G_ZEN_MASK ((uint8_t)0x20)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS0_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL_REG4 LSM6DS0_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_YEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Y-axis output enable: disable */
+#define LSM6DS0_G_YEN_ENABLE ((uint8_t)0x10) /*!< Gyroscope�s Y-axis output enable: enable */
+
+#define LSM6DS0_G_YEN_MASK ((uint8_t)0x10)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS0_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL_REG4 LSM6DS0_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL_REG4
+ * @{
+ */
+#define LSM6DS0_G_XEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s X-axis output enable: disable */
+#define LSM6DS0_G_XEN_ENABLE ((uint8_t)0x08) /*!< Gyroscope�s X-axis output enable: enable */
+
+#define LSM6DS0_G_XEN_MASK ((uint8_t)0x08)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS0_XG_Gyroscope_Selftest_Enable_Selection_CTRL_REG10 LSM6DS0_XG_Gyroscope_Selftest_Enable_Selection_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 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 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_16G ((uint8_t)0x08) /*!< Full scale: +- 16g */
+
+#define LSM6DS0_XL_FS_MASK ((uint8_t)0x18)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS0_XG_Accelerometer_Bandwidth_Selection_CTRL_REG6_XL 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 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_Acceleration_Data_Selection_CTRL_REG5_XL LSM6DS0_XG_Accelerometer_Decimation_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_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL_REG5_XL LSM6DS0_XG_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_ZEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Z-axis output enable: disable */
+#define LSM6DS0_XL_ZEN_ENABLE ((uint8_t)0x20) /*!< Accelerometer�s Z-axis output enable: enable */
+
+#define LSM6DS0_XL_ZEN_MASK ((uint8_t)0x20)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS0_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL_REG5_XL LSM6DS0_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_YEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Y-axis output enable: disable */
+#define LSM6DS0_XL_YEN_ENABLE ((uint8_t)0x10) /*!< Accelerometer�s Y-axis output enable: enable */
+
+#define LSM6DS0_XL_YEN_MASK ((uint8_t)0x10)
+/**
+ * @}
+ */
+
+
+/** @defgroup LSM6DS0_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL_REG5_XL LSM6DS0_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL_REG5_XL
+ * @{
+ */
+#define LSM6DS0_XL_XEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s X-axis output enable: disable */
+#define LSM6DS0_XL_XEN_ENABLE ((uint8_t)0x08) /*!< Accelerometer�s X-axis output enable: enable */
+
+#define LSM6DS0_XL_XEN_MASK ((uint8_t)0x08)
+
+/**
+ * @}
+ */
+
+
+/** @defgroup LSM6DS0_XG_Accelerometer_Selftest_Enable_Selection_CTRL_REG10 LSM6DS0_XG_Accelerometer_Selftest_Enable_Selection_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)
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup LSM6DS0_Imported_Functions LSM6DS0_Imported_Functions
+ * @{
+ */
+
+/* Six axes sensor IO functions */
+extern IMU_6AXES_StatusTypeDef LSM6DS0_IO_Init(void);
+extern IMU_6AXES_StatusTypeDef LSM6DS0_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite);
+extern IMU_6AXES_StatusTypeDef LSM6DS0_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead);
+extern void LSM6DS0_IO_ITConfig( void );
+
+/**
+ * @}
+ */
+
+/* ------------------------------------------------------- */
+/* Here you should declare the internal struct of */
+/* extended features of LIS3MDL. See the example of */
+/* LSM6DS3 in lsm6ds3.h */
+/* ------------------------------------------------------- */
+
+/** @addtogroup LSM6DS0_Exported_Variables LSM6DS0_Exported_Variables
+ * @{
+ */
+
+/* Six axes sensor driver structure */
+extern IMU_6AXES_DrvTypeDef LSM6DS0Drv;
+extern IMU_6AXES_DrvExtTypeDef LSM6DS0Drv_ext;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LSM6DS0_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds0/lsm6ds0_class.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,706 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds0_class.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Implementation file for the LSM6DS0 driver class
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+/* Includes ------------------------------------------------------------------*/
+#include "lsm6ds0_class.h"
+#include "lsm6ds0.h"
+
+/* Methods -------------------------------------------------------------------*/
+/* betzw - based on:
+ X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds0/lsm6ds0.c: revision #400,
+ X-CUBE-MEMS1/trunk: revision #416
+*/
+
+/**
+ * @brief Set LSM6DS0 Initialization
+ * @param LSM6DS0_Init the configuration setting for the LSM6DS0
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_Init(IMU_6AXES_InitTypeDef *LSM6DS0_Init)
+{
+ /* Configure the low level interface ---------------------------------------*/
+ if(LSM6DS0_IO_Init() != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /******* Gyroscope init *******/
+
+ if(LSM6DS0_G_Set_ODR( LSM6DS0_Init->G_OutputDataRate ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_G_Set_FS( LSM6DS0_Init->G_FullScale ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_G_Set_Axes_Status(LSM6DS0_Init->G_X_Axis, LSM6DS0_Init->G_Y_Axis, LSM6DS0_Init->G_Z_Axis) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /******************************/
+
+ /***** Accelerometer init *****/
+
+ if(LSM6DS0_X_Set_ODR( LSM6DS0_Init->X_OutputDataRate ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_X_Set_FS( LSM6DS0_Init->X_FullScale ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_X_Set_Axes_Status(LSM6DS0_Init->X_X_Axis, LSM6DS0_Init->X_Y_Axis, LSM6DS0_Init->X_Z_Axis) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Configure interrupt lines */
+ LSM6DS0_IO_ITConfig();
+
+ return IMU_6AXES_OK;
+
+ /******************************/
+}
+
+
+/**
+ * @brief Read ID of LSM6DS0 Accelerometer and Gyroscope
+ * @param xg_id the pointer where the ID of the device is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_Read_XG_ID(uint8_t *xg_id)
+{
+ if(!xg_id)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return LSM6DS0_IO_Read(xg_id, LSM6DS0_XG_WHO_AM_I_ADDR, 1);
+}
+
+
+/**
+ * @brief Read raw data from LSM6DS0 Accelerometer output register
+ * @param pData the pointer where the accelerometer raw data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0, 0};
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_X_L_XL | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_Y_L_XL | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_Z_L_XL | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ return IMU_6AXES_OK;
+}
+
+
+/**
+ * @brief Read data from LSM6DS0 Accelerometer and calculate linear acceleration in mg
+ * @param pData the pointer where the accelerometer data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_GetAxes(int32_t *pData)
+{
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+
+ if(LSM6DS0_X_GetAxesRaw(pDataRaw) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_X_GetSensitivity( &sensitivity ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = (int32_t)(pDataRaw[0] * sensitivity);
+ pData[1] = (int32_t)(pDataRaw[1] * sensitivity);
+ pData[2] = (int32_t)(pDataRaw[2] * sensitivity);
+
+ return IMU_6AXES_OK;
+}
+
+
+/**
+ * @brief Read raw data from LSM6DS0 Gyroscope output register
+ * @param pData the pointer where the gyroscope raw data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_GetAxesRaw(int16_t *pData)
+{
+ uint8_t tempReg[2] = {0, 0};
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_X_L_G | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_Y_L_G | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS0_IO_Read(&tempReg[0], (LSM6DS0_XG_OUT_Z_L_G | LSM6DS0_I2C_MULTIPLEBYTE_CMD),
+ 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Set the status of the axes for accelerometer
+ * @param enableX the status of the x axis to be set
+ * @param enableY the status of the y axis to be set
+ * @param enableZ the status of the z axis to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ)
+{
+ uint8_t tmp1 = 0x00;
+ uint8_t eX = 0x00;
+ uint8_t eY = 0x00;
+ uint8_t eZ = 0x00;
+
+ eX = ( enableX == 0 ) ? LSM6DS0_XL_XEN_DISABLE : LSM6DS0_XL_XEN_ENABLE;
+ eY = ( enableY == 0 ) ? LSM6DS0_XL_YEN_DISABLE : LSM6DS0_XL_YEN_ENABLE;
+ eZ = ( enableZ == 0 ) ? LSM6DS0_XL_ZEN_DISABLE : LSM6DS0_XL_ZEN_ENABLE;
+
+ if(LSM6DS0_IO_Read(&tmp1, LSM6DS0_XG_CTRL_REG5_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS0_XL_XEN_MASK);
+ tmp1 |= eX;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS0_XL_YEN_MASK);
+ tmp1 |= eY;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS0_XL_ZEN_MASK);
+ tmp1 |= eZ;
+
+ if(LSM6DS0_IO_Write(&tmp1, LSM6DS0_XG_CTRL_REG5_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Set the status of the axes for gyroscope
+ * @param enableX the status of the x axis to be set
+ * @param enableY the status of the y axis to be set
+ * @param enableZ the status of the z axis to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ)
+{
+ uint8_t tmp1 = 0x00;
+ uint8_t eX = 0x00;
+ uint8_t eY = 0x00;
+ uint8_t eZ = 0x00;
+
+ eX = ( enableX == 0 ) ? LSM6DS0_G_XEN_DISABLE : LSM6DS0_G_XEN_ENABLE;
+ eY = ( enableY == 0 ) ? LSM6DS0_G_YEN_DISABLE : LSM6DS0_G_YEN_ENABLE;
+ eZ = ( enableZ == 0 ) ? LSM6DS0_G_ZEN_DISABLE : LSM6DS0_G_ZEN_ENABLE;
+
+ if(LSM6DS0_IO_Read(&tmp1, LSM6DS0_XG_CTRL_REG4, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS0_G_XEN_MASK);
+ tmp1 |= eX;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS0_G_YEN_MASK);
+ tmp1 |= eY;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS0_G_ZEN_MASK);
+ tmp1 |= eZ;
+
+ if(LSM6DS0_IO_Write(&tmp1, LSM6DS0_XG_CTRL_REG4, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+
+/**
+ * @brief Read data from LSM6DS0 Gyroscope and calculate angular rate in mdps
+ * @param pData the pointer where the gyroscope data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_GetAxes(int32_t *pData)
+{
+ int16_t pDataRaw[3];
+ float sensitivity = 0;
+
+ if(LSM6DS0_G_GetAxesRaw(pDataRaw) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS0_G_GetSensitivity( &sensitivity ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = (int32_t)(pDataRaw[0] * sensitivity);
+ pData[1] = (int32_t)(pDataRaw[1] * sensitivity);
+ pData[2] = (int32_t)(pDataRaw[2] * sensitivity);
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Output Data Rate
+ * @param odr the pointer where the accelerometer output data rate is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_Get_ODR( float *odr )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_XL_ODR_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_XL_ODR_PD:
+ *odr = 0.0f;
+ break;
+ case LSM6DS0_XL_ODR_10HZ:
+ *odr = 10.0f;
+ break;
+ case LSM6DS0_XL_ODR_50HZ:
+ *odr = 50.0f;
+ break;
+ case LSM6DS0_XL_ODR_119HZ:
+ *odr = 119.0f;
+ break;
+ case LSM6DS0_XL_ODR_238HZ:
+ *odr = 238.0f;
+ break;
+ case LSM6DS0_XL_ODR_476HZ:
+ *odr = 476.0f;
+ break;
+ case LSM6DS0_XL_ODR_952HZ:
+ *odr = 952.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Accelero Output Data Rate
+ * @param odr the accelerometer output data rate to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_Set_ODR( float odr )
+{
+ uint8_t new_odr = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_odr = ( odr <= 0.0f ) ? LSM6DS0_XL_ODR_PD /* Power Down */
+ : ( odr <= 10.0f ) ? LSM6DS0_XL_ODR_10HZ
+ : ( odr <= 50.0f ) ? LSM6DS0_XL_ODR_50HZ
+ : ( odr <= 119.0f ) ? LSM6DS0_XL_ODR_119HZ
+ : ( odr <= 238.0f ) ? LSM6DS0_XL_ODR_238HZ
+ : ( odr <= 476.0f ) ? LSM6DS0_XL_ODR_476HZ
+ : LSM6DS0_XL_ODR_952HZ;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS0_XL_ODR_MASK);
+ tempReg |= new_odr;
+
+ if(LSM6DS0_IO_Write(&tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Sensitivity
+ * @param pfData the pointer where the accelerometer sensitivity is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_GetSensitivity( float *pfData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_XL_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_XL_FS_2G:
+ *pfData = 0.061f;
+ break;
+ case LSM6DS0_XL_FS_4G:
+ *pfData = 0.122f;
+ break;
+ case LSM6DS0_XL_FS_8G:
+ *pfData = 0.244f;
+ break;
+ case LSM6DS0_XL_FS_16G:
+ *pfData = 0.732f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Full Scale
+ * @param fullScale the pointer where the accelerometer full scale is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_Get_FS( float *fullScale )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_XL_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_XL_FS_2G:
+ *fullScale = 2.0f;
+ break;
+ case LSM6DS0_XL_FS_4G:
+ *fullScale = 4.0f;
+ break;
+ case LSM6DS0_XL_FS_8G:
+ *fullScale = 8.0f;
+ break;
+ case LSM6DS0_XL_FS_16G:
+ *fullScale = 16.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Accelero Full Scale
+ * @param fullScale the accelerometer full scale to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_X_Set_FS( float fullScale )
+{
+ uint8_t new_fs = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_fs = ( fullScale <= 2.0f ) ? LSM6DS0_XL_FS_2G
+ : ( fullScale <= 4.0f ) ? LSM6DS0_XL_FS_4G
+ : ( fullScale <= 8.0f ) ? LSM6DS0_XL_FS_8G
+ : LSM6DS0_XL_FS_16G;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS0_XL_FS_MASK);
+ tempReg |= new_fs;
+
+ if(LSM6DS0_IO_Write(&tempReg, LSM6DS0_XG_CTRL_REG6_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Output Data Rate
+ * @param odr the pointer where the gyroscope output data rate is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_Get_ODR( float *odr )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG1_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_G_ODR_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_G_ODR_PD:
+ *odr = 0.0f;
+ break;
+ case LSM6DS0_G_ODR_14_9HZ:
+ *odr = 14.9f;
+ break;
+ case LSM6DS0_G_ODR_59_5HZ:
+ *odr = 59.5f;
+ break;
+ case LSM6DS0_G_ODR_119HZ:
+ *odr = 119.0f;
+ break;
+ case LSM6DS0_G_ODR_238HZ:
+ *odr = 238.0f;
+ break;
+ case LSM6DS0_G_ODR_476HZ:
+ *odr = 476.0f;
+ break;
+ case LSM6DS0_G_ODR_952HZ:
+ *odr = 952.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Gyro Output Data Rate
+ * @param odr the gyroscope output data rate to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_Set_ODR( float odr )
+{
+ uint8_t new_odr = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_odr = ( odr <= 0.0f ) ? LSM6DS0_G_ODR_PD /* Power Down */
+ : ( odr <= 14.9f ) ? LSM6DS0_G_ODR_14_9HZ
+ : ( odr <= 59.5f ) ? LSM6DS0_G_ODR_59_5HZ
+ : ( odr <= 119.0f ) ? LSM6DS0_G_ODR_119HZ
+ : ( odr <= 238.0f ) ? LSM6DS0_G_ODR_238HZ
+ : ( odr <= 476.0f ) ? LSM6DS0_G_ODR_476HZ
+ : LSM6DS0_G_ODR_952HZ;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG1_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS0_G_ODR_MASK);
+ tempReg |= new_odr;
+
+ if(LSM6DS0_IO_Write(&tempReg, LSM6DS0_XG_CTRL_REG1_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Sensitivity
+ * @param pfData the pointer where the gyroscope sensitivity is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_GetSensitivity( float *pfData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG1_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_G_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_G_FS_245:
+ *pfData = 8.75f;
+ break;
+ case LSM6DS0_G_FS_500:
+ *pfData = 17.50f;
+ break;
+ case LSM6DS0_G_FS_2000:
+ *pfData = 70.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Full Scale
+ * @param fullScale the pointer where the gyroscope full scale is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_Get_FS( float *fullScale )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG1_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS0_G_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS0_G_FS_245:
+ *fullScale = 245.0f;
+ break;
+ case LSM6DS0_G_FS_500:
+ *fullScale = 500.0f;
+ break;
+ case LSM6DS0_G_FS_2000:
+ *fullScale = 2000.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Gyro Full Scale
+ * @param fullScale the gyroscope full scale to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS0::LSM6DS0_G_Set_FS( float fullScale )
+{
+ uint8_t new_fs = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_fs = ( fullScale <= 245.0f ) ? LSM6DS0_G_FS_245
+ : ( fullScale <= 500.0f ) ? LSM6DS0_G_FS_500
+ : LSM6DS0_G_FS_2000;
+
+ if(LSM6DS0_IO_Read( &tempReg, LSM6DS0_XG_CTRL_REG1_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS0_G_FS_MASK);
+ tempReg |= new_fs;
+
+ if(LSM6DS0_IO_Write(&tempReg, LSM6DS0_XG_CTRL_REG1_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds0/lsm6ds0_class.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,214 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds0_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component LSM6DS0
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+#ifndef __LSM6DS0_CLASS_H
+#define __LSM6DS0_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "DevI2C.h"
+#include "lsm6ds0.h"
+#include "../Interfaces/GyroSensor.h"
+#include "../Interfaces/MotionSensor.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a LSM6DS0 sensor component
+ */
+class LSM6DS0 : public GyroSensor, public MotionSensor {
+ public:
+ /** Constructor
+ * @param[in] i2c device I2C to be used for communication
+ */
+ LSM6DS0(DevI2C &i2c) : GyroSensor(), MotionSensor(), dev_i2c(i2c) {
+ }
+
+ /** Destructor
+ */
+ virtual ~LSM6DS0() {}
+
+ /*** Interface Methods ***/
+ virtual int Init(void *init_struct) {
+ return LSM6DS0_Init((IMU_6AXES_InitTypeDef*)init_struct);
+ }
+
+ virtual int ReadID(uint8_t *xg_id) {
+ return LSM6DS0_Read_XG_ID(xg_id);
+ }
+
+ virtual int Get_X_Axes(int32_t *pData) {
+ return LSM6DS0_X_GetAxes(pData);
+ }
+
+ virtual int Get_X_AxesRaw(int16_t *pData) {
+ return LSM6DS0_X_GetAxesRaw(pData);
+ }
+
+ virtual int Get_G_Axes(int32_t *pData) {
+ return LSM6DS0_G_GetAxes(pData);
+ }
+
+ virtual int Get_G_AxesRaw(int16_t *pData) {
+ return LSM6DS0_G_GetAxesRaw(pData);
+ }
+
+ virtual int Get_X_ODR(float *odr) {
+ return LSM6DS0_X_Get_ODR(odr);
+ }
+
+ virtual int Set_X_ODR(float odr) {
+ return LSM6DS0_X_Set_ODR(odr);
+ }
+
+ virtual int Get_X_Sensitivity(float *pfData) {
+ return LSM6DS0_X_GetSensitivity(pfData);
+ }
+
+ virtual int Get_X_FS(float *fullScale) {
+ return LSM6DS0_X_Get_FS(fullScale);
+ }
+
+ virtual int Set_X_FS(float fullScale) {
+ return LSM6DS0_X_Set_FS(fullScale);
+ }
+
+ virtual int Get_G_ODR(float *odr) {
+ return LSM6DS0_G_Get_ODR(odr);
+ }
+
+ virtual int Set_G_ODR(float odr) {
+ return LSM6DS0_G_Set_ODR(odr);
+ }
+
+ virtual int Get_G_Sensitivity(float *pfData) {
+ return LSM6DS0_G_GetSensitivity(pfData);
+ }
+
+ virtual int Get_G_FS(float *fullScale) {
+ return LSM6DS0_G_Get_FS(fullScale);
+ }
+
+ virtual int Set_G_FS(float fullScale) {
+ return LSM6DS0_G_Set_FS(fullScale);
+ }
+
+ protected:
+ /*** Methods ***/
+ IMU_6AXES_StatusTypeDef LSM6DS0_Init(IMU_6AXES_InitTypeDef *LSM6DS0_Init);
+ IMU_6AXES_StatusTypeDef LSM6DS0_Read_XG_ID(uint8_t *xg_id);
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_GetAxes(int32_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_GetAxesRaw(int16_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_GetAxes(int32_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_GetAxesRaw(int16_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_Get_ODR( float *odr );
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_Set_ODR( float odr );
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_GetSensitivity( float *pfData );
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_Get_FS( float *fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_Set_FS( float fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_Get_ODR( float *odr );
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_Set_ODR( float odr );
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_GetSensitivity( float *pfData );
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_Get_FS( float *fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_Set_FS( float fullScale );
+
+ IMU_6AXES_StatusTypeDef LSM6DS0_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
+ IMU_6AXES_StatusTypeDef LSM6DS0_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
+
+ /**
+ * @brief Configures LSM6DS0 interrupt lines for NUCLEO boards
+ */
+ void LSM6DS0_IO_ITConfig(void)
+ {
+ /* To be implemented */
+ }
+
+ /**
+ * @brief Configures LSM6DS0 I2C interface
+ * @return IMU_6AXES_OK in case of success, an error code otherwise
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS0_IO_Init(void)
+ {
+ return IMU_6AXES_OK; /* done in constructor */
+ }
+
+ /**
+ * @brief Utility function to read data from LSM6DS0
+ * @param[out] pBuffer pointer to the byte-array to read data in to
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToRead number of bytes to be read.
+ * @retval IMU_6AXES_OK if ok,
+ * @retval IMU_6AXES_ERROR if an I2C error has occured
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS0_IO_Read(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ int ret = dev_i2c.i2c_read(pBuffer,
+ LSM6DS0_XG_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToRead);
+ if(ret != 0) {
+ return IMU_6AXES_ERROR;
+ }
+ return IMU_6AXES_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to LSM6DS0
+ * @param[in] pBuffer pointer to the byte-array data to send
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToWrite number of bytes to write.
+ * @retval IMU_6AXES_OK if ok,
+ * @retval IMU_6AXES_ERROR if an I2C error has occured
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS0_IO_Write(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ int ret = dev_i2c.i2c_write(pBuffer,
+ LSM6DS0_XG_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToWrite);
+ if(ret != 0) {
+ return IMU_6AXES_ERROR;
+ }
+ return IMU_6AXES_OK;
+ }
+
+ /*** Instance Variables ***/
+ /* IO Device */
+ DevI2C &dev_i2c;
+};
+
+#endif // __LSM6DS0_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds0/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,3 @@ +lsm6ds0.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds0/lsm6ds0.h: revision #402, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds3/lsm6ds3.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,1481 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds3.h
+ * @author MEMS Application Team
+ * @version V1.2.0
+ * @date 28-May-2015
+ * @brief This file contains definitions for the lsm6ds3.c firmware 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 __LSM6DS3_H
+#define __LSM6DS3_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "imu_6axes.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup LSM6DS3
+ * @{
+ */
+
+/** @addtogroup LSM6DS3_Exported_Defines LSM6DS3_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+#define NULL (void *) 0
+#endif
+
+/******************************************************************************/
+/*********** START ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
+/******************************************************************************/
+
+
+/***************************************** COMMON REGISTERS ********************************************/
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] FUNC_CFG_EN: Enable access to the embedded functions configuration registers (1) from address 02h to 32h. Default value: 0.
+ * [6:0] This bit must be set to �0� for the correct operation of the device
+ * \endcode
+*/
+#define LSM6DS3_XG_FUNC_CFG_ACCESS 0x01
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] TPH_[7:0]: Sensor SyncronizationTime Frame with the step of 500ms and full range of 5s. Default: 0000 0000
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSOR_SYNC_TIME_FRAME 0x04
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:2] This bit must be set to �0� for the correct operation of the device
+ * [1] HP_RST: Gyro digital HP filter reset. Default: 0
+ * [1] SENSOR_SYNC_ENHP_RST: Enable sensor synchronization feature. Default 0
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSOR_SYNC_ENABLE 0x05
+
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] FTH_7-0 FIFO threshold level setting - watermark flag is toggled when the number of bytes written to FIFO is greater or equal to threshold level.
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_CTRL1 0x06
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] TIMER_PEDO_FIFO_EN: Enable Pedometer step counter and time stamp as 4th sensor FIFO data. Default: 0 disabled
+ * [6] TIMER_PEDO_FIFO_DRDY : Pedometer FIFO write mode. Default: 0 disabled
+ * [5:4] This bit must be set to �0� for the correct operation of the device
+ * [3:0] FTH_[11:8] FIFO threshold level setting(1). Default value: 0000
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_CTRL2 0x07
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] This bit must be set to �0� for the correct operation of the device
+ * [5:3] DEC_FIFO_GYRO[2:0]: Gyro FIFO decimation setting. Default value: 000
+ * [2:0] DEC_FIFO_XL[2:0]: XL FIFO decimation setting. Default value: 000
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_CTRL3 0x08
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6] ONLY_HIGH_DATA :8 bit data storing in FIFO. Default: 0
+ * [5:3] DEC_SLV1_FIFO[2:0] Second external sensor FIFO decimation setting. Default: 000
+ * [2:0] DEC_SLV1_FIFO[2:0] First external sensor FIFO decimation setting. Default: 000
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_CTRL4 0x09
+
+
+/**
+ * @brief FIFO control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6:3] ODR_FIFO_[3:0]: FIFO ODR selection. Default: 0000
+ * [2:0] FIFO_MODE_[2:0] : FIFO mode selection bits. Default value: 000
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_CTRL5 0x0A
+
+
+/**
+ * @brief Angular rate sensor sign and orientation register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] This bit must be set to �0� for the correct operation of the device
+ * [5] SignX_G: Pitch axis (X) Angular rate sign. Default value: 0
+ * [5] SignY_G: Roll axis (Y) Angular rate sign. Default value: 0
+ * [5] SignZ_G: Pitch axis (Z) Angular rate sign. Default value: 0
+ * [2:0] Orient[2:0] : Directional user orientation selection. Default Value: 000
+ * \endcode
+*/
+#define LSM6DS3_XG_ORIENT_CFG_G 0x0B
+
+/**
+ * @brief INT1 pad control registrer
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] INT1_PEDO: Pedometer step recognition interrupt enable on INT1 pad. Default value: 0
+ * [6] INT1_SIGN_MOT: Significant motion interrupt enable on INT1 pad. Default value: 0
+ * [5] INT1_FULL_FLAG: Full flag Interrupt Enable on INT1 pad. Default value: 0
+ * [4] INT1_OVR: Overrun Interrupt on INT1 pad. Default value: 0
+ * [3] INT1_FTH: FIFO threshold interrupt on INT1 pad. Default value: 0
+ * [2] INT1_BOOT: Overrun Interrupt on INT1 pad. Default value: 0
+ * [1] INT1_DRDY_G: Gyroscope Data Ready on INT1 pad. Default value: 0.
+ * [0] INT1_DRDY_XL: Accelerometer Data Ready on INT1 pad. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_INT1_CTRL 0x0D
+
+
+//new, done
+/**
+ * @brief INT2 pad control registrer
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] INT2_PEDO: Pedometer step recognition interrupt enable on INT1 pad. Default value: 0
+ * [6] INT2_SIGN_MOT: Significant motion interrupt enable on INT1 pad. Default value: 0
+ * [5] INT2_FULL_FLAG: Full flag Interrupt Enable on INT1 pad. Default value: 0
+ * [4] INT2_OVR: Overrun Interrupt on INT1 pad. Default value: 0
+ * [3] INT2_FTH: FIFO threshold interrupt on INT1 pad. Default value: 0
+ * [2] INT2_BOOT: Overrun Interrupt on INT1 pad. Default value: 0
+ * [1] INT2_DRDY_G: Gyroscope Data Ready on INT1 pad. Default value: 0.
+ * [0] INT2_DRDY_XL: Accelerometer Data Ready on INT1 pad. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_INT2_CTRL 0x0E
+
+
+/**
+ * @brief Device identifier register.
+ * \code
+ * Read
+ * Default value:69
+ * [7:0] This read-only register contains the device identifier
+ * \endcode
+*/
+#define LSM6DS3_XG_WHO_AM_I_ADDR 0x0F
+
+
+/**
+ * @brief Control Register 3
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] BOOT: Reboot memory content. Default value: 0
+ * [6] BDU: Block Data Update. Default value: 0
+ * [5] H_LACTIVE: Interrupt activation level. Default value: 0
+ * [4] PP_OD: Push-pull/Open Drain selection on INT pad. Default value: 0
+ * [3] SIM: SPI Serial Interface Mode selection. Default value: 0
+ * [2] IF_INC: Register address automatically incremented during a multiple byte access with a serial interface (I2C or SPI). Default value: 0
+ * [1] BLE: Big/Little Endian Data Selection. Default value: 0
+ * [0] SW_RESET: Software Reset. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_CTRL3_C 0x12
+
+/**
+ * @brief Control Register 4
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] BW_SCAL_ODR: Accelerometer bandwidth selection. Default value: 0
+ * [6] SLEEP_G: Gyroscope sleep mode enable. Default value: 0
+ * [5] INT2_on_INT1: All interrupt signals available on INT1 pad enable. Default value: 0
+ * [4] This bit must be set to �0� for the correct operation of the device
+ * [3] DRDY_MASK: Configuration 1(3) Data Available Enable bit. Default Value: 0
+ * [2] I2C_disable Disable I2C interface. Default value: 0
+ * [1] MODE3_EN Enable auxiliary SPI interface (Mode3, refer to Table 1.). Default value: 0
+ * [0] STOP_ON_FTH Enable FIFO threshold level use. Default value: 0.
+
+ * \endcode
+*/
+#define LSM6DS3_XG_CTRL4_C 0x13
+
+/**
+ * @brief Control Register 4
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] This bit must be set to �0� for the correct operation of the device
+ * [3:2] ST_G[1:0]: Angular rate sensor Self Test Enable. Default value: 00
+ * [1:0] ST_XL[1:0]: Linear acceleration sensor Self Test Enable. Default value: 00
+ * \endcode
+*/
+#define LSM6DS3_XG_CTRL5_C 0x14
+
+
+/**
+ * @brief Control Register 10
+ * \code
+ * Read/write
+ * Default value: 0x38
+ * [7:6] These bits must be set to �0� for the correct operation of the device
+ * [5] Zen_G: Gyroscope�s Z-axis output enable. Default value: 1
+ * [4] Yen_G: Gyroscope�s Y-axis output enable. Default value: 1
+ * [3] Xen_G: Gyroscope�s X-axis output enable. Default value: 1
+ * [2] FUNC_EN: Enable embedded functionalities (pedometer, tilt and significant motion) . Default value: 0
+ * [1] PEDO_RST_STEP: Reset pedometer step counter . Default value: 0
+ * [0] SIGN_MOTION_EN: Enable significant motion function. For a correct functionality of significant motion function, TILT_EN bit in FUNC_SRC (53h) register must be set to 1 . Default value: 1
+ * \endcode
+*/
+#define LSM6DS3_XG_CTRL10_C 0x19
+
+
+/**
+ * @brief Sensor hub Master config Register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] DRDY_ON_INT1:Manage the DRDY signal on INT1 pad. Default: 0
+ * [6] DATA_VALID_SEL_FIFO: Selection of FIFO data-valid signal. Default value: 0
+ * [5] This bit must be set to �0� for the correct operation of the device
+ * [4] START_CONFIG: Sensor Hub trigger signal selection. Default value: 0
+ * [3] PULL_UP_EN: Auxiliary I2C pull-up. Default value: 0
+ * [2] PASS_THROUGH_MODE: I2C interface pass-through. Default value: 0
+ * [1] IRON_EN:Enable soft iron correction algorithm for magnetometer. Default value: 0.
+ * [0] MASTER_ON: Sensor Hub I2C master enable. Default: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_MASTER_CONFIG 0x1A
+
+
+/**
+ * @brief Wake up interrupt source register
+ * \code
+ * Read
+ * Default value: output
+ * [7:6] This bit must be set to �0� for the correct operation of the device
+ * [5] FF_IA: Free fall event detection status. Default: 0
+ * [4] SLEEP_STATE_IA: Sleep event status. Default value: 0
+ * [3] WU_IA: Wake up event detection status. Default
+ * [2] X_WU: detection status on X axis. Default value: 0
+ * [1] Y_WU: detection status on Y axis. Default value: 0
+ * [0] Z_WU: detection status on Z axis. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_WAKE_UP_SRC 0x1B
+
+/**
+ * @brief Tap source register
+ * \code
+ * Read
+ * Default value: output
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6] TAP_IA: Tap event detection status. Default: 0
+ * [5] SINGLE_TAP: Single tap event status. Default value: 0
+ * [4] DOUBLE_TAP: Double tap event detection status. Default value: 0
+ * [3] TAP_SIGN: Sign of acceleration detected by tap event. Default: 0
+ * [2] X_TAP: Tap event detection status on X axis. Default value: 0
+ * [1] Y_TAP: Tap event detection status on Y axis. Default value: 0
+ * [0] Z_TAP: Tap event detection status on Z axis. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_TAP_SRC 0x1C
+
+/**
+ * @brief Portrait, landscape face-up and face-down source register
+ * \code
+ * Read
+ * Default value: output
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6] D6D_IA: Interrupt active for change position portrait, landscape, face-up, face-down. Default value: 0
+ * [5] ZH: Z-axis high event (over-threshold). Default value: 0
+ * [4] ZL: Z-axis low event (under-threshold). Default value: 0
+ * [5] YH: Y-axis high event (over-threshold). Default value: 0
+ * [4] YL: Y-axis low event (under-threshold). Default value: 0
+ * [5] X_H: X-axis high event (over-threshold). Default value: 0
+ * [4] X_L: X-axis low event (under-threshold). Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_D6D_SRC 0x1D
+
+/**
+ * @brief Status register
+ * \code
+ * Read
+ * Default value: output
+ * [7:4] No meaning set
+ * [3] EV_BOOT: Boot running flag signal. Default value: 0
+ * [2] No meaning set
+ * [1] GDA: Gyroscope new data avaialble. Default value: 0
+ * [0] XLDA: Accelerometer new data avaialble. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_STATUS_REG 0x1E
+
+/**
+ * @brief FIFO status control register
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] DIFF_FIFO_[7:0]: Number of unread words (16 bit axes) stored in FIFO . For a complete number of unread samples, consider DIFF_FIFO [11:8] in FIFO_STATUS2 (3Bh)
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_STATUS1 0x3A
+
+/**
+ * @brief FIFO status control register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0.
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7] FTH FIFO watermark status. Deafult value: 0
+ * [6] OVER_RUN: FIFO overrun status. Default value: 0
+ * [5] FIFO_FULL: FIFO full status. Default value: 0
+ * [5] FIFO_EMPTY: FIFO empty bit. Default value: 0; 0: FIFO contains data; 1: FIFO is empty
+ * [3:0] DIFF_FIFO_[11:8] Number of unread words (16 bit axes) stored in FIFO : For a complete number of unread samples, consider DIFF_FIFO [11:8] in FIFO_STATUS1 (3Ah)
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_STATUS2 0x3B
+
+/**
+ * @brief FIFO status control register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] FIFO_PATTERN_[7:0] : Word of recursive pattern read at the next reading
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_STATUS3 0x3C
+
+/**
+ * @brief FIFO status control register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0
+ * \code
+ * Read
+ * Default value: 0x00
+ * [1:0] FIFO_PATTERN_[9:8] : Word of recursive pattern read at the next reading
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_STATUS4 0x3D
+
+/**
+ * @brief FIFO status control register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0.
+ * \code
+ * Read
+ * Default value: 0x00
+ * [4:0] FIFO_PATTERN_[9:8] : Word of recursive pattern read at the next reading
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_STATUS4 0x3D
+
+/**
+ * @brief FIFO data output register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0.
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] DATA_OUT_FIFO_L_[7:0]: FIFO data output (First byte)
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_DATA_OUT_L 0x3E
+
+/**
+ * @brief FIFO data output register (r). For a proper reading of the register it is suggested to set BDU bit in CTRL3_C (12h) to 0.
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] DATA_OUT_FIFO_H_[7:0]: FIFO data output (second byte)
+ * \endcode
+*/
+#define LSM6DS3_XG_FIFO_DATA_OUT_H 0x3F
+
+/**
+ * @brief Time stamp first byte data output register (r). The value is expressed as 24 bit and the bit resolution is defined by setting value in WAKE_UP_DUR (5Ch).
+ * \code
+ * Read
+ * Default value: output
+ * [7:0] TIMESTAMP0_[7:0]: FIFO first byte data output
+ * \endcode
+*/
+#define LSM6DS3_XG_TIMESTAMP0_REG 0x40
+
+/**
+ * @brief Time stamp second byte data output register (r). The value is expressed as 24 bit and the bit resolution is defined by setting value in WAKE_UP_DUR (5Ch).
+ * \code
+ * Read
+ * Default value: output
+ * [7:0] TIMESTAMP1_[7:0]: FIFO second byte data output
+ * \endcode
+*/
+#define LSM6DS3_XG_TIMESTAMP1_REG 0x41
+
+/**
+ * @brief Time stamp third byte data output register (r). The value is expressed as 24 bit and the bit resolution is defined by setting value in WAKE_UP_DUR (5Ch).
+ * \code
+ * Read
+ * Default value: output
+ * [7:0] TIMESTAMP2_[7:0]: FIFO third byte data output
+ * \endcode
+*/
+#define LSM6DS3_XG_TIMESTAMP2_REG 0x42
+
+/**
+ * @brief Step counter output register (r).
+ * \code
+ * Read
+ * Default value: output
+ * [7:0] STEP_COUNTER_L_[7:0]: Step counter output (LSbyte)
+ * \endcode
+*/
+#define LSM6DS3_XG_STEP_COUNTER_L 0x4B
+
+/**
+ * @brief Step counter output register (r).
+ * \code
+ * Read
+ * Default value: output
+ * [7:0] STEP_COUNTER_H_[7:0]: Step counter output (MSbyte)
+ * \endcode
+*/
+#define LSM6DS3_XG_STEP_COUNTER_H 0x4C
+
+/**
+ * @brief Significant motion, tilt, step detector, soft iron and sensor hub interrupt source register
+ * \code
+ * Read
+ * Default value: output
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6] SIGN_MOTION_IA: Significant motion event detection status. Default value: 0
+ * [5] TILT_IA: Tilt event detection status. Default value: 0
+ * [5] STEP_DETECTED: Step detector event detection status. Default value: 0
+ * [3:2] This bit must be set to �0� for the correct operation of the device
+ * [1] SI_END_OP:Soft iron calculation status. Default value: 0
+ * [0] SENSORHUB_END_OP:Senso hub communication status. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_FUNC_SRC 0x53
+
+/**
+ * @brief Time stamp, pedometer, tilt, filtering, and tap recognition functions configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] TIMER_EN: Time stamp count enable, output data are collected in TIMESTAMP0_REG (40h), TIMESTAMP1_REG (41h), TIMESTAMP2_REG (42h) register. Default: 0
+ * [6] PEDO_EN: Pedometer algorithm enable(1). Default value: 0
+ * [5] TILT_EN: Tilt calculation enable.(2) Default value: 0
+ * [4] This bit must be set to �0� for the correct operation of the device
+ * [3] TAP_X_EN: Enable X direction in tap recognition. Default value: 0
+ * [2] TAP_Y_EN: Enable Z direction in tap recognition. Default value: 0
+ * [1] TAP_Z_EN: Enable Z direction in tap recognition. Default value: 0
+ * [0] LIR: Relatch of the time stamp, pedometer, tilt, filtering, and tap recognition functions routed to PINs.
+ * \endcode
+*/
+#define LSM6DS3_XG_TAP_CFG 0x58
+
+/**
+ * @brief Portrait/landscape position and tap function threshold register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] This bit must be set to �0� for the correct operation of the device
+ * [6:5] SIXD_THS[1:0]: Threshold for D6D function. Default value: 00
+ * [4:0] TAP_THS[4:0]: Threshold for tap recognition. Default value: 0000
+ * \endcode
+*/
+#define LSM6DS3_XG_TAP_THS_6D 0x59
+
+/**
+ * @brief Tap recognition function setting register (r/w)
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] DUR[3:0]: Duration of maximum time gap for double tap recognition. Default: 0000
+ * [3:2] QUIET[1:0]: Expected quiet time after a tap detection. Default value: 00
+ * [1:0] SHOCK[1:0]: Maximum duration of over-threshold event. Default value: 00
+ * \endcode
+*/
+#define LSM6DS3_XG_INT_DUR2 0x5A
+
+/**
+ * @brief Tap recognition function setting register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] SINGLE_DOUBLE_TAP: Single/double tap event detection. Default: 0
+ * [6] INACTIVITY: Inactivity event enable. Default value: 0
+ * [5:0] WK_THS[5:0]:Threshold for wake-up. Default value: 0000
+ * \endcode
+*/
+#define LSM6DS3_XG_WAKE_UP_THS 0x5B
+
+/**
+ * @brief Free-fall, wake-up, time stamp and sleep mode functions duration setting register (r/w).
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] FF_DUR5:Free fall duration event. Default: 0
+ * [6:5] WAKE_DUR[1:0]: Wake up duration event. Default: 00
+ * [4] TIMER_HR: Time stamp register resolution setting(1). Default value: 0
+ * [3:0] SLEEP_DUR[3:0] : Duration to go in sleep mode. Default value: 0000
+ * \endcode
+*/
+#define LSM6DS3_XG_WAKE_UP_DUR 0x5C
+
+/**
+ * @brief Free-fall function duration setting register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:3] FF_DUR[4:0]: Free fall duration event. Default: 0. For the complete configuration of the free fall duration, refer to FF_DUR5 in WAKE_UP_DUR (5Ch) configuration
+ * [2:0] FF_THS[2:0]: Free fall threshold setting. Default: 000.
+ * \endcode
+*/
+#define LSM6DS3_XG_WAKE_FREE_FALL 0x5D
+
+/**
+ * @brief Functions routing on INT1 register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] INT1_INACT_STATE: Routing on INT1 of inactivity mode. Default: 0
+ * [6] INT1_SINGLE_TAP: Single tap recognition routing on INT1. Default: 0
+ * [5] INT1_WU: Routing of wake-up event on INT1. Default value: 0
+ * [4] INT1_FF: Routing of free-fall event on INT1. Default value: 0
+ * [3] INT1_TAP: Routing of tap event on INT1. Default value: 0
+ * [2] INT1_6D: Routing of 6D event on INT1. Default value: 0
+ * [1] INT1_TILT: Routing of tilt event on INT1. Default value: 0
+ * [0] INT1_TIMER: Routing of end counter event of timer on INT1. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_MD1_CFG 0x5E
+
+/**
+ * @brief Functions routing on INT2 register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] INT2_INACT_STATE: Routing on INT1 of inactivity mode. Default: 0
+ * [6] INT2_SINGLE_TAP: Single tap recognition routing on INT1. Default: 0
+ * [5] INT2_WU: Routing of wake-up event on INT1. Default value: 0
+ * [4] INT2_FF: Routing of free-fall event on INT1. Default value: 0
+ * [3] INT2_TAP: Routing of tap event on INT1. Default value: 0
+ * [2] INT2_6D: Routing of 6D event on INT1. Default value: 0
+ * [1] INT2_TILT: Routing of tilt event on INT1. Default value: 0
+ * [0] INT2_TIMER: Routing of end counter event of timer on INT1. Default value: 0
+ * \endcode
+*/
+#define LSM6DS3_XG_MD2_CFG 0x5F
+
+/***************************************** SENSORHUB REGISTERS ********************************************/
+
+/**
+ * @brief SENSORHUB REGISTER 1 : SLV0 first external sensor, first axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB1[7:0]: SLV0 first external sensor, first byte of the first axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB1_REG 0x2E
+
+/**
+ * @brief SENSORHUB REGISTER 2 : SLV0 first external sensor, first axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB2[7:0]: SLV0 first external sensor, second byte of the first axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB2_REG 0x2F
+
+/**
+ * @brief SENSORHUB REGISTER 3 : SLV0 first external sensor, second axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB3[7:0]: SLV0 first external sensor, first byte of the second axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB3_REG 0x30
+
+/**
+ * @brief SENSORHUB REGISTER 4 : SLV0 first external sensor, second axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB4[7:0]: SLV0 first external sensor, second byte of the second axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB4_REG 0x31
+
+/**
+ * @brief SENSORHUB REGISTER 5 : SLV0 first external sensor, third axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB5[7:0]: SLV0 first external sensor, second byte of the second axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB5_REG 0x32
+
+/**
+ * @brief SENSORHUB REGISTER 6 : SLV0 first external sensor, third axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB6[7:0]: SLV0 first external sensor, second byte of the third axis
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB6_REG 0x33
+
+/**
+ * @brief SENSORHUB REGISTER 7 : SLV1 second external sensor, first axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB7[7:0]: SLV1 second external sensor, first byte of the first axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB7_REG 0x34
+
+/**
+ * @brief SENSORHUB REGISTER 8 : SLV1 second external sensor, first axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB8[7:0]: SLV1 second external sensor, second byte of the first axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB8_REG 0x35
+
+/**
+ * @brief SENSORHUB REGISTER 9 : SLV1 second external sensor,, second axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB9[7:0]: SLV1 second external sensor, first byte of the second axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB9_REG 0x36
+
+/**
+ * @brief SLV1 second external sensor, second axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB10[7:0]: SLV1 second external sensor, second byte of the second axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB10_REG 0x37
+
+/**
+ * @brief SLV1 second external sensor, third axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB11[7:0]: SLV1 second external sensor, first byte of the third axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB11_REG 0x38
+
+/**
+ * @brief SLV1 second external sensor, third axis output register (r). The value is expressed as 16bit word in two�s complement
+ * \code
+ * Read
+ * Default value: 0x00
+ * [7:0] SHUB12[7:0]: SLV1 second external sensor, second byte of the third axis.
+ * \endcode
+*/
+#define LSM6DS3_XG_SENSORHUB12_REG 0x39
+
+
+
+
+/***************************************** GYROSCOPE REGISTERS ********************************************/
+
+/**
+ * @brief Angular rate sensor Control Register 2
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] ODR_G[3:0]: Gyroscope output data rate selection
+ * [3:2] FS_G[1-0]: Gyroscope full-scale selection
+ * [1] FS_125: Gyroscope full-scale at 125 dps
+ * [0] This bit must be set to �0� for the correct operation of the device
+ * \endcode
+ */
+#define LSM6DS3_XG_CTRL2_G 0x11
+
+
+/**
+ * @brief Angular rate sensor Control Register 6
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7] TRIG_EN: Data edge sensitive trigger Enable. Default value: 0
+ * [6] LVLen: Data level sensitive trigger Enable. Default value: 0
+ * [5] LVL2en: Level sensitive latched Enable. Default value: 0
+ * [4] XL_H_MODE: High Performance operating mode disable for accelerometer(1). Default value: 0
+ * [3:0] This bit must be set to �0� for the correct operation of the device
+ * \endcode
+ */
+#define LSM6DS3_XG_CTRL6_G 0x15
+
+
+/**
+* @brief Angular rate sensor Control Register 7
+* \code
+* Read/write
+* Default value: 0x00
+* [7] G_H_MODE: High Performance operating mode disable for Gyroscope(1) . Default: 0
+* [6] HP_EN: High Pass filter Enable. Default Value: 0
+* [5:4] HPCF_G[1:0]: Gyroscope High Pass filter Cut Off frequency selection. Default value: 00
+* [3:0] This bit must be set to �0� for the correct operation of the device
+* \endcode
+*/
+#define LSM6DS3_XG_CTRL7_G 0x16
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_X_L_G 0x22
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_X_H_G 0x23
+
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Y_L_G 0x24
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Y_H_G 0x25
+
+
+/**
+ * @brief Gyroscope data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Z_L_G 0x26
+
+
+/**
+ * @brief Gyroscope data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Z_H_G 0x27
+
+
+
+/*************************************** ACCELEROMETER REGISTERS *******************************************/
+
+/**
+ * @brief Linear acceleration sensor Control Register 1
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] ODR_XL3-0: Accelerometer Output data rate and power mode selection
+ * [3:2] FS_XL1-0: Accelerometer full-scale selection
+ * [1:0] BW_XL1-0: Anti-aliasing filter bandwidth selection
+ * \endcode
+ */
+#define LSM6DS3_XG_CTRL1_XL 0x10
+
+/**
+* @brief XL sensor Control Register 8
+* \code
+* Read/write
+* Default value: 0x00
+* [7:3] This bit must be set to �0� for the correct operation of the device
+* [2] SLOPE_FDS: Enable HP filter on output registers and FIFO. Default value: 0
+* [1:0] This bit must be set to �0� for the correct operation of the device
+* \endcode
+*/
+#define LSM6DS3_XG_CTRL8_XL 0x17
+
+/**
+ * @brief Linear acceleration sensor Control Register 9
+ * \code
+ * Read/write
+ * Default value: 0x38
+ * [7:6] These bits must be set to �0� for the correct operation of the device
+ * [5] Zen_XL: Accelerometers�s Z-axis output enable
+ * [4] Yen_XL: Accelerometers�s Y-axis output enable
+ * [3] Xen_XL: Accelerometers�s X-axis output enable
+ * [2:0] These bits must be set to �0� for the correct operation of the device
+ * \endcode
+*/
+#define LSM6DS3_XG_CTRL9_XL 0x18
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_X_L_XL 0x28
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_X_H_XL 0x29
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Y_L_XL 0x2A
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Y_H_XL 0x2B
+
+
+/**
+ * @brief Accelerometer data (LSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Z_L_XL 0x2C
+
+
+/**
+ * @brief Accelerometer data (MSB)
+ * \code
+ * Read
+ * \endcode
+ */
+#define LSM6DS3_XG_OUT_Z_H_XL 0x2D
+
+/******************************************************************************/
+/************* END ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/
+/******************************************************************************/
+
+
+/************************************** COMMON REGISTERS VALUE *******************************************/
+
+/**
+* @brief Device Address
+*/
+#define LSM6DS3_ADDRESS_LOW 0xD4 // SAD[0] = 0
+#define LSM6DS3_ADDRESS_HIGH 0xD6 // SAD[0] = 1
+#define LSM6DS3_XG_MEMS_ADDRESS LSM6DS3_ADDRESS_LOW // SAD[0] = 0
+
+
+/**
+ * @brief Device Identifier. Default value of the WHO_AM_I register.
+ */
+#define I_AM_LSM6DS3_XG ((uint8_t)0x69)
+
+
+/**
+ * @brief Register address automatically incremented during a multiple byte
+ * access with a serial interface (I2C or SPI). Default value of the
+ * LSM6DS3_XG_CTRL3_C register.
+ */
+#define LSM6DS3_XG_IF_INC ((uint8_t)0x04)
+
+#define LSM6DS3_XG_IF_INC_MASK ((uint8_t)0x04)
+
+/** @defgroup LSM6DS3_XG_FIFO_Output_Data_Rate_Selection_FIFO_CTRL5 LSM6DS3_XG_FIFO_Output_Data_Rate_Selection_FIFO_CTRL5
+ * @{
+ */
+#define LSM6DS3_XG_FIFO_ODR_NA ((uint8_t)0x00) /*!< FIFO ODR NA */
+#define LSM6DS3_XG_FIFO_ODR_10HZ ((uint8_t)0x08) /*!< FIFO ODR 10Hz */
+#define LSM6DS3_XG_FIFO_ODR_25HZ ((uint8_t)0x10) /*!< FIFO ODR 25Hz */
+#define LSM6DS3_XG_FIFO_ODR_50HZ ((uint8_t)0x18) /*!< FIFO ODR 50Hz */
+#define LSM6DS3_XG_FIFO_ODR_100HZ ((uint8_t)0x20) /*!< FIFO ODR 100Hz */
+#define LSM6DS3_XG_FIFO_ODR_200HZ ((uint8_t)0x28) /*!< FIFO ODR 200Hz */
+#define LSM6DS3_XG_FIFO_ODR_400HZ ((uint8_t)0x30) /*!< FIFO ODR 400Hz */
+#define LSM6DS3_XG_FIFO_ODR_800HZ ((uint8_t)0x38) /*!< FIFO ODR 800Hz */
+#define LSM6DS3_XG_FIFO_ODR_1600HZ ((uint8_t)0x40) /*!< FIFO ODR 1600Hz */
+#define LSM6DS3_XG_FIFO_ODR_3300HZ ((uint8_t)0x48) /*!< FIFO ODR 3300Hz */
+#define LSM6DS3_XG_FIFO_ODR_6600HZ ((uint8_t)0x50) /*!< FIFO ODR 6600Hz */
+
+#define LSM6DS3_XG_FIFO_ODR_MASK ((uint8_t)0x78)
+/**
+ * @}
+ */
+
+/** @defgroup LSM6DS3_XG_FIFO_Mode_Selection_FIFO_CTRL5 LSM6DS3_XG_FIFO_Mode_Selection_FIFO_CTRL5
+ * @{
+ */
+#define LSM6DS3_XG_FIFO_MODE_BYPASS ((uint8_t)0x00) /*!< BYPASS Mode. FIFO turned off */
+#define LSM6DS3_XG_FIFO_MODE_FIFO ((uint8_t)0x01) /*!< FIFO Mode. Stop collecting data when FIFO is full */
+#define LSM6DS3_XG_FIFO_MODE_CONTINUOUS_THEN_FIFO ((uint8_t)0x03) /*!< CONTINUOUS mode until trigger is deasserted, then FIFO mode */
+#define LSM6DS3_XG_FIFO_MODE_BYPASS_THEN_CONTINUOUS ((uint8_t)0x04) /*!< BYPASS mode until trigger is deasserted, then CONTINUOUS mode */
+#define LSM6DS3_XG_FIFO_MODE_CONTINUOUS_OVERWRITE ((uint8_t)0x05) /*!< CONTINUOUS mode. If the FIFO is full the new sample overwrite the older one */
+
+#define LSM6DS3_XG_FIFO_MODE_MASK ((uint8_t)0x07)
+/**
+ * @}
+ */
+
+
+/************************************** GYROSCOPE REGISTERS VALUE *******************************************/
+
+
+/** @addtogroup LSM6DS3_XG_Gyroscope_Output_Data_Rate_Selection_CTRL_REG1_G LSM6DS3_XG_Gyroscope_Output_Data_Rate_Selection_CTRL_REG1_G
+ * @{
+ */
+#define LSM6DS3_G_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
+#define LSM6DS3_G_ODR_13HZ ((uint8_t)0x10) /*!< Output Data Rate: 13 Hz*/
+#define LSM6DS3_G_ODR_26HZ ((uint8_t)0x20) /*!< Output Data Rate: 26 Hz*/
+#define LSM6DS3_G_ODR_52HZ ((uint8_t)0x30) /*!< Output Data Rate: 52 Hz */
+#define LSM6DS3_G_ODR_104HZ ((uint8_t)0x40) /*!< Output Data Rate: 104 Hz */
+#define LSM6DS3_G_ODR_208HZ ((uint8_t)0x50) /*!< Output Data Rate: 208 Hz */
+#define LSM6DS3_G_ODR_416HZ ((uint8_t)0x60) /*!< Output Data Rate: 416 Hz */
+#define LSM6DS3_G_ODR_833HZ ((uint8_t)0x70) /*!< Output Data Rate: 833 Hz */
+#define LSM6DS3_G_ODR_1660HZ ((uint8_t)0x80) /*!< Output Data Rate: 1.66 kHz */
+
+#define LSM6DS3_G_ODR_MASK ((uint8_t)0xF0)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Gyroscope_Full_Scale_Selection_CTRL2_G LSM6DS3_XG_Gyroscope_Full_Scale_Selection_CTRL2_G
+ * @{
+ */
+#define LSM6DS3_G_FS_125_DISABLE ((uint8_t)0x00) /*!< Full scale: 125 dps enable: disable */
+#define LSM6DS3_G_FS_125_ENABLE ((uint8_t)0x02) /*!< Full scale: 125 dps enable: enable */
+
+#define LSM6DS3_G_FS_125_MASK ((uint8_t)0x02)
+
+#define LSM6DS3_G_FS_245 ((uint8_t)0x00) /*!< Full scale: 245 dps*/
+#define LSM6DS3_G_FS_500 ((uint8_t)0x04) /*!< Full scale: 500 dps */
+#define LSM6DS3_G_FS_1000 ((uint8_t)0x08) /*!< Full scale: 1000 dps */
+#define LSM6DS3_G_FS_2000 ((uint8_t)0x0C) /*!< Full scale: 2000 dps */
+
+#define LSM6DS3_G_FS_MASK ((uint8_t)0x0C)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL10_C LSM6DS3_XG_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL10_C
+ * @{
+ */
+#define LSM6DS3_G_ZEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Z-axis output enable: disable */
+#define LSM6DS3_G_ZEN_ENABLE ((uint8_t)0x20) /*!< Gyroscope�s Z-axis output enable: enable */
+
+#define LSM6DS3_G_ZEN_MASK ((uint8_t)0x20)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL10_C LSM6DS3_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL10_C
+ * @{
+ */
+#define LSM6DS3_G_YEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Y-axis output enable: disable */
+#define LSM6DS3_G_YEN_ENABLE ((uint8_t)0x10) /*!< Gyroscope�s Y-axis output enable: enable */
+
+#define LSM6DS3_G_YEN_MASK ((uint8_t)0x10)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL10_C LSM6DS3_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL10_C
+ * @{
+ */
+#define LSM6DS3_G_XEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s X-axis output enable: disable */
+#define LSM6DS3_G_XEN_ENABLE ((uint8_t)0x08) /*!< Gyroscope�s X-axis output enable: enable */
+
+#define LSM6DS3_G_XEN_MASK ((uint8_t)0x08)
+
+/**
+ * @}
+ */
+
+
+/************************************ ACCELEROMETER REGISTERS VALUE *****************************************/
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Output_Data_Rate_Selection_CTRL1_XL LSM6DS3_XG_Accelerometer_Output_Data_Rate_Selection_CTRL1_XL
+ * @{
+ */
+#define LSM6DS3_XL_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/
+#define LSM6DS3_XL_ODR_13HZ ((uint8_t)0x10) /*!< Output Data Rate: 13 Hz*/
+#define LSM6DS3_XL_ODR_26HZ ((uint8_t)0x20) /*!< Output Data Rate: 26 Hz*/
+#define LSM6DS3_XL_ODR_52HZ ((uint8_t)0x30) /*!< Output Data Rate: 52 Hz */
+#define LSM6DS3_XL_ODR_104HZ ((uint8_t)0x40) /*!< Output Data Rate: 104 Hz */
+#define LSM6DS3_XL_ODR_208HZ ((uint8_t)0x50) /*!< Output Data Rate: 208 Hz */
+#define LSM6DS3_XL_ODR_416HZ ((uint8_t)0x60) /*!< Output Data Rate: 416 Hz */
+#define LSM6DS3_XL_ODR_833HZ ((uint8_t)0x70) /*!< Output Data Rate: 833 Hz */
+#define LSM6DS3_XL_ODR_1660HZ ((uint8_t)0x80) /*!< Output Data Rate: 1.66 kHz */
+#define LSM6DS3_XL_ODR_3330HZ ((uint8_t)0x90) /*!< Output Data Rate: 3.33 kHz */
+#define LSM6DS3_XL_ODR_6660HZ ((uint8_t)0xA0) /*!< Output Data Rate: 6.66 kHz */
+
+#define LSM6DS3_XL_ODR_MASK ((uint8_t)0xF0)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Full_Scale_Selection_CTRL1_XL LSM6DS3_XG_Accelerometer_Full_Scale_Selection_CTRL1_XL
+ * @{
+ */
+#define LSM6DS3_XL_FS_2G ((uint8_t)0x00) /*!< Full scale: +- 2g */
+#define LSM6DS3_XL_FS_4G ((uint8_t)0x08) /*!< Full scale: +- 4g */
+#define LSM6DS3_XL_FS_8G ((uint8_t)0x0C) /*!< Full scale: +- 8g */
+#define LSM6DS3_XL_FS_16G ((uint8_t)0x04) /*!< Full scale: +- 16g */
+
+#define LSM6DS3_XL_FS_MASK ((uint8_t)0x0C)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Anti_Aliasing_Filter_Bandwidth_Selection_CTRL1_XL LSM6DS3_XG_Accelerometer_Anti_Aliasing_Filter_Bandwidth_Selection_CTRL1_XL
+ * @{
+ */
+#define LSM6DS3_XL_BW_400HZ ((uint8_t)0x00) /*!< Anti-aliasing filter bandwidht: 400 Hz */
+#define LSM6DS3_XL_BW_200HZ ((uint8_t)0x01) /*!< Anti-aliasing filter bandwidht: 200 Hz */
+#define LSM6DS3_XL_BW_100HZ ((uint8_t)0x02) /*!< Anti-aliasing filter bandwidht: 100 Hz */
+#define LSM6DS3_XL_BW_50HZ ((uint8_t)0x03) /*!< Anti-aliasing filter bandwidht: 50 Hz */
+
+#define LSM6DS3_XL_BW_MASK ((uint8_t)0x03)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS3_XG_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL9_XL
+ * @{
+ */
+#define LSM6DS3_XL_ZEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Z-axis output enable: disable */
+#define LSM6DS3_XL_ZEN_ENABLE ((uint8_t)0x20) /*!< Accelerometer�s Z-axis output enable: enable */
+
+#define LSM6DS3_XL_ZEN_MASK ((uint8_t)0x20)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS3_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL9_XL
+ * @{
+ */
+#define LSM6DS3_XL_YEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Y-axis output enable: disable */
+#define LSM6DS3_XL_YEN_ENABLE ((uint8_t)0x10) /*!< Accelerometer�s Y-axis output enable: enable */
+
+#define LSM6DS3_XL_YEN_MASK ((uint8_t)0x10)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS3_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL9_XL
+ * @{
+ */
+#define LSM6DS3_XL_XEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s X-axis output enable: disable */
+#define LSM6DS3_XL_XEN_ENABLE ((uint8_t)0x08) /*!< Accelerometer�s X-axis output enable: enable */
+
+#define LSM6DS3_XL_XEN_MASK ((uint8_t)0x08)
+
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_FF_DUR5_Selection_WAKE_UP_DUR LSM6DS3_XG_Accelerometer_FF_DUR5_Selection_WAKE_UP_DUR
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_DUR_FF_DUR5_DEFAULT ((uint8_t)0x00)
+
+#define LSM6DS3_XG_WAKE_UP_DUR_FF_DUR5_MASK ((uint8_t)0x80)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_WAKE_DUR_Selection_WAKE_UP_DUR LSM6DS3_XG_Accelerometer_WAKE_DUR_Selection_WAKE_UP_DUR
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_DUR_WAKE_DUR_DEFAULT ((uint8_t)0x00)
+
+#define LSM6DS3_XG_WAKE_UP_DUR_WAKE_DUR_MASK ((uint8_t)0x60)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_TIMER_HR_Selection_WAKE_UP_DUR LSM6DS3_XG_Accelerometer_TIMER_HR_Selection_WAKE_UP_DUR
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_DUR_TIMER_HR_DEFAULT ((uint8_t)0x00)
+
+#define LSM6DS3_XG_WAKE_UP_DUR_TIMER_HR_MASK ((uint8_t)0x10)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_SLEEP_DUR_Selection_WAKE_UP_DUR LSM6DS3_XG_Accelerometer_SLEEP_DUR_Selection_WAKE_UP_DUR
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_DUR_SLEEP_DUR_DEFAULT ((uint8_t)0x00)
+
+#define LSM6DS3_XG_WAKE_UP_DUR_SLEEP_DUR_MASK ((uint8_t)0x0F)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_FF_DUR_Selection_FREE_FALL LSM6DS3_XG_Accelerometer_FF_DUR_Selection_FREE_FALL
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_DEFAULT ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_TYPICAL ((uint8_t)0x30)
+
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_MASK ((uint8_t)0xF8)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_FF_THS_Selection_FREE_FALL LSM6DS3_XG_Accelerometer_FF_THS_Selection_FREE_FALL
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_156MG ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_219MG ((uint8_t)0x01)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_250MG ((uint8_t)0x02)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_312MG ((uint8_t)0x03)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_344MG ((uint8_t)0x04)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_406MG ((uint8_t)0x05)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_469MG ((uint8_t)0x06)
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_500MG ((uint8_t)0x07)
+
+#define LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_MASK ((uint8_t)0x07)
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_INACT_STATE_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_INACT_STATE_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_INACT_STATE_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_INACT_STATE_ENABLE ((uint8_t)0x80)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_INACT_STATE_MASK ((uint8_t)0x80)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_SINGLE_TAP_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_SINGLE_TAP_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_SINGLE_TAP_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_SINGLE_TAP_ENABLE ((uint8_t)0x40)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_SINGLE_TAP_MASK ((uint8_t)0x40)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_WU_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_WU_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_WU_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_WU_ENABLE ((uint8_t)0x20)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_WU_MASK ((uint8_t)0x20)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_FF_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_FF_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_FF_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_FF_ENABLE ((uint8_t)0x10)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_FF_MASK ((uint8_t)0x10)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_DOUBLE_TAP_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_DOUBLE_TAP_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_DOUBLE_TAP_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_DOUBLE_TAP_ENABLE ((uint8_t)0x08)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_DOUBLE_TAP_MASK ((uint8_t)0x08)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_6D_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_6D_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_6D_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_6D_ENABLE ((uint8_t)0x04)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_6D_MASK ((uint8_t)0x04)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_TILT_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_TILT_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_TILT_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_TILT_ENABLE ((uint8_t)0x02)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_TILT_MASK ((uint8_t)0x02)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_INT1_TIMER_Selection_MD1_CFG LSM6DS3_XG_Accelerometer_INT1_TIMER_Selection_MD1_CFG
+ * @{
+ */
+#define LSM6DS3_XG_MD1_CFG_INT1_TIMER_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_MD1_CFG_INT1_TIMER_ENABLE ((uint8_t)0x01)
+
+#define LSM6DS3_XG_MD1_CFG_INT1_TIMER_MASK ((uint8_t)0x01)
+
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_FF_IA_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_FF_IA_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_FF_IA_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_FF_IA_ENABLE ((uint8_t)0x20)
+
+#define LSM6DS3_XG_WAKE_UP_SRC_FF_IA_MASK ((uint8_t)0x20)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_SLEEP_STATE_IA_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_SLEEP_STATE_IA_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_SLEEP_STATE_IA_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_SLEEP_STATE_IA_ENABLE ((uint8_t)0x10)
+
+#define LSM6DS3_XG_WAKE_UP_SRC_SLEEP_STATE_IA_MASK ((uint8_t)0x10)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_WU_IA_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_WU_IA_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_WU_IA_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_WU_IA_ENABLE ((uint8_t)0x08)
+
+#define LSM6DS3_XG_WAKE_UP_SRC_WU_IA_MASK ((uint8_t)0x08)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_X_WU_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_X_WU_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_X_WU_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_X_WU_ENABLE ((uint8_t)0x04)
+
+#define LSM6DS3_XG_WAKE_UP_SRC_X_WU_MASK ((uint8_t)0x04)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Y_WU_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_Y_WU_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_Y_WU_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_Y_WU_ENABLE ((uint8_t)0x02)
+
+
+#define LSM6DS3_XG_WAKE_UP_SRC_Y_WU_MASK ((uint8_t)0x02)
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_XG_Accelerometer_Z_WU_Enable_WAKE_UP_SRC LSM6DS3_XG_Accelerometer_Z_WU_Enable_WAKE_UP_SRC
+ * @{
+ */
+#define LSM6DS3_XG_WAKE_UP_SRC_Z_WU_DISABLE ((uint8_t)0x00)
+#define LSM6DS3_XG_WAKE_UP_SRC_Z_WU_ENABLE ((uint8_t)0x01)
+
+#define LSM6DS3_XG_WAKE_UP_SRC_Z_WU_MASK ((uint8_t)0x01)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_Imported_Functions LSM6DS3_Imported_Functions
+ * @{
+ */
+
+/* Six axes sensor IO functions */
+extern IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init( void );
+extern IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToWrite );
+extern IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
+ uint16_t NumByteToRead );
+extern void LSM6DS3_IO_ITConfig( void );
+
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_Exported_Types LSM6DS3_Exported_Types
+ * @{
+ */
+/**
+ * @brief LSM6DS3 driver extended internal structure definition
+ */
+typedef struct
+{
+ IMU_6AXES_StatusTypeDef (*Enable_Free_Fall_Detection) (void);
+ IMU_6AXES_StatusTypeDef (*Disable_Free_Fall_Detection) (void);
+ IMU_6AXES_StatusTypeDef (*Get_Status_Free_Fall_Detection) (uint8_t *);
+} LSM6DS3_DrvExtTypeDef;
+
+/**
+ * @}
+ */
+
+/** @addtogroup LSM6DS3_Exported_Variables LSM6DS3_Exported_Variables
+ * @{
+ */
+
+/* Six axes sensor driver structure */
+extern IMU_6AXES_DrvTypeDef LSM6DS3Drv;
+extern IMU_6AXES_DrvExtTypeDef LSM6DS3Drv_ext;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LSM6DS3_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds3/lsm6ds3_class.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,1019 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds3_class.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Implementation file for the LSM6DS3 driver class
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+/* Includes ------------------------------------------------------------------*/
+#include "lsm6ds3_class.h"
+#include "lsm6ds3.h"
+
+/* Methods -------------------------------------------------------------------*/
+/* betzw - based on:
+ X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds3/lsm6ds3.c: revision #400,
+ X-CUBE-MEMS1/trunk: revision #416
+*/
+
+/**
+ * @brief Set LSM6DS3 Initialization
+ * @param LSM6DS3_Init the configuration setting for the LSM6DS3
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Init( IMU_6AXES_InitTypeDef *LSM6DS3_Init )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ /* Configure the low level interface -------------------------------------*/
+ if(LSM6DS3_IO_Init() != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+
+ /******** Common init *********/
+
+ if(LSM6DS3_Common_Sensor_Enable() != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+
+ /******* Gyroscope init *******/
+
+ if(LSM6DS3_G_Set_ODR( LSM6DS3_Init->G_OutputDataRate ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_G_Set_FS( LSM6DS3_Init->G_FullScale ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_G_Set_Axes_Status(LSM6DS3_Init->G_X_Axis, LSM6DS3_Init->G_Y_Axis, LSM6DS3_Init->G_Z_Axis) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+
+ /***** Accelerometer init *****/
+
+ if(LSM6DS3_X_Set_ODR( LSM6DS3_Init->X_OutputDataRate ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_X_Set_FS( LSM6DS3_Init->X_FullScale ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_X_Set_Axes_Status(LSM6DS3_Init->X_X_Axis, LSM6DS3_Init->X_Y_Axis, LSM6DS3_Init->X_Z_Axis) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Configure interrupt lines */
+ LSM6DS3_IO_ITConfig();
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read ID of LSM6DS3 Accelerometer and Gyroscope
+ * @param xg_id the pointer where the ID of the device is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Read_XG_ID( uint8_t *xg_id)
+{
+ if(!xg_id)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return LSM6DS3_IO_Read(xg_id, LSM6DS3_XG_WHO_AM_I_ADDR, 1);
+}
+
+/**
+ * @brief Set LSM6DS3 common initialization
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Common_Sensor_Enable(void)
+{
+ uint8_t tmp1 = 0x00;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_CTRL3_C, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Enable register address automatically incremented during a multiple byte
+ access with a serial interface (I2C or SPI) */
+ tmp1 &= ~(LSM6DS3_XG_IF_INC_MASK);
+ tmp1 |= LSM6DS3_XG_IF_INC;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_CTRL3_C, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_FIFO_CTRL5, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* FIFO ODR selection */
+ tmp1 &= ~(LSM6DS3_XG_FIFO_ODR_MASK);
+ tmp1 |= LSM6DS3_XG_FIFO_ODR_NA;
+
+ /* FIFO mode selection */
+ tmp1 &= ~(LSM6DS3_XG_FIFO_MODE_MASK);
+ tmp1 |= LSM6DS3_XG_FIFO_MODE_BYPASS;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_FIFO_CTRL5, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read raw data from LSM6DS3 Accelerometer output register
+ * @param pData the pointer where the accelerometer raw data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_GetAxesRaw( int16_t *pData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg[2] = {0, 0};
+
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_X_L_XL, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_Y_L_XL, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_Z_L_XL, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ return IMU_6AXES_OK;
+}
+
+
+
+/**
+ * @brief Read data from LSM6DS3 Accelerometer and calculate linear acceleration in mg
+ * @param pData the pointer where the accelerometer data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_GetAxes( int32_t *pData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ int16_t pDataRaw[3];
+ float sensitivity = 0.0f;
+
+ if(LSM6DS3_X_GetAxesRaw(pDataRaw) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_X_GetSensitivity( &sensitivity ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = (int32_t)(pDataRaw[0] * sensitivity);
+ pData[1] = (int32_t)(pDataRaw[1] * sensitivity);
+ pData[2] = (int32_t)(pDataRaw[2] * sensitivity);
+
+ return IMU_6AXES_OK;
+}
+
+
+
+/**
+ * @brief Read raw data from LSM6DS3 Gyroscope output register
+ * @param pData the pointer where the gyroscope raw data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_GetAxesRaw( int16_t *pData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg[2] = {0, 0};
+
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_X_L_G, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_Y_L_G, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[1] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ if(LSM6DS3_IO_Read(&tempReg[0], LSM6DS3_XG_OUT_Z_L_G, 2) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[2] = ((((int16_t)tempReg[1]) << 8) + (int16_t)tempReg[0]);
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Set the status of the axes for accelerometer
+ * @param enableX the status of the x axis to be set
+ * @param enableY the status of the y axis to be set
+ * @param enableZ the status of the z axis to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ)
+{
+ uint8_t tmp1 = 0x00;
+ uint8_t eX = 0x00;
+ uint8_t eY = 0x00;
+ uint8_t eZ = 0x00;
+
+ eX = ( enableX == 0 ) ? LSM6DS3_XL_XEN_DISABLE : LSM6DS3_XL_XEN_ENABLE;
+ eY = ( enableY == 0 ) ? LSM6DS3_XL_YEN_DISABLE : LSM6DS3_XL_YEN_ENABLE;
+ eZ = ( enableZ == 0 ) ? LSM6DS3_XL_ZEN_DISABLE : LSM6DS3_XL_ZEN_ENABLE;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_CTRL9_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS3_XL_XEN_MASK);
+ tmp1 |= eX;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS3_XL_YEN_MASK);
+ tmp1 |= eY;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS3_XL_ZEN_MASK);
+ tmp1 |= eZ;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_CTRL9_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Set the status of the axes for gyroscope
+ * @param enableX the status of the x axis to be set
+ * @param enableY the status of the y axis to be set
+ * @param enableZ the status of the z axis to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ)
+{
+ uint8_t tmp1 = 0x00;
+ uint8_t eX = 0x00;
+ uint8_t eY = 0x00;
+ uint8_t eZ = 0x00;
+
+ eX = ( enableX == 0 ) ? LSM6DS3_G_XEN_DISABLE : LSM6DS3_G_XEN_ENABLE;
+ eY = ( enableY == 0 ) ? LSM6DS3_G_YEN_DISABLE : LSM6DS3_G_YEN_ENABLE;
+ eZ = ( enableZ == 0 ) ? LSM6DS3_G_ZEN_DISABLE : LSM6DS3_G_ZEN_ENABLE;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_CTRL10_C, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Enable X axis selection */
+ tmp1 &= ~(LSM6DS3_G_XEN_MASK);
+ tmp1 |= eX;
+
+ /* Enable Y axis selection */
+ tmp1 &= ~(LSM6DS3_G_YEN_MASK);
+ tmp1 |= eY;
+
+ /* Enable Z axis selection */
+ tmp1 &= ~(LSM6DS3_G_ZEN_MASK);
+ tmp1 |= eZ;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_CTRL10_C, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read data from LSM6DS3 Gyroscope and calculate angular rate in mdps
+ * @param pData the pointer where the gyroscope data are stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_GetAxes( int32_t *pData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ int16_t pDataRaw[3];
+ float sensitivity = 0.0f;
+
+ if(LSM6DS3_G_GetAxesRaw(pDataRaw) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_G_GetSensitivity( &sensitivity ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ pData[0] = (int32_t)(pDataRaw[0] * sensitivity);
+ pData[1] = (int32_t)(pDataRaw[1] * sensitivity);
+ pData[2] = (int32_t)(pDataRaw[2] * sensitivity);
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Output Data Rate
+ * @param odr the pointer where the accelerometer output data rate is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_Get_ODR( float *odr )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_XL_ODR_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_XL_ODR_PD:
+ *odr = 0.0f;
+ break;
+ case LSM6DS3_XL_ODR_13HZ:
+ *odr = 13.0f;
+ break;
+ case LSM6DS3_XL_ODR_26HZ:
+ *odr = 26.0f;
+ break;
+ case LSM6DS3_XL_ODR_52HZ:
+ *odr = 52.0f;
+ break;
+ case LSM6DS3_XL_ODR_104HZ:
+ *odr = 104.0f;
+ break;
+ case LSM6DS3_XL_ODR_208HZ:
+ *odr = 208.0f;
+ break;
+ case LSM6DS3_XL_ODR_416HZ:
+ *odr = 416.0f;
+ break;
+ case LSM6DS3_XL_ODR_833HZ:
+ *odr = 833.0f;
+ break;
+ case LSM6DS3_XL_ODR_1660HZ:
+ *odr = 1660.0f;
+ break;
+ case LSM6DS3_XL_ODR_3330HZ:
+ *odr = 3330.0f;
+ break;
+ case LSM6DS3_XL_ODR_6660HZ:
+ *odr = 6660.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Accelero Output Data Rate
+ * @param odr the accelerometer output data rate to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_Set_ODR( float odr )
+{
+ uint8_t new_odr = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_odr = ( odr <= 0.0f ) ? LSM6DS3_XL_ODR_PD /* Power Down */
+ : ( odr <= 13.0f ) ? LSM6DS3_XL_ODR_13HZ
+ : ( odr <= 26.0f ) ? LSM6DS3_XL_ODR_26HZ
+ : ( odr <= 52.0f ) ? LSM6DS3_XL_ODR_52HZ
+ : ( odr <= 104.0f ) ? LSM6DS3_XL_ODR_104HZ
+ : ( odr <= 208.0f ) ? LSM6DS3_XL_ODR_208HZ
+ : ( odr <= 416.0f ) ? LSM6DS3_XL_ODR_416HZ
+ : ( odr <= 833.0f ) ? LSM6DS3_XL_ODR_833HZ
+ : ( odr <= 1660.0f ) ? LSM6DS3_XL_ODR_1660HZ
+ : ( odr <= 3330.0f ) ? LSM6DS3_XL_ODR_3330HZ
+ : LSM6DS3_XL_ODR_6660HZ;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_XL_ODR_MASK);
+ tempReg |= new_odr;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL1_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Sensitivity
+ * @param pfData the pointer where the accelerometer sensitivity is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_GetSensitivity( float *pfData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg = 0x00;
+
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_XL_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_XL_FS_2G:
+ *pfData = 0.061f;
+ break;
+ case LSM6DS3_XL_FS_4G:
+ *pfData = 0.122f;
+ break;
+ case LSM6DS3_XL_FS_8G:
+ *pfData = 0.244f;
+ break;
+ case LSM6DS3_XL_FS_16G:
+ *pfData = 0.488f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Accelero Full Scale
+ * @param fullScale the pointer where the accelerometer full scale is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_Get_FS( float *fullScale )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg = 0x00;
+
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_XL_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_XL_FS_2G:
+ *fullScale = 2.0f;
+ break;
+ case LSM6DS3_XL_FS_4G:
+ *fullScale = 4.0f;
+ break;
+ case LSM6DS3_XL_FS_8G:
+ *fullScale = 8.0f;
+ break;
+ case LSM6DS3_XL_FS_16G:
+ *fullScale = 16.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Accelero Full Scale
+ * @param fullScale the accelerometer full scale to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_X_Set_FS( float fullScale )
+{
+ uint8_t new_fs = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_fs = ( fullScale <= 2.0f ) ? LSM6DS3_XL_FS_2G
+ : ( fullScale <= 4.0f ) ? LSM6DS3_XL_FS_4G
+ : ( fullScale <= 8.0f ) ? LSM6DS3_XL_FS_8G
+ : LSM6DS3_XL_FS_16G;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_XL_FS_MASK);
+ tempReg |= new_fs;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL1_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Output Data Rate
+ * @param odr the pointer where the gyroscope output data rate is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_Get_ODR( float *odr )
+{
+ /*Here we have to add the check if the parameters are valid*/
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_G_ODR_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_G_ODR_PD:
+ *odr = 0.0f;
+ break;
+ case LSM6DS3_G_ODR_13HZ:
+ *odr = 13.0f;
+ break;
+ case LSM6DS3_G_ODR_26HZ:
+ *odr = 26.0f;
+ break;
+ case LSM6DS3_G_ODR_52HZ:
+ *odr = 52.0f;
+ break;
+ case LSM6DS3_G_ODR_104HZ:
+ *odr = 104.0f;
+ break;
+ case LSM6DS3_G_ODR_208HZ:
+ *odr = 208.0f;
+ break;
+ case LSM6DS3_G_ODR_416HZ:
+ *odr = 416.0f;
+ break;
+ case LSM6DS3_G_ODR_833HZ:
+ *odr = 833.0f;
+ break;
+ case LSM6DS3_G_ODR_1660HZ:
+ *odr = 1660.0f;
+ break;
+ default:
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Gyro Output Data Rate
+ * @param odr the gyroscope output data rate to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+ */
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_Set_ODR( float odr )
+{
+ uint8_t new_odr = 0x00;
+ uint8_t tempReg = 0x00;
+
+ new_odr = ( odr <= 0.0f ) ? LSM6DS3_G_ODR_PD /* Power Down */
+ : ( odr <= 13.0f ) ? LSM6DS3_G_ODR_13HZ
+ : ( odr <= 26.0f ) ? LSM6DS3_G_ODR_26HZ
+ : ( odr <= 52.0f ) ? LSM6DS3_G_ODR_52HZ
+ : ( odr <= 104.0f ) ? LSM6DS3_G_ODR_104HZ
+ : ( odr <= 208.0f ) ? LSM6DS3_G_ODR_208HZ
+ : ( odr <= 416.0f ) ? LSM6DS3_G_ODR_416HZ
+ : ( odr <= 833.0f ) ? LSM6DS3_G_ODR_833HZ
+ : LSM6DS3_G_ODR_1660HZ;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_G_ODR_MASK);
+ tempReg |= new_odr;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL2_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Sensitivity
+ * @param pfData the pointer where the gyroscope sensitivity is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_GetSensitivity( float *pfData )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_G_FS_125_MASK;
+
+ if(tempReg == LSM6DS3_G_FS_125_ENABLE)
+ {
+ *pfData = 4.375f;
+ }
+ else
+ {
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_G_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_G_FS_245:
+ *pfData = 8.75f;
+ break;
+ case LSM6DS3_G_FS_500:
+ *pfData = 17.50f;
+ break;
+ case LSM6DS3_G_FS_1000:
+ *pfData = 35.0f;
+ break;
+ case LSM6DS3_G_FS_2000:
+ *pfData = 70.0f;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Read Gyro Full Scale
+ * @param fullScale the pointer where the gyroscope full scale is stored
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_Get_FS( float *fullScale )
+{
+ /*Here we have to add the check if the parameters are valid*/
+
+ uint8_t tempReg = 0x00;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_G_FS_125_MASK;
+
+ if(tempReg == LSM6DS3_G_FS_125_ENABLE)
+ {
+ *fullScale = 125.0f;
+ }
+ else
+ {
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= LSM6DS3_G_FS_MASK;
+
+ switch( tempReg )
+ {
+ case LSM6DS3_G_FS_245:
+ *fullScale = 245.0f;
+ break;
+ case LSM6DS3_G_FS_500:
+ *fullScale = 500.0f;
+ break;
+ case LSM6DS3_G_FS_1000:
+ *fullScale = 1000.0f;
+ break;
+ case LSM6DS3_G_FS_2000:
+ *fullScale = 2000.0f;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Write Gyro Full Scale
+ * @param fullScale the gyroscope full scale to be set
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_G_Set_FS( float fullScale )
+{
+ uint8_t new_fs = 0x00;
+ uint8_t tempReg = 0x00;
+
+ if(fullScale <= 125.0f)
+ {
+ new_fs = LSM6DS3_G_FS_125_ENABLE;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_G_FS_125_MASK);
+ tempReg |= new_fs;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL2_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+ }
+ else
+ {
+ /* Disable G FS 125dpp */
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_G_FS_125_MASK);
+ tempReg |= LSM6DS3_G_FS_125_DISABLE;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL2_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ new_fs = ( fullScale <= 245.0f ) ? LSM6DS3_G_FS_245
+ : ( fullScale <= 500.0f ) ? LSM6DS3_G_FS_500
+ : ( fullScale <= 1000.0f ) ? LSM6DS3_G_FS_1000
+ : LSM6DS3_G_FS_2000;
+
+ if(LSM6DS3_IO_Read( &tempReg, LSM6DS3_XG_CTRL2_G, 1 ) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tempReg &= ~(LSM6DS3_G_FS_MASK);
+ tempReg |= new_fs;
+
+ if(LSM6DS3_IO_Write(&tempReg, LSM6DS3_XG_CTRL2_G, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Enable free fall detection
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Enable_Free_Fall_Detection( void )
+{
+ uint8_t tmp1 = 0x00;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_CTRL1_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* Output Data Rate selection */
+ tmp1 &= ~(LSM6DS3_XL_ODR_MASK);
+ tmp1 |= LSM6DS3_XL_ODR_416HZ;
+
+ /* Full scale selection */
+ tmp1 &= ~(LSM6DS3_XL_FS_MASK);
+ tmp1 |= LSM6DS3_XL_FS_2G;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_CTRL1_XL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_WAKE_UP_DUR, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* FF_DUR5 setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_UP_DUR_FF_DUR5_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_UP_DUR_FF_DUR5_DEFAULT;
+
+ /* WAKE_DUR setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_UP_DUR_WAKE_DUR_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_UP_DUR_WAKE_DUR_DEFAULT;
+
+ /* TIMER_HR setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_UP_DUR_TIMER_HR_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_UP_DUR_TIMER_HR_DEFAULT;
+
+ /* SLEEP_DUR setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_UP_DUR_SLEEP_DUR_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_UP_DUR_SLEEP_DUR_DEFAULT;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_WAKE_UP_DUR, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_WAKE_FREE_FALL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* FF_DUR setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_TYPICAL;
+
+ /* FF_THS setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_312MG;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_WAKE_FREE_FALL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_MD1_CFG, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* INT1_FF setting */
+ tmp1 &= ~(LSM6DS3_XG_MD1_CFG_INT1_FF_MASK);
+ tmp1 |= LSM6DS3_XG_MD1_CFG_INT1_FF_ENABLE;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_MD1_CFG, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Disable free fall detection
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Disable_Free_Fall_Detection( void )
+{
+ uint8_t tmp1 = 0x00;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_MD1_CFG, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* INT1_FF setting */
+ tmp1 &= ~(LSM6DS3_XG_MD1_CFG_INT1_FF_MASK);
+ tmp1 |= LSM6DS3_XG_MD1_CFG_INT1_FF_DISABLE;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_MD1_CFG, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_WAKE_FREE_FALL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ /* FF_DUR setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_FREE_FALL_FF_DUR_DEFAULT;
+
+ /* FF_THS setting */
+ tmp1 &= ~(LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_MASK);
+ tmp1 |= LSM6DS3_XG_WAKE_FREE_FALL_FF_THS_156MG;
+
+ if(LSM6DS3_IO_Write(&tmp1, LSM6DS3_XG_WAKE_FREE_FALL, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/**
+ * @brief Get status of free fall detection
+ * @param status the pointer where the status of free fall detection is stored; 0 means no detection, 1 means detection happened
+ * @retval IMU_6AXES_OK in case of success, an error code otherwise
+*/
+IMU_6AXES_StatusTypeDef LSM6DS3::LSM6DS3_Get_Status_Free_Fall_Detection( uint8_t *status )
+{
+ uint8_t tmp1 = 0x00;
+
+ if(LSM6DS3_IO_Read(&tmp1, LSM6DS3_XG_WAKE_UP_SRC, 1) != IMU_6AXES_OK)
+ {
+ return IMU_6AXES_ERROR;
+ }
+
+ tmp1 &= LSM6DS3_XG_WAKE_UP_SRC_FF_IA_MASK;
+
+ switch( tmp1 )
+ {
+ case LSM6DS3_XG_WAKE_UP_SRC_FF_IA_ENABLE:
+ *status = 1;
+ break;
+ case LSM6DS3_XG_WAKE_UP_SRC_FF_IA_DISABLE:
+ default:
+ *status = 0;
+ break;
+ }
+
+ return IMU_6AXES_OK;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds3/lsm6ds3_class.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,270 @@
+/**
+ ******************************************************************************
+ * @file lsm6ds3_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component LSM6DS3
+ ******************************************************************************
+ * @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.
+ *
+ ******************************************************************************
+*/
+
+#ifndef __LSM6DS3_CLASS_H
+#define __LSM6DS3_CLASS_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "DevI2C.h"
+#include "lsm6ds3.h"
+#include "../Interfaces/GyroSensor.h"
+#include "../Interfaces/MotionSensor.h"
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a LSM6DS3 sensor component
+ */
+class LSM6DS3 : public GyroSensor, public MotionSensor {
+ public:
+ /** Constructor
+ * @param[in] i2c device I2C to be used for communication
+ * @param[in] irq_pin pin name for free fall detection interrupt
+ */
+ LSM6DS3(DevI2C &i2c, PinName irq_pin) : GyroSensor(), MotionSensor(),
+ dev_i2c(i2c), free_fall(irq_pin) {
+ }
+
+ /** Destructor
+ */
+ virtual ~LSM6DS3() {}
+
+ /*** Interface Methods ***/
+ virtual int Init(void *init_struct) {
+ return LSM6DS3_Init((IMU_6AXES_InitTypeDef*)init_struct);
+ }
+
+ virtual int ReadID(uint8_t *xg_id) {
+ return LSM6DS3_Read_XG_ID(xg_id);
+ }
+
+ virtual int Get_X_Axes(int32_t *pData) {
+ return LSM6DS3_X_GetAxes(pData);
+ }
+
+ virtual int Get_X_AxesRaw(int16_t *pData) {
+ return LSM6DS3_X_GetAxesRaw(pData);
+ }
+
+ virtual int Get_G_Axes(int32_t *pData) {
+ return LSM6DS3_G_GetAxes(pData);
+ }
+
+ virtual int Get_G_AxesRaw(int16_t *pData) {
+ return LSM6DS3_G_GetAxesRaw(pData);
+ }
+
+ virtual int Get_X_ODR(float *odr) {
+ return LSM6DS3_X_Get_ODR(odr);
+ }
+
+ virtual int Set_X_ODR(float odr) {
+ return LSM6DS3_X_Set_ODR(odr);
+ }
+
+ virtual int Get_X_Sensitivity(float *pfData) {
+ return LSM6DS3_X_GetSensitivity(pfData);
+ }
+
+ virtual int Get_X_FS(float *fullScale) {
+ return LSM6DS3_X_Get_FS(fullScale);
+ }
+
+ virtual int Set_X_FS(float fullScale) {
+ return LSM6DS3_X_Set_FS(fullScale);
+ }
+
+ virtual int Get_G_ODR(float *odr) {
+ return LSM6DS3_G_Get_ODR(odr);
+ }
+
+ virtual int Set_G_ODR(float odr) {
+ return LSM6DS3_G_Set_ODR(odr);
+ }
+
+ virtual int Get_G_Sensitivity(float *pfData) {
+ return LSM6DS3_G_GetSensitivity(pfData);
+ }
+
+ virtual int Get_G_FS(float *fullScale) {
+ return LSM6DS3_G_Get_FS(fullScale);
+ }
+
+ virtual int Set_G_FS(float fullScale) {
+ return LSM6DS3_G_Set_FS(fullScale);
+ }
+
+ /* Additional Public Methods */
+ /**
+ * @brief Enable free fall detection
+ * @return IMU_6AXES_OK in case of success, an error code otherwise
+ */
+ IMU_6AXES_StatusTypeDef Enable_Free_Fall_Detection(void) {
+ return LSM6DS3_Enable_Free_Fall_Detection();
+ }
+
+ /**
+ * @brief Disable free fall detection
+ * @return IMU_6AXES_OK in case of success, an error code otherwise
+ */
+ IMU_6AXES_StatusTypeDef Disable_Free_Fall_Detection(void) {
+ return LSM6DS3_Disable_Free_Fall_Detection();
+ }
+
+ /**
+ * @brief Get status of free fall detection
+ * @param[out] status the pointer where the status of free fall detection is stored;
+ * 0 means no detection, 1 means detection happened
+ * @return IMU_6AXES_OK in case of success, an error code otherwise
+ */
+ IMU_6AXES_StatusTypeDef Get_Status_Free_Fall_Detection(uint8_t *status) {
+ return LSM6DS3_Get_Status_Free_Fall_Detection(status);
+ }
+
+ /** Attach a function to call when a free fall is detected
+ *
+ * @param[in] fptr A pointer to a void function, or 0 to set as none
+ */
+ void Attach_Free_Fall_Detection_IRQ(void (*fptr)(void)) {
+ free_fall.rise(fptr);
+ }
+
+ /** Enable Free Fall IRQ
+ */
+ void Enable_Free_Fall_Detection_IRQ(void) {
+ free_fall.enable_irq();
+ }
+
+ /** Disable free Fall IRQ
+ */
+ void Disable_Free_Fall_Detection_IRQ(void) {
+ free_fall.disable_irq();
+ }
+
+ protected:
+ /*** Methods ***/
+ IMU_6AXES_StatusTypeDef LSM6DS3_Init(IMU_6AXES_InitTypeDef *LSM6DS3_Init);
+ IMU_6AXES_StatusTypeDef LSM6DS3_Read_XG_ID(uint8_t *xg_id);
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxes(int32_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxesRaw(int16_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxes(int32_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxesRaw(int16_t *pData);
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_ODR( float *odr );
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_ODR( float odr );
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_GetSensitivity( float *pfData );
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_FS( float *fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_FS( float fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_ODR( float *odr );
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_ODR( float odr );
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_GetSensitivity( float *pfData );
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_FS( float *fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_FS( float fullScale );
+ IMU_6AXES_StatusTypeDef LSM6DS3_Enable_Free_Fall_Detection( void );
+ IMU_6AXES_StatusTypeDef LSM6DS3_Disable_Free_Fall_Detection( void );
+ IMU_6AXES_StatusTypeDef LSM6DS3_Get_Status_Free_Fall_Detection( uint8_t *status );
+
+ IMU_6AXES_StatusTypeDef LSM6DS3_Common_Sensor_Enable(void);
+ IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
+ IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
+
+ /**
+ * @brief Configures LSM6DS3 interrupt lines for NUCLEO boards
+ */
+ void LSM6DS3_IO_ITConfig(void)
+ {
+ free_fall.mode(PullNone); /* be precise about pin mode */
+ }
+
+ /**
+ * @brief Configures LSM6DS3 I2C interface
+ * @return IMU_6AXES_OK in case of success, an error code otherwise
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init(void)
+ {
+ return IMU_6AXES_OK; /* done in constructor */
+ }
+
+ /**
+ * @brief Utility function to read data from LSM6DS3
+ * @param[out] pBuffer pointer to the byte-array to read data in to
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToRead number of bytes to be read.
+ * @retval IMU_6AXES_OK if ok,
+ * @retval IMU_6AXES_ERROR if an I2C error has occured
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToRead)
+ {
+ int ret = dev_i2c.i2c_read(pBuffer,
+ LSM6DS3_XG_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToRead);
+ if(ret != 0) {
+ return IMU_6AXES_ERROR;
+ }
+ return IMU_6AXES_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to LSM6DS3
+ * @param[in] pBuffer pointer to the byte-array data to send
+ * @param[in] RegisterAddr specifies internal address register to read from.
+ * @param[in] NumByteToWrite number of bytes to write.
+ * @retval IMU_6AXES_OK if ok,
+ * @retval IMU_6AXES_ERROR if an I2C error has occured
+ */
+ IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write(uint8_t* pBuffer,
+ uint8_t RegisterAddr, uint16_t NumByteToWrite)
+ {
+ int ret = dev_i2c.i2c_write(pBuffer,
+ LSM6DS3_XG_MEMS_ADDRESS,
+ RegisterAddr,
+ NumByteToWrite);
+ if(ret != 0) {
+ return IMU_6AXES_ERROR;
+ }
+ return IMU_6AXES_OK;
+ }
+
+ /*** Instance Variables ***/
+ /* IO Device */
+ DevI2C &dev_i2c;
+
+ /* Free Fall Detection IRQ */
+ InterruptIn free_fall;
+};
+
+#endif // __LSM6DS3_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/Components/lsm6ds3/readme.txt Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,3 @@ +lsm6ds0.h corresponds to: +- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds3/lsm6ds3.h: revision #402, +- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/X_NUCLEO_COMMON.lib Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/X_NUCLEO_COMMON/#216930edb6b7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/x_nucleo_iks01a1.cpp Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,311 @@
+/**
+ ******************************************************************************
+ * @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"
+
+/* Static variables ----------------------------------------------------------*/
+X_NUCLEO_IKS01A1* X_NUCLEO_IKS01A1::_instance = NULL;
+
+
+/* Methods -------------------------------------------------------------------*/
+/**
+ * @brief Constructor
+ */
+X_NUCLEO_IKS01A1::X_NUCLEO_IKS01A1(DevI2C *ext_i2c, PinName ff_irq_pin) : dev_i2c(ext_i2c),
+ ht_sensor(new HTS221(*dev_i2c)),
+ magnetometer(new LIS3MDL(*dev_i2c)),
+ pt_sensor(new LPS25H(*dev_i2c)),
+ gyro_lsm6ds0(new LSM6DS0(*dev_i2c))
+{
+ if(ff_irq_pin == NC) {
+ gyro_lsm6ds3 = NULL;
+ } else {
+ gyro_lsm6ds3 = new LSM6DS3(*dev_i2c, ff_irq_pin);
+ }
+}
+
+/**
+ * @brief Get singleton instance
+ * @return a pointer to the initialized singleton instance of class X_NUCLEO_IKS01A1.
+ * A return value of NULL indicates an out of memory situation.
+ * @param[in] ext_i2c (optional) pointer to an instance of DevI2C to be used
+ * for communication on the expansion board.
+ * Defaults to NULL.
+ * Taken into account only on the very first call of one of the 'Instance' functions.
+ * If not provided a new DevI2C will be created with standard
+ * configuration parameters.
+ * The used DevI2C object gets saved in instance variable dev_i2c.
+ * @param[in] ff_irq_pin (optional) PinName of the pin associated to asynchronous
+ * (i.e. interrupt based) free fall detection in case a LSM6DS3 3D
+ * Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket.
+ * Defaults to IKS01A1_PIN_FF.
+ * Taken into account only on the very first call of one of the 'Instance' functions.
+ * A value of 'NC' will avoid instantiation of the LSM6DS3 even if present.
+ */
+X_NUCLEO_IKS01A1* X_NUCLEO_IKS01A1::Instance(DevI2C *ext_i2c, PinName ff_irq_pin) {
+ if(_instance == NULL) {
+ if(ext_i2c == NULL)
+ ext_i2c = new DevI2C(IKS01A1_PIN_I2C_SDA, IKS01A1_PIN_I2C_SCL);
+
+ if(ext_i2c != NULL)
+ _instance = new X_NUCLEO_IKS01A1(ext_i2c, ff_irq_pin);
+
+ if(_instance != NULL) {
+ bool ret = _instance->Init();
+ if(!ret) {
+ error("Failed to init X_NUCLEO_IKS01A1 expansion board!\n");
+ }
+ }
+ }
+
+ return _instance;
+}
+
+/**
+ * @brief Get singleton instance
+ * @return a pointer to the initialized singleton instance of class X_NUCLEO_IKS01A1.
+ * A return value of NULL indicates an out of memory situation.
+ * @param[in] sda I2C data line pin.
+ * Taken into account only on the very first call of one of the 'Instance' functions.
+ * A new DevI2C will be created based on parameters 'sda' and 'scl'.
+ * The used DevI2C object gets saved in instance variable dev_i2c.
+ * @param[in] scl I2C clock line pin.
+ * Taken into account only on the very first call of one of the 'Instance' functions.
+ * A new DevI2C will be created based on parameters 'sda' and 'scl'.
+ * The used DevI2C object gets saved in instance variable dev_i2c.
+ * @param[in] ff_irq_pin (optional) PinName of the pin associated to asynchronous
+ * (i.e. interrupt based) free fall detection in case a LSM6DS3 3D
+ * Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket.
+ * Defaults to NC.
+ * Taken into account only on the very first call of one of the 'Instance' functions.
+ * A value of 'NC' will avoid instantiation of the LSM6DS3 even if present.
+ */
+X_NUCLEO_IKS01A1* X_NUCLEO_IKS01A1::Instance(PinName sda, PinName scl, PinName ff_irq_pin) {
+ if(_instance == NULL) {
+ DevI2C *ext_i2c = new DevI2C(sda, scl);
+
+ if(ext_i2c != NULL)
+ _instance = new X_NUCLEO_IKS01A1(ext_i2c, ff_irq_pin);
+
+ if(_instance != NULL) {
+ bool ret = _instance->Init();
+ if(!ret) {
+ error("Failed to init X_NUCLEO_IKS01A1 expansion board!\n");
+ }
+ }
+ }
+
+ return _instance;
+}
+
+/**
+ * @brief Initialize the singleton's HT sensor
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+bool X_NUCLEO_IKS01A1::Init_HTS221(void) {
+ uint8_t ht_id = 0;
+ HUM_TEMP_InitTypeDef InitStructure;
+
+ /* Check presence */
+ if((ht_sensor->ReadID(&ht_id) != HUM_TEMP_OK) ||
+ (ht_id != I_AM_HTS221))
+ {
+ delete ht_sensor;
+ ht_sensor = NULL;
+ return true;
+ }
+
+ /* Configure sensor */
+ InitStructure.OutputDataRate = HTS221_ODR_12_5Hz;
+
+ if(ht_sensor->Init(&InitStructure) != HUM_TEMP_OK)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Initialize the singleton's magnetometer
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+bool X_NUCLEO_IKS01A1::Init_LIS3MDL(void) {
+ uint8_t m_id = 0;
+ MAGNETO_InitTypeDef InitStructure;
+
+ /* Check presence */
+ if((magnetometer->ReadID(&m_id) != MAGNETO_OK) ||
+ (m_id != I_AM_LIS3MDL_M))
+ {
+ delete magnetometer;
+ magnetometer = NULL;
+ return true;
+ }
+
+ /* Configure sensor */
+ InitStructure.M_FullScale = LIS3MDL_M_FS_4;
+ InitStructure.M_OperatingMode = LIS3MDL_M_MD_CONTINUOUS;
+ InitStructure.M_XYOperativeMode = LIS3MDL_M_OM_HP;
+ InitStructure.M_OutputDataRate = LIS3MDL_M_DO_80;
+
+ if(magnetometer->Init(&InitStructure) != MAGNETO_OK)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Initialize the singleton's pressure sensor
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+bool X_NUCLEO_IKS01A1::Init_LPS25H(void) {
+ uint8_t p_id = 0;
+ PRESSURE_InitTypeDef InitStructure;
+
+ /* Check presence */
+ if((pt_sensor->ReadID(&p_id) != PRESSURE_OK) ||
+ (p_id != I_AM_LPS25H))
+ {
+ delete pt_sensor;
+ pt_sensor = NULL;
+ return true;
+ }
+
+ /* Configure sensor */
+ InitStructure.OutputDataRate = LPS25H_ODR_1Hz;
+ InitStructure.BlockDataUpdate = LPS25H_BDU_CONT;
+ InitStructure.DiffEnable = LPS25H_DIFF_ENABLE;
+ InitStructure.SPIMode = LPS25H_SPI_SIM_3W;
+ InitStructure.PressureResolution = LPS25H_P_RES_AVG_32;
+ InitStructure.TemperatureResolution = LPS25H_T_RES_AVG_16;
+
+ if(pt_sensor->Init(&InitStructure) != PRESSURE_OK)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Initialize the singleton's LSM6DS0 gyroscope
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+bool X_NUCLEO_IKS01A1::Init_LSM6DS0(void) {
+ IMU_6AXES_InitTypeDef InitStructure;
+ uint8_t xg_id = 0;
+
+ /* Check presence */
+ if((gyro_lsm6ds3 != NULL) || // by default do not instantiate two gyroscopes
+ (gyro_lsm6ds0->ReadID(&xg_id) != IMU_6AXES_OK) ||
+ (xg_id != I_AM_LSM6DS0_XG))
+ {
+ delete gyro_lsm6ds0;
+ gyro_lsm6ds0 = NULL;
+ return true;
+ }
+
+ /* Configure sensor */
+ InitStructure.G_FullScale = 2000.0f; /* 2000DPS */
+ InitStructure.G_OutputDataRate = 119.0f; /* 119HZ */
+ InitStructure.G_X_Axis = 1; /* Enable */
+ InitStructure.G_Y_Axis = 1; /* Enable */
+ InitStructure.G_Z_Axis = 1; /* Enable */
+
+ InitStructure.X_FullScale = 2.0f; /* 2G */
+ InitStructure.X_OutputDataRate = 119.0f; /* 119HZ */
+ InitStructure.X_X_Axis = 1; /* Enable */
+ InitStructure.X_Y_Axis = 1; /* Enable */
+ InitStructure.X_Z_Axis = 1; /* Enable */
+
+ if(gyro_lsm6ds0->Init(&InitStructure) != IMU_6AXES_OK)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Initialize the singleton's LSMDS3 gyroscope
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+bool X_NUCLEO_IKS01A1::Init_LSM6DS3(void) {
+ IMU_6AXES_InitTypeDef InitStructure;
+ uint8_t xg_id = 0;
+
+ /* Check presence */
+ if(gyro_lsm6ds3 == NULL) return true;
+
+ if((gyro_lsm6ds3->ReadID(&xg_id) != IMU_6AXES_OK) ||
+ (xg_id != I_AM_LSM6DS3_XG))
+ {
+ delete gyro_lsm6ds3;
+ gyro_lsm6ds3 = NULL;
+ return true;
+ }
+
+ /* Configure sensor */
+ InitStructure.G_FullScale = 2000.0f; /* 2000DPS */
+ InitStructure.G_OutputDataRate = 104.0f; /* 104HZ */
+ InitStructure.G_X_Axis = 1; /* Enable */
+ InitStructure.G_Y_Axis = 1; /* Enable */
+ InitStructure.G_Z_Axis = 1; /* Enable */
+
+ InitStructure.X_FullScale = 2.0f; /* 2G */
+ InitStructure.X_OutputDataRate = 104.0f; /* 104HZ */
+ InitStructure.X_X_Axis = 1; /* Enable */
+ InitStructure.X_Y_Axis = 1; /* Enable */
+ InitStructure.X_Z_Axis = 1; /* Enable */
+
+ if(gyro_lsm6ds3->Init(&InitStructure) != IMU_6AXES_OK)
+ {
+ return false;
+ }
+
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/x_nucleo_iks01a1.h Wed May 11 21:03:33 2016 +0000
@@ -0,0 +1,143 @@
+/**
+ ******************************************************************************
+ * @file x_nucleo_iks01a1.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief Header file for class X_NUCLEO_IKS01A1 representing a X-NUCLEO-IKS01A1
+ * expansion board
+ ******************************************************************************
+ * @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 __X_NUCLEO_IKS01A1_H
+#define __X_NUCLEO_IKS01A1_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
+#include "x_nucleo_iks01a1_targets.h"
+#include "hts221/hts221_class.h"
+#include "lis3mdl/lis3mdl_class.h"
+#include "lps25h/lps25h_class.h"
+#include "lsm6ds0/lsm6ds0_class.h"
+#include "lsm6ds3/lsm6ds3_class.h"
+#include "DevI2C.h"
+
+/* Macros -------------------------------------------------------------------*/
+#define CALL_METH(obj, meth, param, ret) ((obj == NULL) ? \
+ ((*(param) = (ret)), 0) : \
+ ((obj)->meth(param)) \
+ )
+
+/* Classes -------------------------------------------------------------------*/
+/** Class X_NUCLEO_IKS01A1 is intended to represent the MEMS Inertial & Environmental
+ * Nucleo Expansion Board with the same name.
+ *
+ * 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 (and Temperature Sensor)\n
+ * -# and a LSM6DS0 3D Acceleromenter and 3D Gyroscope\n
+ *
+ * The expansion board features also a DIL 24-pin socket which makes it possible
+ * to add further MEMS adapters and other sensors (e.g. UV index).
+ *
+ * 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
+ * // Inertial & Environmental expansion board singleton instance
+ * static X_NUCLEO_IKS01A1 *<TODO>_expansion_board = X_NUCLEO_IKS01A1::Instance();
+ * @endcode
+ */
+class X_NUCLEO_IKS01A1
+{
+ protected:
+ X_NUCLEO_IKS01A1(DevI2C *ext_i2c, PinName ff_irq_pin);
+
+ /**
+ * @brief Initialize the singleton's sensors to default settings
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ */
+ bool Init(void) {
+ return (Init_HTS221() &&
+ Init_LIS3MDL() &&
+ Init_LPS25H() &&
+ Init_Gyro());
+ }
+
+ /**
+ * @brief Initialize the singleton's gyroscope
+ * @retval true if initialization successful,
+ * @retval false otherwise
+ * @note only one sensor among LSM6DS3 & LSM6DS0 will be instantiated
+ * with a preference on LSM6DS3 when available
+ */
+ bool Init_Gyro(void) {
+ // Note: order is important!
+ return (Init_LSM6DS3() &&
+ Init_LSM6DS0());
+ }
+
+ bool Init_HTS221(void);
+ bool Init_LIS3MDL(void);
+ bool Init_LPS25H(void);
+ bool Init_LSM6DS0(void);
+ bool Init_LSM6DS3(void);
+
+ public:
+ static X_NUCLEO_IKS01A1* Instance(DevI2C *ext_i2c = NULL,
+ PinName ff_irq_pin = IKS01A1_PIN_FF);
+ static X_NUCLEO_IKS01A1* Instance(PinName sda, PinName scl, PinName ff_irq_pin = NC);
+
+ DevI2C *dev_i2c;
+
+ HTS221 *ht_sensor;
+ LIS3MDL *magnetometer;
+ LPS25H *pt_sensor;
+
+ GyroSensor *GetGyroscope(void) {
+ return ((gyro_lsm6ds3 == NULL) ?
+ (GyroSensor*)gyro_lsm6ds0 : (GyroSensor*)gyro_lsm6ds3);
+ }
+ MotionSensor *GetAccelerometer(void) {
+ return ((gyro_lsm6ds3 == NULL) ?
+ (MotionSensor*)gyro_lsm6ds0 : (MotionSensor*)gyro_lsm6ds3);
+ }
+ LSM6DS0 *gyro_lsm6ds0;
+ LSM6DS3 *gyro_lsm6ds3;
+
+ private:
+ static X_NUCLEO_IKS01A1 *_instance;
+};
+
+#endif /* __X_NUCLEO_IKS01A1_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5/X_NUCLEO_IKS01A1-f255a2c75ecb/x_nucleo_iks01a1_targets.h Wed May 11 21:03:33 2016 +0000 @@ -0,0 +1,52 @@ +/** + ****************************************************************************** + * @file x_nucleo_iks01a1_targets.h + * @author AST / EST + * @version V0.0.1 + * @date 14-April-2015 + * @brief This header file is intended to manage the differences between + * the different supported base-boards which might mount the + * X_NUCLEO_IKS01A1 MEMS Inertial & Environmental Nucleo Expansion Board. + ****************************************************************************** + * @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 _X_NUCLEO_IKS01A1_TARGETS_H_ +#define _X_NUCLEO_IKS01A1_TARGETS_H_ + +/*** I2C ***/ +/* Use Arduino I2C Connectors */ +#define IKS01A1_PIN_I2C_SDA (D14) +#define IKS01A1_PIN_I2C_SCL (D15) + +/* Free Fall Detection IRQ */ +#define IKS01A1_PIN_FF (A2) + +#endif // _X_NUCLEO_IKS01A1_TARGETS_H_