Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of XYZ_sensor_Platform by
Revision 15:db753c75e53f, committed 2018-08-03
- Comitter:
- hober
- Date:
- Fri Aug 03 01:32:16 2018 +0000
- Parent:
- 14:1363e4b2fbac
- Commit message:
- Change AltIMU_10_v5 to magring board, and change transmit interface from I2C to SPI.
Changed in this revision
--- a/AltIMU_10_v5/ST_INTERFACES/Common/Component.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/** - ****************************************************************************** - * @file Component.h - * @author AST - * @version V1.0.0 - * @date April 13th, 2015 - * @brief This file contains the abstract class describing the interface of a - * generic component. - ****************************************************************************** - * @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 __COMPONENT_CLASS_H -#define __COMPONENT_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <stdint.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Generic components. - */ -class Component { -public: - - /** - * @brief Initializing the component. - * @param[in] init pointer to device specific initalization structure. - * @retval "0" in case of success, an error code otherwise. - */ - virtual int init(void *init) = 0; - - /** - * @brief Getting the ID of the component. - * @param[out] id pointer to an allocated variable to store the ID into. - * @retval "0" in case of success, an error code otherwise. - */ - virtual int read_id(uint8_t *id) = 0; - - /** - * @brief Destructor. - */ - virtual ~Component() {}; -}; - -#endif /* __COMPONENT_CLASS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/GyroSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a Gyroscope - */ -class GyroSensor : public Component { -public: - - /** - * @brief Get current gyroscope angular rate X/Y/Z-axes values - * in standard data units [mdps] - * @param[out] p_data Pointer to where to store angular rates to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_axes(int32_t *p_data) = 0; - - /** - * @brief Get current gyroscope raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store gyroscope raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Get gyroscope's current sensitivity [mdps/LSB] - * @param[out] pf_data 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 *pf_data) = 0; - - /** - * @brief Get gyroscope's current output data rate [Hz] - * @param[out] pf_data 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 *pf_data) = 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] pf_data 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 *pf_data) = 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; - - /** - * @brief Destructor. - */ - virtual ~GyroSensor() {}; -}; - -#endif /* __GYRO_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/HumiditySensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Humidity sensors - */ -class HumiditySensor : public Component { -public: - - /** - * @brief Get current humidity [%] - * @param[out] pf_data Pointer to where to store humidity to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_humidity(float *pf_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~HumiditySensor() {}; -}; - -#endif /* __HUMIDITY_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/LightSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file LightSensor.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 ambient light sensor (ALS) - ****************************************************************************** - * @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 __LIGHT_SENSOR_CLASS_H -#define __LIGHT_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for ambient light sensors - */ -class LightSensor : public Component { -public: - - /** - * @brief Get current light [lux] - * @param[out] pi_data Pointer to where to store light to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_lux(uint32_t *pi_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~LightSensor() {}; -}; - -#endif /* __LIGHT_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/MagneticSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a magnetometer - */ -class MagneticSensor : public Component { -public: - - /** - * @brief Get current magnetometer magnetic X/Y/Z-axes values - * in standard data units [mgauss] - * @param[out] p_data Pointer to where to store magnetic values to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_m_axes(int32_t *p_data) = 0; - - /** - * @brief Get current magnetometer raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store magnetometer raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_m_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~MagneticSensor() {}; -}; - -#endif /* __MAGNETIC_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/MotionSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for an Accelerometer - */ -class MotionSensor : public Component { -public: - - /** - * @brief Get current accelerometer linear acceleration X/Y/Z-axes values - * in standard data units [mg] - * @param[out] p_data Pointer to where to store linear accelerations to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_axes(int32_t *p_data) = 0; - - /** - * @brief Get current accelerometer raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store accelerometer raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Get accelerometer's current sensitivity [mg/LSB] - * @param[out] pf_data 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 *pf_data) = 0; - - /** - * @brief Get accelerometer's current output data rate [Hz] - * @param[out] pf_data 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 *pf_data) = 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] pf_data 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 *pf_data) = 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; - - /** - * @brief Destructor. - */ - virtual ~MotionSensor() {}; -}; - -#endif /* __MOTION_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/PressureSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a Pressure Sensor - */ -class PressureSensor : public Component { -public: - - /** - * @brief Get current pressure [mbar] - * @param[out] pf_data Pointer to where to store pressure to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_pressure(float *pf_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~PressureSensor() {}; -}; - -#endif /* __PRESSURE_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/RangeSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file RangeSensor.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 range 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 __RANGE_SENSOR_CLASS_H -#define __RANGE_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for range sensors - */ -class RangeSensor : public Component { -public: - - /** - * @brief Get current range [mm] - * @param[out] pi_data Pointer to where to store range to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_distance(uint32_t *pi_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~RangeSensor() {}; -}; - -#endif /* __RANGE_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/ST_INTERFACES/Sensors/TempSensor.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/** - ****************************************************************************** - * @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 <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Temperature sensors - */ -class TempSensor : public Component { -public: - - /** - * @brief Get current temperature in degrees Celsius [°C] - * @param[out] pf_data Pointer to where to store temperature to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_temperature(float *pf_data) = 0; - - /** - * @brief Get current temperature in degrees Fahrenheit [°F] - * @param[out] pf_data Pointer to where to store temperature to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_fahrenheit(float *pf_data) { - float celsius; - int ret; - - ret = get_temperature(&celsius); - if (ret) { - return ret; - } - - *pf_data = ((celsius * 1.8f) + 32.0f); - - return 0; - } - - /** - * @brief Destructor. - */ - virtual ~TempSensor() {}; -}; - -#endif /* __TEMP_SENSOR_CLASS_H */
--- a/AltIMU_10_v5/X_NUCLEO_COMMON/DevI2C/DevI2C.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/** - ****************************************************************************** - * @file DevI2C.h - * @author AST / EST - * @version V1.1.0 - * @date 21-January-2016 - * @brief Header file for a special I2C class DevI2C which provides some - * helper function for on-board communication - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2016 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 __DEV_I2C_H -#define __DEV_I2C_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" -#include "pinmap.h" - -/* Classes -------------------------------------------------------------------*/ -/** Helper class DevI2C providing functions for multi-register I2C communication - * common for a series of I2C devices - */ -class DevI2C : public I2C -{ -public: - /** Create a DevI2C Master interface, connected to the specified pins - * - * @param sda I2C data line pin - * @param scl I2C clock line pin - */ - DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {} - - /** - * @brief Writes a buffer towards the I2C peripheral device. - * @param pBuffer pointer to the byte-array data to send - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start writing to (must be correctly masked). - * @param NumByteToWrite number of bytes to be written. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured, or - * @retval -2 on temporary buffer overflow (i.e. NumByteToWrite was too high) - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToWrite) { - int ret; - uint8_t tmp[TEMP_BUF_SIZE]; - - if(NumByteToWrite >= TEMP_BUF_SIZE) return -2; - - /* First, send device address. Then, send data and STOP condition */ - tmp[0] = RegisterAddr; - memcpy(tmp+1, pBuffer, NumByteToWrite); - - ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, false); - - if(ret) return -1; - return 0; - } - - /** - * @brief Reads a buffer from the I2C peripheral device. - * @param pBuffer pointer to the byte-array to read data in to - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start reading from (must be correctly masked). - * @param NumByteToRead number of bytes to be read. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToRead) { - int ret; - - /* Send device address, with no STOP condition */ - ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, true); - if(!ret) { - /* Read data, with STOP condition */ - ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, false); - } - - if(ret) return -1; - return 0; - } - -private: - static const unsigned int TEMP_BUF_SIZE = 32; -}; - -#endif /* __DEV_I2C_H */
--- a/AltIMU_10_v5/altimu_10_v5.cpp Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,236 +0,0 @@ -/** - ****************************************************************************** - * @file altimu_10_v5.cpp - * @author AST / EST - * @version V0.0.1 - * @date 08-October-2014 - * @brief Implementation file for the AltIMU_10_v5 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 "altimu_10_v5.h" - -/* Static variables ----------------------------------------------------------*/ -AltIMU_10_v5* AltIMU_10_v5::_instance = NULL; - - -/* Methods -------------------------------------------------------------------*/ -/** - * @brief Constructor - */ -AltIMU_10_v5::AltIMU_10_v5(DevI2C *ext_i2c) : dev_i2c(ext_i2c), - magnetometer(new LIS3MDL(*dev_i2c)), - pt_sensor(new LPS25H(*dev_i2c)), - gyro_lsm6ds33(new LSM6DS33(*dev_i2c)) -{ -} - -/** - * @brief Get singleton instance - * @return a pointer to the initialized singleton instance of class AltIMU_10_v5. - * 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 LSM6DS33 3D - * Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket. - * Defaults to F746ZG_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 LSM6DS33 even if present. - */ -AltIMU_10_v5* AltIMU_10_v5::Instance(DevI2C *ext_i2c) { - if(_instance == NULL) { - if(ext_i2c == NULL) - ext_i2c = new DevI2C(F746ZG_PIN_I2C_SDA, F746ZG_PIN_I2C_SCL); - - if(ext_i2c != NULL) - _instance = new AltIMU_10_v5(ext_i2c); - - if(_instance != NULL) { - bool ret = _instance->Init(); - if(!ret) { - error("Failed to init AltIMU_10_v5 expansion board!\n"); - } - } - } - - return _instance; -} - -/** - * @brief Get singleton instance - * @return a pointer to the initialized singleton instance of class AltIMU_10_v5. - * 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 LSM6DS33 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 LSM6DS33 even if present. - */ -AltIMU_10_v5* AltIMU_10_v5::Instance(PinName sda, PinName scl) { - if(_instance == NULL) { - DevI2C *ext_i2c = new DevI2C(sda, scl); - - if(ext_i2c != NULL) - _instance = new AltIMU_10_v5(ext_i2c); - - if(_instance != NULL) { - bool ret = _instance->Init(); - if(!ret) { - error("Failed to init AltIMU_10_v5 expansion board!\n"); - } - } - } - - return _instance; -} - - -/** - * @brief Initialize the singleton's magnetometer - * @retval true if initialization successful, - * @retval false otherwise - */ -bool AltIMU_10_v5::Init_LIS3MDL(void) { - uint8_t m_id = 0; - MAGNETO_InitTypeDef InitStructure; - - /* Check presence */ - if((magnetometer->read_id(&m_id) != MAGNETO_OK) || - (m_id != I_AM_LIS3MDL_M)) - { - delete magnetometer; - magnetometer = NULL; - return true; - } - - /* Configure sensor */ - InitStructure.M_FullScale = 4.0f; - InitStructure.M_OperatingMode = LIS3MDL_M_MD_CONTINUOUS; - InitStructure.M_XYOperativeMode = LIS3MDL_M_OM_HP; - InitStructure.M_OutputDataRate = 1000.0f; - - 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 AltIMU_10_v5::Init_LPS25H(void) { - uint8_t p_id = 0; - PRESSURE_InitTypeDef InitStructure; - - /* Check presence */ - if((pt_sensor->read_id(&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 LSM6DS33 gyroscope - * @retval true if initialization successful, - * @retval false otherwise - */ -bool AltIMU_10_v5::Init_LSM6DS33(void) { - IMU_6AXES_InitTypeDef InitStructure; - uint8_t xg_id = 0; - bool status=true; - - /* Check presence */ - if((status=(gyro_lsm6ds33->read_id(&xg_id) != IMU_6AXES_OK)) || - (xg_id != I_AM_LSM6DS33_XG)) - { - delete gyro_lsm6ds33; - gyro_lsm6ds33 = 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_lsm6ds33->init(&InitStructure) != IMU_6AXES_OK) - { - return false; - } - - return true; -}
--- a/AltIMU_10_v5/altimu_10_v5.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - ****************************************************************************** - * @file altimu_10_v5.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief Header file for class AltIMU_10_v5 representing a AltIMU-10 v5 - * 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 __ALTIMU_10_V5_H -#define __ALTIMU_10_V5_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" -#include "altimu_10_v5_targets.h" -#include "lis3mdl/lis3mdl_class.h" -#include "lps25h/lps25h_class.h" -#include "lsm6ds33/lsm6ds33_class.h" -#include "DevI2C.h" - -/* Macros -------------------------------------------------------------------*/ -#define CALL_METH(obj, meth, param, ret) ((obj == NULL) ? \ - ((*(param) = (ret)), 0) : \ - ((obj)->meth(param)) \ - ) - -/* Classes -------------------------------------------------------------------*/ -/** Class AltIMU_10_v5 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 LSM6DS33 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 - * AltIMU_10_v5 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 AltIMU_10_v5 *<TODO>_expansion_board = AltIMU_10_v5::Instance(); - * @endcode - */ -class AltIMU_10_v5 -{ - protected: - AltIMU_10_v5(DevI2C *ext_i2c); - - ~AltIMU_10_v5(void) { - /* should never be called */ - error("Trial to delete AltIMU_10_v5 singleton!\n"); - } - - /** - * @brief Initialize the singleton's sensors to default settings - * @retval true if initialization successful, - * @retval false otherwise - */ - bool Init(void) { - return (Init_LIS3MDL() && - Init_LPS25H() && - Init_LSM6DS33()); - } - - bool Init_LIS3MDL(void); - bool Init_LPS25H(void); - bool Init_LSM6DS33(void); - - public: - static AltIMU_10_v5* Instance(DevI2C *ext_i2c = NULL); - static AltIMU_10_v5* Instance(PinName sda, PinName scl); - - DevI2C *dev_i2c; - - LIS3MDL *magnetometer; - LPS25H *pt_sensor; - - GyroSensor *GetGyroscope(void) { - return gyro_lsm6ds33; - } - MotionSensor *GetAccelerometer(void) { - return gyro_lsm6ds33; - } - void setI2cFrequency(int hz){ dev_i2c->frequency(hz); } - LSM6DS33 *gyro_lsm6ds33; - - private: - static AltIMU_10_v5 *_instance; -}; - -#endif /* __ALTIMU_10_V5_H */
--- a/AltIMU_10_v5/altimu_10_v5_targets.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/** - ****************************************************************************** - * @file altimu_10_v5_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 - * ALTIMU_10_V5 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 _ALTIMU_10_V5_TARGETS_H_ -#define _ALTIMU_10_V5_TARGETS_H_ - -/*** I2C ***/ -/* Use Arduino I2C Connectors */ -#define F746ZG_PIN_I2C_SDA (D14) -#define F746ZG_PIN_I2C_SCL (D15) - -#endif // _ALTIMU_10_V5_TARGETS_H_
--- a/AltIMU_10_v5/components/Common/hum_temp.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/** - ****************************************************************************** - * @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****/
--- a/AltIMU_10_v5/components/Common/imu_6axes.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/** - ****************************************************************************** - * @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****/
--- a/AltIMU_10_v5/components/Common/magneto.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/** - ****************************************************************************** - * @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 -{ - float M_OutputDataRate; - uint8_t M_OperatingMode; - float 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****/
--- a/AltIMU_10_v5/components/Common/pressure.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/** - ****************************************************************************** - * @file pressure.h - * @author MEMS Application Team - * @version V1.2.0 - * @date 28-January-2015 - * @brief This header file contains the functions prototypes for the - * pressure driver. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __PRESSURE_H -#define __PRESSURE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include <stdint.h> - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup PRESSURE - * @{ - */ - -/** @defgroup PRESSURE_Exported_Types - * @{ - */ - -/** - * @brief PRESSURE init structure definition - */ -typedef struct -{ - uint8_t OutputDataRate; - uint8_t PressureResolution; - uint8_t TemperatureResolution; - uint8_t DiffEnable; - uint8_t BlockDataUpdate; - uint8_t SPIMode; -} PRESSURE_InitTypeDef; - -/** - * @brief PRESSURE status enumerator definition - */ -typedef enum -{ - PRESSURE_OK = 0, - PRESSURE_ERROR = 1, - PRESSURE_TIMEOUT = 2, - PRESSURE_NOT_IMPLEMENTED = 3 -} PRESSURE_StatusTypeDef; - -/** - * @brief PRESSURE component id enumerator definition - */ -typedef enum -{ - PRESSURE_NONE_COMPONENT = 0, - PRESSURE_LPS25H_COMPONENT = 1, - PRESSURE_LPS25HB_DIL24_COMPONENT = 2 -} PRESSURE_ComponentTypeDef; - -/** - * @brief PRESSURE driver extended structure definition - */ -typedef struct -{ - PRESSURE_ComponentTypeDef - id; /* This id must be unique for each component belonging to this class that wants to extend common class */ - void *pData; /* This pointer is specific for each component */ -} PRESSURE_DrvExtTypeDef; - -/** - * @brief PRESSURE driver structure definition - */ -typedef struct -{ - PRESSURE_StatusTypeDef (*Init)(PRESSURE_InitTypeDef *); - PRESSURE_StatusTypeDef (*PowerOff)(void); - PRESSURE_StatusTypeDef (*ReadID)(uint8_t *); - PRESSURE_StatusTypeDef (*Reset)(void); - void (*ConfigIT)(uint16_t); - void (*EnableIT)(uint8_t); - void (*DisableIT)(uint8_t); - uint8_t (*ITStatus)(uint16_t, uint16_t); - void (*ClearIT)(uint16_t, uint16_t); - PRESSURE_StatusTypeDef (*GetPressure)(float *); - PRESSURE_StatusTypeDef (*GetTemperature)(float *); - void (*SlaveAddrRemap)(uint8_t); - PRESSURE_DrvExtTypeDef *extData; -} PRESSURE_DrvTypeDef; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __PRESSURE_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/AltIMU_10_v5/components/Common/readme.txt Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -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
--- a/AltIMU_10_v5/components/lis3mdl/lis3mdl.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,466 +0,0 @@ -/** - ****************************************************************************** - * @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_Fast_Output_Data_Rate_Enable_Selection_CTRL_REG1_M LIS3MDL_M_Fast_Output_Data_Rate_Enable_Selection_CTRL_REG1_M - * @{ - */ -#define LIS3MDL_M_FAST_ODR_DISABLE ((uint8_t)0x00) /*!< Fast output data rate: disable */ -#define LIS3MDL_M_FAST_ODR_ENABLE ((uint8_t)0x02) /*!< Fast output data rate: enable */ - -#define LIS3MDL_M_FAST_ODR_MASK ((uint8_t)0x02) -/** - * @} - */ - -/** @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****/
--- a/AltIMU_10_v5/components/lis3mdl/lis3mdl_class.cpp Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,378 +0,0 @@ -/** - ****************************************************************************** - * @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_M_Set_ODR( LIS3MDL_Init->M_OutputDataRate ) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - if(LIS3MDL_M_Set_FS( LIS3MDL_Init->M_FullScale ) != 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; -} - -MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Get_ODR( float *odr ) -{ - /*Here we have to add the check if the parameters are valid*/ - uint8_t tempReg = 0x00; - - if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - tempReg &= LIS3MDL_M_FAST_ODR_MASK; - if(tempReg == LIS3MDL_M_FAST_ODR_ENABLE) { - - if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - tempReg &= LIS3MDL_M_OM_MASK; - switch(tempReg) { - case LIS3MDL_M_OM_LP: - *odr = 1000.0f; - break; - case LIS3MDL_M_OM_MP: - *odr = 560.0f; - break; - case LIS3MDL_M_OM_HP: - *odr = 300.0f; - break; - case LIS3MDL_M_OM_UHP: - *odr = 155.0f; - break; - } - } else { - if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - tempReg &= LIS3MDL_M_DO_MASK; - switch(tempReg) { - case LIS3MDL_M_DO_0_625: - *odr = 0.625f; - break; - case LIS3MDL_M_DO_1_25: - *odr = 1.25f; - break; - case LIS3MDL_M_DO_2_5: - *odr = 2.5f; - break; - case LIS3MDL_M_DO_5: - *odr = 5.0f; - break; - case LIS3MDL_M_DO_10: - *odr = 10.0f; - break; - case LIS3MDL_M_DO_20: - *odr = 20.0f; - break; - case LIS3MDL_M_DO_40: - *odr = 40.0f; - break; - case LIS3MDL_M_DO_80: - *odr = 80.0f; - break; - } - } - return MAGNETO_OK; -} - -MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Set_ODR( float odr ) -{ - uint8_t new_odr = 0x00; - uint8_t tempReg = 0x00; - -if(odr>80.0f){ - new_odr = ( odr <= 155.0f ) ? LIS3MDL_M_OM_UHP - : ( odr <= 300.0f ) ? LIS3MDL_M_OM_HP - : ( odr <= 560.0f ) ? LIS3MDL_M_OM_MP - : LIS3MDL_M_OM_LP; - - if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - tempReg &= ~(LIS3MDL_M_OM_MASK); - tempReg |= (new_odr|LIS3MDL_M_FAST_ODR_ENABLE); - - if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - } - else{ - - new_odr = ( odr <= 0.625f ) ? LIS3MDL_M_DO_0_625 - : ( odr <= 1.25f ) ? LIS3MDL_M_DO_1_25 - : ( odr <= 2.5f ) ? LIS3MDL_M_DO_2_5 - : ( odr <= 5.0f ) ? LIS3MDL_M_DO_5 - : ( odr <= 10.0f ) ? LIS3MDL_M_DO_10 - : ( odr <= 20.0f ) ? LIS3MDL_M_DO_20 - : ( odr <= 40.0f ) ? LIS3MDL_M_DO_40 - : LIS3MDL_M_DO_80; - - if(LIS3MDL_IO_Read( &tempReg, LIS3MDL_M_CTRL_REG1_M, 1 ) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - tempReg &= ~(LIS3MDL_M_DO_MASK); - tempReg |= new_odr; - - if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } -} - return MAGNETO_OK; -} - -MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Get_FS( float *fullScale ) -{ - /*Here we have to add the check if the parameters are valid*/ - uint8_t tempReg = 0x00; - - 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: - *fullScale = 4.0f; - break; - case LIS3MDL_M_FS_8: - *fullScale = 8.0f; - break; - case LIS3MDL_M_FS_12: - *fullScale = 12.0f; - break; - case LIS3MDL_M_FS_16: - *fullScale = 16.0f; - break; - } - - return MAGNETO_OK; -} - -MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Set_FS( float fullScale ) -{ - uint8_t new_fs = 0x00; - uint8_t tempReg = 0x00; - - new_fs = ( fullScale <= 4.0f ) ? LIS3MDL_M_FS_4 - : ( fullScale <= 8.0f ) ? LIS3MDL_M_FS_8 - : ( fullScale <= 12.0f ) ? LIS3MDL_M_FS_12 - : LIS3MDL_M_FS_16; - - if(LIS3MDL_IO_Read( &tempReg, LIS3MDL_M_CTRL_REG2_M, 1 ) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - tempReg &= ~(LIS3MDL_M_FS_MASK); - tempReg |= new_fs; - - if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK) { - return MAGNETO_ERROR; - } - - return MAGNETO_OK; -} - -MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_GetSensitivity( float *pfData ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg = 0x00; - 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: - *pfData = 0.14; - break; - case LIS3MDL_M_FS_8: - *pfData = 0.29; - break; - case LIS3MDL_M_FS_12: - *pfData = 0.43; - break; - case LIS3MDL_M_FS_16: - *pfData = 0.58; - break; - } - - return MAGNETO_OK; -} -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/AltIMU_10_v5/components/lis3mdl/lis3mdl_class.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/** - ****************************************************************************** - * @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 "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 read_id(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_axes_raw(int16_t *pData) { - return LIS3MDL_M_GetAxesRaw(pData); - } - - virtual int get_m_odr(float *odr) { - return LIS3MDL_M_Get_ODR(odr); - } - - virtual int set_m_odr(float odr) { - return LIS3MDL_M_Set_ODR(odr); - } - - virtual int get_m_sensitivity(float *pfData) { - return LIS3MDL_M_GetSensitivity(pfData); - } - - virtual int get_m_fs(float *fullScale) { - return LIS3MDL_M_Get_FS(fullScale); - } - - virtual int set_m_fs(float fullScale) { - return LIS3MDL_M_Set_FS(fullScale); - } - - 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); - MAGNETO_StatusTypeDef LIS3MDL_M_Get_ODR( float *odr ); - MAGNETO_StatusTypeDef LIS3MDL_M_Set_ODR( float odr ); - MAGNETO_StatusTypeDef LIS3MDL_M_Get_FS( float *fullScale ); - MAGNETO_StatusTypeDef LIS3MDL_M_Set_FS( float fullScale ); - MAGNETO_StatusTypeDef LIS3MDL_M_GetSensitivity( float *pfData ); - - /** - * @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
--- a/AltIMU_10_v5/components/lis3mdl/readme.txt Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -lis3mdl.h corresponds to: -- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lis3mdl/lis3mdl.h: revision #402, -- X-CUBE-MEMS1/trunk: revision #416
--- a/AltIMU_10_v5/components/lps25h/lps25h.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,572 +0,0 @@ -/** - ****************************************************************************** - * @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****/
--- a/AltIMU_10_v5/components/lps25h/lps25h_class.cpp Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,317 +0,0 @@ -/** - ****************************************************************************** - * @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****/
--- a/AltIMU_10_v5/components/lps25h/lps25h_class.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -/** - ****************************************************************************** - * @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 "PressureSensor.h" -#include "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 read_id(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 get_pressure(float *pfData) { - return LPS25H_GetPressure(pfData); - } - - virtual int get_temperature(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
--- a/AltIMU_10_v5/components/lps25h/readme.txt Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -lps25h.h corresponds to: -- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lps25h/lps25h.h: revision #402, -- X-CUBE-MEMS1/trunk: revision #416
--- a/AltIMU_10_v5/components/lsm6ds33/lsm6ds33.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1328 +0,0 @@ -/** - ****************************************************************************** - * @file lsm6ds33.h - * @author MEMS Application Team - * @version V1.2.0 - * @date 28-May-2015 - * @brief This file contains definitions for the lsm6ds33.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 _LSM6DS33_XG_H -#define _LSM6DS33_XG_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "imu_6axes.h" - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup Components - * @{ - */ - -/** @addtogroup LSM6DS33 - * @{ - */ - -/** @addtogroup LSM6DS33_Exported_Defines LSM6DS33_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 LSM6DS33_XG_FUNC_CFG_ACCESS 0x01 - - -/** - * @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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_CTRL10_C 0x19 - - - -/** - * @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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_STATUS_REG 0x1E - -#define LSM6DS33_XG_OUT_TEMP_L 0x20 -#define LSM6DS33_XG_OUT_TEMP_H 0x21 - -/** - * @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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_TIMESTAMP2_REG 0x42 - -#define LSM6DS33_XG_STEP_TIMESTAMP_L 0x49 -#define LSM6DS33_XG_STEP_TIMESTAMP_H 0x4A -/** - * @brief Step counter output register (r). - * \code - * Read - * Default value: output - * [7:0] STEP_COUNTER_L_[7:0]: Step counter output (LSbyte) - * \endcode -*/ -#define LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_MD2_CFG 0x5F - -/***************************************** SENSORHUB REGISTERS ********************************************/ - - - - -/***************************************** 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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_CTRL7_G 0x16 - -/** - * @brief Gyroscope data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_X_L_G 0x22 - - -/** - * @brief Gyroscope data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_X_H_G 0x23 - - -/** - * @brief Gyroscope data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Y_L_G 0x24 - - -/** - * @brief Gyroscope data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Y_H_G 0x25 - - -/** - * @brief Gyroscope data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Z_L_G 0x26 - - -/** - * @brief Gyroscope data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_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 LSM6DS33_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 LSM6DS33_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 LSM6DS33_XG_CTRL9_XL 0x18 - - -/** - * @brief Accelerometer data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_X_L_XL 0x28 - - -/** - * @brief Accelerometer data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_X_H_XL 0x29 - - -/** - * @brief Accelerometer data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Y_L_XL 0x2A - - -/** - * @brief Accelerometer data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Y_H_XL 0x2B - - -/** - * @brief Accelerometer data (LSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Z_L_XL 0x2C - - -/** - * @brief Accelerometer data (MSB) - * \code - * Read - * \endcode - */ -#define LSM6DS33_XG_OUT_Z_H_XL 0x2D - -/******************************************************************************/ -/************* END ACCELEROMETER AND GYROSCOPE REGISTER MAPPING **************/ -/******************************************************************************/ - - -/************************************** COMMON REGISTERS VALUE *******************************************/ - -/** -* @brief Device Address -*/ -#define LSM6DS33_ADDRESS_LOW 0xD4 // SAD[0] = 0 -#define LSM6DS33_ADDRESS_HIGH 0xD6 // SAD[0] = 1 -#define LSM6DS33_XG_MEMS_ADDRESS LSM6DS33_ADDRESS_HIGH // SAD[0] = 1 - - -/** - * @brief Device Identifier. Default value of the WHO_AM_I register. - */ -#define I_AM_LSM6DS33_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 - * LSM6DS33_XG_CTRL3_C register. - */ -#define LSM6DS33_XG_IF_INC ((uint8_t)0x04) - -#define LSM6DS33_XG_IF_INC_MASK ((uint8_t)0x04) - -/** @defgroup LSM6DS33_XG_FIFO_Output_Data_Rate_Selection_FIFO_CTRL5 LSM6DS33_XG_FIFO_Output_Data_Rate_Selection_FIFO_CTRL5 - * @{ - */ -#define LSM6DS33_XG_FIFO_ODR_NA ((uint8_t)0x00) /*!< FIFO ODR NA */ -#define LSM6DS33_XG_FIFO_ODR_10HZ ((uint8_t)0x08) /*!< FIFO ODR 10Hz */ -#define LSM6DS33_XG_FIFO_ODR_25HZ ((uint8_t)) /*!< FIFO ODR 25Hz */ -#define LSM6DS33_XG_FIFO_ODR_50HZ ((uint8_t)0x18) /*!< FIFO ODR 50Hz */ -#define LSM6DS33_XG_FIFO_ODR_100HZ ((uint8_t)0x20) /*!< FIFO ODR 100Hz */ -#define LSM6DS33_XG_FIFO_ODR_200HZ ((uint8_t)0x28) /*!< FIFO ODR 200Hz */ -#define LSM6DS33_XG_FIFO_ODR_400HZ ((uint8_t)0x30) /*!< FIFO ODR 400Hz */ -#define LSM6DS33_XG_FIFO_ODR_800HZ ((uint8_t)0x38) /*!< FIFO ODR 800Hz */ -#define LSM6DS33_XG_FIFO_ODR_1600HZ ((uint8_t)0x40) /*!< FIFO ODR 1600Hz */ -#define LSM6DS33_XG_FIFO_ODR_3300HZ ((uint8_t)0x48) /*!< FIFO ODR 3300Hz */ -#define LSM6DS33_XG_FIFO_ODR_6600HZ ((uint8_t)0x50) /*!< FIFO ODR 6600Hz */ - -#define LSM6DS33_XG_FIFO_ODR_MASK ((uint8_t)0x78) -/** - * @} - */ - -/** @defgroup LSM6DS33_XG_FIFO_Mode_Selection_FIFO_CTRL5 LSM6DS33_XG_FIFO_Mode_Selection_FIFO_CTRL5 - * @{ - */ -#define LSM6DS33_XG_FIFO_MODE_BYPASS ((uint8_t)0x00) /*!< BYPASS Mode. FIFO turned off */ -#define LSM6DS33_XG_FIFO_MODE_FIFO ((uint8_t)0x01) /*!< FIFO Mode. Stop collecting data when FIFO is full */ -#define LSM6DS33_XG_FIFO_MODE_CONTINUOUS_THEN_FIFO ((uint8_t)0x03) /*!< CONTINUOUS mode until trigger is deasserted, then FIFO mode */ -#define LSM6DS33_XG_FIFO_MODE_BYPASS_THEN_CONTINUOUS ((uint8_t)0x04) /*!< BYPASS mode until trigger is deasserted, then CONTINUOUS mode */ -#define LSM6DS33_XG_FIFO_MODE_CONTINUOUS_OVERWRITE ((uint8_t)0x06) /*!< CONTINUOUS mode. If the FIFO is full the new sample overwrite the older one */ - -#define LSM6DS33_XG_FIFO_MODE_MASK ((uint8_t)0x07) -/** - * @} - */ - - -/************************************** GYROSCOPE REGISTERS VALUE *******************************************/ - - -/** @addtogroup LSM6DS33_XG_Gyroscope_Output_Data_Rate_Selection_CTRL_REG1_G LSM6DS33_XG_Gyroscope_Output_Data_Rate_Selection_CTRL_REG1_G - * @{ - */ -#define LSM6DS33_G_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/ -#define LSM6DS33_G_ODR_13HZ ((uint8_t)0x10) /*!< Output Data Rate: 13 Hz*/ -#define LSM6DS33_G_ODR_26HZ ((uint8_t)0x20) /*!< Output Data Rate: 26 Hz*/ -#define LSM6DS33_G_ODR_52HZ ((uint8_t)0x30) /*!< Output Data Rate: 52 Hz */ -#define LSM6DS33_G_ODR_104HZ ((uint8_t)0x40) /*!< Output Data Rate: 104 Hz */ -#define LSM6DS33_G_ODR_208HZ ((uint8_t)0x50) /*!< Output Data Rate: 208 Hz */ -#define LSM6DS33_G_ODR_416HZ ((uint8_t)0x60) /*!< Output Data Rate: 416 Hz */ -#define LSM6DS33_G_ODR_833HZ ((uint8_t)0x70) /*!< Output Data Rate: 833 Hz */ -#define LSM6DS33_G_ODR_1660HZ ((uint8_t)0x80) /*!< Output Data Rate: 1.66 kHz */ - -#define LSM6DS33_G_ODR_MASK ((uint8_t)0xF0) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Gyroscope_Full_Scale_Selection_CTRL2_G LSM6DS33_XG_Gyroscope_Full_Scale_Selection_CTRL2_G - * @{ - */ -#define LSM6DS33_G_FS_125_DISABLE ((uint8_t)0x00) /*!< Full scale: 125 dps enable: disable */ -#define LSM6DS33_G_FS_125_ENABLE ((uint8_t)0x02) /*!< Full scale: 125 dps enable: enable */ - -#define LSM6DS33_G_FS_125_MASK ((uint8_t)0x02) - -#define LSM6DS33_G_FS_245 ((uint8_t)0x00) /*!< Full scale: 245 dps*/ -#define LSM6DS33_G_FS_500 ((uint8_t)0x04) /*!< Full scale: 500 dps */ -#define LSM6DS33_G_FS_1000 ((uint8_t)0x08) /*!< Full scale: 1000 dps */ -#define LSM6DS33_G_FS_2000 ((uint8_t)0x0C) /*!< Full scale: 2000 dps */ - -#define LSM6DS33_G_FS_MASK ((uint8_t)0x0C) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL10_C LSM6DS33_XG_Gyroscope_Z_Axis_Output_Enable_Selection_CTRL10_C - * @{ - */ -#define LSM6DS33_G_ZEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Z-axis output enable: disable */ -#define LSM6DS33_G_ZEN_ENABLE ((uint8_t)0x20) /*!< Gyroscope�s Z-axis output enable: enable */ - -#define LSM6DS33_G_ZEN_MASK ((uint8_t)0x20) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL10_C LSM6DS33_XG_Gyroscope_Y_Axis_Output_Enable_Selection_CTRL10_C - * @{ - */ -#define LSM6DS33_G_YEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s Y-axis output enable: disable */ -#define LSM6DS33_G_YEN_ENABLE ((uint8_t)0x10) /*!< Gyroscope�s Y-axis output enable: enable */ - -#define LSM6DS33_G_YEN_MASK ((uint8_t)0x10) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL10_C LSM6DS33_XG_Gyroscope_X_Axis_Output_Enable_Selection_CTRL10_C - * @{ - */ -#define LSM6DS33_G_XEN_DISABLE ((uint8_t)0x00) /*!< Gyroscope�s X-axis output enable: disable */ -#define LSM6DS33_G_XEN_ENABLE ((uint8_t)0x08) /*!< Gyroscope�s X-axis output enable: enable */ - -#define LSM6DS33_G_XEN_MASK ((uint8_t)0x08) - -/** - * @} - */ - - -/************************************ ACCELEROMETER REGISTERS VALUE *****************************************/ - -/** @addtogroup LSM6DS33_XG_Accelerometer_Output_Data_Rate_Selection_CTRL1_XL LSM6DS33_XG_Accelerometer_Output_Data_Rate_Selection_CTRL1_XL - * @{ - */ -#define LSM6DS33_XL_ODR_PD ((uint8_t)0x00) /*!< Output Data Rate: Power-down*/ -#define LSM6DS33_XL_ODR_13HZ ((uint8_t)0x10) /*!< Output Data Rate: 13 Hz*/ -#define LSM6DS33_XL_ODR_26HZ ((uint8_t)0x20) /*!< Output Data Rate: 26 Hz*/ -#define LSM6DS33_XL_ODR_52HZ ((uint8_t)0x30) /*!< Output Data Rate: 52 Hz */ -#define LSM6DS33_XL_ODR_104HZ ((uint8_t)0x40) /*!< Output Data Rate: 104 Hz */ -#define LSM6DS33_XL_ODR_208HZ ((uint8_t)0x50) /*!< Output Data Rate: 208 Hz */ -#define LSM6DS33_XL_ODR_416HZ ((uint8_t)0x60) /*!< Output Data Rate: 416 Hz */ -#define LSM6DS33_XL_ODR_833HZ ((uint8_t)0x70) /*!< Output Data Rate: 833 Hz */ -#define LSM6DS33_XL_ODR_1660HZ ((uint8_t)0x80) /*!< Output Data Rate: 1.66 kHz */ -#define LSM6DS33_XL_ODR_3330HZ ((uint8_t)0x90) /*!< Output Data Rate: 3.33 kHz */ -#define LSM6DS33_XL_ODR_6660HZ ((uint8_t)0xA0) /*!< Output Data Rate: 6.66 kHz */ - -#define LSM6DS33_XL_ODR_MASK ((uint8_t)0xF0) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_Full_Scale_Selection_CTRL1_XL LSM6DS33_XG_Accelerometer_Full_Scale_Selection_CTRL1_XL - * @{ - */ -#define LSM6DS33_XL_FS_2G ((uint8_t)0x00) /*!< Full scale: +- 2g */ -#define LSM6DS33_XL_FS_4G ((uint8_t)0x08) /*!< Full scale: +- 4g */ -#define LSM6DS33_XL_FS_8G ((uint8_t)0x0C) /*!< Full scale: +- 8g */ -#define LSM6DS33_XL_FS_16G ((uint8_t)0x04) /*!< Full scale: +- 16g */ - -#define LSM6DS33_XL_FS_MASK ((uint8_t)0x0C) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_Anti_Aliasing_Filter_Bandwidth_Selection_CTRL1_XL LSM6DS33_XG_Accelerometer_Anti_Aliasing_Filter_Bandwidth_Selection_CTRL1_XL - * @{ - */ -#define LSM6DS33_XL_BW_400HZ ((uint8_t)0x00) /*!< Anti-aliasing filter bandwidht: 400 Hz */ -#define LSM6DS33_XL_BW_200HZ ((uint8_t)0x01) /*!< Anti-aliasing filter bandwidht: 200 Hz */ -#define LSM6DS33_XL_BW_100HZ ((uint8_t)0x02) /*!< Anti-aliasing filter bandwidht: 100 Hz */ -#define LSM6DS33_XL_BW_50HZ ((uint8_t)0x03) /*!< Anti-aliasing filter bandwidht: 50 Hz */ - -#define LSM6DS33_XL_BW_MASK ((uint8_t)0x03) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS33_XG_Accelerometer_Z_Axis_Output_Enable_Selection_CTRL9_XL - * @{ - */ -#define LSM6DS33_XL_ZEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Z-axis output enable: disable */ -#define LSM6DS33_XL_ZEN_ENABLE ((uint8_t)0x20) /*!< Accelerometer�s Z-axis output enable: enable */ - -#define LSM6DS33_XL_ZEN_MASK ((uint8_t)0x20) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS33_XG_Accelerometer_Y_Axis_Output_Enable_Selection_CTRL9_XL - * @{ - */ -#define LSM6DS33_XL_YEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s Y-axis output enable: disable */ -#define LSM6DS33_XL_YEN_ENABLE ((uint8_t)0x10) /*!< Accelerometer�s Y-axis output enable: enable */ - -#define LSM6DS33_XL_YEN_MASK ((uint8_t)0x10) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL9_XL LSM6DS33_XG_Accelerometer_X_Axis_Output_Enable_Selection_CTRL9_XL - * @{ - */ -#define LSM6DS33_XL_XEN_DISABLE ((uint8_t)0x00) /*!< Accelerometer�s X-axis output enable: disable */ -#define LSM6DS33_XL_XEN_ENABLE ((uint8_t)0x08) /*!< Accelerometer�s X-axis output enable: enable */ - -#define LSM6DS33_XL_XEN_MASK ((uint8_t)0x08) - -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_FF_DUR5_Selection_WAKE_UP_DUR LSM6DS33_XG_Accelerometer_FF_DUR5_Selection_WAKE_UP_DUR - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_DUR_FF_DUR5_DEFAULT ((uint8_t)0x00) - -#define LSM6DS33_XG_WAKE_UP_DUR_FF_DUR5_MASK ((uint8_t)0x80) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_WAKE_DUR_Selection_WAKE_UP_DUR LSM6DS33_XG_Accelerometer_WAKE_DUR_Selection_WAKE_UP_DUR - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_DUR_WAKE_DUR_DEFAULT ((uint8_t)0x00) - -#define LSM6DS33_XG_WAKE_UP_DUR_WAKE_DUR_MASK ((uint8_t)0x60) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_TIMER_HR_Selection_WAKE_UP_DUR LSM6DS33_XG_Accelerometer_TIMER_HR_Selection_WAKE_UP_DUR - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_DUR_TIMER_HR_DEFAULT ((uint8_t)0x00) - -#define LSM6DS33_XG_WAKE_UP_DUR_TIMER_HR_MASK ((uint8_t)0x10) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_SLEEP_DUR_Selection_WAKE_UP_DUR LSM6DS33_XG_Accelerometer_SLEEP_DUR_Selection_WAKE_UP_DUR - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_DUR_SLEEP_DUR_DEFAULT ((uint8_t)0x00) - -#define LSM6DS33_XG_WAKE_UP_DUR_SLEEP_DUR_MASK ((uint8_t)0x0F) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_FF_DUR_Selection_FREE_FALL LSM6DS33_XG_Accelerometer_FF_DUR_Selection_FREE_FALL - * @{ - */ -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_DUR_DEFAULT ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_DUR_TYPICAL ((uint8_t)0x30) - -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_DUR_MASK ((uint8_t)0xF8) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_FF_THS_Selection_FREE_FALL LSM6DS33_XG_Accelerometer_FF_THS_Selection_FREE_FALL - * @{ - */ -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_156MG ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_219MG ((uint8_t)0x01) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_250MG ((uint8_t)0x02) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_312MG ((uint8_t)0x03) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_344MG ((uint8_t)0x04) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_406MG ((uint8_t)0x05) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_469MG ((uint8_t)0x06) -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_500MG ((uint8_t)0x07) - -#define LSM6DS33_XG_WAKE_FREE_FALL_FF_THS_MASK ((uint8_t)0x07) - -/** - * @} - */ - - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_INACT_STATE_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_INACT_STATE_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_INACT_STATE_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_INACT_STATE_ENABLE ((uint8_t)0x80) - -#define LSM6DS33_XG_MD1_CFG_INT1_INACT_STATE_MASK ((uint8_t)0x80) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_SINGLE_TAP_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_SINGLE_TAP_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_SINGLE_TAP_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_SINGLE_TAP_ENABLE ((uint8_t)0x40) - -#define LSM6DS33_XG_MD1_CFG_INT1_SINGLE_TAP_MASK ((uint8_t)0x40) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_WU_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_WU_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_WU_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_WU_ENABLE ((uint8_t)0x20) - -#define LSM6DS33_XG_MD1_CFG_INT1_WU_MASK ((uint8_t)0x20) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_FF_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_FF_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_FF_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_FF_ENABLE ((uint8_t)0x10) - -#define LSM6DS33_XG_MD1_CFG_INT1_FF_MASK ((uint8_t)0x10) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_DOUBLE_TAP_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_DOUBLE_TAP_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_DOUBLE_TAP_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_DOUBLE_TAP_ENABLE ((uint8_t)0x08) - -#define LSM6DS33_XG_MD1_CFG_INT1_DOUBLE_TAP_MASK ((uint8_t)0x08) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_6D_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_6D_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_6D_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_6D_ENABLE ((uint8_t)0x04) - -#define LSM6DS33_XG_MD1_CFG_INT1_6D_MASK ((uint8_t)0x04) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_TILT_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_TILT_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_TILT_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_TILT_ENABLE ((uint8_t)0x02) - -#define LSM6DS33_XG_MD1_CFG_INT1_TILT_MASK ((uint8_t)0x02) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_INT1_TIMER_Selection_MD1_CFG LSM6DS33_XG_Accelerometer_INT1_TIMER_Selection_MD1_CFG - * @{ - */ -#define LSM6DS33_XG_MD1_CFG_INT1_TIMER_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_MD1_CFG_INT1_TIMER_ENABLE ((uint8_t)0x01) - -#define LSM6DS33_XG_MD1_CFG_INT1_TIMER_MASK ((uint8_t)0x01) - -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_FF_IA_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_FF_IA_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_FF_IA_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_FF_IA_ENABLE ((uint8_t)0x20) - -#define LSM6DS33_XG_WAKE_UP_SRC_FF_IA_MASK ((uint8_t)0x20) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_SLEEP_STATE_IA_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_SLEEP_STATE_IA_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_SLEEP_STATE_IA_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_SLEEP_STATE_IA_ENABLE ((uint8_t)0x10) - -#define LSM6DS33_XG_WAKE_UP_SRC_SLEEP_STATE_IA_MASK ((uint8_t)0x10) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_WU_IA_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_WU_IA_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_WU_IA_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_WU_IA_ENABLE ((uint8_t)0x08) - -#define LSM6DS33_XG_WAKE_UP_SRC_WU_IA_MASK ((uint8_t)0x08) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_X_WU_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_X_WU_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_X_WU_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_X_WU_ENABLE ((uint8_t)0x04) - -#define LSM6DS33_XG_WAKE_UP_SRC_X_WU_MASK ((uint8_t)0x04) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_Y_WU_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_Y_WU_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_Y_WU_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_Y_WU_ENABLE ((uint8_t)0x02) - - -#define LSM6DS33_XG_WAKE_UP_SRC_Y_WU_MASK ((uint8_t)0x02) -/** - * @} - */ - -/** @addtogroup LSM6DS33_XG_Accelerometer_Z_WU_Enable_WAKE_UP_SRC LSM6DS33_XG_Accelerometer_Z_WU_Enable_WAKE_UP_SRC - * @{ - */ -#define LSM6DS33_XG_WAKE_UP_SRC_Z_WU_DISABLE ((uint8_t)0x00) -#define LSM6DS33_XG_WAKE_UP_SRC_Z_WU_ENABLE ((uint8_t)0x01) - -#define LSM6DS33_XG_WAKE_UP_SRC_Z_WU_MASK ((uint8_t)0x01) -/** - * @} - */ - -/** - * @} - */ - -/** @addtogroup LSM6DS33_Imported_Functions LSM6DS33_Imported_Functions - * @{ - */ - -/* Six axes sensor IO functions */ -extern IMU_6AXES_StatusTypeDef LSM6DS33_IO_Init( void ); -extern IMU_6AXES_StatusTypeDef LSM6DS33_IO_Write( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToWrite ); -extern IMU_6AXES_StatusTypeDef LSM6DS33_IO_Read( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToRead ); -extern void LSM6DS33_IO_ITConfig( void ); - -/** - * @} - */ - -/** @addtogroup LSM6DS33_Exported_Types LSM6DS33_Exported_Types - * @{ - */ -/** - * @brief LSM6DS33 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 *); -} LSM6DS33_DrvExtTypeDef; - -/** - * @} - */ - -/** @addtogroup LSM6DS33_Exported_Variables LSM6DS33_Exported_Variables - * @{ - */ - -/* Six axes sensor driver structure */ -extern IMU_6AXES_DrvTypeDef LSM6DS33Drv; -extern IMU_6AXES_DrvExtTypeDef LSM6DS33Drv_ext; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* _LSM6DS33_XG_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/AltIMU_10_v5/components/lsm6ds33/lsm6ds33_class.cpp Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,859 +0,0 @@ -/** - ****************************************************************************** - * @file lsm6ds33_class.cpp - * @author AST / EST - * @version V0.0.1 - * @date 14-April-2015 - * @brief Implementation file for the LSM6DS33 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 "lsm6ds33_class.h" -#include "lsm6ds33.h" - -/* Methods -------------------------------------------------------------------*/ -/* betzw - based on: - X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds33/lsm6ds33.c: revision #400, - X-CUBE-MEMS1/trunk: revision #416 -*/ - -/** - * @brief Set LSM6DS33 Initialization - * @param LSM6DS33_Init the configuration setting for the LSM6DS3 - * @retval IMU_6AXES_OK in case of success, an error code otherwise - */ -IMU_6AXES_StatusTypeDef LSM6DS33::LSM6DS33_Init( IMU_6AXES_InitTypeDef *LSM6DS33_Init ) -{ - /*Here we have to add the check if the parameters are valid*/ - - /* Configure the low level interface -------------------------------------*/ - if(LSM6DS33_IO_Init() != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - - /******** Common init *********/ - - if(LSM6DS33_Common_Sensor_Enable() != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - - /******* Gyroscope init *******/ - - if(LSM6DS33_G_Set_ODR( LSM6DS33_Init->G_OutputDataRate ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_G_Set_FS( LSM6DS33_Init->G_FullScale ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_G_Set_Axes_Status(LSM6DS33_Init->G_X_Axis, LSM6DS33_Init->G_Y_Axis, LSM6DS33_Init->G_Z_Axis) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - - /***** Accelerometer init *****/ - - if(LSM6DS33_X_Set_ODR( LSM6DS33_Init->X_OutputDataRate ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_X_Set_FS( LSM6DS33_Init->X_FullScale ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_X_Set_Axes_Status(LSM6DS33_Init->X_X_Axis, LSM6DS33_Init->X_Y_Axis, LSM6DS33_Init->X_Z_Axis) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - /* Configure interrupt lines */ - LSM6DS33_IO_ITConfig(); - - return IMU_6AXES_OK; -} - -/** - * @brief Read ID of LSM6DS33 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 LSM6DS33::LSM6DS33_Read_XG_ID( uint8_t *xg_id) -{ - if(!xg_id) - { - return IMU_6AXES_ERROR; - } - - return LSM6DS33_IO_Read(xg_id, LSM6DS33_XG_WHO_AM_I_ADDR, 1); -} - -/** - * @brief Set LSM6DS33 common initialization - * @retval IMU_6AXES_OK in case of success, an error code otherwise - */ -IMU_6AXES_StatusTypeDef LSM6DS33::LSM6DS33_Common_Sensor_Enable(void) -{ - uint8_t tmp1 = 0x00; - - if(LSM6DS33_IO_Read(&tmp1, LSM6DS33_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 &= ~(LSM6DS33_XG_IF_INC_MASK); - tmp1 |= LSM6DS33_XG_IF_INC; - - if(LSM6DS33_IO_Write(&tmp1, LSM6DS33_XG_CTRL3_C, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - - if(LSM6DS33_IO_Read(&tmp1, LSM6DS33_XG_FIFO_CTRL5, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - /* FIFO ODR selection */ - tmp1 &= ~(LSM6DS33_XG_FIFO_ODR_MASK); - tmp1 |= LSM6DS33_XG_FIFO_ODR_NA; - - /* FIFO mode selection */ - tmp1 &= ~(LSM6DS33_XG_FIFO_MODE_MASK); - tmp1 |= LSM6DS33_XG_FIFO_MODE_BYPASS; - - if(LSM6DS33_IO_Write(&tmp1, LSM6DS33_XG_FIFO_CTRL5, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - return IMU_6AXES_OK; -} - -/** - * @brief Read raw data from LSM6DS33 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 LSM6DS33::LSM6DS33_X_GetAxesRaw( int16_t *pData ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg[2] = {0, 0}; - - - if(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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 LSM6DS33 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 LSM6DS33::LSM6DS33_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(LSM6DS33_X_GetAxesRaw(pDataRaw) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_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 LSM6DS33 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 LSM6DS33::LSM6DS33_G_GetAxesRaw( int16_t *pData ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg[2] = {0, 0}; - - - if(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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(LSM6DS33_IO_Read(&tempReg[0], LSM6DS33_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 LSM6DS33::LSM6DS33_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 ) ? LSM6DS33_XL_XEN_DISABLE : LSM6DS33_XL_XEN_ENABLE; - eY = ( enableY == 0 ) ? LSM6DS33_XL_YEN_DISABLE : LSM6DS33_XL_YEN_ENABLE; - eZ = ( enableZ == 0 ) ? LSM6DS33_XL_ZEN_DISABLE : LSM6DS33_XL_ZEN_ENABLE; - - if(LSM6DS33_IO_Read(&tmp1, LSM6DS33_XG_CTRL9_XL, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - /* Enable X axis selection */ - tmp1 &= ~(LSM6DS33_XL_XEN_MASK); - tmp1 |= eX; - - /* Enable Y axis selection */ - tmp1 &= ~(LSM6DS33_XL_YEN_MASK); - tmp1 |= eY; - - /* Enable Z axis selection */ - tmp1 &= ~(LSM6DS33_XL_ZEN_MASK); - tmp1 |= eZ; - - if(LSM6DS33_IO_Write(&tmp1, LSM6DS33_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 LSM6DS33::LSM6DS33_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 ) ? LSM6DS33_G_XEN_DISABLE : LSM6DS33_G_XEN_ENABLE; - eY = ( enableY == 0 ) ? LSM6DS33_G_YEN_DISABLE : LSM6DS33_G_YEN_ENABLE; - eZ = ( enableZ == 0 ) ? LSM6DS33_G_ZEN_DISABLE : LSM6DS33_G_ZEN_ENABLE; - - if(LSM6DS33_IO_Read(&tmp1, LSM6DS33_XG_CTRL10_C, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - /* Enable X axis selection */ - tmp1 &= ~(LSM6DS33_G_XEN_MASK); - tmp1 |= eX; - - /* Enable Y axis selection */ - tmp1 &= ~(LSM6DS33_G_YEN_MASK); - tmp1 |= eY; - - /* Enable Z axis selection */ - tmp1 &= ~(LSM6DS33_G_ZEN_MASK); - tmp1 |= eZ; - - if(LSM6DS33_IO_Write(&tmp1, LSM6DS33_XG_CTRL10_C, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - return IMU_6AXES_OK; -} - -/** - * @brief Read data from LSM6DS33 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 LSM6DS33::LSM6DS33_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(LSM6DS33_G_GetAxesRaw(pDataRaw) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - if(LSM6DS33_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 LSM6DS33::LSM6DS33_X_Get_ODR( float *odr ) -{ - /*Here we have to add the check if the parameters are valid*/ - uint8_t tempReg = 0x00; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_XL_ODR_MASK; - - switch( tempReg ) - { - case LSM6DS33_XL_ODR_PD: - *odr = 0.0f; - break; - case LSM6DS33_XL_ODR_13HZ: - *odr = 13.0f; - break; - case LSM6DS33_XL_ODR_26HZ: - *odr = 26.0f; - break; - case LSM6DS33_XL_ODR_52HZ: - *odr = 52.0f; - break; - case LSM6DS33_XL_ODR_104HZ: - *odr = 104.0f; - break; - case LSM6DS33_XL_ODR_208HZ: - *odr = 208.0f; - break; - case LSM6DS33_XL_ODR_416HZ: - *odr = 416.0f; - break; - case LSM6DS33_XL_ODR_833HZ: - *odr = 833.0f; - break; - case LSM6DS33_XL_ODR_1660HZ: - *odr = 1660.0f; - break; - case LSM6DS33_XL_ODR_3330HZ: - *odr = 3330.0f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_X_Set_ODR( float odr ) -{ - uint8_t new_odr = 0x00; - uint8_t tempReg = 0x00; - - new_odr = ( odr <= 0.0f ) ? LSM6DS33_XL_ODR_PD /* Power Down */ - : ( odr <= 13.0f ) ? LSM6DS33_XL_ODR_13HZ - : ( odr <= 26.0f ) ? LSM6DS33_XL_ODR_26HZ - : ( odr <= 52.0f ) ? LSM6DS33_XL_ODR_52HZ - : ( odr <= 104.0f ) ? LSM6DS33_XL_ODR_104HZ - : ( odr <= 208.0f ) ? LSM6DS33_XL_ODR_208HZ - : ( odr <= 416.0f ) ? LSM6DS33_XL_ODR_416HZ - : ( odr <= 833.0f ) ? LSM6DS33_XL_ODR_833HZ - : ( odr <= 1660.0f ) ? LSM6DS33_XL_ODR_1660HZ - : ( odr <= 3330.0f ) ? LSM6DS33_XL_ODR_3330HZ - : LSM6DS33_XL_ODR_6660HZ; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_XL_ODR_MASK); - tempReg |= new_odr; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_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 LSM6DS33::LSM6DS33_X_GetSensitivity( float *pfData ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg = 0x00; - - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_XL_FS_MASK; - - switch( tempReg ) - { - case LSM6DS33_XL_FS_2G: - *pfData = 0.061f; - break; - case LSM6DS33_XL_FS_4G: - *pfData = 0.122f; - break; - case LSM6DS33_XL_FS_8G: - *pfData = 0.244f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_X_Get_FS( float *fullScale ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg = 0x00; - - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_XL_FS_MASK; - - switch( tempReg ) - { - case LSM6DS33_XL_FS_2G: - *fullScale = 2.0f; - break; - case LSM6DS33_XL_FS_4G: - *fullScale = 4.0f; - break; - case LSM6DS33_XL_FS_8G: - *fullScale = 8.0f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_X_Set_FS( float fullScale ) -{ - uint8_t new_fs = 0x00; - uint8_t tempReg = 0x00; - - new_fs = ( fullScale <= 2.0f ) ? LSM6DS33_XL_FS_2G - : ( fullScale <= 4.0f ) ? LSM6DS33_XL_FS_4G - : ( fullScale <= 8.0f ) ? LSM6DS33_XL_FS_8G - : LSM6DS33_XL_FS_16G; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL1_XL, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_XL_FS_MASK); - tempReg |= new_fs; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_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 LSM6DS33::LSM6DS33_G_Get_ODR( float *odr ) -{ - /*Here we have to add the check if the parameters are valid*/ - uint8_t tempReg = 0x00; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_G_ODR_MASK; - - switch( tempReg ) - { - case LSM6DS33_G_ODR_PD: - *odr = 0.0f; - break; - case LSM6DS33_G_ODR_13HZ: - *odr = 13.0f; - break; - case LSM6DS33_G_ODR_26HZ: - *odr = 26.0f; - break; - case LSM6DS33_G_ODR_52HZ: - *odr = 52.0f; - break; - case LSM6DS33_G_ODR_104HZ: - *odr = 104.0f; - break; - case LSM6DS33_G_ODR_208HZ: - *odr = 208.0f; - break; - case LSM6DS33_G_ODR_416HZ: - *odr = 416.0f; - break; - case LSM6DS33_G_ODR_833HZ: - *odr = 833.0f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_G_Set_ODR( float odr ) -{ - uint8_t new_odr = 0x00; - uint8_t tempReg = 0x00; - - new_odr = ( odr <= 0.0f ) ? LSM6DS33_G_ODR_PD /* Power Down */ - : ( odr <= 13.0f ) ? LSM6DS33_G_ODR_13HZ - : ( odr <= 26.0f ) ? LSM6DS33_G_ODR_26HZ - : ( odr <= 52.0f ) ? LSM6DS33_G_ODR_52HZ - : ( odr <= 104.0f ) ? LSM6DS33_G_ODR_104HZ - : ( odr <= 208.0f ) ? LSM6DS33_G_ODR_208HZ - : ( odr <= 416.0f ) ? LSM6DS33_G_ODR_416HZ - : ( odr <= 833.0f ) ? LSM6DS33_G_ODR_833HZ - : LSM6DS33_G_ODR_1660HZ; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_G_ODR_MASK); - tempReg |= new_odr; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_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 LSM6DS33::LSM6DS33_G_GetSensitivity( float *pfData ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg = 0x00; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_G_FS_125_MASK; - - if(tempReg == LSM6DS33_G_FS_125_ENABLE) - { - *pfData = 4.375f; - } - else - { - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_G_FS_MASK; - - switch( tempReg ) - { - case LSM6DS33_G_FS_245: - *pfData = 8.75f; - break; - case LSM6DS33_G_FS_500: - *pfData = 17.50f; - break; - case LSM6DS33_G_FS_1000: - *pfData = 35.0f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_G_Get_FS( float *fullScale ) -{ - /*Here we have to add the check if the parameters are valid*/ - - uint8_t tempReg = 0x00; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_G_FS_125_MASK; - - if(tempReg == LSM6DS33_G_FS_125_ENABLE) - { - *fullScale = 125.0f; - } - else - { - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= LSM6DS33_G_FS_MASK; - - switch( tempReg ) - { - case LSM6DS33_G_FS_245: - *fullScale = 245.0f; - break; - case LSM6DS33_G_FS_500: - *fullScale = 500.0f; - break; - case LSM6DS33_G_FS_1000: - *fullScale = 1000.0f; - break; - case LSM6DS33_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 LSM6DS33::LSM6DS33_G_Set_FS( float fullScale ) -{ - uint8_t new_fs = 0x00; - uint8_t tempReg = 0x00; - - if(fullScale <= 125.0f) - { - new_fs = LSM6DS33_G_FS_125_ENABLE; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_G_FS_125_MASK); - tempReg |= new_fs; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_XG_CTRL2_G, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - } - else - { - /* Disable G FS 125dpp */ - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_G_FS_125_MASK); - tempReg |= LSM6DS33_G_FS_125_DISABLE; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_XG_CTRL2_G, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - new_fs = ( fullScale <= 245.0f ) ? LSM6DS33_G_FS_245 - : ( fullScale <= 500.0f ) ? LSM6DS33_G_FS_500 - : ( fullScale <= 1000.0f ) ? LSM6DS33_G_FS_1000 - : LSM6DS33_G_FS_2000; - - if(LSM6DS33_IO_Read( &tempReg, LSM6DS33_XG_CTRL2_G, 1 ) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - - tempReg &= ~(LSM6DS33_G_FS_MASK); - tempReg |= new_fs; - - if(LSM6DS33_IO_Write(&tempReg, LSM6DS33_XG_CTRL2_G, 1) != IMU_6AXES_OK) - { - return IMU_6AXES_ERROR; - } - } - - return IMU_6AXES_OK; -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/AltIMU_10_v5/components/lsm6ds33/lsm6ds33_class.h Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/** - ****************************************************************************** - * @file lsm6ds3_class.h - * @author AST / EST - * @version V0.0.1 - * @date 14-April-2015 - * @brief Header file for component LSM6DS33 - ****************************************************************************** - * @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 __LSM6DS33_CLASS_H -#define __LSM6DS33_CLASS_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" -#include "DevI2C.h" -#include "lsm6ds33.h" -#include "GyroSensor.h" -#include "MotionSensor.h" - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a LSM6DS33 sensor component - */ -class LSM6DS33 : 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 - */ - LSM6DS33(DevI2C &i2c) : GyroSensor(), MotionSensor(), dev_i2c(i2c){ } - - /** Destructor - */ - virtual ~LSM6DS33() {} - - /*** Interface Methods ***/ - virtual int init(void *init_struct) { - return LSM6DS33_Init((IMU_6AXES_InitTypeDef*)init_struct); - } - - virtual int read_id(uint8_t *xg_id) { - return LSM6DS33_Read_XG_ID(xg_id); - } - - virtual int get_x_axes(int32_t *pData) { - return LSM6DS33_X_GetAxes(pData); - } - - virtual int get_x_axes_raw(int16_t *pData) { - return LSM6DS33_X_GetAxesRaw(pData); - } - - virtual int get_g_axes(int32_t *pData) { - return LSM6DS33_G_GetAxes(pData); - } - - virtual int get_g_axes_raw(int16_t *pData) { - return LSM6DS33_G_GetAxesRaw(pData); - } - - virtual int get_x_odr(float *odr) { - return LSM6DS33_X_Get_ODR(odr); - } - - virtual int set_x_odr(float odr) { - return LSM6DS33_X_Set_ODR(odr); - } - - virtual int get_x_sensitivity(float *pfData) { - return LSM6DS33_X_GetSensitivity(pfData); - } - - virtual int get_x_fs(float *fullScale) { - return LSM6DS33_X_Get_FS(fullScale); - } - - virtual int set_x_fs(float fullScale) { - return LSM6DS33_X_Set_FS(fullScale); - } - - virtual int get_g_odr(float *odr) { - return LSM6DS33_G_Get_ODR(odr); - } - - virtual int set_g_odr(float odr) { - return LSM6DS33_G_Set_ODR(odr); - } - - virtual int get_g_sensitivity(float *pfData) { - return LSM6DS33_G_GetSensitivity(pfData); - } - - virtual int get_g_fs(float *fullScale) { - return LSM6DS33_G_Get_FS(fullScale); - } - - virtual int set_g_fs(float fullScale) { - return LSM6DS33_G_Set_FS(fullScale); - } - - protected: - /*** Methods ***/ - IMU_6AXES_StatusTypeDef LSM6DS33_Init(IMU_6AXES_InitTypeDef *LSM6DS33_Init); - IMU_6AXES_StatusTypeDef LSM6DS33_Read_XG_ID(uint8_t *xg_id); - IMU_6AXES_StatusTypeDef LSM6DS33_X_GetAxes(int32_t *pData); - IMU_6AXES_StatusTypeDef LSM6DS33_X_GetAxesRaw(int16_t *pData); - IMU_6AXES_StatusTypeDef LSM6DS33_G_GetAxes(int32_t *pData); - IMU_6AXES_StatusTypeDef LSM6DS33_G_GetAxesRaw(int16_t *pData); - IMU_6AXES_StatusTypeDef LSM6DS33_X_Get_ODR( float *odr ); - IMU_6AXES_StatusTypeDef LSM6DS33_X_Set_ODR( float odr ); - IMU_6AXES_StatusTypeDef LSM6DS33_X_GetSensitivity( float *pfData ); - IMU_6AXES_StatusTypeDef LSM6DS33_X_Get_FS( float *fullScale ); - IMU_6AXES_StatusTypeDef LSM6DS33_X_Set_FS( float fullScale ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_Get_ODR( float *odr ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_Set_ODR( float odr ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_GetSensitivity( float *pfData ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_Get_FS( float *fullScale ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_Set_FS( float fullScale ); - IMU_6AXES_StatusTypeDef LSM6DS33_Common_Sensor_Enable(void); - IMU_6AXES_StatusTypeDef LSM6DS33_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ); - IMU_6AXES_StatusTypeDef LSM6DS33_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ); - - /** - * @brief Configures LSM6DS33 interrupt lines for NUCLEO boards - */ - void LSM6DS33_IO_ITConfig(void) - { - } - - /** - * @brief Configures LSM6DS33 I2C interface - * @return IMU_6AXES_OK in case of success, an error code otherwise - */ - IMU_6AXES_StatusTypeDef LSM6DS33_IO_Init(void) - { - return IMU_6AXES_OK; /* done in constructor */ - } - - /** - * @brief Utility function to read data from LSM6DS33 - * @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 LSM6DS33_IO_Read(uint8_t* pBuffer, - uint8_t RegisterAddr, uint16_t NumByteToRead) - { - int ret = dev_i2c.i2c_read(pBuffer, - LSM6DS33_XG_MEMS_ADDRESS, - RegisterAddr, - NumByteToRead); - if(ret != 0) { - return IMU_6AXES_ERROR; - } - return IMU_6AXES_OK; - } - - /** - * @brief Utility function to write data to LSM6DS33 - * @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 LSM6DS33_IO_Write(uint8_t* pBuffer, - uint8_t RegisterAddr, uint16_t NumByteToWrite) - { - int ret = dev_i2c.i2c_write(pBuffer, - LSM6DS33_XG_MEMS_ADDRESS, - RegisterAddr, - NumByteToWrite); - if(ret != 0) { - return IMU_6AXES_ERROR; - } - return IMU_6AXES_OK; - } - - /*** Instance Variables ***/ - /* IO Device */ - DevI2C &dev_i2c; - -}; - -#endif // __LSM6DS33_CLASS_H
--- a/AltIMU_10_v5/components/lsm6ds33/readme.txt Mon Jul 02 07:41:35 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -lsm6ds0.h corresponds to: -- X-CUBE-MEMS1/trunk/Drivers/BSP/Components/lsm6ds33/lsm6ds33.h: revision #402, -- X-CUBE-MEMS1/trunk: revision #416
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Common/Component.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * @file Component.h + * @author AST + * @version V1.0.0 + * @date April 13th, 2015 + * @brief This file contains the abstract class describing the interface of a + * generic component. + ****************************************************************************** + * @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 __COMPONENT_CLASS_H +#define __COMPONENT_CLASS_H + + +/* Includes ------------------------------------------------------------------*/ + +#include <stdint.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for Generic components. + */ +class Component { +public: + + /** + * @brief Initializing the component. + * @param[in] init pointer to device specific initalization structure. + * @retval "0" in case of success, an error code otherwise. + */ + virtual int init(void *init) = 0; + + /** + * @brief Getting the ID of the component. + * @param[out] id pointer to an allocated variable to store the ID into. + * @retval "0" in case of success, an error code otherwise. + */ + virtual int read_id(uint8_t *id) = 0; + + /** + * @brief Destructor. + */ + virtual ~Component() {}; +}; + +#endif /* __COMPONENT_CLASS_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/GyroSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,126 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for a Gyroscope + */ +class GyroSensor : public Component { +public: + + /** + * @brief Get current gyroscope angular rate X/Y/Z-axes values + * in standard data units [mdps] + * @param[out] p_data Pointer to where to store angular rates to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_g_axes(int32_t *p_data) = 0; + + /** + * @brief Get current gyroscope raw data X/Y/Z-axes values + * in device sepcific LSB units + * @param[out] p_data Pointer to where to store gyroscope raw data to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_g_axes_raw(int16_t *p_data) = 0; + + /** + * @brief Get gyroscope's current sensitivity [mdps/LSB] + * @param[out] pf_data 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 *pf_data) = 0; + + /** + * @brief Get gyroscope's current output data rate [Hz] + * @param[out] pf_data 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 *pf_data) = 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] pf_data 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 *pf_data) = 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; + + /** + * @brief Destructor. + */ + virtual ~GyroSensor() {}; +}; + +#endif /* __GYRO_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/HumiditySensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,72 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for Humidity sensors + */ +class HumiditySensor : public Component { +public: + + /** + * @brief Get current humidity [%] + * @param[out] pf_data Pointer to where to store humidity to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_humidity(float *pf_data) = 0; + + /** + * @brief Destructor. + */ + virtual ~HumiditySensor() {}; +}; + +#endif /* __HUMIDITY_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/LightSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,72 @@ +/** + ****************************************************************************** + * @file LightSensor.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 ambient light sensor (ALS) + ****************************************************************************** + * @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 __LIGHT_SENSOR_CLASS_H +#define __LIGHT_SENSOR_CLASS_H + + +/* Includes ------------------------------------------------------------------*/ + +#include <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for ambient light sensors + */ +class LightSensor : public Component { +public: + + /** + * @brief Get current light [lux] + * @param[out] pi_data Pointer to where to store light to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_lux(uint32_t *pi_data) = 0; + + /** + * @brief Destructor. + */ + virtual ~LightSensor() {}; +}; + +#endif /* __LIGHT_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/MagneticSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,89 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for a magnetometer + */ +class MagneticSensor : public Component { +public: + + /** + * @brief Get current magnetometer magnetic X/Y/Z-axes values + * in standard data units [mgauss] + * @param[out] p_data Pointer to where to store magnetic values to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_m_axes(int32_t *p_data) = 0; + + /** + * @brief Get current magnetometer raw data X/Y/Z-axes values + * in device sepcific LSB units + * @param[out] p_data Pointer to where to store magnetometer raw data to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_m_axes_raw(int16_t *p_data) = 0; + + /** + * @brief Destructor. + */ + virtual ~MagneticSensor() {}; +}; + +#endif /* __MAGNETIC_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/MotionSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,126 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for an Accelerometer + */ +class MotionSensor : public Component { +public: + + /** + * @brief Get current accelerometer linear acceleration X/Y/Z-axes values + * in standard data units [mg] + * @param[out] p_data Pointer to where to store linear accelerations to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_x_axes(int32_t *p_data) = 0; + + /** + * @brief Get current accelerometer raw data X/Y/Z-axes values + * in device sepcific LSB units + * @param[out] p_data Pointer to where to store accelerometer raw data to. + * p_data must point to an array of (at least) three elements, where: + * p_data[0] corresponds to X-axis, + * p_data[1] corresponds to Y-axis, and + * p_data[2] corresponds to Z-axis. + * @return 0 in case of success, an error code otherwise + */ + virtual int get_x_axes_raw(int16_t *p_data) = 0; + + /** + * @brief Get accelerometer's current sensitivity [mg/LSB] + * @param[out] pf_data 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 *pf_data) = 0; + + /** + * @brief Get accelerometer's current output data rate [Hz] + * @param[out] pf_data 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 *pf_data) = 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] pf_data 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 *pf_data) = 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; + + /** + * @brief Destructor. + */ + virtual ~MotionSensor() {}; +}; + +#endif /* __MOTION_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/PressureSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,72 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for a Pressure Sensor + */ +class PressureSensor : public Component { +public: + + /** + * @brief Get current pressure [mbar] + * @param[out] pf_data Pointer to where to store pressure to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_pressure(float *pf_data) = 0; + + /** + * @brief Destructor. + */ + virtual ~PressureSensor() {}; +}; + +#endif /* __PRESSURE_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/RangeSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,72 @@ +/** + ****************************************************************************** + * @file RangeSensor.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 range 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 __RANGE_SENSOR_CLASS_H +#define __RANGE_SENSOR_CLASS_H + + +/* Includes ------------------------------------------------------------------*/ + +#include <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for range sensors + */ +class RangeSensor : public Component { +public: + + /** + * @brief Get current range [mm] + * @param[out] pi_data Pointer to where to store range to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_distance(uint32_t *pi_data) = 0; + + /** + * @brief Destructor. + */ + virtual ~RangeSensor() {}; +}; + +#endif /* __RANGE_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/ST_INTERFACES/Sensors/TempSensor.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,91 @@ +/** + ****************************************************************************** + * @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 <Component.h> + + +/* Classes ------------------------------------------------------------------*/ + +/** + * An abstract class for Temperature sensors + */ +class TempSensor : public Component { +public: + + /** + * @brief Get current temperature in degrees Celsius [°C] + * @param[out] pf_data Pointer to where to store temperature to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_temperature(float *pf_data) = 0; + + /** + * @brief Get current temperature in degrees Fahrenheit [°F] + * @param[out] pf_data Pointer to where to store temperature to + * @return 0 in case of success, an error code otherwise + */ + virtual int get_fahrenheit(float *pf_data) { + float celsius; + int ret; + + ret = get_temperature(&celsius); + if (ret) { + return ret; + } + + *pf_data = ((celsius * 1.8f) + 32.0f); + + return 0; + } + + /** + * @brief Destructor. + */ + virtual ~TempSensor() {}; +}; + +#endif /* __TEMP_SENSOR_CLASS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/X_NUCLEO_COMMON/DbgMCU/DbgMCU.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,64 @@ +/** + ****************************************************************************** + * @file DbgMCU.h + * @author AST / EST + * @version V0.0.1 + * @date 30-March-2015 + * @brief Header file for enabling debugging in sleep modes for STM32 MCUs + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent from recursive inclusion --------------------------------*/ +#ifndef __DBG_MCU_H +#define __DBG_MCU_H + +/* Includes ------------------------------------------------------------------*/ + +/* Classes -------------------------------------------------------------------*/ +/** Helper class DbgMCU providing a default constructor which enables debugging + * on STM32 MCUs while using sleep modes. + */ +class DbgMCU +{ + public: + /** Create a DbgMCU dummy object */ + DbgMCU(void) { + /* the following code is NOT portable */ + volatile uint32_t *dbgmcu_creg = (uint32_t*)0xE0042004; + uint32_t tmp = *dbgmcu_creg; + + tmp &= ~(0xE7); + tmp |= 0x27; // Set asynchronous communication via DBGMCU_CR (for ITM/printf) + // tmp |= 0xE7; // Set 4-pin tracing via DBGMCU_CR (for ETM) + *dbgmcu_creg = tmp; + } +}; + +#endif /* __DBG_MCU_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/X_NUCLEO_COMMON/DevI2C/DevI2C.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,122 @@ +/** + ****************************************************************************** + * @file DevI2C.h + * @author AST / EST + * @version V1.1.0 + * @date 21-January-2016 + * @brief Header file for a special I2C class DevI2C which provides some + * helper function for on-board communication + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2016 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 __DEV_I2C_H +#define __DEV_I2C_H + +/* Includes ------------------------------------------------------------------*/ +#include "mbed.h" +#include "pinmap.h" + +/* Classes -------------------------------------------------------------------*/ +/** Helper class DevI2C providing functions for multi-register I2C communication + * common for a series of I2C devices + */ +class DevI2C : public I2C +{ +public: + /** Create a DevI2C Master interface, connected to the specified pins + * + * @param sda I2C data line pin + * @param scl I2C clock line pin + */ + DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {} + + /** + * @brief Writes a buffer towards the I2C peripheral device. + * @param pBuffer pointer to the byte-array data to send + * @param DeviceAddr specifies the peripheral device slave address. + * @param RegisterAddr specifies the internal address register + * where to start writing to (must be correctly masked). + * @param NumByteToWrite number of bytes to be written. + * @retval 0 if ok, + * @retval -1 if an I2C error has occured, or + * @retval -2 on temporary buffer overflow (i.e. NumByteToWrite was too high) + * @note On some devices if NumByteToWrite is greater + * than one, the RegisterAddr must be masked correctly! + */ + int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, + uint16_t NumByteToWrite) { + int ret; + uint8_t tmp[TEMP_BUF_SIZE]; + + if(NumByteToWrite >= TEMP_BUF_SIZE) return -2; + + /* First, send device address. Then, send data and STOP condition */ + tmp[0] = RegisterAddr; + memcpy(tmp+1, pBuffer, NumByteToWrite); + + ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, false); + + if(ret) return -1; + return 0; + } + + /** + * @brief Reads a buffer from the I2C peripheral device. + * @param pBuffer pointer to the byte-array to read data in to + * @param DeviceAddr specifies the peripheral device slave address. + * @param RegisterAddr specifies the internal address register + * where to start reading from (must be correctly masked). + * @param NumByteToRead number of bytes to be read. + * @retval 0 if ok, + * @retval -1 if an I2C error has occured + * @note On some devices if NumByteToWrite is greater + * than one, the RegisterAddr must be masked correctly! + */ + int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, + uint16_t NumByteToRead) { + int ret; + + /* Send device address, with no STOP condition */ + ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, true); + if(!ret) { + /* Read data, with STOP condition */ + ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, false); + } + + if(ret) return -1; + return 0; + } + +private: + static const unsigned int TEMP_BUF_SIZE = 32; +}; + +#endif /* __DEV_I2C_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/X_NUCLEO_COMMON/DevSPI/DevSPI.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,388 @@ +/** + ****************************************************************************** + * @file DevSPI.h + * @author AST / Software Platforms and Cloud / EST + * @version V1.2.1 + * @date 19-February-2016 + * @brief Header file for a special SPI class DevSPI which provides some + * helper functions for on-board communication. + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2016 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 __DEV_SPI_H +#define __DEV_SPI_H + +/* Includes ------------------------------------------------------------------*/ +#include "mbed.h" + +/* Macros --------------------------------------------------------------------*/ +#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) /* GCC */ || \ + (defined(G_BYTE_ORDER) && (G_BYTE_ORDER == G_BIG_ENDIAN)) /* IAR */ || \ + (defined(__BIG_ENDIAN)) /* ARM */ +#define __DEV_SPI_BIG_ENDIAN +#endif + +/* Classes -------------------------------------------------------------------*/ +/** Helper class DevSPI providing functions for synchronous SPI communication + * common for a series of SPI devices. + */ +class DevSPI : public SPI +{ + public: + /* + * Create a DevSPI interface. + * @param mosi pin name of the MOSI pin of the SPI device to be used for communication. + * @param miso pin name of the MISO pin of the SPI device to be used for communication. + * @param sclk pin name of the SCLK pin of the SPI device to be used for communication. + */ + DevSPI(PinName mosi, PinName miso, PinName sclk) : SPI(mosi, miso, sclk) + { + /* Set default configuration. */ + setup(8, 3, 1E6); + } + + /* + * Setup the spi. + * Typically: + * + 8 bit data; + * + high steady state clock; + * + second edge capture; + * + 1MHz clock rate. + * + * @param bits Number of bits per SPI frame (4 - 16) + * @param mode Clock polarity and phase mode (0 - 3) + * @param frequency_hz SCLK frequency in hz (default = 1MHz) + * + * @code + * mode | POL PHA + * -----+-------- + * 0 | 0 0 + * 1 | 0 1 + * 2 | 1 0 + * 3 | 1 1 + * @endcode + */ + void setup(int bits, int mode = 0, int frequency_hz = 1E6) + { + /* Set given configuration. */ + format(bits, mode); + frequency(frequency_hz); + } + + /** + * @brief Writes a buffer to the SPI peripheral device in 8-bit data mode + * using synchronous SPI communication. + * @param[in] pBuffer pointer to the buffer of data to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumBytesToWrite number of bytes to write. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + */ + int spi_write(uint8_t* pBuffer, DigitalOut &ssel, uint16_t NumBytesToWrite) + { + /* Check data format */ + if(_bits != 8) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Write data. */ + for (int i = 0; i < NumBytesToWrite; i++) { + write(pBuffer[i]); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + + + /** + * @brief Reads a buffer from the SPI peripheral device in 8-bit data mode + * using synchronous SPI communication. + * @param[out] pBuffer pointer to the buffer to read data into. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumBytesToRead number of bytes to read. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + */ + int spi_read(uint8_t* pBuffer, DigitalOut &ssel, uint16_t NumBytesToRead) + { + /* Check data format */ + if(_bits != 8) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Read data. */ + for (int i = 0; i < NumBytesToRead; i++) { + pBuffer[i] = write(0); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + + /** + * @brief Writes a buffer to the SPI peripheral device in 8-bit data mode + * using synchronous SPI communication. + * @param[in] pBuffer pointer to the buffer of data to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumBytesToWrite number of bytes to write. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + */ + int spi_write_reg(uint8_t* pBuffer, uint8_t regAddr, DigitalInOut &ssel, uint16_t NumBytes) + { + /* Check data format */ + if(_bits != 8) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Write data. */ + /* + uint8_t *pData = new uint8_t [NumBytes+1]; + pData[0] = regAddr; + for (int i = 0; i < NumBytes; i++) { + pData[i+1] = pBuffer[i]; + } + SPI::write((char *)pData, NumBytes+1, NULL, 0); + + */ + write(regAddr); + for (int i = 0; i < NumBytes; i++) { + write(pBuffer[i]); + } + int i = 1; + while(i++<10); + + /* Unselect the chip. */ + ssel = 1; + + + return 0; + } + + /** + * @brief Reads a buffer from the SPI peripheral device + * in 8-bit data mode using synchronous SPI communication. + * @param[out] pBufferToRead pointer to the buffer to read data into. + * @param[in] regAddr register address to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumBytes number of bytes to read. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + */ + int spi_read_reg(uint8_t* pBuffer, uint8_t regAddr, DigitalInOut &ssel, uint16_t NumBytes) + { + /* Check data format */ + if(_bits != 8) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Read and write data at the same time. */ + /* + char *pData = new char [NumBytes+1]; + SPI::write((char *)®Addr, 1, pData, NumBytes+1); + for(int i = 1; i < NumBytes; i++) + { + pBuffer[i] = pData[i+1]; + } + */ + + write(regAddr); + for (int i = 0; i < NumBytes; i++) { + pBuffer[i] = write(0); + } + + /* Unselect the chip. */ + ssel = 1; + + + return 0; + } + + /** + * @brief Reads and write a buffer from/to the SPI peripheral device at the same time + * in 8-bit data mode using synchronous SPI communication. + * @param[out] pBufferToRead pointer to the buffer to read data into. + * @param[in] pBufferToWrite pointer to the buffer of data to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumBytes number of bytes to read and write. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + */ + int spi_read_write(uint8_t* pBufferToRead, uint8_t* pBufferToWrite, DigitalOut &ssel, uint16_t NumBytes) + { + /* Check data format */ + if(_bits != 8) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Read and write data at the same time. */ + for (int i = 0; i < NumBytes; i++) { + pBufferToRead[i] = write(pBufferToWrite[i]); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + + /** + * @brief Writes a buffer to the SPI peripheral device in 16-bit data mode + * using synchronous SPI communication. + * @param[in] pBuffer pointer to the buffer of data to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumValuesToWrite number of 16-bit values to write. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + * @note In order to guarantee this method to work correctly you have to + * pass buffers which are correctly aligned. + */ + int spi_write(uint16_t* pBuffer, DigitalOut &ssel, uint16_t NumValuesToWrite) + { + /* Check data format */ + if(_bits != 16) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Write data. */ + for (int i = 0; i < NumValuesToWrite; i++) { + write(htons(pBuffer[i])); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + + /** + * @brief Reads a buffer from the SPI peripheral device in 16-bit data mode + * using synchronous SPI communication. + * @param[out] pBuffer pointer to the buffer to read data into. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumValuesToRead number of 16-bit values to read. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + * @note In order to guarantee this method to work correctly you have to + * pass buffers which are correctly aligned. + */ + int spi_read(uint16_t* pBuffer, DigitalOut &ssel, uint16_t NumValuesToRead) + { + /* Check data format */ + if(_bits != 16) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Read data. */ + for (int i = 0; i < NumValuesToRead; i++) { + pBuffer[i] = ntohs((uint16_t)write(0)); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + + /** + * @brief Reads and write a buffer from/to the SPI peripheral device at the same time + * in 16-bit data mode using synchronous SPI communication. + * @param[out] pBufferToRead pointer to the buffer to read data into. + * @param[in] pBufferToWrite pointer to the buffer of data to send. + * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. + * @param[in] NumValues number of 16-bit values to read and write. + * @retval 0 if ok. + * @retval -1 if data format error. + * @note When using the SPI in Interrupt-mode, remember to disable interrupts + * before calling this function and to enable them again after. + * @note In order to guarantee this method to work correctly you have to + * pass buffers which are correctly aligned. + */ + int spi_read_write(uint16_t* pBufferToRead, uint16_t* pBufferToWrite, DigitalOut &ssel, uint16_t NumValues) + { + /* Check data format */ + if(_bits != 16) return -1; + + /* Select the chip. */ + ssel = 0; + + /* Read and write data at the same time. */ + for (int i = 0; i < NumValues; i++) { + pBufferToRead[i] = ntohs((uint16_t)write(htons(pBufferToWrite[i]))); + } + + /* Unselect the chip. */ + ssel = 1; + + return 0; + } + +protected: + inline uint16_t htons(uint16_t x) { +#ifndef __DEV_SPI_BIG_ENDIAN + return (((x)<<8)|((x)>>8)); +#else // __DEV_SPI_BIG_ENDIAN + return (x); +#endif // __DEV_SPI_BIG_ENDIAN + } + + inline uint16_t ntohs(uint16_t x) { + return htons(x); + } +}; + +#endif /* __DEV_SPI_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/components/Common/hum_temp.h Fri Aug 03 01:32:16 2018 +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/mag_ring/components/Common/imu_6axes.h Fri Aug 03 01:32:16 2018 +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/mag_ring/components/Common/magneto.h Fri Aug 03 01:32:16 2018 +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 +{ + float M_OutputDataRate; + uint8_t M_OperatingMode; + float 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/mag_ring/components/Common/pressure.h Fri Aug 03 01:32:16 2018 +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/mag_ring/components/Common/readme.txt Fri Aug 03 01:32:16 2018 +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/mag_ring/components/lis3mdl/lis3mdl.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,487 @@ +/** + ****************************************************************************** + * @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) + +/** + * @brief Read Byte. Mask for reading. + */ +#define LIS3MDL_SPI_READ_CMD ((uint8_t)0x80) + +/** + * @brief Write Byte. Mask for writing. + */ +#define LIS3MDL_SPI_WRITE_CMD ((uint8_t)0x00) + +/** + * @brief Auto-incremented. Mask for auto-incrementing address in multiple read/write commands. + */ +#define LIS3MDL_SPI_AUTO_INC_CMD ((uint8_t)0x40) + +/** + * @brief Unchange. Mask for remaining unchanged address in multiple read/write commands. + */ +#define LIS3MDL_SPI_UNCHANGE_CMD ((uint8_t)0x00) + + +/*********************************** 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_Fast_Output_Data_Rate_Enable_Selection_CTRL_REG1_M LIS3MDL_M_Fast_Output_Data_Rate_Enable_Selection_CTRL_REG1_M + * @{ + */ +#define LIS3MDL_M_FAST_ODR_DISABLE ((uint8_t)0x00) /*!< Fast output data rate: disable */ +#define LIS3MDL_M_FAST_ODR_ENABLE ((uint8_t)0x02) /*!< Fast output data rate: enable */ + +#define LIS3MDL_M_FAST_ODR_MASK ((uint8_t)0x02) +/** + * @} + */ + +/** @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/mag_ring/components/lis3mdl/lis3mdl_class.cpp Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,393 @@ +/** + ****************************************************************************** + * @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_M_Set_ODR( LIS3MDL_Init->M_OutputDataRate ) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + if(LIS3MDL_M_Set_FS( LIS3MDL_Init->M_FullScale ) != 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[6] = {0, 0, 0, 0, 0, 0}; + + if(LIS3MDL_IO_Read(&tempReg[0], (LIS3MDL_M_OUT_X_L_M), 6) != 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), 2) != MAGNETO_OK) { + return MAGNETO_ERROR; + } +*/ + pData[1] = ((((int16_t)tempReg[3]) << 8) + (int16_t)tempReg[2]); +/* + if(LIS3MDL_IO_Read(&tempReg[0], (LIS3MDL_M_OUT_Z_L_M), 2) != MAGNETO_OK) { + return MAGNETO_ERROR; + } +*/ + pData[2] = ((((int16_t)tempReg[5]) << 8) + (int16_t)tempReg[4]); + + 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; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Get_ODR( float *odr ) +{ + /*Here we have to add the check if the parameters are valid*/ + uint8_t tempReg = 0x00; + + if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + tempReg &= LIS3MDL_M_FAST_ODR_MASK; + if(tempReg == LIS3MDL_M_FAST_ODR_ENABLE) { + + if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + tempReg &= LIS3MDL_M_OM_MASK; + switch(tempReg) { + case LIS3MDL_M_OM_LP: + *odr = 1000.0f; + break; + case LIS3MDL_M_OM_MP: + *odr = 560.0f; + break; + case LIS3MDL_M_OM_HP: + *odr = 300.0f; + break; + case LIS3MDL_M_OM_UHP: + *odr = 155.0f; + break; + } + } else { + if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + tempReg &= LIS3MDL_M_DO_MASK; + switch(tempReg) { + case LIS3MDL_M_DO_0_625: + *odr = 0.625f; + break; + case LIS3MDL_M_DO_1_25: + *odr = 1.25f; + break; + case LIS3MDL_M_DO_2_5: + *odr = 2.5f; + break; + case LIS3MDL_M_DO_5: + *odr = 5.0f; + break; + case LIS3MDL_M_DO_10: + *odr = 10.0f; + break; + case LIS3MDL_M_DO_20: + *odr = 20.0f; + break; + case LIS3MDL_M_DO_40: + *odr = 40.0f; + break; + case LIS3MDL_M_DO_80: + *odr = 80.0f; + break; + } + } + return MAGNETO_OK; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Set_ODR( float odr ) +{ + uint8_t new_odr = 0x00; + uint8_t tempReg = 0x00; + +if(odr>80.0f){ + new_odr = ( odr <= 155.0f ) ? LIS3MDL_M_OM_UHP + : ( odr <= 300.0f ) ? LIS3MDL_M_OM_HP + : ( odr <= 560.0f ) ? LIS3MDL_M_OM_MP + : LIS3MDL_M_OM_LP; + + if(LIS3MDL_IO_Read(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + tempReg &= ~(LIS3MDL_M_OM_MASK); + tempReg |= (new_odr|LIS3MDL_M_FAST_ODR_ENABLE); + + if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + } + else{ + + new_odr = ( odr <= 0.625f ) ? LIS3MDL_M_DO_0_625 + : ( odr <= 1.25f ) ? LIS3MDL_M_DO_1_25 + : ( odr <= 2.5f ) ? LIS3MDL_M_DO_2_5 + : ( odr <= 5.0f ) ? LIS3MDL_M_DO_5 + : ( odr <= 10.0f ) ? LIS3MDL_M_DO_10 + : ( odr <= 20.0f ) ? LIS3MDL_M_DO_20 + : ( odr <= 40.0f ) ? LIS3MDL_M_DO_40 + : LIS3MDL_M_DO_80; + + if(LIS3MDL_IO_Read( &tempReg, LIS3MDL_M_CTRL_REG1_M, 1 ) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + tempReg &= ~(LIS3MDL_M_DO_MASK); + tempReg |= new_odr; + + if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG1_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } +} + return MAGNETO_OK; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Get_FS( float *fullScale ) +{ + /*Here we have to add the check if the parameters are valid*/ + uint8_t tempReg = 0x00; + + 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: + *fullScale = 4.0f; + break; + case LIS3MDL_M_FS_8: + *fullScale = 8.0f; + break; + case LIS3MDL_M_FS_12: + *fullScale = 12.0f; + break; + case LIS3MDL_M_FS_16: + *fullScale = 16.0f; + break; + } + + return MAGNETO_OK; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_Set_FS( float fullScale ) +{ + uint8_t new_fs = 0x00; + uint8_t tempReg = 0x00; + + new_fs = ( fullScale <= 4.0f ) ? LIS3MDL_M_FS_4 + : ( fullScale <= 8.0f ) ? LIS3MDL_M_FS_8 + : ( fullScale <= 12.0f ) ? LIS3MDL_M_FS_12 + : LIS3MDL_M_FS_16; + + if(LIS3MDL_IO_Read( &tempReg, LIS3MDL_M_CTRL_REG2_M, 1 ) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + tempReg &= ~(LIS3MDL_M_FS_MASK); + tempReg |= new_fs; + + if(LIS3MDL_IO_Write(&tempReg, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + return MAGNETO_OK; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_M_GetSensitivity( float *pfData ) +{ + /*Here we have to add the check if the parameters are valid*/ + + uint8_t tempReg = 0x00; + 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: + *pfData = 0.14; + break; + case LIS3MDL_M_FS_8: + *pfData = 0.29; + break; + case LIS3MDL_M_FS_12: + *pfData = 0.43; + break; + case LIS3MDL_M_FS_16: + *pfData = 0.58; + break; + } + + return MAGNETO_OK; +} + +MAGNETO_StatusTypeDef LIS3MDL::LIS3MDL_Reset_Regs() +{ + uint8_t tmp = 0; + + if(LIS3MDL_IO_Read( &tmp, LIS3MDL_M_CTRL_REG2_M, 1 ) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + tmp &= LIS3MDL_M_SOFT_RST_MASK; + tmp |= LIS3MDL_M_SOFT_RST_RESET; + + if(LIS3MDL_IO_Write( &tmp, LIS3MDL_M_CTRL_REG2_M, 1) != MAGNETO_OK) { + return MAGNETO_ERROR; + } + + return MAGNETO_OK; +} +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/components/lis3mdl/lis3mdl_class.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,189 @@ +/** + ****************************************************************************** + * @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 "DevSPI.h" +#include "lis3mdl.h" +#include "MagneticSensor.h" + +/* Classes -------------------------------------------------------------------*/ +/** Class representing a LIS3MDL sensor component + */ +class LIS3MDL : public MagneticSensor { + public: + /** Constructor + * @param[in] spi device I2C to be used for communication + */ + LIS3MDL(DevSPI &spi, PinName cs) : MagneticSensor(), dev_spi(spi), pin_cs(cs) { + pin_cs.mode(PullUp); + pin_cs.output(); + pin_cs = 1; + } + + /** Destructor + */ + virtual ~LIS3MDL() {} + + /*** Interface Methods ***/ + virtual int init(void *init_struct) { + return LIS3MDL_Init((MAGNETO_InitTypeDef*)init_struct); + } + + virtual int read_id(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_axes_raw(int16_t *pData) { + return LIS3MDL_M_GetAxesRaw(pData); + } + + virtual int get_m_odr(float *odr) { + return LIS3MDL_M_Get_ODR(odr); + } + + virtual int set_m_odr(float odr) { + return LIS3MDL_M_Set_ODR(odr); + } + + virtual int get_m_sensitivity(float *pfData) { + return LIS3MDL_M_GetSensitivity(pfData); + } + + virtual int get_m_fs(float *fullScale) { + return LIS3MDL_M_Get_FS(fullScale); + } + + virtual int set_m_fs(float fullScale) { + return LIS3MDL_M_Set_FS(fullScale); + } + + virtual int resetRegs() { + return LIS3MDL_Reset_Regs(); + } + + 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); + MAGNETO_StatusTypeDef LIS3MDL_M_Get_ODR( float *odr ); + MAGNETO_StatusTypeDef LIS3MDL_M_Set_ODR( float odr ); + MAGNETO_StatusTypeDef LIS3MDL_M_Get_FS( float *fullScale ); + MAGNETO_StatusTypeDef LIS3MDL_M_Set_FS( float fullScale ); + MAGNETO_StatusTypeDef LIS3MDL_M_GetSensitivity( float *pfData ); + MAGNETO_StatusTypeDef LIS3MDL_Reset_Regs(); + + /** + * @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) + { + RegisterAddr = RegisterAddr | LIS3MDL_SPI_READ_CMD; + if(NumByteToRead > 1) RegisterAddr |= LIS3MDL_SPI_AUTO_INC_CMD; + int ret = dev_spi.spi_read_reg(pBuffer, + RegisterAddr, + pin_cs, + NumByteToRead); + if(ret != 0) { + printf("error"); + 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) + { + RegisterAddr = RegisterAddr | LIS3MDL_SPI_WRITE_CMD; + if(NumByteToWrite > 1) RegisterAddr |= LIS3MDL_SPI_AUTO_INC_CMD; + int ret = dev_spi.spi_write_reg(pBuffer, + RegisterAddr, + pin_cs, + NumByteToWrite); + if(ret != 0) { + return MAGNETO_ERROR; + } + return MAGNETO_OK; + } + + /*** Instance Variables ***/ + /* IO Device */ + DevSPI &dev_spi; + DigitalInOut pin_cs; +}; + +#endif // __LIS3MDL_CLASS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/components/lis3mdl/readme.txt Fri Aug 03 01:32:16 2018 +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/mag_ring/mag_ring.cpp Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,246 @@ +/** + ****************************************************************************** + * @file mag_ring.cpp + * @author AST / EST + * @version V0.0.1 + * @date 08-October-2014 + * @brief Implementation file for the MagRing 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 "mag_ring.h" + +/* Static variables ----------------------------------------------------------*/ +MagRing* MagRing::_instance = NULL; + + +/* Methods -------------------------------------------------------------------*/ +/** + * @brief Constructor + */ +MagRing::MagRing(DevSPI *ext_spi) : dev_spi(ext_spi) +{ + magnetometers = new LIS3MDL* [NUMBER_OF_MAGNETOMETERS]; + magnetometers[0] = new LIS3MDL(*dev_spi, (M1_PIN_SPI_CS)); + magnetometers[1] = new LIS3MDL(*dev_spi, (M2_PIN_SPI_CS)); + magnetometers[2] = new LIS3MDL(*dev_spi, (M3_PIN_SPI_CS)); + magnetometers[3] = new LIS3MDL(*dev_spi, (M4_PIN_SPI_CS)); + magnetometers[4] = new LIS3MDL(*dev_spi, (M5_PIN_SPI_CS)); + magnetometers[5] = new LIS3MDL(*dev_spi, (M6_PIN_SPI_CS)); + magnetometers[6] = new LIS3MDL(*dev_spi, (M7_PIN_SPI_CS)); + magnetometers[7] = new LIS3MDL(*dev_spi, (M8_PIN_SPI_CS)); +} + +/** + * @brief Get singleton instance + * @return a pointer to the initialized singleton instance of class MagRing. + * A return value of NULL indicates an out of memory situation. + * @param[in] ext_spi (optional) pointer to an instance of DevSPI 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 DevSPI will be created with standard + * configuration parameters. + * The used DevSPI object gets saved in instance variable dev_spi. + * @param[in] ff_irq_pin (optional) PinName of the pin associated to asynchronous + * (i.e. interrupt based) free fall detection in case a LSM6DS33 3D + * Acceleromenter and 3D Gyroscope is mounted on top of the DIL 24-pin socket. + * Defaults to F746ZG_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 LSM6DS33 even if present. + */ +MagRing* MagRing::Instance(DevSPI *ext_spi) { + if(_instance == NULL) { + if(ext_spi == NULL) + ext_spi = new DevSPI(F746ZG_PIN_SPI_MOSI, F746ZG_PIN_SPI_MISO, F746ZG_PIN_SPI_SCLK); + + if(ext_spi != NULL) + _instance = new MagRing(ext_spi); + + if(_instance != NULL) { + bool ret = _instance->Init(); + if(!ret) { + error("Failed to init MagRing expansion board!\n"); + } + } + } + + return _instance; +} + +/** + * @brief Get singleton instance + * @return a pointer to the initialized singleton instance of class MagRing. + * A return value of NULL indicates an out of memory situation. + * @param[in] sda SPI data line pin. + * Taken into account only on the very first call of one of the 'Instance' functions. + * A new DevSPI will be created based on parameters 'sda' and 'scl'. + * The used DevSPI object gets saved in instance variable dev_spi. + * @param[in] scl SPI clock line pin. + * Taken into account only on the very first call of one of the 'Instance' functions. + * A new DevSPI will be created based on parameters 'sda' and 'scl'. + * The used DevSPI object gets saved in instance variable dev_spi. + * @param[in] ff_irq_pin (optional) PinName of the pin associated to asynchronous + * (i.e. interrupt based) free fall detection in case a LSM6DS33 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 LSM6DS33 even if present. + */ +MagRing* MagRing::Instance(PinName mosi, PinName miso, PinName sclk) { + if(_instance == NULL) { + DevSPI *ext_spi = new DevSPI(mosi, miso, sclk); + + if(ext_spi != NULL) + _instance = new MagRing(ext_spi); + + if(_instance != NULL) { + bool ret = _instance->Init(); + if(!ret) { + error("Failed to init MagRing expansion board!\n"); + } + } + } + + return _instance; +} + + +/** + * @brief Initialize the singleton's magnetometers + * @retval true if initialization successful, + * @retval false otherwise + */ +bool MagRing::Init_LIS3MDL(void) { + uint8_t m_id = 0; + MAGNETO_InitTypeDef InitStructure; + + /* Configure sensor */ + InitStructure.M_FullScale = 4.0f; + InitStructure.M_OperatingMode = LIS3MDL_M_MD_CONTINUOUS; + InitStructure.M_XYOperativeMode = LIS3MDL_M_OM_HP; + InitStructure.M_OutputDataRate = 1000.0f; + + dev_spi->frequency(1e2); + /* Check presence */ + for(int i = 0; i < NUMBER_OF_MAGNETOMETERS; i++){ + if((magnetometers[i]->read_id(&m_id) != MAGNETO_OK) || + (m_id != I_AM_LIS3MDL_M)) + { + printf(" m%d_id: %d, SHOULDBE: %d", i+1, m_id, I_AM_LIS3MDL_M);/* + for(int j = 0; j < NUMBER_OF_MAGNETOMETERS; j++){ + delete magnetometers[j]; + magnetometers[j] = NULL; + } + delete [] magnetometers; + magnetometers = NULL; + return true;*/ + } + + if(magnetometers[i]->init(&InitStructure) != MAGNETO_OK) + { + printf("%d init fail",i); + return false; + } + } + + return true; +} + +int MagRing::get_m_axes_raw(int16_t pData[][3]) +{ + for(int i = 0; i < NUMBER_OF_MAGNETOMETERS; i++) + { + if(magnetometers[i]->get_m_axes_raw((int16_t *)pData[i]) != 0) + { + return -1; + } + } + return 0; +} +int MagRing::get_m_axes(int32_t **pData) +{ + for(int i = 0; i < NUMBER_OF_MAGNETOMETERS; i++) + { + if(magnetometers[i]->get_m_axes(pData[i]) != 0) + { + return -1; + } + } + return 0; +} + + +int MagRing::get_m_axes_raw(int magIndex, int16_t *pData) +{ + return magnetometers[magIndex]->get_m_axes_raw(pData); +} +bool MagRing::resetMagnetometer(int magIndex) +{ + if(magnetometers[magIndex]->resetRegs() != MAGNETO_OK) + { + return MAGNETO_ERROR; + } + + uint8_t m_id = 0; + MAGNETO_InitTypeDef InitStructure; + + /* Configure sensor */ + InitStructure.M_FullScale = 4.0f; + InitStructure.M_OperatingMode = LIS3MDL_M_MD_CONTINUOUS; + InitStructure.M_XYOperativeMode = LIS3MDL_M_OM_HP; + InitStructure.M_OutputDataRate = 1000.0f; + + dev_spi->frequency(1e2); + /* Check presence */ + if((magnetometers[magIndex]->read_id(&m_id) != MAGNETO_OK) || + (m_id != I_AM_LIS3MDL_M)) + { + printf(" m%d_id: %d, SHOULDBE: %d", magIndex+1, m_id, I_AM_LIS3MDL_M);/* + for(int j = 0; j < NUMBER_OF_MAGNETOMETERS; j++){ + delete magnetometers[j]; + magnetometers[j] = NULL; + } + delete [] magnetometers; + magnetometers = NULL; + return true;*/ + } + + if(magnetometers[magIndex]->init(&InitStructure) != MAGNETO_OK) + { + printf("%d init fail",magIndex); + return false; + } + + return true; +} + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/mag_ring.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,123 @@ +/** + ****************************************************************************** + * @file mag_ring.h + * @author AST / EST + * @version V0.0.1 + * @date 13-April-2015 + * @brief Header file for class mag_ring representing a mag_ring + * 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 __MAG_RING_H +#define __MAG_RING_H + +/* Includes ------------------------------------------------------------------*/ +#include "mbed.h" +#include "mag_ring_targets.h" +#include "lis3mdl/lis3mdl_class.h" +#include "DevSPI.h" + +/* Macros -------------------------------------------------------------------*/ +#define CALL_METH(obj, meth, param, ret) ((obj == NULL) ? \ + ((*(param) = (ret)), 0) : \ + ((obj)->meth(param)) \ + ) + +/* Classes -------------------------------------------------------------------*/ +/** Class mag_ring 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 LSM6DS33 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 + * mag_ring 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 mag_ring *<TODO>_expansion_board = mag_ring::Instance(); + * @endcode + */ +class MagRing +{ + protected: + MagRing(DevSPI *ext_spi); + + ~MagRing(void) { + /* should never be called */ + error("Trial to delete mag_ring singleton!\n"); + } + + /** + * @brief Initialize the singleton's sensors to default settings + * @retval true if initialization successful, + * @retval false otherwise + */ + bool Init(void) { + return (Init_LIS3MDL()); + } + + bool Init_LIS3MDL(void); + + public: + static MagRing* Instance(DevSPI *ext_spi = NULL); + static MagRing* Instance(PinName mosi, PinName miso, PinName sclk); + + DevSPI *dev_spi; + + LIS3MDL **magnetometers; +/* GyroSensor *GetGyroscope(void) { + return gyro_lsm6ds33; + } + MotionSensor *GetAccelerometer(void) { + return gyro_lsm6ds33; + }*/ + void setSpiFrequency(int hz){ dev_spi->frequency(hz); } + int get_m_axes_raw(int16_t pData[][3]); + int get_m_axes_raw(int magIndex, int16_t *pData); + int get_m_axes(int32_t **pData); + bool resetMagnetometer(int magIndex); +// void setMagenticRegister(float **); +// LSM6DS33 *gyro_lsm6ds33; + + private: + static MagRing *_instance; +}; + +#endif /* __MAG_RING_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mag_ring/mag_ring_targets.h Fri Aug 03 01:32:16 2018 +0000 @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * @file mag_ring_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 + * MAG_RING 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 _MAG_RING_TARGETS_H_ +#define _MAG_RING_TARGETS_H_ + +/*** SPI ***/ +/* Use Arduino SPI Connectors */ +#define F746ZG_PIN_SPI_MOSI (SPI_MOSI) // D11 +#define F746ZG_PIN_SPI_MISO (SPI_MISO) // D12 +#define F746ZG_PIN_SPI_SCLK (SPI_SCK) // D13 + +#define M1_PIN_SPI_CS (PC_6) +#define M2_PIN_SPI_CS (PB_15) +#define M3_PIN_SPI_CS (PB_13) +#define M4_PIN_SPI_CS (PB_12) +#define M5_PIN_SPI_CS (PA_15) +#define M6_PIN_SPI_CS (PC_7) +#define M7_PIN_SPI_CS (PB_5) +#define M8_PIN_SPI_CS (PB_3) + +#define NUMBER_OF_MAGNETOMETERS 8 + +#endif // _MAG_RING_TARGETS_H_
--- a/motor/motor.h Mon Jul 02 07:41:35 2018 +0000 +++ b/motor/motor.h Fri Aug 03 01:32:16 2018 +0000 @@ -23,13 +23,23 @@ return (float)_TXcm_s/(_onDelay+_offDelay); } void reset() { + if(_lock){ + return; + } _pos=0; } void to(float p); float position() { + if(_lock){ + return -1; + } return _pos; } + bool moving(){ return _lock; } void setPosition(float p) { + if(_lock){ + return; + } _pos = p; } void stop(void);
--- a/motor/motor_targets.h Mon Jul 02 07:41:35 2018 +0000 +++ b/motor/motor_targets.h Fri Aug 03 01:32:16 2018 +0000 @@ -1,6 +1,6 @@ /** ****************************************************************************** - * @file altimu_10_v5_targets.h + * @file motor_targets.h * @author AST / EST * @version V0.0.1 * @date 14-April-2015
--- a/xyz_sensor_platform.cpp Mon Jul 02 07:41:35 2018 +0000 +++ b/xyz_sensor_platform.cpp Fri Aug 03 01:32:16 2018 +0000 @@ -7,7 +7,7 @@ yEnd(MOTOR_Y_PINT_END), zZero(MOTOR_Z_PINT_ZERO), zEnd(MOTOR_Z_PINT_END), - movedTimes(0) + _movedTimes(0) { motorX = new CD_2D34M("motorX\0", \ MOTOR_X_POUT_DIRECTION, \ @@ -23,35 +23,38 @@ MOTOR_Z_POUT_PU, \ MOTOR_Z_POUT_DR, \ MOTOR_Z_POUT_MF); - sensor = AltIMU_10_v5::Instance(); - gyroscope = sensor->GetGyroscope(); - accelerometer = sensor->GetAccelerometer(); - magnetometer = sensor->magnetometer; - temp_sensor = sensor->pt_sensor; + sensor = MagRing::Instance(); +// gyroscope = sensor->GetGyroscope(); + //magnetometer = sensor->magnetometers; init(); } void XYZSensorPlatform::init(void) { - uint8_t id1, id2; +// uint8_t id1, id2; /* Determine ID of Gyro & Motion Sensor */ - CALL_METH(gyroscope, read_id, &id1, 0x0); - CALL_METH(accelerometer, read_id, &id2, 0x0); - printf("\r\ngyr_addr: %p, accer_addr: %p\r\n",gyroscope,accelerometer); +// CALL_METH(gyroscope, read_id, &id1, 0x0); +// CALL_METH(accelerometer, read_id, &id2, 0x0); +// printf("\r\ngyr_addr: %p, accer_addr: %p\r\n",gyroscope,accelerometer); //#ifdef MOTOR_INITIAL //#endif } void XYZSensorPlatform::reset() { /** Motor Initial **/ - movedTimes = 0; + _movedTimes = 0; x = 1; y = 1; z = 1; int step = 0; - while(xEnd!=0 && step++ < 10) go_right(); + while(xEnd!=0 && step++ < 10) + { + go_right(); + _movedTimes = 0; + } while(xZero!=0) { go_left(); + _movedTimes = 0; wait(0.01); } go_right(); @@ -59,6 +62,7 @@ while(yEnd!=0 && step++ < 10) go_forward(); while(yZero!=0 && yZero != 0) { go_backward(); + _movedTimes = 0; wait(0.01); } go_forward(); @@ -66,6 +70,7 @@ while(zEnd!=0 && step++ < 10) go_up(); while(zZero!=0) { go_down(); + _movedTimes = 0; wait(0.01); } go_up(); @@ -125,3 +130,14 @@ } else if(yEnd == 1) motorY->to(y); } +void XYZSensorPlatform::checkMovedTimes() +{ + if(_movedTimes++>=CALIBRATION_TIME) + { +// float p[3] = {0.0}; +// position(p); + reset(); +// to(p[0],p[1],p[2]); +// _movedTimes = 0; + } +}
--- a/xyz_sensor_platform.h Mon Jul 02 07:41:35 2018 +0000 +++ b/xyz_sensor_platform.h Fri Aug 03 01:32:16 2018 +0000 @@ -3,7 +3,7 @@ /*** Includes ----------------------------------------------------------------- ***/ //#include "mbed.h" -#include "altimu_10_v5.h" +#include "mag_ring.h" #include "motor.h" #include "motor_targets.h" #define MOTOR_INITIAL @@ -16,6 +16,10 @@ int32_t AXIS_Z; } AxesRaw_TypeDef; +typedef struct { + AxesRaw_TypeDef Magnetic[NUMBER_OF_MAGNETOMETERS]; +} MagneticArray_TypeDef; + class XYZSensorPlatform { public: @@ -30,6 +34,8 @@ void go_right(); void go_left(); + bool isMoving(){ return motorX->moving() || motorY->moving() || motorZ->moving(); } + void set_speed(float speed) { motorX->setSpeed(speed); motorY->setSpeed(speed); @@ -55,16 +61,25 @@ void to(float x, float y, float z) ; - AxesRaw_TypeDef get_mag() { - AxesRaw_TypeDef ret; + MagneticArray_TypeDef get_mag() { + MagneticArray_TypeDef ret; magnetometer->get_m_axes((int32_t *)&ret); return ret; } - int get_mag_raw(int16_t *ret) { - return magnetometer->get_m_axes_raw(ret); + int get_mag_raw(int16_t ret[][3]) { + return sensor->get_m_axes_raw(ret); } + int get_mag_raw(int magIndex, int16_t *ret) { + return sensor->get_m_axes_raw(magIndex, ret); + } + + void resetMagnetometer(int magIndex) + { + sensor->resetMagnetometer(magIndex); + } + /* AxesRaw_TypeDef get_acc() { AxesRaw_TypeDef ret; accelerometer->get_x_axes((int32_t *)&ret); @@ -76,26 +91,18 @@ gyroscope->get_g_axes((int32_t *)&ret); return ret; } - - void setSensorI2cFrequency(int hz){ sensor->setI2cFrequency(hz); } + */ + void setSensorSpiFrequency(int hz){ sensor->setSpiFrequency(hz); } private: - void checkMovedTimes(){ - if(movedTimes++>=CALIBRATION_TIME) - { - float p[3] = {0.0}; - position(p); - reset(); - to(p[0],p[1],p[2]); - } - } + void checkMovedTimes(); Motor *motorX, *motorY, *motorZ; float x,y,z; - int movedTimes; + int _movedTimes; InterruptIn xZero, xEnd, yZero, yEnd, zZero, zEnd; - AltIMU_10_v5 *sensor; - GyroSensor *gyroscope; - MotionSensor *accelerometer; + MagRing *sensor; + //GyroSensor *gyroscope; + //MotionSensor *accelerometer; MagneticSensor *magnetometer; - TempSensor *temp_sensor; + //TempSensor *temp_sensor; }; #endif // __XYZ_SENSOR_PLATFORM_H \ No newline at end of file