ITG3200 Library as part of the 9DOF stick from Sparkfun.com
Dependents: 9DOF-Stick 6dof_new_workwith_v2 aigamozu_program_ver2 aigamozu_program_ver2_yokokawa ... more
ITG3200.h@0:8967cbe04d96, 2011-10-07 (annotated)
- Committer:
- Digixx
- Date:
- Fri Oct 07 21:08:25 2011 +0000
- Revision:
- 0:8967cbe04d96
Had to modify I2C address from 0x69 to 0x68 to use this Lib
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Digixx | 0:8967cbe04d96 | 1 | /** |
Digixx | 0:8967cbe04d96 | 2 | * @author Uwe Gartmann |
Digixx | 0:8967cbe04d96 | 3 | * @author Used ITG3200 library developed Aaron Berk as template |
Digixx | 0:8967cbe04d96 | 4 | * |
Digixx | 0:8967cbe04d96 | 5 | * @section LICENSE |
Digixx | 0:8967cbe04d96 | 6 | * |
Digixx | 0:8967cbe04d96 | 7 | * Copyright (c) 2010 ARM Limited |
Digixx | 0:8967cbe04d96 | 8 | * |
Digixx | 0:8967cbe04d96 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
Digixx | 0:8967cbe04d96 | 10 | * of this software and associated documentation files (the "Software"), to deal |
Digixx | 0:8967cbe04d96 | 11 | * in the Software without restriction, including without limitation the rights |
Digixx | 0:8967cbe04d96 | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
Digixx | 0:8967cbe04d96 | 13 | * copies of the Software, and to permit persons to whom the Software is |
Digixx | 0:8967cbe04d96 | 14 | * furnished to do so, subject to the following conditions: |
Digixx | 0:8967cbe04d96 | 15 | * |
Digixx | 0:8967cbe04d96 | 16 | * The above copyright notice and this permission notice shall be included in |
Digixx | 0:8967cbe04d96 | 17 | * all copies or substantial portions of the Software. |
Digixx | 0:8967cbe04d96 | 18 | * |
Digixx | 0:8967cbe04d96 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Digixx | 0:8967cbe04d96 | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Digixx | 0:8967cbe04d96 | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
Digixx | 0:8967cbe04d96 | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Digixx | 0:8967cbe04d96 | 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Digixx | 0:8967cbe04d96 | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
Digixx | 0:8967cbe04d96 | 25 | * THE SOFTWARE. |
Digixx | 0:8967cbe04d96 | 26 | * |
Digixx | 0:8967cbe04d96 | 27 | * @section DESCRIPTION |
Digixx | 0:8967cbe04d96 | 28 | * |
Digixx | 0:8967cbe04d96 | 29 | * ITG-3200 triple axis, digital interface, gyroscope. |
Digixx | 0:8967cbe04d96 | 30 | * |
Digixx | 0:8967cbe04d96 | 31 | * Datasheet: |
Digixx | 0:8967cbe04d96 | 32 | * |
Digixx | 0:8967cbe04d96 | 33 | * http://invensense.com/mems/gyro/documents/PS-ITG-3200-00-01.4.pdf |
Digixx | 0:8967cbe04d96 | 34 | */ |
Digixx | 0:8967cbe04d96 | 35 | |
Digixx | 0:8967cbe04d96 | 36 | #ifndef ITG3200_H |
Digixx | 0:8967cbe04d96 | 37 | #define ITG3200_H |
Digixx | 0:8967cbe04d96 | 38 | |
Digixx | 0:8967cbe04d96 | 39 | /** |
Digixx | 0:8967cbe04d96 | 40 | * Includes |
Digixx | 0:8967cbe04d96 | 41 | */ |
Digixx | 0:8967cbe04d96 | 42 | #include "mbed.h" |
Digixx | 0:8967cbe04d96 | 43 | |
Digixx | 0:8967cbe04d96 | 44 | /** |
Digixx | 0:8967cbe04d96 | 45 | * Defines |
Digixx | 0:8967cbe04d96 | 46 | */ |
Digixx | 0:8967cbe04d96 | 47 | #define ITG3200_I2C_ADDRESS 0x68 //7-bit address. |
Digixx | 0:8967cbe04d96 | 48 | |
Digixx | 0:8967cbe04d96 | 49 | //----------- |
Digixx | 0:8967cbe04d96 | 50 | // Registers |
Digixx | 0:8967cbe04d96 | 51 | //----------- |
Digixx | 0:8967cbe04d96 | 52 | #define WHO_AM_I_REG 0x00 |
Digixx | 0:8967cbe04d96 | 53 | #define SMPLRT_DIV_REG 0x15 |
Digixx | 0:8967cbe04d96 | 54 | #define DLPF_FS_REG 0x16 |
Digixx | 0:8967cbe04d96 | 55 | #define INT_CFG_REG 0x17 |
Digixx | 0:8967cbe04d96 | 56 | #define INT_STATUS 0x1A |
Digixx | 0:8967cbe04d96 | 57 | #define TEMP_OUT_H_REG 0x1B |
Digixx | 0:8967cbe04d96 | 58 | #define TEMP_OUT_L_REG 0x1C |
Digixx | 0:8967cbe04d96 | 59 | #define GYRO_XOUT_H_REG 0x1D |
Digixx | 0:8967cbe04d96 | 60 | #define GYRO_XOUT_L_REG 0x1E |
Digixx | 0:8967cbe04d96 | 61 | #define GYRO_YOUT_H_REG 0x1F |
Digixx | 0:8967cbe04d96 | 62 | #define GYRO_YOUT_L_REG 0x20 |
Digixx | 0:8967cbe04d96 | 63 | #define GYRO_ZOUT_H_REG 0x21 |
Digixx | 0:8967cbe04d96 | 64 | #define GYRO_ZOUT_L_REG 0x22 |
Digixx | 0:8967cbe04d96 | 65 | #define PWR_MGM_REG 0x3E |
Digixx | 0:8967cbe04d96 | 66 | |
Digixx | 0:8967cbe04d96 | 67 | //---------------------------- |
Digixx | 0:8967cbe04d96 | 68 | // Low Pass Filter Bandwidths |
Digixx | 0:8967cbe04d96 | 69 | //---------------------------- |
Digixx | 0:8967cbe04d96 | 70 | #define LPFBW_256HZ 0x00 |
Digixx | 0:8967cbe04d96 | 71 | #define LPFBW_188HZ 0x01 |
Digixx | 0:8967cbe04d96 | 72 | #define LPFBW_98HZ 0x02 |
Digixx | 0:8967cbe04d96 | 73 | #define LPFBW_42HZ 0x03 |
Digixx | 0:8967cbe04d96 | 74 | #define LPFBW_20HZ 0x04 |
Digixx | 0:8967cbe04d96 | 75 | #define LPFBW_10HZ 0x05 |
Digixx | 0:8967cbe04d96 | 76 | #define LPFBW_5HZ 0x06 |
Digixx | 0:8967cbe04d96 | 77 | |
Digixx | 0:8967cbe04d96 | 78 | /** |
Digixx | 0:8967cbe04d96 | 79 | * ITG-3200 triple axis digital gyroscope. |
Digixx | 0:8967cbe04d96 | 80 | */ |
Digixx | 0:8967cbe04d96 | 81 | class ITG3200 { |
Digixx | 0:8967cbe04d96 | 82 | |
Digixx | 0:8967cbe04d96 | 83 | public: |
Digixx | 0:8967cbe04d96 | 84 | |
Digixx | 0:8967cbe04d96 | 85 | /** |
Digixx | 0:8967cbe04d96 | 86 | * Constructor. |
Digixx | 0:8967cbe04d96 | 87 | * |
Digixx | 0:8967cbe04d96 | 88 | * Sets FS_SEL to 0x03 for proper opertaion. |
Digixx | 0:8967cbe04d96 | 89 | * |
Digixx | 0:8967cbe04d96 | 90 | * @param sda - mbed pin to use for the SDA I2C line. |
Digixx | 0:8967cbe04d96 | 91 | * @param scl - mbed pin to use for the SCL I2C line. |
Digixx | 0:8967cbe04d96 | 92 | */ |
Digixx | 0:8967cbe04d96 | 93 | ITG3200(PinName sda, PinName scl); |
Digixx | 0:8967cbe04d96 | 94 | |
Digixx | 0:8967cbe04d96 | 95 | /** |
Digixx | 0:8967cbe04d96 | 96 | * Get the identity of the device. |
Digixx | 0:8967cbe04d96 | 97 | * |
Digixx | 0:8967cbe04d96 | 98 | * @return The contents of the Who Am I register which contains the I2C |
Digixx | 0:8967cbe04d96 | 99 | * address of the device. |
Digixx | 0:8967cbe04d96 | 100 | */ |
Digixx | 0:8967cbe04d96 | 101 | char getWhoAmI(void); |
Digixx | 0:8967cbe04d96 | 102 | |
Digixx | 0:8967cbe04d96 | 103 | /** |
Digixx | 0:8967cbe04d96 | 104 | * Set the address of the device. |
Digixx | 0:8967cbe04d96 | 105 | * |
Digixx | 0:8967cbe04d96 | 106 | * @param address The I2C slave address to write to the Who Am I register |
Digixx | 0:8967cbe04d96 | 107 | * on the device. |
Digixx | 0:8967cbe04d96 | 108 | */ |
Digixx | 0:8967cbe04d96 | 109 | void setWhoAmI(char address); |
Digixx | 0:8967cbe04d96 | 110 | |
Digixx | 0:8967cbe04d96 | 111 | /** |
Digixx | 0:8967cbe04d96 | 112 | * Get the sample rate divider. |
Digixx | 0:8967cbe04d96 | 113 | * |
Digixx | 0:8967cbe04d96 | 114 | * @return The sample rate divider as a number from 0-255. |
Digixx | 0:8967cbe04d96 | 115 | */ |
Digixx | 0:8967cbe04d96 | 116 | char getSampleRateDivider(void); |
Digixx | 0:8967cbe04d96 | 117 | |
Digixx | 0:8967cbe04d96 | 118 | /** |
Digixx | 0:8967cbe04d96 | 119 | * Set the sample rate divider. |
Digixx | 0:8967cbe04d96 | 120 | * |
Digixx | 0:8967cbe04d96 | 121 | * Fsample = Finternal / (divider + 1), where Finternal = 1kHz or 8kHz, |
Digixx | 0:8967cbe04d96 | 122 | * as decidied by the DLPF_FS register. |
Digixx | 0:8967cbe04d96 | 123 | * |
Digixx | 0:8967cbe04d96 | 124 | * @param The sample rate divider as a number from 0-255. |
Digixx | 0:8967cbe04d96 | 125 | */ |
Digixx | 0:8967cbe04d96 | 126 | void setSampleRateDivider(char divider); |
Digixx | 0:8967cbe04d96 | 127 | |
Digixx | 0:8967cbe04d96 | 128 | /** |
Digixx | 0:8967cbe04d96 | 129 | * Get the internal sample rate. |
Digixx | 0:8967cbe04d96 | 130 | * |
Digixx | 0:8967cbe04d96 | 131 | * @return The internal sample rate in kHz - either 1 or 8. |
Digixx | 0:8967cbe04d96 | 132 | */ |
Digixx | 0:8967cbe04d96 | 133 | int getInternalSampleRate(void); |
Digixx | 0:8967cbe04d96 | 134 | |
Digixx | 0:8967cbe04d96 | 135 | /** |
Digixx | 0:8967cbe04d96 | 136 | * Set the low pass filter bandwidth. |
Digixx | 0:8967cbe04d96 | 137 | * |
Digixx | 0:8967cbe04d96 | 138 | * Also used to set the internal sample rate. |
Digixx | 0:8967cbe04d96 | 139 | * Pass the #define bandwidth codes as a parameter. |
Digixx | 0:8967cbe04d96 | 140 | * |
Digixx | 0:8967cbe04d96 | 141 | * 256Hz -> 8kHz internal sample rate. |
Digixx | 0:8967cbe04d96 | 142 | * Everything else -> 1kHz internal rate. |
Digixx | 0:8967cbe04d96 | 143 | * |
Digixx | 0:8967cbe04d96 | 144 | * @param bandwidth Low pass filter bandwidth code |
Digixx | 0:8967cbe04d96 | 145 | */ |
Digixx | 0:8967cbe04d96 | 146 | void setLpBandwidth(char bandwidth); |
Digixx | 0:8967cbe04d96 | 147 | |
Digixx | 0:8967cbe04d96 | 148 | /** |
Digixx | 0:8967cbe04d96 | 149 | * Get the interrupt configuration. |
Digixx | 0:8967cbe04d96 | 150 | * |
Digixx | 0:8967cbe04d96 | 151 | * See datasheet for register contents details. |
Digixx | 0:8967cbe04d96 | 152 | * |
Digixx | 0:8967cbe04d96 | 153 | * 7 6 5 4 |
Digixx | 0:8967cbe04d96 | 154 | * +------+------+--------------+------------------+ |
Digixx | 0:8967cbe04d96 | 155 | * | ACTL | OPEN | LATCH_INT_EN | INT_ANYRD_2CLEAR | |
Digixx | 0:8967cbe04d96 | 156 | * +------+------+--------------+------------------+ |
Digixx | 0:8967cbe04d96 | 157 | * |
Digixx | 0:8967cbe04d96 | 158 | * 3 2 1 0 |
Digixx | 0:8967cbe04d96 | 159 | * +---+------------+------------+---+ |
Digixx | 0:8967cbe04d96 | 160 | * | 0 | ITG_RDY_EN | RAW_RDY_EN | 0 | |
Digixx | 0:8967cbe04d96 | 161 | * +---+------------+------------+---+ |
Digixx | 0:8967cbe04d96 | 162 | * |
Digixx | 0:8967cbe04d96 | 163 | * ACTL Logic level for INT output pin; 1 = active low, 0 = active high. |
Digixx | 0:8967cbe04d96 | 164 | * OPEN Drive type for INT output pin; 1 = open drain, 0 = push-pull. |
Digixx | 0:8967cbe04d96 | 165 | * LATCH_INT_EN Latch mode; 1 = latch until interrupt is cleared, |
Digixx | 0:8967cbe04d96 | 166 | * 0 = 50us pulse. |
Digixx | 0:8967cbe04d96 | 167 | * INT_ANYRD_2CLEAR Latch clear method; 1 = any register read, |
Digixx | 0:8967cbe04d96 | 168 | * 0 = status register read only. |
Digixx | 0:8967cbe04d96 | 169 | * ITG_RDY_EN Enable interrupt when device is ready, |
Digixx | 0:8967cbe04d96 | 170 | * (PLL ready after changing clock source). |
Digixx | 0:8967cbe04d96 | 171 | * RAW_RDY_EN Enable interrupt when data is available. |
Digixx | 0:8967cbe04d96 | 172 | * 0 Bits 1 and 3 of the INT_CFG register should be zero. |
Digixx | 0:8967cbe04d96 | 173 | * |
Digixx | 0:8967cbe04d96 | 174 | * @return the contents of the INT_CFG register. |
Digixx | 0:8967cbe04d96 | 175 | */ |
Digixx | 0:8967cbe04d96 | 176 | char getInterruptConfiguration(void); |
Digixx | 0:8967cbe04d96 | 177 | |
Digixx | 0:8967cbe04d96 | 178 | /** |
Digixx | 0:8967cbe04d96 | 179 | * Set the interrupt configuration. |
Digixx | 0:8967cbe04d96 | 180 | * |
Digixx | 0:8967cbe04d96 | 181 | * See datasheet for configuration byte details. |
Digixx | 0:8967cbe04d96 | 182 | * |
Digixx | 0:8967cbe04d96 | 183 | * 7 6 5 4 |
Digixx | 0:8967cbe04d96 | 184 | * +------+------+--------------+------------------+ |
Digixx | 0:8967cbe04d96 | 185 | * | ACTL | OPEN | LATCH_INT_EN | INT_ANYRD_2CLEAR | |
Digixx | 0:8967cbe04d96 | 186 | * +------+------+--------------+------------------+ |
Digixx | 0:8967cbe04d96 | 187 | * |
Digixx | 0:8967cbe04d96 | 188 | * 3 2 1 0 |
Digixx | 0:8967cbe04d96 | 189 | * +---+------------+------------+---+ |
Digixx | 0:8967cbe04d96 | 190 | * | 0 | ITG_RDY_EN | RAW_RDY_EN | 0 | |
Digixx | 0:8967cbe04d96 | 191 | * +---+------------+------------+---+ |
Digixx | 0:8967cbe04d96 | 192 | * |
Digixx | 0:8967cbe04d96 | 193 | * ACTL Logic level for INT output pin; 1 = active low, 0 = active high. |
Digixx | 0:8967cbe04d96 | 194 | * OPEN Drive type for INT output pin; 1 = open drain, 0 = push-pull. |
Digixx | 0:8967cbe04d96 | 195 | * LATCH_INT_EN Latch mode; 1 = latch until interrupt is cleared, |
Digixx | 0:8967cbe04d96 | 196 | * 0 = 50us pulse. |
Digixx | 0:8967cbe04d96 | 197 | * INT_ANYRD_2CLEAR Latch clear method; 1 = any register read, |
Digixx | 0:8967cbe04d96 | 198 | * 0 = status register read only. |
Digixx | 0:8967cbe04d96 | 199 | * ITG_RDY_EN Enable interrupt when device is ready, |
Digixx | 0:8967cbe04d96 | 200 | * (PLL ready after changing clock source). |
Digixx | 0:8967cbe04d96 | 201 | * RAW_RDY_EN Enable interrupt when data is available. |
Digixx | 0:8967cbe04d96 | 202 | * 0 Bits 1 and 3 of the INT_CFG register should be zero. |
Digixx | 0:8967cbe04d96 | 203 | * |
Digixx | 0:8967cbe04d96 | 204 | * @param config Configuration byte to write to INT_CFG register. |
Digixx | 0:8967cbe04d96 | 205 | */ |
Digixx | 0:8967cbe04d96 | 206 | void setInterruptConfiguration(char config); |
Digixx | 0:8967cbe04d96 | 207 | |
Digixx | 0:8967cbe04d96 | 208 | /** |
Digixx | 0:8967cbe04d96 | 209 | * Check the ITG_RDY bit of the INT_STATUS register. |
Digixx | 0:8967cbe04d96 | 210 | * |
Digixx | 0:8967cbe04d96 | 211 | * @return True if the ITG_RDY bit is set, corresponding to PLL ready, |
Digixx | 0:8967cbe04d96 | 212 | * false if the ITG_RDY bit is not set, corresponding to PLL not |
Digixx | 0:8967cbe04d96 | 213 | * ready. |
Digixx | 0:8967cbe04d96 | 214 | */ |
Digixx | 0:8967cbe04d96 | 215 | bool isPllReady(void); |
Digixx | 0:8967cbe04d96 | 216 | |
Digixx | 0:8967cbe04d96 | 217 | /** |
Digixx | 0:8967cbe04d96 | 218 | * Check the RAW_DATA_RDY bit of the INT_STATUS register. |
Digixx | 0:8967cbe04d96 | 219 | * |
Digixx | 0:8967cbe04d96 | 220 | * @return True if the RAW_DATA_RDY bit is set, corresponding to new data |
Digixx | 0:8967cbe04d96 | 221 | * in the sensor registers, false if the RAW_DATA_RDY bit is not |
Digixx | 0:8967cbe04d96 | 222 | * set, corresponding to no new data yet in the sensor registers. |
Digixx | 0:8967cbe04d96 | 223 | */ |
Digixx | 0:8967cbe04d96 | 224 | bool isRawDataReady(void); |
Digixx | 0:8967cbe04d96 | 225 | |
Digixx | 0:8967cbe04d96 | 226 | /** |
Digixx | 0:8967cbe04d96 | 227 | * Get the temperature of the device. |
Digixx | 0:8967cbe04d96 | 228 | * |
Digixx | 0:8967cbe04d96 | 229 | * @return The temperature in degrees celsius. |
Digixx | 0:8967cbe04d96 | 230 | */ |
Digixx | 0:8967cbe04d96 | 231 | float getTemperature(void); |
Digixx | 0:8967cbe04d96 | 232 | |
Digixx | 0:8967cbe04d96 | 233 | /** |
Digixx | 0:8967cbe04d96 | 234 | * Get the output for the x-axis gyroscope. |
Digixx | 0:8967cbe04d96 | 235 | * |
Digixx | 0:8967cbe04d96 | 236 | * Typical sensitivity is 14.375 LSB/(degrees/sec). |
Digixx | 0:8967cbe04d96 | 237 | * |
Digixx | 0:8967cbe04d96 | 238 | * @return The output on the x-axis in raw ADC counts. |
Digixx | 0:8967cbe04d96 | 239 | */ |
Digixx | 0:8967cbe04d96 | 240 | int getGyroX(void); |
Digixx | 0:8967cbe04d96 | 241 | |
Digixx | 0:8967cbe04d96 | 242 | /** |
Digixx | 0:8967cbe04d96 | 243 | * Get the output for the y-axis gyroscope. |
Digixx | 0:8967cbe04d96 | 244 | * |
Digixx | 0:8967cbe04d96 | 245 | * Typical sensitivity is 14.375 LSB/(degrees/sec). |
Digixx | 0:8967cbe04d96 | 246 | * |
Digixx | 0:8967cbe04d96 | 247 | * @return The output on the y-axis in raw ADC counts. |
Digixx | 0:8967cbe04d96 | 248 | */ |
Digixx | 0:8967cbe04d96 | 249 | int getGyroY(void); |
Digixx | 0:8967cbe04d96 | 250 | |
Digixx | 0:8967cbe04d96 | 251 | /** |
Digixx | 0:8967cbe04d96 | 252 | * Get the output on the z-axis gyroscope. |
Digixx | 0:8967cbe04d96 | 253 | * |
Digixx | 0:8967cbe04d96 | 254 | * Typical sensitivity is 14.375 LSB/(degrees/sec). |
Digixx | 0:8967cbe04d96 | 255 | * |
Digixx | 0:8967cbe04d96 | 256 | * @return The output on the z-axis in raw ADC counts. |
Digixx | 0:8967cbe04d96 | 257 | */ |
Digixx | 0:8967cbe04d96 | 258 | int getGyroZ(void); |
Digixx | 0:8967cbe04d96 | 259 | |
Digixx | 0:8967cbe04d96 | 260 | /** |
Digixx | 0:8967cbe04d96 | 261 | * Get the power management configuration. |
Digixx | 0:8967cbe04d96 | 262 | * |
Digixx | 0:8967cbe04d96 | 263 | * See the datasheet for register contents details. |
Digixx | 0:8967cbe04d96 | 264 | * |
Digixx | 0:8967cbe04d96 | 265 | * 7 6 5 4 |
Digixx | 0:8967cbe04d96 | 266 | * +---------+-------+---------+---------+ |
Digixx | 0:8967cbe04d96 | 267 | * | H_RESET | SLEEP | STBY_XG | STBY_YG | |
Digixx | 0:8967cbe04d96 | 268 | * +---------+-------+---------+---------+ |
Digixx | 0:8967cbe04d96 | 269 | * |
Digixx | 0:8967cbe04d96 | 270 | * 3 2 1 0 |
Digixx | 0:8967cbe04d96 | 271 | * +---------+----------+----------+----------+ |
Digixx | 0:8967cbe04d96 | 272 | * | STBY_ZG | CLK_SEL2 | CLK_SEL1 | CLK_SEL0 | |
Digixx | 0:8967cbe04d96 | 273 | * +---------+----------+----------+----------+ |
Digixx | 0:8967cbe04d96 | 274 | * |
Digixx | 0:8967cbe04d96 | 275 | * H_RESET Reset device and internal registers to the power-up-default settings. |
Digixx | 0:8967cbe04d96 | 276 | * SLEEP Enable low power sleep mode. |
Digixx | 0:8967cbe04d96 | 277 | * STBY_XG Put gyro X in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 278 | * STBY_YG Put gyro Y in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 279 | * STBY_ZG Put gyro Z in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 280 | * CLK_SEL Select device clock source: |
Digixx | 0:8967cbe04d96 | 281 | * |
Digixx | 0:8967cbe04d96 | 282 | * CLK_SEL | Clock Source |
Digixx | 0:8967cbe04d96 | 283 | * --------+-------------- |
Digixx | 0:8967cbe04d96 | 284 | * 0 Internal oscillator |
Digixx | 0:8967cbe04d96 | 285 | * 1 PLL with X Gyro reference |
Digixx | 0:8967cbe04d96 | 286 | * 2 PLL with Y Gyro reference |
Digixx | 0:8967cbe04d96 | 287 | * 3 PLL with Z Gyro reference |
Digixx | 0:8967cbe04d96 | 288 | * 4 PLL with external 32.768kHz reference |
Digixx | 0:8967cbe04d96 | 289 | * 5 PLL with external 19.2MHz reference |
Digixx | 0:8967cbe04d96 | 290 | * 6 Reserved |
Digixx | 0:8967cbe04d96 | 291 | * 7 Reserved |
Digixx | 0:8967cbe04d96 | 292 | * |
Digixx | 0:8967cbe04d96 | 293 | * @return The contents of the PWR_MGM register. |
Digixx | 0:8967cbe04d96 | 294 | */ |
Digixx | 0:8967cbe04d96 | 295 | char getPowerManagement(void); |
Digixx | 0:8967cbe04d96 | 296 | |
Digixx | 0:8967cbe04d96 | 297 | /** |
Digixx | 0:8967cbe04d96 | 298 | * Set power management configuration. |
Digixx | 0:8967cbe04d96 | 299 | * |
Digixx | 0:8967cbe04d96 | 300 | * See the datasheet for configuration byte details |
Digixx | 0:8967cbe04d96 | 301 | * |
Digixx | 0:8967cbe04d96 | 302 | * 7 6 5 4 |
Digixx | 0:8967cbe04d96 | 303 | * +---------+-------+---------+---------+ |
Digixx | 0:8967cbe04d96 | 304 | * | H_RESET | SLEEP | STBY_XG | STBY_YG | |
Digixx | 0:8967cbe04d96 | 305 | * +---------+-------+---------+---------+ |
Digixx | 0:8967cbe04d96 | 306 | * |
Digixx | 0:8967cbe04d96 | 307 | * 3 2 1 0 |
Digixx | 0:8967cbe04d96 | 308 | * +---------+----------+----------+----------+ |
Digixx | 0:8967cbe04d96 | 309 | * | STBY_ZG | CLK_SEL2 | CLK_SEL1 | CLK_SEL0 | |
Digixx | 0:8967cbe04d96 | 310 | * +---------+----------+----------+----------+ |
Digixx | 0:8967cbe04d96 | 311 | * |
Digixx | 0:8967cbe04d96 | 312 | * H_RESET Reset device and internal registers to the power-up-default settings. |
Digixx | 0:8967cbe04d96 | 313 | * SLEEP Enable low power sleep mode. |
Digixx | 0:8967cbe04d96 | 314 | * STBY_XG Put gyro X in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 315 | * STBY_YG Put gyro Y in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 316 | * STBY_ZG Put gyro Z in standby mode (1=standby, 0=normal). |
Digixx | 0:8967cbe04d96 | 317 | * CLK_SEL Select device clock source: |
Digixx | 0:8967cbe04d96 | 318 | * |
Digixx | 0:8967cbe04d96 | 319 | * CLK_SEL | Clock Source |
Digixx | 0:8967cbe04d96 | 320 | * --------+-------------- |
Digixx | 0:8967cbe04d96 | 321 | * 0 Internal oscillator |
Digixx | 0:8967cbe04d96 | 322 | * 1 PLL with X Gyro reference |
Digixx | 0:8967cbe04d96 | 323 | * 2 PLL with Y Gyro reference |
Digixx | 0:8967cbe04d96 | 324 | * 3 PLL with Z Gyro reference |
Digixx | 0:8967cbe04d96 | 325 | * 4 PLL with external 32.768kHz reference |
Digixx | 0:8967cbe04d96 | 326 | * 5 PLL with external 19.2MHz reference |
Digixx | 0:8967cbe04d96 | 327 | * 6 Reserved |
Digixx | 0:8967cbe04d96 | 328 | * 7 Reserved |
Digixx | 0:8967cbe04d96 | 329 | * |
Digixx | 0:8967cbe04d96 | 330 | * @param config The configuration byte to write to the PWR_MGM register. |
Digixx | 0:8967cbe04d96 | 331 | */ |
Digixx | 0:8967cbe04d96 | 332 | void setPowerManagement(char config); |
Digixx | 0:8967cbe04d96 | 333 | |
Digixx | 0:8967cbe04d96 | 334 | private: |
Digixx | 0:8967cbe04d96 | 335 | |
Digixx | 0:8967cbe04d96 | 336 | I2C i2c_; |
Digixx | 0:8967cbe04d96 | 337 | |
Digixx | 0:8967cbe04d96 | 338 | }; |
Digixx | 0:8967cbe04d96 | 339 | |
Digixx | 0:8967cbe04d96 | 340 | #endif /* ITG3200_H */ |