Changed default pin defines to match those available on MTS boards
Dependencies: HTS221 LPS22HB LSM303AGR LSM6DSL
Fork of X_NUCLEO_IKS01A2 by
XNucleoIKS01A2.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file XNucleoIKS01A2.cpp 00004 * @author CLab 00005 * @version V1.0.0 00006 * @date 9-August-2016 00007 * @brief Implementation file for the X_NUCLEO_IKS01A2 singleton class 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Includes ------------------------------------------------------------------*/ 00039 #include "mbed.h" 00040 #include "XNucleoIKS01A2.h" 00041 00042 /* Static variables ----------------------------------------------------------*/ 00043 XNucleoIKS01A2 *XNucleoIKS01A2::_instance = NULL; 00044 00045 00046 /* Methods -------------------------------------------------------------------*/ 00047 /** 00048 * @brief Constructor 00049 */ 00050 XNucleoIKS01A2::XNucleoIKS01A2(DevI2C *ext_i2c, PinName int1, PinName int2) : dev_i2c(ext_i2c), 00051 ht_sensor(new HTS221Sensor(dev_i2c)), 00052 magnetometer(new LSM303AGRMagSensor(dev_i2c)), 00053 accelerometer(new LSM303AGRAccSensor(dev_i2c)), 00054 pt_sensor(new LPS22HBSensor(dev_i2c)), 00055 acc_gyro(new LSM6DSLSensor(dev_i2c, LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH, int1, int2)) 00056 { 00057 ht_sensor->init(NULL); 00058 magnetometer->init(NULL); 00059 accelerometer->init(NULL); 00060 pt_sensor->init(NULL); 00061 acc_gyro->init(NULL); 00062 } 00063 00064 /** 00065 * @brief Get singleton instance 00066 * @return a pointer to the initialized singleton instance of class XNucleoIKS01A2. 00067 * A return value of NULL indicates an out of memory situation. 00068 * @param[in] ext_i2c (optional) pointer to an instance of DevI2C to be used 00069 * for communication on the expansion board. 00070 * Defaults to NULL. 00071 * Taken into account only on the very first call of one of the 'Instance' functions. 00072 * If not provided a new DevI2C will be created with standard 00073 * configuration parameters. 00074 * The used DevI2C object gets saved in instance variable dev_i2c. 00075 * @param[in] int1 LSM6DSL INT1 pin. 00076 * Taken into account only on the very first call of one of the 'Instance' functions. 00077 * It maps the INT1 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT1. 00078 * @param[in] int2 LSM6DSL INT1 pin. 00079 * Taken into account only on the very first call of one of the 'Instance' functions. 00080 * It maps the INT2 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT2. 00081 */ 00082 XNucleoIKS01A2 *XNucleoIKS01A2::instance(DevI2C *ext_i2c, PinName int1, PinName int2) { 00083 if(_instance == NULL) { 00084 if(ext_i2c == NULL) 00085 ext_i2c = new DevI2C(IKS01A2_PIN_I2C_SDA, IKS01A2_PIN_I2C_SCL); 00086 00087 if(ext_i2c != NULL) 00088 _instance = new XNucleoIKS01A2(ext_i2c, int1, int2); 00089 } 00090 00091 return _instance; 00092 } 00093 00094 /** 00095 * @brief Get singleton instance 00096 * @return a pointer to the initialized singleton instance of class X_NUCLEO_IKS01A1. 00097 * A return value of NULL indicates an out of memory situation. 00098 * @param[in] sda I2C data line pin. 00099 * Taken into account only on the very first call of one of the 'Instance' functions. 00100 * A new DevI2C will be created based on parameters 'sda' and 'scl'. 00101 * The used DevI2C object gets saved in instance variable dev_i2c. 00102 * @param[in] scl I2C clock line pin. 00103 * Taken into account only on the very first call of one of the 'Instance' functions. 00104 * A new DevI2C will be created based on parameters 'sda' and 'scl'. 00105 * The used DevI2C object gets saved in instance variable dev_i2c. 00106 * @param[in] int1 LSM6DSL INT1 pin. 00107 * Taken into account only on the very first call of one of the 'Instance' functions. 00108 * It maps the INT1 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT1. 00109 * @param[in] int2 LSM6DSL INT1 pin. 00110 * Taken into account only on the very first call of one of the 'Instance' functions. 00111 * It maps the INT2 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT2. 00112 */ 00113 XNucleoIKS01A2 *XNucleoIKS01A2::instance(PinName sda, PinName scl, PinName int1, PinName int2) { 00114 if(_instance == NULL) { 00115 DevI2C *ext_i2c = new DevI2C(sda, scl); 00116 00117 if(ext_i2c != NULL) 00118 _instance = new XNucleoIKS01A2(ext_i2c, int1, int2); 00119 } 00120 00121 return _instance; 00122 }
Generated on Thu Jul 14 2022 10:48:34 by
1.7.2
