Interface library for the Atmel Inertial One IMU. Contains drivers for the ITG 3200 3 axis gyro, BMA-150 3 axis accelerometer, and AK8975 3 axis compass

Committer:
Ductapemaster
Date:
Thu Feb 02 08:07:41 2012 +0000
Revision:
7:9e3b79b06e27
Parent:
6:7a77438c94fb
Child:
8:062d536a04cd
doxygen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ductapemaster 5:3756a7bc1f06 1 /**
Ductapemaster 5:3756a7bc1f06 2 * @author Daniel Kouba
Ductapemaster 7:9e3b79b06e27 3 *
Ductapemaster 7:9e3b79b06e27 4 * @section LICENCE
Ductapemaster 5:3756a7bc1f06 5 *
Ductapemaster 5:3756a7bc1f06 6 * Atmel Inertial One IMU Library
Ductapemaster 5:3756a7bc1f06 7 * Copyright (c) 2012 Daniel Kouba
Ductapemaster 0:5a636973285e 8 *
Ductapemaster 0:5a636973285e 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
Ductapemaster 0:5a636973285e 10 * of this software and associated documentation files (the "Software"), to deal
Ductapemaster 0:5a636973285e 11 * in the Software without restriction, including without limitation the rights
Ductapemaster 0:5a636973285e 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Ductapemaster 0:5a636973285e 13 * copies of the Software, and to permit persons to whom the Software is
Ductapemaster 0:5a636973285e 14 * furnished to do so, subject to the following conditions:
Ductapemaster 0:5a636973285e 15 *
Ductapemaster 0:5a636973285e 16 * The above copyright notice and this permission notice shall be included in
Ductapemaster 0:5a636973285e 17 * all copies or substantial portions of the Software.
Ductapemaster 0:5a636973285e 18 *
Ductapemaster 0:5a636973285e 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Ductapemaster 0:5a636973285e 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Ductapemaster 0:5a636973285e 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Ductapemaster 0:5a636973285e 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Ductapemaster 0:5a636973285e 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Ductapemaster 0:5a636973285e 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Ductapemaster 0:5a636973285e 25 * THE SOFTWARE.
Ductapemaster 0:5a636973285e 26 *
Ductapemaster 7:9e3b79b06e27 27 * @section DESCRIPTION
Ductapemaster 6:7a77438c94fb 28 *
Ductapemaster 6:7a77438c94fb 29 * Atmel Inertial One IMU Library
Ductapemaster 6:7a77438c94fb 30 *
Ductapemaster 6:7a77438c94fb 31 * Includes control routines for:
Ductapemaster 6:7a77438c94fb 32 * - ITG-3200 3-axis, 16 bit gyroscope
Ductapemaster 6:7a77438c94fb 33 * - BMA-150 3-axis, 16 bit accelerometer
Ductapemaster 6:7a77438c94fb 34 * - AK8975 3-axis, 16 bit magnetometer
Ductapemaster 6:7a77438c94fb 35 *
Ductapemaster 6:7a77438c94fb 36 * Datasheets:
Ductapemaster 6:7a77438c94fb 37 *
Ductapemaster 6:7a77438c94fb 38 * http://www.atmel.com/dyn/resources/prod_documents/doc8354.pdf
Ductapemaster 6:7a77438c94fb 39 *
Ductapemaster 6:7a77438c94fb 40 * http://invensense.com/mems/gyro/documents/PS-ITG-3200A.pdf
Ductapemaster 6:7a77438c94fb 41 *
Ductapemaster 6:7a77438c94fb 42 * http://www.bosch-sensortec.com/content/language1/downloads/BMA150_DataSheet_Rev.1.5_30May2008.pdf
Ductapemaster 6:7a77438c94fb 43 *
Ductapemaster 6:7a77438c94fb 44 * http://pdf1.alldatasheet.com/datasheet-pdf/view/219477/AKM/AK8973/+Q18W89VYpLawLCDwv+/datasheet.pdf
Ductapemaster 6:7a77438c94fb 45 *
Ductapemaster 0:5a636973285e 46 */
Ductapemaster 0:5a636973285e 47
Ductapemaster 0:5a636973285e 48 #ifndef IMU_AIO_H //IMU Atmel Inertial One
Ductapemaster 0:5a636973285e 49 #define IMU_AIO_H
Ductapemaster 0:5a636973285e 50
Ductapemaster 0:5a636973285e 51 #include "mbed.h"
Ductapemaster 0:5a636973285e 52
Ductapemaster 0:5a636973285e 53 /* Defines */
Ductapemaster 0:5a636973285e 54
Ductapemaster 0:5a636973285e 55 //7 bit I2C Addresses, shifted left to allow for read/write bit as LSB
Ductapemaster 0:5a636973285e 56
Ductapemaster 0:5a636973285e 57 #define GYRO_ADR 0x68 << 1
Ductapemaster 0:5a636973285e 58 #define ACC_ADR 0x38 << 1
Ductapemaster 0:5a636973285e 59 #define COMP_ADR 0x0C << 1
Ductapemaster 0:5a636973285e 60
Ductapemaster 0:5a636973285e 61 // ITG3200 Gyro Registers
Ductapemaster 0:5a636973285e 62
Ductapemaster 0:5a636973285e 63 #define GYRO_WHO_AM_I_REG 0x00
Ductapemaster 0:5a636973285e 64 #define GYRO_SAMPLE_DIV_REG 0x15
Ductapemaster 0:5a636973285e 65 #define GYRO_DLPF_REG 0x16
Ductapemaster 0:5a636973285e 66 #define GYRO_INT_CFG_REG 0x17
Ductapemaster 0:5a636973285e 67 #define GYRO_INT_STATUS_REG 0x1A
Ductapemaster 0:5a636973285e 68 #define GYRO_TEMP_H_REG 0x1B
Ductapemaster 0:5a636973285e 69 #define GYRO_TEMP_L_REG 0x1C
Ductapemaster 0:5a636973285e 70 #define GYRO_XOUT_H_REG 0x1D
Ductapemaster 0:5a636973285e 71 #define GYRO_XOUT_L_REG 0x1E
Ductapemaster 0:5a636973285e 72 #define GYRO_YOUT_H_REG 0x1F
Ductapemaster 0:5a636973285e 73 #define GYRO_YOUT_L_REG 0x20
Ductapemaster 0:5a636973285e 74 #define GYRO_ZOUT_H_REG 0x21
Ductapemaster 0:5a636973285e 75 #define GYRO_ZOUT_L_REG 0x22
Ductapemaster 0:5a636973285e 76
Ductapemaster 0:5a636973285e 77 // Gyro LPF bandwidths
Ductapemaster 0:5a636973285e 78
Ductapemaster 0:5a636973285e 79 #define BW_256HZ 0x00 //8kHz sample rate
Ductapemaster 0:5a636973285e 80 #define BW_188HZ 0x01 //1kHz sample rate for 188Hz and below
Ductapemaster 0:5a636973285e 81 #define BW_98HZ 0x02
Ductapemaster 0:5a636973285e 82 #define BW_42HZ 0x03
Ductapemaster 0:5a636973285e 83 #define BW_20HZ 0x04
Ductapemaster 0:5a636973285e 84 #define BW_10HZ 0x05
Ductapemaster 0:5a636973285e 85 #define BW_5HZ 0x06
Ductapemaster 0:5a636973285e 86
Ductapemaster 0:5a636973285e 87 // Gyro Initial FS_SEL Register Config
Ductapemaster 0:5a636973285e 88
Ductapemaster 0:5a636973285e 89 #define FS_SEL_INIT 0x03 << 3
Ductapemaster 0:5a636973285e 90
Ductapemaster 0:5a636973285e 91 // BMA150 Accelerometer Registers
Ductapemaster 0:5a636973285e 92
Ductapemaster 0:5a636973285e 93
Ductapemaster 0:5a636973285e 94
Ductapemaster 0:5a636973285e 95 // AK8973 Compass Registers
Ductapemaster 2:262f9878bebf 96
Ductapemaster 0:5a636973285e 97
Ductapemaster 5:3756a7bc1f06 98 /** Atmel Inertial One IMU Control Class
Ductapemaster 2:262f9878bebf 99 *
Ductapemaster 2:262f9878bebf 100 */
Ductapemaster 0:5a636973285e 101 class IMU {
Ductapemaster 0:5a636973285e 102
Ductapemaster 0:5a636973285e 103 public:
Ductapemaster 0:5a636973285e 104
Ductapemaster 2:262f9878bebf 105 /** Creates IMU object and initializes all three chips
Ductapemaster 2:262f9878bebf 106 *
Ductapemaster 2:262f9878bebf 107 * Gyro: FS_SEL register is set to 0x03, as required by datasheet
Ductapemaster 2:262f9878bebf 108 * Accelerometer:
Ductapemaster 2:262f9878bebf 109 * Compass:
Ductapemaster 2:262f9878bebf 110 *
Ductapemaster 2:262f9878bebf 111 * @param sda - pin for I2C sda signal
Ductapemaster 2:262f9878bebf 112 * @param scl - pin for I2C scl signal
Ductapemaster 2:262f9878bebf 113 */
Ductapemaster 0:5a636973285e 114 IMU(PinName sda, PinName scl);
Ductapemaster 0:5a636973285e 115
Ductapemaster 0:5a636973285e 116 /* Gyro Methods */
Ductapemaster 0:5a636973285e 117
Ductapemaster 0:5a636973285e 118 /** Gets current X axis gyro measurement
Ductapemaster 0:5a636973285e 119 *
Ductapemaster 0:5a636973285e 120 * @return Raw X axis ADC measurement (signed 16 bits)
Ductapemaster 0:5a636973285e 121 */
Ductapemaster 0:5a636973285e 122 int gyroX(void);
Ductapemaster 0:5a636973285e 123
Ductapemaster 0:5a636973285e 124 /** Gets current Y axis gyro measurement
Ductapemaster 0:5a636973285e 125 *
Ductapemaster 0:5a636973285e 126 * @return Raw Y axis ADC measurement (signed 16 bits)
Ductapemaster 0:5a636973285e 127 */
Ductapemaster 0:5a636973285e 128 int gyroY(void);
Ductapemaster 0:5a636973285e 129
Ductapemaster 0:5a636973285e 130 /** Gets current Z axis gyro measurement
Ductapemaster 0:5a636973285e 131 *
Ductapemaster 0:5a636973285e 132 * @return Raw Z axis ADC measurement (signed 16 bits)
Ductapemaster 0:5a636973285e 133 */
Ductapemaster 0:5a636973285e 134 int gyroZ(void);
Ductapemaster 0:5a636973285e 135
Ductapemaster 0:5a636973285e 136 /** Gets current ADC data from all axes of gyro (uses burst read mode)
Ductapemaster 0:5a636973285e 137 *
Ductapemaster 0:5a636973285e 138 * @return Array of X, Y, and Z axis gyro measurements (signed 16 bits)
Ductapemaster 0:5a636973285e 139 */
Ductapemaster 0:5a636973285e 140 int[3] gyroXYZ(void);
Ductapemaster 0:5a636973285e 141
Ductapemaster 0:5a636973285e 142 /** Sets digital LPF bandwidth for all gyro channels
Ductapemaster 0:5a636973285e 143 *
Ductapemaster 0:5a636973285e 144 * @param Filter Bandwidth (use defined bandwidths)
Ductapemaster 0:5a636973285e 145 */
Ductapemaster 0:5a636973285e 146 void gyroSetLPF(char _BW);
Ductapemaster 0:5a636973285e 147
Ductapemaster 0:5a636973285e 148 /* Accelerometer Methods */
Ductapemaster 0:5a636973285e 149
Ductapemaster 0:5a636973285e 150
Ductapemaster 0:5a636973285e 151
Ductapemaster 0:5a636973285e 152 /* Compass Methods */
Ductapemaster 0:5a636973285e 153
Ductapemaster 0:5a636973285e 154
Ductapemaster 0:5a636973285e 155
Ductapemaster 2:262f9878bebf 156 protected:
Ductapemaster 0:5a636973285e 157
Ductapemaster 0:5a636973285e 158 I2C _i2c; //I2C object constructor
Ductapemaster 0:5a636973285e 159
Ductapemaster 0:5a636973285e 160 };
Ductapemaster 0:5a636973285e 161
Ductapemaster 0:5a636973285e 162 #endif