Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: LIS331.cpp
- Revision:
- 4:c3df518a938e
- Parent:
- 3:147d95b7a525
- Child:
- 5:3443fb9646bd
diff -r 147d95b7a525 -r c3df518a938e LIS331.cpp
--- a/LIS331.cpp Wed Nov 17 18:34:25 2010 +0000
+++ b/LIS331.cpp Fri Jan 07 16:31:35 2011 +0000
@@ -4,12 +4,12 @@
*
* @section DESCRIPTION
*
- * LIS331 triple axis, digital interface, accelerometer.
+ * LIS331DLH triple axis, digital interface, accelerometer.
* Based off Aaron Berk's ITG3200 Gyro Library
*
* Datasheet:
*
- * http://www.st.com/stonline/products/literature/ds/13951.pdf
+ * http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00213470.pdf
*/
/**
@@ -34,14 +34,6 @@
tx[1] = 0x3F;
i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, tx, 2);
-
- // Set Big endian bit
- //tx2[0] = CTRL_REG_4;
- //i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, tx2, 1); // Request control reg 4
- //i2c_.read((LIS331_I2C_ADDRESS << 1) | 0x01, rx, 1); //Read control reg 4
- //tx2[1] = rx[0] | 1<<7; // Set bit 7
- //i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, tx2, 2);
-
}
char LIS331::getWhoAmI(void){
@@ -101,6 +93,37 @@
}
+void LIS331:setFullScaleRange8g(void){ // Does not preserve rest of CTRL_REG_4!
+
+ char tx[2];
+ tx[0] = CTRL_REG_4;
+ tx[1] = 0x30;
+
+ i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, &tx, 2);
+
+}
+
+void LIS331:setFullScaleRange4g(void){ // Does not preserve rest of CTRL_REG_4!
+
+ char tx[2];
+ tx[0] = CTRL_REG_4;
+ tx[1] = 0x10;
+
+ i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, &tx, 2);
+
+}
+
+
+void LIS331:setFullScaleRange2g(void){ // Does not preserve rest of CTRL_REG_4!
+
+ char tx[2];
+ tx[0] = CTRL_REG_4;
+ tx[1] = 0x00;
+
+ i2c_.write((LIS331_I2C_ADDRESS << 1) & 0xFE, &tx, 2);
+
+}
+
char LIS331::getAccelStatus(void){