i2c driver for ITG3200 gyroscope sensor

Dependents:   m3Dpi

Fork of ITG3200 by Aaron Berk

Revision:
3:2dd53a8427e9
Parent:
1:f27e66e954dd
diff -r 92aec36778a7 -r 2dd53a8427e9 ITG3200.cpp
--- a/ITG3200.cpp	Thu Dec 17 14:03:30 2015 +0000
+++ b/ITG3200.cpp	Sat Dec 19 10:41:01 2015 +0000
@@ -37,11 +37,18 @@
  */
 #include "ITG3200.h"
 
+ITG3200::ITG3200(I2C &i2c) : i2c_(i2c) {
+    initialize();
+}
+
 ITG3200::ITG3200(PinName sda, PinName scl) : i2c_(sda, scl) {
-
     //400kHz, fast mode.
     //i2c_.frequency(400000);
     
+    initialize();
+}
+
+void ITG3200::initialize(){  
     //Set FS_SEL to 0x03 for proper operation.
     //See datasheet for details.
     char tx[2];
@@ -49,8 +56,7 @@
     //FS_SEL bits sit in bits 4 and 3 of DLPF_FS register.
     tx[1] = 0x03 << 3;
     
-    i2c_.write((ITG3200_I2C_ADDRESS << 1) & 0xFE, tx, 2);
-
+    i2c_.write((ITG3200_I2C_ADDRESS << 1) & 0xFE, tx, 2);   
 }
 
 char ITG3200::getWhoAmI(void){