some correction to work nice

Dependents:   Minimu-9v2

Fork of L3GD20 by brian claus

Revision:
2:90eddd0eff29
Parent:
0:62dfce144cf7
--- a/L3GD20.h	Tue Nov 12 17:25:28 2013 +0000
+++ b/L3GD20.h	Sun Nov 17 17:59:04 2013 +0000
@@ -1,35 +1,16 @@
-/* Copyright (c) 2011 Pololu Corporation.  For more information, see
- * 
- * http://www.pololu.com/
- * http://forum.pololu.com/
- * 
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
 #ifndef __L3GD20_H
 #define __L3GD20_H
 
 #include "mbed.h"
 
+// Defines ////////////////////////////////////////////////////////////////
+
+// The Arduino two-wire interface uses a 7-bit number for the address, 
+// and sets the last bit correctly based on reads and writes
+// mbed I2C libraries take the 7-bit address shifted left 1 bit
+// #define GYR_ADDRESS (0xD2 >> 1)
+#define GYR_ADDRESS 0xD6
+
 // register addresses
 
 #define L3GD20_WHO_AM_I      0x0F
@@ -63,6 +44,18 @@
 #define L3GD20_INT1_THS_ZL   0x37
 #define L3GD20_INT1_DURATION 0x38
 
+// device types
+
+#define L3G_DEVICE_AUTO 0
+#define L3G4200D_DEVICE 1
+#define L3GD20_DEVICE 2
+
+// SA0 states
+
+#define L3G_SA0_LOW 0
+#define L3G_SA0_HIGH 1
+#define L3G_SA0_AUTO 2
+
 /** Interface library for the ST L3GD20 3-axis gyro
  *
  * Ported from Pololu L3GD20 library for Arduino by
@@ -90,12 +83,13 @@
          * @return g Array containing x, y, and z gyro values
          */
         bool read(float *gx, float *gy, float *gz);
+        bool write_reg(int addr_i2c,int addr_reg, char v);
         
     private:
             I2C _L3GD20;
         float gx, gy, gz;
 
-        bool write_reg(int addr_i2c,int addr_reg, char v);
+        
         bool read_reg(int addr_i2c,int addr_reg, char *v);
         bool recv(char sad, char sub, char *buf, int length);
 };