i2c driver for ITG3200 gyroscope sensor
Fork of ITG3200 by
Revision 3:2dd53a8427e9, committed 2015-12-19
- Comitter:
- sillevl
- Date:
- Sat Dec 19 10:41:01 2015 +0000
- Parent:
- 2:92aec36778a7
- Commit message:
- add constructor that accepts I2C object
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 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){
--- a/ITG3200.h Thu Dec 17 14:03:30 2015 +0000
+++ b/ITG3200.h Sat Dec 19 10:41:01 2015 +0000
@@ -81,6 +81,8 @@
public:
+ ITG3200(I2C &i2c);
+
/**
* Constructor.
*
@@ -332,6 +334,7 @@
private:
+ void initialize();
I2C i2c_;
};
