Diff: ITG3200.h
- Revision:
- 0:012badc736c0
diff -r 000000000000 -r 012badc736c0 ITG3200.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ITG3200.h Tue Dec 17 17:49:17 2019 +0000 @@ -0,0 +1,80 @@ + + +#ifndef ITG3200_H +#define ITG3200_H + +/** + * Includes + */ +#include "mbed.h" + +/** + * Defines + */ +#define ITG3200_DEFAULT_I2C_ADDRESS 0b11010000 + +//----------- +// Registers +//----------- +#define GYRO_XOUT_H 0x1D +#define GYRO_YOUT_H 0x1F +#define GYRO_ZOUT_H 0x21 +#define GYRO_TEMP_H 0x1B + +/** + * ITG3200 digital compass module. + */ +class ITG3200 { + + I2C* i2c; + int i2cAddW,i2cAddR; + +public: + + /** + * Constructor. + * + * @param sda mbed pin to use for I2C SDA + * @param scl mbed pin to use for I2C SCL + * @param address I2C address of this device. + */ + ITG3200(PinName sda, PinName scl, int i2cAddressW, int i2cAddressR); + + void Init(void); + + + /** + * Reads the current X-axis rotational rate(roll) of the gyroscope. + * + * @return roll integer. + * + */ + int GetX(void); + + /** + * Reads the current Y-axis rotational rate(pitch) of the gyroscope. + * + * @return pitch integer. + * + */ + int GetY(void); + + /** + * Reads the current Z-axis rotational rate(yaw) of the gyroscope. + * + * @return yaw integer. + * + */ + int GetZ(void); + + /** + * Reads the current temperature of the gyroscope's die. + * + * @return temperature integer. + * + */ + int GetTemp(void); + +}; + +#endif /* ITG3200_H */