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