imu rev1

Dependencies:   IMUfilter mbed

Fork of AIviate by UCLA IEEE

Committer:
teamgoat
Date:
Wed Oct 30 02:31:43 2013 +0000
Revision:
0:0c627ff4c5ed
Child:
2:452dd766d212
First compiled version (reads sensors, I think)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
teamgoat 0:0c627ff4c5ed 1 #ifndef SENSOR_H
teamgoat 0:0c627ff4c5ed 2 #define SENSOR_H
teamgoat 0:0c627ff4c5ed 3
teamgoat 0:0c627ff4c5ed 4 #include "mbed.h"
teamgoat 0:0c627ff4c5ed 5
teamgoat 0:0c627ff4c5ed 6
teamgoat 0:0c627ff4c5ed 7
teamgoat 0:0c627ff4c5ed 8 #define accel_w 0x3A
teamgoat 0:0c627ff4c5ed 9 #define accel_r 0x3B
teamgoat 0:0c627ff4c5ed 10 #define ACCEL_X 0x32 // x: 0x32,0x33 y: 0x34,0x35 z: 0x36,0x37 Little Endian!!! (x = 0x33<<8|0x22), etc...
teamgoat 0:0c627ff4c5ed 11 #define ACCEL_Z
teamgoat 0:0c627ff4c5ed 12 #define gyro_w 0xD0
teamgoat 0:0c627ff4c5ed 13 #define gyro_r 0xD1
teamgoat 0:0c627ff4c5ed 14 #define compass_w 0x3C
teamgoat 0:0c627ff4c5ed 15 #define compass_r 0x3D
teamgoat 0:0c627ff4c5ed 16 #define barometer_w 0xEE
teamgoat 0:0c627ff4c5ed 17 #define barometer_r 0xEF
teamgoat 0:0c627ff4c5ed 18
teamgoat 0:0c627ff4c5ed 19 struct accel
teamgoat 0:0c627ff4c5ed 20 {
teamgoat 0:0c627ff4c5ed 21 int ax, ay, az;
teamgoat 0:0c627ff4c5ed 22 char raw_data[6];
teamgoat 0:0c627ff4c5ed 23 };
teamgoat 0:0c627ff4c5ed 24
teamgoat 0:0c627ff4c5ed 25 struct gyro
teamgoat 0:0c627ff4c5ed 26 {
teamgoat 0:0c627ff4c5ed 27 int gy, gx, gz;
teamgoat 0:0c627ff4c5ed 28 };
teamgoat 0:0c627ff4c5ed 29
teamgoat 0:0c627ff4c5ed 30 struct config
teamgoat 0:0c627ff4c5ed 31 {
teamgoat 0:0c627ff4c5ed 32 int frequency;
teamgoat 0:0c627ff4c5ed 33 };
teamgoat 0:0c627ff4c5ed 34
teamgoat 0:0c627ff4c5ed 35
teamgoat 0:0c627ff4c5ed 36 char set_i2c_pointer(char addr, char reg);
teamgoat 0:0c627ff4c5ed 37
teamgoat 0:0c627ff4c5ed 38 int read(char addr, char reg, char *buf, int n);
teamgoat 0:0c627ff4c5ed 39
teamgoat 0:0c627ff4c5ed 40 int write(char addr, char reg, char *buf, int n);
teamgoat 0:0c627ff4c5ed 41
teamgoat 0:0c627ff4c5ed 42 int read_accelerometer(struct accel* s);
teamgoat 0:0c627ff4c5ed 43
teamgoat 0:0c627ff4c5ed 44 void read_gyro(struct gyro* s);
teamgoat 0:0c627ff4c5ed 45 int read_compass(void);
teamgoat 0:0c627ff4c5ed 46 int read_barometer(void);
teamgoat 0:0c627ff4c5ed 47
teamgoat 0:0c627ff4c5ed 48 void config_accelerometer(void);
teamgoat 0:0c627ff4c5ed 49 void config_gyro(void);
teamgoat 0:0c627ff4c5ed 50 void config_compass(void);
teamgoat 0:0c627ff4c5ed 51 void config_barometer(void);
teamgoat 0:0c627ff4c5ed 52
teamgoat 0:0c627ff4c5ed 53 void config_gy80(struct config *c);
teamgoat 0:0c627ff4c5ed 54
teamgoat 0:0c627ff4c5ed 55 #endif //SENSOR_H