X_NUCLEO_IKS01A3 sensor board modified library
Dependencies: STTS751 LPS22HH LIS2MDL HTS221 LIS2DW12 LSM6DSO
Dependents: LELEC2811_LPS22HH_Altimeter LELEC2811_LISDW12_Accelerometer LELEC2811_LIS2MDL_Magnetometer LELEC2811_IKS01A3_Multisensors
XNucleoIKS01A3.h@13:8814d413ae68, 2019-09-17 (annotated)
- Committer:
- martlefebvre94
- Date:
- Tue Sep 17 12:32:19 2019 +0000
- Revision:
- 13:8814d413ae68
- Parent:
- 5:463962d6f485
New configuration functions for LSM6DSO accelerometer and gyroscope
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cparata | 0:cbbff52ff25a | 1 | /** |
cparata | 0:cbbff52ff25a | 2 | ****************************************************************************** |
cparata | 0:cbbff52ff25a | 3 | * @file XNucleoIKS01A3.h |
cparata | 0:cbbff52ff25a | 4 | * @author SRA |
cparata | 0:cbbff52ff25a | 5 | * @version V1.0.0 |
cparata | 0:cbbff52ff25a | 6 | * @date 5-March-2019 |
cparata | 0:cbbff52ff25a | 7 | * @brief Header file for class XNucleoIKS01A3 representing a X-NUCLEO-IKS01A3 |
cparata | 0:cbbff52ff25a | 8 | * expansion board |
cparata | 0:cbbff52ff25a | 9 | ****************************************************************************** |
cparata | 0:cbbff52ff25a | 10 | * @attention |
cparata | 0:cbbff52ff25a | 11 | * |
cparata | 0:cbbff52ff25a | 12 | * <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2> |
cparata | 0:cbbff52ff25a | 13 | * |
cparata | 0:cbbff52ff25a | 14 | * Redistribution and use in source and binary forms, with or without modification, |
cparata | 0:cbbff52ff25a | 15 | * are permitted provided that the following conditions are met: |
cparata | 0:cbbff52ff25a | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
cparata | 0:cbbff52ff25a | 17 | * this list of conditions and the following disclaimer. |
cparata | 0:cbbff52ff25a | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
cparata | 0:cbbff52ff25a | 19 | * this list of conditions and the following disclaimer in the documentation |
cparata | 0:cbbff52ff25a | 20 | * and/or other materials provided with the distribution. |
cparata | 0:cbbff52ff25a | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
cparata | 0:cbbff52ff25a | 22 | * may be used to endorse or promote products derived from this software |
cparata | 0:cbbff52ff25a | 23 | * without specific prior written permission. |
cparata | 0:cbbff52ff25a | 24 | * |
cparata | 0:cbbff52ff25a | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
cparata | 0:cbbff52ff25a | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
cparata | 0:cbbff52ff25a | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
cparata | 0:cbbff52ff25a | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
cparata | 0:cbbff52ff25a | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
cparata | 0:cbbff52ff25a | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
cparata | 0:cbbff52ff25a | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
cparata | 0:cbbff52ff25a | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
cparata | 0:cbbff52ff25a | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
cparata | 0:cbbff52ff25a | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
cparata | 0:cbbff52ff25a | 35 | * |
cparata | 0:cbbff52ff25a | 36 | ****************************************************************************** |
cparata | 0:cbbff52ff25a | 37 | */ |
cparata | 0:cbbff52ff25a | 38 | |
cparata | 0:cbbff52ff25a | 39 | /* Define to prevent from recursive inclusion --------------------------------*/ |
cparata | 0:cbbff52ff25a | 40 | #ifndef __X_NUCLEO_IKS01A3_H |
cparata | 0:cbbff52ff25a | 41 | #define __X_NUCLEO_IKS01A3_H |
cparata | 0:cbbff52ff25a | 42 | |
cparata | 0:cbbff52ff25a | 43 | /* Includes ------------------------------------------------------------------*/ |
cparata | 0:cbbff52ff25a | 44 | #include "mbed.h" |
cparata | 0:cbbff52ff25a | 45 | #include "x_nucleo_iks01a3_targets.h" |
cparata | 0:cbbff52ff25a | 46 | #include "HTS221Sensor.h" |
cparata | 0:cbbff52ff25a | 47 | #include "LIS2DW12Sensor.h" |
cparata | 0:cbbff52ff25a | 48 | #include "LIS2MDLSensor.h" |
cparata | 0:cbbff52ff25a | 49 | #include "LPS22HHSensor.h" |
cparata | 0:cbbff52ff25a | 50 | #include "LSM6DSOSensor.h" |
cparata | 0:cbbff52ff25a | 51 | #include "STTS751Sensor.h" |
cparata | 0:cbbff52ff25a | 52 | #include "DevI2C.h" |
cparata | 0:cbbff52ff25a | 53 | |
cparata | 0:cbbff52ff25a | 54 | /* Macros -------------------------------------------------------------------*/ |
cparata | 0:cbbff52ff25a | 55 | #define CALL_METH(obj, meth, param, ret) ((obj == NULL) ? \ |
cparata | 0:cbbff52ff25a | 56 | ((*(param) = (ret)), 0) : \ |
cparata | 0:cbbff52ff25a | 57 | ((obj)->meth(param)) \ |
cparata | 0:cbbff52ff25a | 58 | ) |
cparata | 0:cbbff52ff25a | 59 | |
cparata | 0:cbbff52ff25a | 60 | /* Classes -------------------------------------------------------------------*/ |
cparata | 5:463962d6f485 | 61 | /** Class XNucleoIKS01A3 is intended to represent the MEMS Inertial & Environmental |
cparata | 0:cbbff52ff25a | 62 | * Nucleo Expansion Board with the same name. |
cparata | 0:cbbff52ff25a | 63 | * |
cparata | 0:cbbff52ff25a | 64 | * The expansion board is featuring basically four IPs:\n |
cparata | 0:cbbff52ff25a | 65 | * -# a HTS221 Relative Humidity and Temperature Sensor\n |
cparata | 0:cbbff52ff25a | 66 | * -# a LPS22HH MEMS Pressure Sensor (and Temperature Sensor)\n |
cparata | 0:cbbff52ff25a | 67 | * -# a STTS751 MEMS Temperature Sensor\n |
cparata | 0:cbbff52ff25a | 68 | * -# a LIS2DW12 3D Acceleromenter\n |
cparata | 0:cbbff52ff25a | 69 | * -# a LIS2MDL 3D Magnetometer\n |
cparata | 0:cbbff52ff25a | 70 | * -# and a LSM6DSO 3D Acceleromenter and 3D Gyroscope\n |
cparata | 0:cbbff52ff25a | 71 | * |
cparata | 0:cbbff52ff25a | 72 | * The expansion board features also a DIL 24-pin socket which makes it possible |
cparata | 5:463962d6f485 | 73 | * to add further MEMS adapters and other sensors (e.g. UV index). |
cparata | 0:cbbff52ff25a | 74 | * |
cparata | 0:cbbff52ff25a | 75 | * It is intentionally implemented as a singleton because only one |
cparata | 0:cbbff52ff25a | 76 | * X_NUCLEO_IKS01A3 at a time might be deployed in a HW component stack.\n |
cparata | 5:463962d6f485 | 77 | * In order to get the singleton instance you have to call class method `Instance()`, |
cparata | 0:cbbff52ff25a | 78 | * e.g.: |
cparata | 0:cbbff52ff25a | 79 | * @code |
cparata | 0:cbbff52ff25a | 80 | * // Inertial & Environmental expansion board singleton instance |
cparata | 0:cbbff52ff25a | 81 | * static X_NUCLEO_IKS01A3 *<TODO>_expansion_board = X_NUCLEO_IKS01A3::Instance(); |
cparata | 0:cbbff52ff25a | 82 | * @endcode |
cparata | 0:cbbff52ff25a | 83 | */ |
cparata | 5:463962d6f485 | 84 | class XNucleoIKS01A3 { |
cparata | 5:463962d6f485 | 85 | protected: |
cparata | 0:cbbff52ff25a | 86 | XNucleoIKS01A3(DevI2C *ext_i2c, PinName lsm6dso_int1, PinName lsm6dso_int2, PinName lis2dw12_int1, PinName lps22hh_int, PinName stts751_int); |
cparata | 0:cbbff52ff25a | 87 | |
cparata | 5:463962d6f485 | 88 | ~XNucleoIKS01A3(void) |
cparata | 5:463962d6f485 | 89 | { |
cparata | 0:cbbff52ff25a | 90 | /* should never be called */ |
cparata | 0:cbbff52ff25a | 91 | error("Trial to delete XNucleoIKS01A3 singleton!\n"); |
cparata | 0:cbbff52ff25a | 92 | } |
cparata | 0:cbbff52ff25a | 93 | |
cparata | 5:463962d6f485 | 94 | public: |
cparata | 5:463962d6f485 | 95 | static XNucleoIKS01A3 *instance(DevI2C *ext_i2c = NULL, PinName lsm6dso_int1 = IKS01A3_PIN_LSM6DSO_INT1, PinName lsm6dso_int2 = IKS01A3_PIN_LSM6DSO_INT2, PinName lis2dw12_int1 = IKS01A3_PIN_LIS2DW12_INT1, PinName lps22hh_int = IKS01A3_PIN_LPS22HH_INT, PinName stts751_int = IKS01A3_PIN_STTS751_INT); |
cparata | 5:463962d6f485 | 96 | static XNucleoIKS01A3 *instance(PinName sda, PinName scl, PinName lsm6dso_int1 = IKS01A3_PIN_LSM6DSO_INT1, PinName lsm6dso_int2 = IKS01A3_PIN_LSM6DSO_INT2, PinName lis2dw12_int1 = IKS01A3_PIN_LIS2DW12_INT1, PinName lps22hh_int = IKS01A3_PIN_LPS22HH_INT, PinName stts751_int = IKS01A3_PIN_STTS751_INT); |
cparata | 0:cbbff52ff25a | 97 | |
cparata | 0:cbbff52ff25a | 98 | DevI2C *dev_i2c; |
cparata | 0:cbbff52ff25a | 99 | |
cparata | 0:cbbff52ff25a | 100 | HTS221Sensor *ht_sensor; |
cparata | 0:cbbff52ff25a | 101 | LIS2MDLSensor *magnetometer; |
cparata | 0:cbbff52ff25a | 102 | LIS2DW12Sensor *accelerometer; |
cparata | 0:cbbff52ff25a | 103 | LPS22HHSensor *pt_sensor; |
cparata | 0:cbbff52ff25a | 104 | LSM6DSOSensor *acc_gyro; |
cparata | 0:cbbff52ff25a | 105 | STTS751Sensor *t_sensor; |
cparata | 0:cbbff52ff25a | 106 | |
cparata | 5:463962d6f485 | 107 | private: |
cparata | 0:cbbff52ff25a | 108 | static XNucleoIKS01A3 *_instance; |
cparata | 0:cbbff52ff25a | 109 | }; |
cparata | 0:cbbff52ff25a | 110 | |
cparata | 0:cbbff52ff25a | 111 | #endif /* __X_NUCLEO_IKS01A3_H */ |