void LSM9DS0::setUpGyroscope(void) { // Set Up the Configuration for the Gyroscope Control Register 1 /* // Set the Output Data Rate uint8_t config1 = lsm_gyrodatarate; // Set the Power Down Mode Enable config1 |= lsm_gyromode; // Set the Gyroscpe Z-Axis Enable config1 |= lsm_gyrozen; // Set the Gyroscpe Y-Axis Enable config1 |= lsm_gyroyen; // Set the Gyroscpe X-Axis Enable config1 |= lsm_gyroxen; */ uint8_t config1 = LSM9DS0_REG_GYRO_CTRL_REG1_PD_NORMAL | // Normal Mode LSM9DS0_REG_GYRO_CTRL_REG1_ZEN_ENABLE | // Gyroscope Z-Axis Enabled LSM9DS0_REG_GYRO_CTRL_REG1_YEN_ENABLE | // Gyroscope Y-Axis Enabled LSM9DS0_REG_GYRO_CTRL_REG1_XEN_ENABLE; // Gyroscope X-Axis Enabled config1 |= lsm_gyrodatarate; // Output Data Rate and Bandwidth Selection // Write the configuration to the Gyroscope Control Register 1 writeRegister(lsm_i2cAddressG, LSM9DS0_REG_GYRO_CTRL_REG1, config1); // Wait for the configuration to complete delay(lsm_conversionDelay); // Set Up the Configuration for the Gyroscope Control Register 4 /* // Set the Block Data Update uint8_t config4 = lsm_gyroblockdata; // Set the Big/Little Endian Data Selection config4 |= lsm_gyroendiandata; // Set the Full Scale Selection config4 |= lsm_gyroscale; // Set the Self-Test Enable config4 |= lsm_gyroselftest; // Set the SPI Serial Interface Mode Selection config4 |= lsm_gyrospiwire; */ uint8_t config4 = LSM9DS0_REG_GYRO_CTRL_REG4_BDU_CONTINUOUS | // Continuous Update LSM9DS0_REG_GYRO_CTRL_REG4_BLE_LSB | // Data LSB @ Lower Address LSM9DS0_REG_GYRO_CTRL_REG4_ST_NORMAL | // Normal Mode LSM9DS0_REG_GYRO_CTRL_REG4_SIM_4WIRE; // 4-Wire Interface config4 |= lsm_gyroscale; // Full-Scale Selection // Write the configuration to the Gyroscope Control Register 4 writeRegister(lsm_i2cAddressG, LSM9DS0_REG_GYRO_CTRL_REG4, config4); // Wait for the configuration to complete delay(lsm_conversionDelay); } /**************************************************************************/ /* Sets up the Accelerometer */ /**************************************************************************/ void LSM9DS0::setUpAccelerometer(void) { // Set Up the Configuration for the Accelerometer/Magnetometer Control Register 1 /* // Set the Acceleration Output Data Rate uint8_t config1 = lsm_acceldatarate; // Set the Block Data Update for Acceleration and Magnetic Data config1 |= lsm_accelmagblockdata; // Set the Acceleration Z-Axis Enable config1 |= lsm_accelzen; // Set the Acceleration Y-Axis Enable config1 |= lsm_accelyen; // Set the Acceleration X-Axis Enable config1 |= lsm_accelxen; */ uint8_t config1 = LSM9DS0_REG_ACCELMAG_CTRL_REG1_BDU_CONTINUOUS | // Continuous Update LSM9DS0_REG_ACCELMAG_CTRL_REG1_AZEN_ENABLE | // Acceleration Z-Axis Enabled LSM9DS0_REG_ACCELMAG_CTRL_REG1_AYEN_ENABLE | // Acceleration Y-Axis Enabled LSM9DS0_REG_ACCELMAG_CTRL_REG1_AXEN_ENABLE; // Acceleration X-Axis Enabled config1 |= lsm_acceldatarate; // Acceleration Data Rate Configuration // Write the configuration to the Accelerometer/Magnetometer Control Register 1 writeRegister(lsm_i2cAddressXM, LSM9DS0_REG_ACCELMAG_CTRL_REG1, config1); // Wait for the configuration to complete delay(lsm_conversionDelay); // Set Up the Configuration for the Accelerometer/Magnetometer Control Register 2 /* // Set the Accelerometer Anti-Alias Filter Bandwidth uint8_t config2 = lsm_accelbandwidth; // Set the Acceleration Full-Scale Selection config2 |= lsm_accelrange; // Set the Acceleration Self-Test Enable config2 |= lsm_sccelselftest; // Set the SPI Serial Interface Mode Selection config2 |= lsm_accelmagspiwire; */ uint8_t config2 = LSM9DS0_REG_ACCELMAG_CTRL_REG2_ABW_773 | // 773 Hz, Accelerometer Anti-Alias Filter Bandwidth LSM9DS0_REG_ACCELMAG_CTRL_REG2_AST_NORMAL | // Normal Mode LSM9DS0_REG_ACCELMAG_CTRL_REG2_SIM_4WIRE; // 4-Wire Interface config2 |= lsm_accelrange; // Acceleration Full-Scale Selection // Write the configuration to the Accelerometer/Magnetometer Control Register 2 writeRegister(lsm_i2cAddressXM, LSM9DS0_REG_ACCELMAG_CTRL_REG2, config2); // Wait for the configuration to complete delay(lsm_conversionDelay); } /**************************************************************************/ /* Sets up the Magnetometer */ /**************************************************************************/ void LSM9DS0::setUpMagnetometer(void) { // Set Up the Configuration for the Accelerometer/Magnetometer Control Register 5 /* // Set the Temperature Sensor Enable uint8_t config5 = lsm_tempsensor; // Set the Magnetic Resolution Selection config5 |= lsm_magresolution; // Set the Magnetic Data Rate Selection config5 |= lsm_magdatarate; // Set the Latch Interrupt Request on INT2_SRC Register config5 |= lsm_magintr2latch; // Set the Latch Interrupt Request on INT1_SRC Register config5 |= lsm_magintr1latch; */ uint8_t config5 = LSM9DS0_REG_ACCELMAG_CTRL_REG5_TEMP_ENABLED | // Temperature Sensor Enabled LSM9DS0_REG_ACCELMAG_CTRL_REG5_M_RES_HIGH; // Magnetic Resolution High config5 |= lsm_magdatarate; // Magnetic Data Rate Selection // Write the configuration to the Accelerometer/Magnetometer Control Register 5 writeRegister(lsm_i2cAddressXM, LSM9DS0_REG_ACCELMAG_CTRL_REG5, config5); // Wait for the configuration to complete delay(lsm_conversionDelay); // Set Up the Configuration for the Accelerometer/Magnetometer Control Register 6 // Set the Magnetic Full-Scale Selection uint8_t config6 = lsm_maggain; // Write the configuration to the Accelerometer/Magnetometer Control Register 6 writeRegister(lsm_i2cAddressXM, LSM9DS0_REG_ACCELMAG_CTRL_REG6, config6); // Wait for the configuration to complete delay(lsm_conversionDelay); // Set Up the Configuration for the Accelerometer/Magnetometer Control Register 7 uint8_t config7 = LSM9DS0_REG_ACCELMAG_CTRL_REG7_AHPM_NORMAL | // Normal Mode LSM9DS0_REG_ACCELMAG_CTRL_REG7_AFDS_BYPASS | // Internal Filter Bypassed LSM9DS0_REG_ACCELMAG_CTRL_REG7_MLP_MODR | // Magnetic Data Rate is Configured by MODR Bits LSM9DS0_REG_ACCELMAG_CTRL_REG7_MD_CONTINUOUS; // Continuous-Conversion Mode // Set the Magnetic Sensor Mode config7 |= lsm_magmode; // Write the configuration to the Accelerometer/Magnetometer Control Register 7 writeRegister(lsm_i2cAddressXM, LSM9DS0_REG_ACCELMAG_CTRL_REG7, config7); // Wait for the configuration to complete delay(lsm_conversionDelay); }