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
Diff: IMU.h
- Revision:
- 13:eca05448904d
- Parent:
- 12:cab3f7305522
diff -r cab3f7305522 -r eca05448904d IMU.h --- a/IMU.h Thu Feb 02 08:50:58 2012 +0000 +++ b/IMU.h Thu Feb 16 08:56:11 2012 +0000 @@ -61,12 +61,37 @@ // Gyro Initial FS_SEL Register Config - #define FS_SEL_INIT 0x03 << 3 + #define FS_SEL_INIT 0x03 << 3 // BMA150 Accelerometer Registers + #define ACC_XOUT_L_REG 0x02 //Acceleration data registers + #define ACC_XOUT_H_REG 0x03 + #define ACC_YOUT_L_REG 0x04 + #define ACC_YOUT_H_REG 0x05 + #define ACC_ZOUT_L_REG 0x06 + #define ACC_ZOUT_H_REG 0x07 + #define ACC_TEMP_REG 0x08 //Temperature register, 0.5 deg. C / LSB + #define ACC_CTRL_REG 0x0A //Control registers + #define ACC_OPER_REG 0x14 //Operational registers + #define ACC_INT_REG 0x15 //Interrupt registers + // Accelerometer LPF bandwidths + #define BW_25HZ 0x00 + #define BW_50HZ 0x01 + #define BW_100HZ 0x02 + #define BW_190HZ 0x03 + #define BW_375HZ 0x04 + #define BW_750HZ 0x05 + #define BW_1500HZ 0x06 + + // Accelerometer Range values + + #define RANGE_2G 0x00 + #define RANGE_4G 0x01 + #define RANGE_8G 0x02 + // AK8973 Compass Registers @@ -74,7 +99,7 @@ * * Includes control routines for: * - ITG-3200 3-axis, 16 bit gyroscope - * - BMA-150 3-axis, 16 bit accelerometer + * - BMA-150 3-axis, 10 bit accelerometer * - AK8975 3-axis, 16 bit magnetometer * * Datasheets: @@ -91,6 +116,12 @@ class IMU { public: + struct data3d + { + int x, y, z; + } gyro_data, acc_data, mag_data; + + public: /** Creates IMU object and initializes all three chips * @@ -107,39 +138,66 @@ /* 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) + * @return data3d struct of X, Y, and Z axis gyro measurements (signed 16 bits) */ - int* gyroXYZ(void); + data3d getGyroData(void); - /** Sets digital LPF bandwidth for all gyro channels + /** Sets digital LPF bandwidth for all gyro channels - Not working currently * - * @param _BW Filter Bandwidth (use defined bandwidths) + * @param bw Filter Bandwidth (use defined bandwidths) */ - void gyroSetLPF(char _BW); + void setGyroLPF(char bw); /* Accelerometer Methods */ + /** Gets current X acceleration + * + * @return Raw X acceleration, 10 bits signed + */ + int accX(void); + + /** Gets current Y acceleration + * + * @return Raw Y acceleration, 10 bits signed + */ + int accY(void); + + /** Gets current Z acceleration + * + * @return Raw Z acceleration, 10 bits signed + */ + int accZ(void); + /** Gets current acceleration on all axes + * + * @return data3d struct of acceleration data, signed ints + */ + data3d getAccData(void); + + /** Sets digital LPF filter bandwidth + * + * @param bw Digital LPF filter bandwidth + */ + void setAccLPF(char bw); + + /** Sets accelerometer measurement range (+/-2, 4, or 8g's) + * + * @param range Range of g measurements + */ + void setAccRange(char range); + + /** Updates all image registers with data stored in EEPROM + * + */ + void accUpdateImage(void); + + /** Set EEPROM write enable + * + * @param we Write enable value + */ + void accEEWriteEn(bool we); /* Compass Methods */