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

Revision:
0:5a636973285e
Child:
1:1ea611e007f3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IMU.h	Thu Feb 02 07:34:36 2012 +0000
@@ -0,0 +1,161 @@
+/* Atmel Inertial One IMU Library
+ * Copyright (c) 2012 Dan Kouba
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+ 
+ #ifndef IMU_AIO_H        //IMU Atmel Inertial One
+ #define IMU_AIO_H
+ 
+ /* Includes */
+ 
+ #include "mbed.h"
+ 
+ /** Atmel Inertial One IMU Control Library
+ * 
+ * Includes control routines for:
+ * - ITG-3200 3-axis, 16 bit gyroscope
+ * - BMA-150 3-axis, 16 bit accelerometer
+ * - AK8975 3-axis, 16 bit magnetometer
+ *
+ * Datasheets:
+ *
+ * Inertial One: http://www.atmel.com/dyn/resources/prod_documents/doc8354.pdf
+ * Gyro: http://invensense.com/mems/gyro/documents/PS-ITG-3200A.pdf
+ * Accelerometer: http://www.bosch-sensortec.com/content/language1/downloads/BMA150_DataSheet_Rev.1.5_30May2008.pdf
+ * Magnetometer: http://pdf1.alldatasheet.com/datasheet-pdf/view/219477/AKM/AK8973/+Q18W89VYpLawLCDwv+/datasheet.pdf
+ * 
+ */
+ 
+ /* Defines */
+ 
+ //7 bit I2C Addresses, shifted left to allow for read/write bit as LSB
+ 
+ #define GYRO_ADR  0x68 << 1
+ #define ACC_ADR   0x38 << 1
+ #define COMP_ADR  0x0C << 1
+ 
+ // ITG3200 Gyro Registers
+ 
+ #define GYRO_WHO_AM_I_REG         0x00
+ #define GYRO_SAMPLE_DIV_REG       0x15
+ #define GYRO_DLPF_REG             0x16
+ #define GYRO_INT_CFG_REG          0x17
+ #define GYRO_INT_STATUS_REG       0x1A
+ #define GYRO_TEMP_H_REG           0x1B
+ #define GYRO_TEMP_L_REG           0x1C
+ #define GYRO_XOUT_H_REG           0x1D
+ #define GYRO_XOUT_L_REG           0x1E
+ #define GYRO_YOUT_H_REG           0x1F
+ #define GYRO_YOUT_L_REG           0x20
+ #define GYRO_ZOUT_H_REG           0x21
+ #define GYRO_ZOUT_L_REG           0x22
+ 
+ // Gyro LPF bandwidths
+ 
+ #define BW_256HZ       0x00        //8kHz sample rate
+ #define BW_188HZ       0x01        //1kHz sample rate for 188Hz and below
+ #define BW_98HZ        0x02
+ #define BW_42HZ        0x03
+ #define BW_20HZ        0x04
+ #define BW_10HZ        0x05
+ #define BW_5HZ         0x06
+ 
+ // Gyro Initial FS_SEL Register Config
+ 
+ #define FS_SEL_INIT   0x03 << 3
+  
+ // BMA150 Accelerometer Registers
+ 
+ 
+ 
+ // AK8973 Compass Registers
+ 
+ // CLass and Prototype Functions
+ 
+ class IMU {
+ 
+ public:
+ 
+     /**
+     * Constructor: Creates IMU object and initializes all three chips:
+     *
+     * Gyro: FS_SEL register is set to 0x03, as required by datasheet
+     * Accelerometer:
+     * Compass:
+     *
+     * @param sda - pin for I2C sda signal
+     * @param scl - pin for I2C scl signal
+     */
+ 
+    IMU(PinName sda, PinName scl);
+    
+    /* Gyro Methods */
+    
+    /** Gets current X axis gyro measurement
+    *
+    * @return Raw X axis ADC measurement (signed 16 bits)
+    */
+    
+    int gyroX(void);
+    
+    /** Gets current Y axis gyro measurement
+    * 
+    * @return Raw Y axis ADC measurement (signed 16 bits)
+    */
+    
+    int gyroY(void);
+    
+    /** Gets current Z axis gyro measurement
+    * 
+    * @return Raw Z axis ADC measurement (signed 16 bits)
+    */
+    
+    int gyroZ(void);
+    
+    /** Gets current ADC data from all axes of gyro (uses burst read mode)
+    * 
+    * @return Array of X, Y, and Z axis gyro measurements (signed 16 bits)
+    */
+    
+    int[3] gyroXYZ(void);
+    
+    /** Sets digital LPF bandwidth for all gyro channels
+    * 
+    * @param Filter Bandwidth (use defined bandwidths)
+    */
+ 
+    void gyroSetLPF(char _BW);
+    
+    /* Accelerometer Methods */
+    
+    
+    
+    /* Compass Methods */
+    
+    
+ 
+ private:
+ 
+    I2C _i2c;       //I2C object constructor
+ 
+ };
+ 
+ #endif
\ No newline at end of file