I2Cdevlib

I2C device library collection for AVR/Arduino or other C++-based MCUs

Public Member Functions
ITG3200 Class Reference

Public Member Functions

 ITG3200 ()
 ITG3200 (uint8_t address)
void initialize ()
bool testConnection ()
uint8_t getDeviceID ()
void setDeviceID (uint8_t id)
uint8_t getRate ()
void setRate (uint8_t rate)
uint8_t getFullScaleRange ()
void setFullScaleRange (uint8_t range)
uint8_t getDLPFBandwidth ()
void setDLPFBandwidth (uint8_t bandwidth)
bool getInterruptMode ()
void setInterruptMode (bool mode)
bool getInterruptDrive ()
void setInterruptDrive (bool drive)
bool getInterruptLatch ()
void setInterruptLatch (bool latch)
bool getInterruptLatchClear ()
void setInterruptLatchClear (bool clear)
bool getIntDeviceReadyEnabled ()
void setIntDeviceReadyEnabled (bool enabled)
bool getIntDataReadyEnabled ()
void setIntDataReadyEnabled (bool enabled)
bool getIntDeviceReadyStatus ()
bool getIntDataReadyStatus ()
int16_t getTemperature ()
void getRotation (int16_t *x, int16_t *y, int16_t *z)
int16_t getRotationX ()
int16_t getRotationY ()
int16_t getRotationZ ()
void reset ()
bool getSleepEnabled ()
void setSleepEnabled (bool enabled)
bool getStandbyXEnabled ()
void setStandbyXEnabled (bool enabled)
bool getStandbyYEnabled ()
void setStandbyYEnabled (bool enabled)
bool getStandbyZEnabled ()
void setStandbyZEnabled (bool enabled)
uint8_t getClockSource ()
void setClockSource (uint8_t source)

Constructor & Destructor Documentation

ITG3200::ITG3200 ( )

Default constructor, uses default I2C address.

See also:
ITG3200_DEFAULT_ADDRESS
ITG3200::ITG3200 ( uint8_t  address)

Specific address constructor.

Parameters:
addressI2C address
See also:
ITG3200_DEFAULT_ADDRESS
ITG3200_ADDRESS_AD0_LOW
ITG3200_ADDRESS_AD0_HIGH

Member Function Documentation

uint8_t ITG3200::getClockSource ( )

Get clock source setting.

Returns:
Current clock source setting
See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_CLK_SEL_BIT
ITG3200_PWR_CLK_SEL_LENGTH
uint8_t ITG3200::getDeviceID ( )

Get Device ID. This register is used to verify the identity of the device (0b110100).

Returns:
Device ID (should be 0x34, 52 dec, 64 oct)
See also:
ITG3200_RA_WHO_AM_I
ITG3200_RA_DEVID_BIT
ITG3200_RA_DEVID_LENGTH
uint8_t ITG3200::getDLPFBandwidth ( )

Get digital low-pass filter bandwidth. The DLPF_CFG parameter sets the digital low pass filter configuration. It also determines the internal sampling rate used by the device as shown in the table below.

DLPF_CFG | Low-Pass Filter Bandwidth | Internal Sample Rate ---------+---------------------------+--------------------- 0 | 256Hz | 8kHz 1 | 188Hz | 1kHz 2 | 98Hz | 1kHz 3 | 42Hz | 1kHz 4 | 20Hz | 1kHz 5 | 10Hz | 1kHz 6 | 5Hz | 1kHz 7 | Reserved | Reserved

Returns:
DLFP bandwidth setting
See also:
ITG3200_RA_DLPF_FS
ITG3200_DF_DLPF_CFG_BIT
ITG3200_DF_DLPF_CFG_LENGTH
uint8_t ITG3200::getFullScaleRange ( )

Set full-scale range. The FS_SEL parameter allows setting the full-scale range of the gyro sensors, as described in the table below. The power-on-reset value of FS_SEL is 00h. Set to 03h for proper operation.

