NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Committer:
maetugr
Date:
Sat Oct 20 17:28:28 2012 +0000
Revision:
12:67a06c9b69d5
Parent:
11:9bf69bc6df45
Child:
14:cf260677ecde
mit unterbrochenem RC signal, kompass fertig mit speicherung!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 11:9bf69bc6df45 1 #ifndef HMC5883_H
maetugr 11:9bf69bc6df45 2 #define HMC5883_H
maetugr 11:9bf69bc6df45 3
maetugr 11:9bf69bc6df45 4 #define HMC5883_CONF_REG_A 0x00
maetugr 11:9bf69bc6df45 5 #define HMC5883_CONF_REG_B 0x01
maetugr 11:9bf69bc6df45 6 #define HMC5883_MODE_REG 0x02
maetugr 11:9bf69bc6df45 7 #define HMC5883_DATA_OUT_X_MSB 0x03
maetugr 11:9bf69bc6df45 8
maetugr 11:9bf69bc6df45 9 // I2C addresses
maetugr 11:9bf69bc6df45 10 #define HMC5883_ADDRESS 0x1E
maetugr 11:9bf69bc6df45 11 #define I2CADR_W(ADR) (ADR << 1&0xFE) // ADR & 1111 1110
maetugr 11:9bf69bc6df45 12 #define I2CADR_R(ADR) (ADR << 1|0x01) // ADR | 0000 0001
maetugr 11:9bf69bc6df45 13
maetugr 11:9bf69bc6df45 14 class HMC5883
maetugr 11:9bf69bc6df45 15 {
maetugr 11:9bf69bc6df45 16 public:
maetugr 11:9bf69bc6df45 17 HMC5883(PinName sda, PinName scl);
maetugr 11:9bf69bc6df45 18
maetugr 11:9bf69bc6df45 19 //my
maetugr 11:9bf69bc6df45 20 float data[3];
maetugr 11:9bf69bc6df45 21
maetugr 11:9bf69bc6df45 22 void read();
maetugr 12:67a06c9b69d5 23
maetugr 12:67a06c9b69d5 24 void calibrate(int s);
maetugr 12:67a06c9b69d5 25 int Min[3];
maetugr 12:67a06c9b69d5 26 int Max[3];
maetugr 12:67a06c9b69d5 27 float scale[3];
maetugr 12:67a06c9b69d5 28 float offset[3];
maetugr 12:67a06c9b69d5 29 LocalFileSystem local;
maetugr 12:67a06c9b69d5 30
maetugr 12:67a06c9b69d5 31 float get_angle();
maetugr 12:67a06c9b69d5 32
maetugr 12:67a06c9b69d5 33 private:
maetugr 12:67a06c9b69d5 34 I2C i2c;
maetugr 12:67a06c9b69d5 35
maetugr 12:67a06c9b69d5 36 // raw data and function to measure it
maetugr 12:67a06c9b69d5 37 int raw[3];
maetugr 12:67a06c9b69d5 38 void readraw();
maetugr 12:67a06c9b69d5 39
maetugr 12:67a06c9b69d5 40 // I2C functions
maetugr 11:9bf69bc6df45 41 void writeReg(char address, char data);
maetugr 11:9bf69bc6df45 42 void readMultiReg(char address, char* output, int size);
maetugr 11:9bf69bc6df45 43
maetugr 11:9bf69bc6df45 44 };
maetugr 11:9bf69bc6df45 45
maetugr 11:9bf69bc6df45 46 #endif