Forked from Aaron Berk's ITG3200 driver class library, customized for my specific application using 9DoF-Stick by Sparkfun.
Fork of ITG3200 by
ITG-3200 is triple axis, digital interface, gyro sensor.
This library is forked from Aaron Berk's work.
This library is for specific application using 9DoF-Stick.
Datasheet:
http://invensense.com/mems/gyro/documents/PS-ITG-3200-00-01.4.pdf
This library has a feature to correct thermal drift of the device. For details, see Thermal Drift.
ITG-3200は3軸のデジタルインターフェースを備えたジャイロセンサです。
このライブラリは 9DoF-Stick を使用した特定の企画のために保守しています。
mbed IDEが日本語をサポートするまでは英語でコメントを書いていきますが、サポートした後もきっと英語で書いていくでしょう。
このライブラリはデバイスの熱ドリフトを補正する機能を持っています。詳しくは Thermal Drift。
Diff: ITG3200.h
- Revision:
- 7:43b936a53b64
- Parent:
- 6:a7ad6046824c
- Child:
- 8:ac0365ab3cef
--- a/ITG3200.h Thu Sep 13 14:36:13 2012 +0000 +++ b/ITG3200.h Sat Sep 29 14:34:17 2012 +0000 @@ -103,8 +103,9 @@ * * @param sda - mbed pin to use for the SDA I2C line. * @param scl - mbed pin to use for the SCL I2C line. + * @param fastmode Sets the internal I2C interface to use 400kHz clock. */ - ITG3200(PinName sda, PinName scl); + ITG3200(PinName sda, PinName scl, bool fastmode = false); /** * Get the identity of the device. @@ -284,8 +285,9 @@ * Typical sensitivity is 14.375 LSB/(degrees/sec). * * @param readings The output buffer array that has at least 3 length. + * @param subtractOffset Make the returned values subtracted of zero offset. */ - void getGyroXYZ(int readings[3]); + void getGyroXYZ(int readings[3], bool subtractOffset = true); /** * Burst read the outputs on the x,y,z-axis gyroscope and convert them into degrees per second. @@ -298,8 +300,9 @@ * Burst read the outputs on the x,y,z-axis gyroscope and convert them into degrees per second. * * @param readings The output buffer array that has at least 3 length. + * @param subtractOffset Make the returned values subtracted of zero offset. */ - void getGyroXYZRadians(double readings[3]); + void getGyroXYZRadians(double readings[3], bool subtractOffset = true); /** * Get the power management configuration. @@ -396,6 +399,20 @@ return calibSamples; } + /** + * Returns the I2C object that this object is using for communication. + */ + I2C &getI2C(){ + return i2c_; + } + + /** + * Returns internal offset values for zero adjusting. Returned pointer is pointing an array of 3 elements. + */ + const int *getOffset()const{ + return offset; + } + protected: /** @@ -426,7 +443,7 @@ int offset[3]; long calibSamples; - + private: I2C i2c_; @@ -450,10 +467,12 @@ }; -inline void ITG3200::getGyroXYZ(int readings[3]){ +inline void ITG3200::getGyroXYZ(int readings[3], bool subtractOffset){ getRawGyroXYZ(readings); - for(int i = 0; i < 3; i++) - readings[i] -= offset[i]; + if(subtractOffset){ + for(int i = 0; i < 3; i++) + readings[i] -= offset[i]; + } } inline void ITG3200::getGyroXYZDegrees(double readings[3]){ @@ -463,9 +482,9 @@ readings[i] = intData[i] * 2000. / 32767.; } -inline void ITG3200::getGyroXYZRadians(double readings[3]){ +inline void ITG3200::getGyroXYZRadians(double readings[3], bool subtractOffset){ int intData[3]; - getGyroXYZ(intData); + getGyroXYZ(intData, subtractOffset); for(int i = 0; i < 3; i++) readings[i] = intData[i] * 2000. / 32767. * 2. * M_PI / 360.; }