0 = Reserved 1 = Reserved 2 = Reserved 3 = +/- 2000 degrees/sec

Returns:
Current full-scale range setting
See also:
ITG3200_FULLSCALE_2000
ITG3200_RA_DLPF_FS
ITG3200_DF_FS_SEL_BIT
ITG3200_DF_FS_SEL_LENGTH
bool ITG3200::getIntDataReadyEnabled ( )

Get "data ready" interrupt enabled setting. Will be set 0 for disabled, 1 for enabled.

Returns:
Current interrupt enabled setting
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_RAW_RDY_EN_BIT
bool ITG3200::getIntDataReadyStatus ( )

Get Data Ready interrupt status. In normal use, the RAW_DATA_RDY interrupt is used to determine when new sensor data is available in and of the sensor registers (27 to 32).

Returns:
Data Ready interrupt status
See also:
ITG3200_RA_INT_STATUS
ITG3200_INTSTAT_RAW_DATA_READY_BIT
bool ITG3200::getIntDeviceReadyEnabled ( )

Get "device ready" interrupt enabled setting. Will be set 0 for disabled, 1 for enabled.

Returns:
Current interrupt enabled setting
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_ITG_RDY_EN_BIT
bool ITG3200::getIntDeviceReadyStatus ( )

Get Device Ready interrupt status. The ITG_RDY interrupt indicates that the PLL is ready and gyroscopic data can be read.

Returns:
Device Ready interrupt status
See also:
ITG3200_RA_INT_STATUS
ITG3200_INTSTAT_RAW_DATA_READY_BIT
bool ITG3200::getInterruptDrive ( )

Get interrupt drive mode. Will be set 0 for push-pull, 1 for open-drain.

Returns:
Current interrupt drive mode (0=push-pull, 1=open-drain)
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_OPEN_BIT
bool ITG3200::getInterruptLatch ( )

Get interrupt latch mode. Will be set 0 for 50us-pulse, 1 for latch-until-int-cleared.

Returns:
Current latch mode (0=50us-pulse, 1=latch-until-int-cleared)
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_LATCH_INT_EN_BIT
bool ITG3200::getInterruptLatchClear ( )

Get interrupt latch clear mode. Will be set 0 for status-read-only, 1 for any-register-read.

Returns:
Current latch clear mode (0=status-read-only, 1=any-register-read)
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_INT_ANYRD_2CLEAR_BIT
bool ITG3200::getInterruptMode ( )

Get interrupt logic level mode. Will be set 0 for active-high, 1 for active-low.

Returns:
Current interrupt mode (0=active-high, 1=active-low)
See also:
ITG3200_RA_INT_CFG
ITG3200_INTCFG_ACTL_BIT
uint8_t ITG3200::getRate ( )

Get sample rate. This register determines the sample rate of the ITG-3200 gyros. The gyros' outputs are sampled internally at either 1kHz or 8kHz, determined by the DLPF_CFG setting (see register 22). This sampling is then filtered digitally and delivered into the sensor registers after the number of cycles determined by this register. The sample rate is given by the following formula:

F_sample = F_internal / (divider+1), where F_internal is either 1kHz or 8kHz

As an example, if the internal sampling is at 1kHz, then setting this register to 7 would give the following:

F_sample = 1kHz / (7 + 1) = 125Hz, or 8ms per sample

Returns:
Current sample rate
See also:
setDLPFBandwidth()
ITG3200_RA_SMPLRT_DIV
void ITG3200::getRotation ( int16_t *  x,
int16_t *  y,
int16_t *  z 
)

Get 3-axis gyroscope readings.

Parameters:
x16-bit signed integer container for X-axis rotation
y16-bit signed integer container for Y-axis rotation
z16-bit signed integer container for Z-axis rotation
See also:
ITG3200_RA_GYRO_XOUT_H
int16_t ITG3200::getRotationX ( )

