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 07:53:40 2012 +0000
Revision:
3:39715110564f
Parent:
2:262f9878bebf
Child:
4:eebcc95ee80f
doxygen - testing wiki syntax within comments

Who changed what in which revision?

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