Driver for ITG3200 gyro

Dependents:   Seeed_Grove_Digital_Gyro Seeed_Grove_Digital_Gyro_ben mbed_websocket_client_for_gyro_and_3_Axio mbed_websocket_client_for_gyro

Fork of ITG3200 by Aaron Berk

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Fri Aug 15 23:43:39 2014 +0000
Parent:
0:b098d99dd81e
Commit message:
Update constructor to take address as an argument but use original as the default if one isn't provided for backwards compatibility

Changed in this revision

ITG3200.cpp Show annotated file Show diff for this revision Revisions of this file
ITG3200.h Show annotated file Show diff for this revision Revisions of this file
--- a/ITG3200.cpp	Mon Sep 06 13:49:59 2010 +0000
+++ b/ITG3200.cpp	Fri Aug 15 23:43:39 2014 +0000
@@ -37,11 +37,11 @@
  */
 #include "ITG3200.h"
 
-ITG3200::ITG3200(PinName sda, PinName scl) : i2c_(sda, scl) {
+ITG3200::ITG3200(PinName sda, PinName scl, uint8_t address) : i2c_(sda, scl) {
 
     //400kHz, fast mode.
     i2c_.frequency(400000);
-    
+    ITG3200_I2C_ADDRESS = address;
     //Set FS_SEL to 0x03 for proper operation.
     //See datasheet for details.
     char tx[2];
--- a/ITG3200.h	Mon Sep 06 13:49:59 2010 +0000
+++ b/ITG3200.h	Fri Aug 15 23:43:39 2014 +0000
@@ -43,7 +43,6 @@
 /**
  * Defines
  */
-#define ITG3200_I2C_ADDRESS 0x69 //7-bit address.
 
 //-----------
 // Registers
@@ -88,8 +87,9 @@
      *
      * @param sda - mbed pin to use for the SDA I2C line.
      * @param scl - mbed pin to use for the SCL I2C line.
+     * @param address - address of the device 0x69 bu default but some use 0x68.
      */
-    ITG3200(PinName sda, PinName scl);
+    ITG3200(PinName sda, PinName scl, uint8_t address = 0x69);
 
     /**
      * Get the identity of the device.
@@ -333,7 +333,7 @@
 private:
 
     I2C i2c_;
-
+    uint8_t ITG3200_I2C_ADDRESS;
 };
 
 #endif /* ITG3200_H */