Get X-axis gyroscope reading.

Returns:
X-axis rotation measurement in 16-bit 2's complement format
See also:
ITG3200_RA_GYRO_XOUT_H
int16_t ITG3200::getRotationY ( )

Get Y-axis gyroscope reading.

Returns:
Y-axis rotation measurement in 16-bit 2's complement format
See also:
ITG3200_RA_GYRO_YOUT_H
int16_t ITG3200::getRotationZ ( )

Get Z-axis gyroscope reading.

Returns:
Z-axis rotation measurement in 16-bit 2's complement format
See also:
ITG3200_RA_GYRO_ZOUT_H
bool ITG3200::getSleepEnabled ( )

Get sleep mode status. Setting the SLEEP bit in the register puts the device into very low power sleep mode. In this mode, only the serial interface and internal registers remain active, allowing for a very low standby current. Clearing this bit puts the device back into normal mode. To save power, the individual standby selections for each of the gyros should be used if any gyro axis is not used by the application.

Returns:
Current sleep mode enabled status
See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_SLEEP_BIT
bool ITG3200::getStandbyXEnabled ( )

Get X-axis standby enabled status. If enabled, the X-axis will not gather or report data (or use power).

Returns:
Current X-axis standby enabled status
See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_XG_BIT
bool ITG3200::getStandbyYEnabled ( )

Get Y-axis standby enabled status. If enabled, the Y-axis will not gather or report data (or use power).

Returns:
Current Y-axis standby enabled status
See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_YG_BIT
bool ITG3200::getStandbyZEnabled ( )

Get Z-axis standby enabled status. If enabled, the Z-axis will not gather or report data (or use power).

Returns:
Current Z-axis standby enabled status
See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_ZG_BIT
int16_t ITG3200::getTemperature ( )

Get current internal temperature.

Returns:
Temperature reading in 16-bit 2's complement format
See also:
ITG3200_RA_TEMP_OUT_H
void ITG3200::initialize ( )

Power on and prepare for general usage. This will activate the gyroscope, so be sure to adjust the power settings after you call this method if you want it to enter standby mode, or another less demanding mode of operation. This also sets the gyroscope to use the X-axis gyro for a clock source. Note that it doesn't have any delays in the routine, which means you might want to add ~50ms to be safe if you happen to need to read gyro data immediately after initialization. The data will flow in either case, but the first reports may have higher error offsets.

void ITG3200::reset ( )

Trigger a full device reset. A small delay of ~50ms may be desirable after triggering a reset.

See also:
ITG3200_RA_PWR_MGM
ITG3200_PWR_H_RESET_BIT
void ITG3200::setClockSource ( uint8_t  source)

Set clock source setting. On power up, the ITG-3200 defaults to the internal oscillator. It is highly recommended that the device is configured to use one of the gyros (or an external clock) as the clock reference, due to the improved stability.

The CLK_SEL setting determines the device clock source as follows:

CLK_SEL | Clock Source --------+-------------------------------------- 0 | Internal oscillator 1 | PLL with X Gyro reference 2 | PLL with Y Gyro reference 3 | PLL with Z Gyro reference 4 | PLL with external 32.768kHz reference 5 | PLL with external 19.2MHz reference 6 | Reserved 7 | Reserved

Parameters:
sourceNew clock source setting
See also:
getClockSource()
ITG3200_RA_PWR_MGM
ITG3200_PWR_CLK_SEL_BIT
ITG3200_PWR_CLK_SEL_LENGTH
void ITG3200::setDeviceID ( uint8_t  id)

Set Device ID. Write a new ID into the WHO_AM_I register (no idea why this should ever be necessary though).

Parameters:
idNew device ID to set.
See also:
getDeviceID()
ITG3200_RA_WHO_AM_I
ITG3200_RA_DEVID_BIT
ITG3200_RA_DEVID_LENGTH
void ITG3200::setDLPFBandwidth ( uint8_t  bandwidth)

