Skip to content
Browse files

Library started

  • Loading branch information...
1 parent 7bdc81e commit 16d33ead5535e2d8310c87bb06ef0860694386d3 @qwertyboy committed Aug 15, 2012
View
199 code/tinyIMU_test/tinyIMU.cpp
@@ -0,0 +1,199 @@
+/*
+tinyIMU.cpp
+Arduino library for the tinyIMU 3-axis
+accelerometer and gyroscope breakout board
+*/
+
+//Bring in the correct file
+#if ARDUINO >= 100
+#include "Arduino.h"
+#else
+#include "Wprogram.h"
+#endif
+
+
+#include <Wire.h>
+#include "tinyIMU.h"
+
+//Memory map for BMA220 accelerometer
+//SPI memory map
+#ifdef SPI_MODE //Use this set of definitions for SPI
+
+#define SOFTRESET 0x19
+#define SUSPEND 0x18
+#define WDT_TO_EN 0x17
+#define WDT_TO_SEL 0x17
+#define SPI3 0x17
+#define SBIST_SIGN 0x11
+#define SBIST 0x11
+#define RANGE 0x11
+#define SERIAL_HIGH_BW 0x10
+#define FILT_CONFIG 0x10
+#define SLEEP_EN 0x0F
+#define SLEEP_DUR 0x0F
+#define EN_X_CHANNEL 0x0F
+#define EN_Y_CHANNEL 0x0F
+#define EN_Z_CHANNEL 0x0F
+#define RESET_INT 0x0E
+#define LAT_INT 0x0E
+#define EN_LOW 0x0E
+#define EN_HIGH_X 0x0E
+#define EN_HIGH_Y 0x0E
+#define EN_HIGH_Z 0x0E
+#define EN_DATA 0x0D
+#define EN_ORIENT 0x0D
+#define EN_SLOPE_X 0x0D
+#define EN_CLOPE_Y 0x0D
+#define EN_SLOPE_Z 0x0D
+#define EN_TT_X 0x0D
+#define EN_TT_Y 0x0D
+#define EN_TT_Z 0x0D
+#define TT_INT 0x0C
+#define LOW_INT 0x0C
+#define HIGH_INT 0x0C
+#define DATA_INT 0x0C
+#define SLOPE_INT 0x0C
+#define ORIENT_INT 0x0B
+#define ORIENT 0x0B
+#define INT_FIRST_X 0x0B
+#define INT_FIRST_Y 0x0B
+#define INT_FIRST_Z 0x0B
+#define INT_SIGN 0x0B
+#define TIP_EN 0x0A
+#define ORIENT_BLOCKING 0x0A
+#define TT_SAMP 0x0A
+#define ORIENT_EX 0x09
+#define SLOPE_FILT 0x09
+#define SLOPE_TH 0x09
+#define SLOPE_DUR 0x09
+#define TT_FILT 0x08
+#define TT_TH 0x08
+#define TT_DUR 0x08
+#define LOW_HY 0x07
+#define LOW_DUR 0x07
+#define LOW_TH 0x06
+#define HIGH_TH 0x06
+#define HIGH_HY 0x05
+#define HIGH_DUR 0x05
+#define ACC_Z 0x04
+#define ACC_Y 0x03
+#define ACC_X 0x02
+#define REVISION_ID 0x01
+#define CHIP_ID 0x00
+
+#endif //SPI_MODE
+
+
+
+//I2C memory map
+#ifdef I2C_MODE //Use this set of definitions for I2C
+
+#define SOFTRESET 0x32
+#define SUSPEND 0x20
+#define WDT_TO_EN 0x2E
+#define WDT_TO_SEL 0x2E
+#define SPI3 0x2E
+#define SBIST_SIGN 0x22
+#define SBIST 0x22
+#define RANGE 0x22
+#define SERIAL_HIGH_BW 0x20
+#define FILT_CONFIG 0x20
+#define SLEEP_EN 0x1E
+#define SLEEP_DUR 0x1E
+#define EN_X_CHANNEL 0x1E
+#define EN_Y_CHANNEL 0x1E
+#define EN_Z_CHANNEL 0x1E
+#define RESET_INT 0x1C
+#define LAT_INT 0x1C
+#define EN_LOW 0x1C
+#define EN_HIGH_X 0x1C
+#define EN_HIGH_Y 0x1C
+#define EN_HIGH_Z 0x1C
+#define EN_DATA 0x1A
+#define EN_ORIENT 0x1A
+#define EN_SLOPE_X 0x1A
+#define EN_CLOPE_Y 0x1A
+#define EN_SLOPE_Z 0x1A
+#define EN_TT_X 0x1A
+#define EN_TT_Y 0x1A
+#define EN_TT_Z 0x1A
+#define TT_INT 0x18
+#define LOW_INT 0x18
+#define HIGH_INT 0x18
+#define DATA_INT 0x18
+#define SLOPE_INT 0x18
+#define ORIENT_INT 0x16
+#define ORIENT 0x16
+#define INT_FIRST_X 0x16
+#define INT_FIRST_Y 0x16
+#define INT_FIRST_Z 0x16
+#define INT_SIGN 0x16
+#define TIP_EN 0x14
+#define ORIENT_BLOCKING 0x14
+#define TT_SAMP 0x14
+#define ORIENT_EX 0x12
+#define SLOPE_FILT 0x12
+#define SLOPE_TH 0x12
+#define SLOPE_DUR 0x12
+#define TT_FILT 0x10
+#define TT_TH 0x10
+#define TT_DUR 0x10
+#define LOW_HY 0xE
+#define LOW_DUR 0xE
+#define LOW_TH 0xC
+#define HIGH_TH 0xC
+#define HIGH_HY 0xA
+#define HIGH_DUR 0xA
+#define ACC_Z 0x8
+#define ACC_Y 0x6
+#define ACC_X 0x4
+#define REVISION_ID 0x2
+#define CHIP_ID 0x0
+
+#endif //I2C_MODE
+
+
+//Memory map for L3G4200 gyroscope
+#define GYRO_WHO_AM_I 0x0F
+#define GYRO_CTRL_REG1 0x20
+#define GYRO_CTRL_REG2 0x21
+#define GYRO_CTRL_REG3 0x22
+#define GYRO_CTRL_REG4 0x23
+#define GYRO_CTRL_REG5 0x24
+#define GYRO_REFERENCE 0x25
+#define GYRO_OUT_TEMP 0x26
+#define GYRO_STATUS_REG 0x27
+#define GYRO_OUT_X_L 0x28
+#define GYRO_OUT_X_H 0x29
+#define GYRO_OUT_Y_L 0x2A
+#define GYRO_OUT_Y_H 0X2B
+#define GYRO_OUT_Z_L 0x2C
+#define GYRO_OUT_Z_H 0x2D
+#define GYRO_FIFO_CTRL_REG 0x2E
+#define GYRO_FIFO_SRC_REG 0x2F
+#define GYRO_INT1_CFG 0x30
+#define GYRO_INT1_SRC 0x31
+#define GYRO_INT1_TSH_XH 0x32
+#define GYRO_INT1_TSH_XL 0x33
+#define GYRO_INT1_TSH_YH 0x34
+#define GYRO_INT1_TSH_YL 0x35
+#define GYRO_INT1_THS_ZH 0x36
+#define GYRO_INT1_THS_ZL 0x37
+#define GYRO_INT1_DURATION 0x38
+
+
+void IMUinit(char MODE, byte ACCEL_CS, byte GYRO_CS)
+{
+ if(MODE == "SPI"){
+ SPI.begin();
+ SPI.setBitOrder(MSBFIRST);
+ SPI.setDataMode(SPI_MODE2);
+
+ digitalWrite(ACCEL_CS, HIGH);
+ digitalWrite(GYRO_CS, HIGH);
+ }
+
+ if(MODE == "I2C"){
+ Wire.begin();
+ }
+}
View
5 code/tinyIMU_test/tinyIMU.h
@@ -0,0 +1,5 @@
+/*
+tinyIMU.h
+Arduino library for the tinyIMU 3-axis
+accelerometer and gyroscope breakout board
+*/
View
15 code/tinyIMU_test/tinyIMU_test.pde
@@ -0,0 +1,15 @@
+/*
+tinyIMU test program
+
+This sketch demonstrates the use of the tinyIMU
+board and library by printing the X, Y, and Z
+acceleration and rotation values to the serial port.
+*/
+
+void setup()
+{
+}
+
+void loop()
+{
+}
View
BIN revA/imu.b#1
Binary file not shown.
View
BIN revA/imu.b#2
Binary file not shown.
View
BIN revA/imu.brd
Binary file not shown.
View
BIN revA/imu.s#1
Binary file not shown.
View
BIN revA/imu.s#2
Binary file not shown.
View
BIN revA/imu.sch
Binary file not shown.
View
21 revA/parts.txt
@@ -0,0 +1,21 @@
+Partlist
+
+Exported from imu.sch at 7/5/2012 4:36:42 PM
+
+EAGLE Version 5.11.0 Copyright (c) 1988-2010 CadSoft
+
+Part Value Device Package Library Sheet
+
+C1 .1uF C-USC0805K C0805K adafruit 1
+C2 .1uF C-USC0805K C0805K adafruit 1
+C3 C-USC0805K C0805K adafruit 1
+C4 10nF C-USC0805K C0805K adafruit 1
+C5 470nF C-USC0805K C0805K adafruit 1
+C6 .1uF C-USC0805K C0805K adafruit 1
+I2C/SPI SOLDERJUMPER_2WAY-OLDT SJ_2 SparkFun 1
+I2C_ADDR SOLDERJUMPER_2WAY-OLDT SJ_2 SparkFun 1
+JP1 I/O M10LOCK 1X10_LOCK SparkFun 1
+R1 10K R-US_R0805 R0805 adafruit 1
+U1 STLQ50C STLQ50C SOT323-5 st-microelectronics 1
+U2 BMA220 BMA220 12-LGA bosch 1
+U3 L3G4200D L3G4200D LGA16-4X4 SparkFun 1

0 comments on commit 16d33ea

Please sign in to comment.
Something went wrong with that request. Please try again.