Library to communicate with a ST LIS331DLH

Files at this revision

API Documentation at this revision

Comitter:
atommota
Date:
Fri Jan 07 16:31:35 2011 +0000
Parent:
3:147d95b7a525
Child:
5:3443fb9646bd
Commit message:
Added support to set full scale ranges of 2, 4, and 8g\s
Updated LIS331DLH datasheet web reference

Changed in this revision

LIS331.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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){