Set digital low-pass filter bandwidth.

Parameters:
bandwidthNew DLFP bandwidth setting
See also:
getDLPFBandwidth()
ITG3200_DLPF_BW_256
ITG3200_RA_DLPF_FS
ITG3200_DF_DLPF_CFG_BIT
ITG3200_DF_DLPF_CFG_LENGTH
void ITG3200::setFullScaleRange ( uint8_t  range)

Set full-scale range setting.

Parameters:
rangeNew full-scale range value
See also:
getFullScaleRange()
ITG3200_FULLSCALE_2000
ITG3200_RA_DLPF_FS
ITG3200_DF_FS_SEL_BIT
ITG3200_DF_FS_SEL_LENGTH
void ITG3200::setIntDataReadyEnabled ( bool  enabled)

Set "data ready" interrupt enabled setting.

Parameters:
enabledNew interrupt enabled setting
See also:
getIntDataReadyEnabled()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_RAW_RDY_EN_BIT
void ITG3200::setIntDeviceReadyEnabled ( bool  enabled)

Set "device ready" interrupt enabled setting.

Parameters:
enabledNew interrupt enabled setting
See also:
getIntDeviceReadyEnabled()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_ITG_RDY_EN_BIT
void ITG3200::setInterruptDrive ( bool  drive)

Set interrupt drive mode.

Parameters:
driveNew interrupt drive mode (0=push-pull, 1=open-drain)
See also:
getInterruptDrive()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_OPEN_BIT
void ITG3200::setInterruptLatch ( bool  latch)

Set interrupt latch mode.

Parameters:
latchNew latch mode (0=50us-pulse, 1=latch-until-int-cleared)
See also:
getInterruptLatch()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_LATCH_INT_EN_BIT
void ITG3200::setInterruptLatchClear ( bool  clear)

Set interrupt latch clear mode.

Parameters:
clearNew latch clear mode (0=status-read-only, 1=any-register-read)
See also:
getInterruptLatchClear()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_INT_ANYRD_2CLEAR_BIT
void ITG3200::setInterruptMode ( bool  mode)

Set interrupt logic level mode.

Parameters:
modeNew interrupt mode (0=active-high, 1=active-low)
See also:
getInterruptMode()
ITG3200_RA_INT_CFG
ITG3200_INTCFG_ACTL_BIT
void ITG3200::setRate ( uint8_t  rate)

Set sample rate.

Parameters:
rateNew sample rate
See also:
getRate()
setDLPFBandwidth()
ITG3200_RA_SMPLRT_DIV
void ITG3200::setSleepEnabled ( bool  enabled)

Set sleep mode status.

Parameters:
enabledNew sleep mode enabled status
See also:
getSleepEnabled()
ITG3200_RA_PWR_MGM
ITG3200_PWR_SLEEP_BIT
void ITG3200::setStandbyXEnabled ( bool  enabled)

Set X-axis standby enabled status.

Parameters:
NewX-axis standby enabled status
See also:
getStandbyXEnabled()
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_XG_BIT
void ITG3200::setStandbyYEnabled ( bool  enabled)

Set Y-axis standby enabled status.

Parameters:
NewY-axis standby enabled status
See also:
getStandbyYEnabled()
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_YG_BIT
void ITG3200::setStandbyZEnabled ( bool  enabled)

Set Z-axis standby enabled status.

Parameters:
NewZ-axis standby enabled status
See also:
getStandbyZEnabled()
ITG3200_RA_PWR_MGM
ITG3200_PWR_STBY_ZG_BIT
bool ITG3200::testConnection ( )

Verify the I2C connection. Make sure the device is connected and responds as expected.

Returns:
True if connection is valid, false otherwise

The documentation for this class was generated from the following files:
 All Data Structures Functions Variables