Beta
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_IKS01A2 by
Revision 2:49e6947ee5a7, committed 2016-11-28
- Comitter:
- cparata
- Date:
- Mon Nov 28 15:16:46 2016 +0000
- Parent:
- 1:bd2a01e81e6f
- Child:
- 3:2c8568da2e3a
- Commit message:
- Update library
Changed in this revision
x_nucleo_iks01a2.cpp | Show annotated file Show diff for this revision Revisions of this file |
x_nucleo_iks01a2.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/x_nucleo_iks01a2.cpp Mon Nov 28 14:56:18 2016 +0000 +++ b/x_nucleo_iks01a2.cpp Mon Nov 28 15:16:46 2016 +0000 @@ -47,23 +47,6 @@ /** * @brief Constructor */ -X_NUCLEO_IKS01A2::X_NUCLEO_IKS01A2(DevI2C *ext_i2c) : dev_i2c(ext_i2c), - ht_sensor(new HTS221Sensor(*dev_i2c)), - magnetometer(new LSM303AGR_MAG_Sensor(*dev_i2c)), - accelerometer(new LSM303AGR_ACC_Sensor(*dev_i2c)), - pt_sensor(new LPS22HBSensor(*dev_i2c)), - acc_gyro(new LSM6DSLSensor(*dev_i2c, IKS01A2_PIN_LSM6DSL_INT1, IKS01A2_PIN_LSM6DSL_INT2)) -{ - ht_sensor->Init(NULL); - magnetometer->Init(NULL); - accelerometer->Init(NULL); - pt_sensor->Init(NULL); - acc_gyro->Init(NULL); -} - -/** - * @brief Constructor - */ X_NUCLEO_IKS01A2::X_NUCLEO_IKS01A2(DevI2C *ext_i2c, PinName int1, PinName int2) : dev_i2c(ext_i2c), ht_sensor(new HTS221Sensor(*dev_i2c)), magnetometer(new LSM303AGR_MAG_Sensor(*dev_i2c)), @@ -89,38 +72,20 @@ * 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] int1 LSM6DSL INT1 pin. + * Taken into account only on the very first call of one of the 'Instance' functions. + * It maps the INT1 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT1. + * @param[in] int2 LSM6DSL INT1 pin. + * Taken into account only on the very first call of one of the 'Instance' functions. + * It maps the INT2 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT2. */ -X_NUCLEO_IKS01A2* X_NUCLEO_IKS01A2::Instance(DevI2C *ext_i2c) { +X_NUCLEO_IKS01A2* X_NUCLEO_IKS01A2::Instance(DevI2C *ext_i2c, PinName int1, PinName int2) { if(_instance == NULL) { if(ext_i2c == NULL) ext_i2c = new DevI2C(IKS01A2_PIN_I2C_SDA, IKS01A2_PIN_I2C_SCL); if(ext_i2c != NULL) - _instance = new X_NUCLEO_IKS01A2(ext_i2c); - } - - return _instance; -} - -/** - * @brief Get singleton instance - * @return a pointer to the initialized singleton instance of class X_NUCLEO_IKS01A1. - * A return value of NULL indicates an out of memory situation. - * @param[in] sda I2C data line pin. - * Taken into account only on the very first call of one of the 'Instance' functions. - * A new DevI2C will be created based on parameters 'sda' and 'scl'. - * The used DevI2C object gets saved in instance variable dev_i2c. - * @param[in] scl I2C clock line pin. - * Taken into account only on the very first call of one of the 'Instance' functions. - * A new DevI2C will be created based on parameters 'sda' and 'scl'. - * The used DevI2C object gets saved in instance variable dev_i2c. - */ -X_NUCLEO_IKS01A2* X_NUCLEO_IKS01A2::Instance(PinName sda, PinName scl) { - if(_instance == NULL) { - DevI2C *ext_i2c = new DevI2C(sda, scl); - - if(ext_i2c != NULL) - _instance = new X_NUCLEO_IKS01A2(ext_i2c); + _instance = new X_NUCLEO_IKS01A2(ext_i2c, int1, int2); } return _instance; @@ -140,10 +105,10 @@ * The used DevI2C object gets saved in instance variable dev_i2c. * @param[in] int1 LSM6DSL INT1 pin. * Taken into account only on the very first call of one of the 'Instance' functions. - * It maps the INT1 pin for LSM6DSL. + * It maps the INT1 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT1. * @param[in] int2 LSM6DSL INT1 pin. * Taken into account only on the very first call of one of the 'Instance' functions. - * It maps the INT2 pin for LSM6DSL. + * It maps the INT2 pin for LSM6DSL. Defaults to IKS01A2_PIN_LSM6DSL_INT2. */ X_NUCLEO_IKS01A2* X_NUCLEO_IKS01A2::Instance(PinName sda, PinName scl, PinName int1, PinName int2) { if(_instance == NULL) {
--- a/x_nucleo_iks01a2.h Mon Nov 28 14:56:18 2016 +0000 +++ b/x_nucleo_iks01a2.h Mon Nov 28 15:16:46 2016 +0000 @@ -81,8 +81,7 @@ class X_NUCLEO_IKS01A2 { protected: - X_NUCLEO_IKS01A2(DevI2C *ext_i2c); - X_NUCLEO_IKS01A2(DevI2C *ext_i2c, PinName int1, PinName int2); + X_NUCLEO_IKS01A2(DevI2C *ext_i2c, PinName int1 = IKS01A2_PIN_LSM6DSL_INT1, PinName int2 = IKS01A2_PIN_LSM6DSL_INT2); ~X_NUCLEO_IKS01A2(void) { /* should never be called */ @@ -90,9 +89,8 @@ } public: - static X_NUCLEO_IKS01A2* Instance(DevI2C *ext_i2c = NULL); - static X_NUCLEO_IKS01A2* Instance(PinName sda, PinName scl); - static X_NUCLEO_IKS01A2* Instance(PinName sda, PinName scl, PinName int1, PinName int2); + static X_NUCLEO_IKS01A2* Instance(DevI2C *ext_i2c = NULL, PinName int1 = IKS01A2_PIN_LSM6DSL_INT1, PinName int2 = IKS01A2_PIN_LSM6DSL_INT2); + static X_NUCLEO_IKS01A2* Instance(PinName sda, PinName scl, PinName int1 = IKS01A2_PIN_LSM6DSL_INT1, PinName int2 = IKS01A2_PIN_LSM6DSL_INT2); DevI2C *dev_i2c;