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