library for using LSM303DM chip

Files at this revision

API Documentation at this revision

Comitter:
fin4478
Date:
Fri Nov 08 14:44:00 2013 +0000
Parent:
2:1052b1b97cc2
Child:
4:52892e52889a
Commit message:
accel init bug fixed

Changed in this revision

LSM303.cpp Show annotated file Show diff for this revision Revisions of this file
LSM303.h Show annotated file Show diff for this revision Revisions of this file
--- a/LSM303.cpp	Sun Oct 13 02:38:38 2013 +0000
+++ b/LSM303.cpp	Fri Nov 08 14:44:00 2013 +0000
@@ -23,6 +23,7 @@
     m_min.y = 0;
     m_min.z = 0;
 #endif
+    LSM303_write(0x27, CTRL_REG1_A);
     LSM303_write(0x00, CTRL_REG4_A);
     LSM303_write(MAG_SCALE_1_3, CRB_REG_M); //magnetic scale = +/-1.3Gauss
     LSM303_write(0x00, MR_REG_M);  // 0x00 = continouous conversion mode
@@ -93,8 +94,8 @@
     a->z /= mag;
 }
 
-int LSM303::getLSM303_accel()
-{
+void LSM303::getLSM303_accel()
+{   
     char data[1] = { OUT_X_L_A | (1<<7)};
     char out[6] = {0,0,0,0,0,0};
     i2c.write( LSM303_ACC, data,1);
@@ -102,8 +103,7 @@
 
     a.x = short( (((short)out[1]) << 8) | out[0] );
     a.y = short( (((short)out[3]) << 8) | out[2] );
-    a.z = short( (((short)out[5]) << 8) | out[4] );
-    return  0;
+    a.z = short( (((short)out[5]) << 8) | out[4] );    
 }
 
 void LSM303::getLSM303_mag()
--- a/LSM303.h	Sun Oct 13 02:38:38 2013 +0000
+++ b/LSM303.h	Fri Nov 08 14:44:00 2013 +0000
@@ -114,7 +114,7 @@
     int setup();
     
     void getLSM303_mag();
-    int getLSM303_accel();
+    void getLSM303_accel();
     int LSM303_read(int address);
     int LSM303_write(int data, int address);