Tollos – ITG3200.c | ||||||||||||||
Libraries
Background
|
ITG3200.c – gyroscope device I/O for Tollos These functions provide basic IO for using the ITG3200 3-axis gyroscope device, attached via I2C. The following connections are assumed:
This code assumes only one ITG3200 device will be used on a controller, so some state information can be held (the device channel and address). This simplifies the tollosGyro interface and allows initialization checking.
gyroGetXYZIO – read latest x, y, and z angular rates int gyroGetXYZIO(int *x, int *y, int *z);
x, y, z – receive angular rates [in milli-degrees/sec]
returns 0 if data read, −1 if the device is not initialized, or −2 if there was an error reading the data (or no data ready) Results are returned scaled to milli-degrees/sec; resolution is 69-70 md/s. This should normally be called only after a Data Ready interrupt; the interrupt is cleared by calling this. gyroInitIO – configure and initialize gyroscope int gyroInitIO(uint channel);
channel – I2C channel on which device is to be found
returns 0 if initialized OK, negative if error The tollosGyro interface expects:
The caller should set up the interrupt handler before calling this function, or clear Data Ready by calling gyroGetXYZIO. All three axes of the gyroscope are enabled. Current consumption should be about 6.5mA. gyroRateIO – change update rate of gyroscope int gyroRateIO(uint rate);
rate – rate requested [Hz, 1..200]
returns the rate chosen if the rate was changed OK, or −1 if error (rate zero or too high, or a bus error) The gyroscope will be set to a slowest available rate that is >= the requested rate, to minimize resource usage. The low-pass filter bandwidth is set to match or exceed the rate. To ensure working with 100kHz I2C, the maximum rate is limited to 200Hz – but note that this may use significant processor bandwidth. gyroStopIO – stop and power-down gyroscope int gyroStopIO(void);
returns 0 if gyroscope stopped OK, negative if an error or it was not running. gyroTemperatureIO – return current gyroscope die temperature int gyroTemperatureIO(void);
returns the latest temperature reading in milli-degrees Celsius, or GYRO_NOTEMP if no reading is available Converts the recorded raw temperature saved during the last read. |
Tollos and these web pages were written by Mike Cowlishaw; Please send me any corrections, suggestions, etc. | |
All content © Mike Cowlishaw, 2010–2012, except where marked
otherwise. All rights reserved. The pages here are for non-commercial
use only (see the separate licence for Tollos source code).
Privacy policy: the Speleotrove website
records no personal information and sets no ‘cookies’.
However, statistics, etc. might be recorded by the web hosting
service.
This page was last updated on 2011-12-30 by c2wiki. |