Ultra-compact high-performance eCompass module: ultra-low power 3D accelerometer and 3D magnetometer.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client LSM303AGR_JS ... more
Diff: LSM303AGRAccSensor.cpp
- Revision:
- 2:e37be5550633
- Parent:
- 1:86d530a7f949
--- a/LSM303AGRAccSensor.cpp Wed Sep 27 16:49:51 2017 +0200 +++ b/LSM303AGRAccSensor.cpp Mon Oct 02 09:29:33 2017 +0200 @@ -43,6 +43,24 @@ /* Class Implementation ------------------------------------------------------*/ +LSM303AGRAccSensor::LSM303AGRAccSensor(SPI *spi, PinName cs_pin, PinName int1_pin, PinName int2_pin) : + _dev_spi(spi), _cs_pin(cs_pin), _int1_pin(int1_pin), _int2_pin(int2_pin) // SPI3W ONLY +{ + assert (spi); + if (cs_pin == NC) + { + printf ("ERROR LSM303AGRAccSensor CS MUST NOT BE NC\n\r"); + _dev_spi = NULL; + _dev_i2c=NULL; + return; + } + _cs_pin = 0; // enable SPI3W disable I2C + _dev_i2c=NULL; + + LSM303AGR_ACC_W_SPI_mode((void *)this, LSM303AGR_ACC_SIM_3_WIRES); +} + + /** Constructor * @param i2c object of an helper class which handles the I2C peripheral * @param address the address of the component's instance @@ -51,6 +69,7 @@ _dev_i2c(i2c), _address(address), _cs_pin(NC), _int1_pin(int1_pin), _int2_pin(int2_pin) { assert (i2c); + _dev_spi = NULL; }; /**