My attempt to made a more useful lib. You can get the accelerator and magnetometer.

Fork of LSM303DLH by Michael Shimniok

Revision:
4:4f2ed3f8726c
Parent:
3:9b4ff901b5c9
Child:
5:48722ae56546
--- a/LSM303DLH.cpp	Sun Aug 06 00:43:57 2017 +0000
+++ b/LSM303DLH.cpp	Sun Aug 06 03:19:17 2017 +0000
@@ -142,18 +142,19 @@
  
     m_ptr_I2C->frequency(100000);
     
-       
-    debug("in ACC \n");
-    reg_v = 0;
-    reg_v |= 0x01 << 5;     /* Normal mode  */
-    reg_v |= 0x07;          /* X/Y/Z axis enable. */
+    ((Ctrl_Reg1_A_t*)&reg_v)->byte = 0;
+    ((Ctrl_Reg1_A_t*)&reg_v)->ODR |= 0b0010;     /* Normal mode  */
+    ((Ctrl_Reg1_A_t*)&reg_v)->Xen |= 1;          /* X/Y/Z axis enable. */
+    ((Ctrl_Reg1_A_t*)&reg_v)->Yen |= 1;
+    ((Ctrl_Reg1_A_t*)&reg_v)->Zen |= 1;
     write_reg(addr_acc,CTRL_REG1_A,reg_v);
-    reg_v = 0;
-    read_reg(addr_acc,CTRL_REG1_A,&reg_v);
+    //not sure if we need to read the register
+    //reg_v = 0;
+    //read_reg(addr_acc,CTRL_REG1_A,&reg_v);
 
     reg_v = 0;
     reg_v |= 0x01 << 7;     //full read
-    reg_v |= 0x01 << 3;     //hi res
+    //reg_v |= 0x01 << 3;     //hi res
     //reg_v |= 0x01 << 6;     /* 1: data MSB @ lower address */
     reg_v |= 0x01 << 4;     /* +/- 4g */
     write_reg(addr_acc,CTRL_REG4_A,reg_v);