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.
Sensors/Gyro/L3G4200D.h@17:e096e85f6c36, 2012-10-31 (annotated)
- Committer:
- maetugr
- Date:
- Wed Oct 31 16:53:01 2012 +0000
- Revision:
- 17:e096e85f6c36
- Parent:
- 16:74a6531350b5
- Child:
- 18:c8c09a3913ba
alle Sensoren mit i2c auf I2C_Sensor umgestellt (nicht getestet), noch keine calibration save per I2C_Sensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 0:0c4fafa398b4 | 1 | // based on http://mbed.org/users/shimniok/code/L3G4200D/ |
maetugr | 0:0c4fafa398b4 | 2 | |
maetugr | 2:93f703d2c4d7 | 3 | #ifndef L3G4200D_H |
maetugr | 2:93f703d2c4d7 | 4 | #define L3G4200D_H |
maetugr | 0:0c4fafa398b4 | 5 | |
maetugr | 0:0c4fafa398b4 | 6 | #include "mbed.h" |
maetugr | 16:74a6531350b5 | 7 | #include "I2C_Sensor.h" |
maetugr | 0:0c4fafa398b4 | 8 | |
maetugr | 17:e096e85f6c36 | 9 | #define L3G4200D_I2C_ADDRESS 0xD0 // TODO: Adressen??? |
maetugr | 17:e096e85f6c36 | 10 | |
maetugr | 0:0c4fafa398b4 | 11 | // register addresses |
maetugr | 17:e096e85f6c36 | 12 | #define L3G4200D_WHO_AM_I 0x0F |
maetugr | 0:0c4fafa398b4 | 13 | |
maetugr | 17:e096e85f6c36 | 14 | #define L3G4200D_CTRL_REG1 0x20 |
maetugr | 17:e096e85f6c36 | 15 | #define L3G4200D_CTRL_REG2 0x21 |
maetugr | 17:e096e85f6c36 | 16 | #define L3G4200D_CTRL_REG3 0x22 |
maetugr | 17:e096e85f6c36 | 17 | #define L3G4200D_CTRL_REG4 0x23 |
maetugr | 17:e096e85f6c36 | 18 | #define L3G4200D_CTRL_REG5 0x24 |
maetugr | 17:e096e85f6c36 | 19 | #define L3G4200D_REFERENCE 0x25 |
maetugr | 17:e096e85f6c36 | 20 | #define L3G4200D_OUT_TEMP 0x26 |
maetugr | 17:e096e85f6c36 | 21 | #define L3G4200D_STATUS_REG 0x27 |
maetugr | 0:0c4fafa398b4 | 22 | |
maetugr | 17:e096e85f6c36 | 23 | #define L3G4200D_OUT_X_L 0x28 |
maetugr | 17:e096e85f6c36 | 24 | #define L3G4200D_OUT_X_H 0x29 |
maetugr | 17:e096e85f6c36 | 25 | #define L3G4200D_OUT_Y_L 0x2A |
maetugr | 17:e096e85f6c36 | 26 | #define L3G4200D_OUT_Y_H 0x2B |
maetugr | 17:e096e85f6c36 | 27 | #define L3G4200D_OUT_Z_L 0x2C |
maetugr | 17:e096e85f6c36 | 28 | #define L3G4200D_OUT_Z_H 0x2D |
maetugr | 0:0c4fafa398b4 | 29 | |
maetugr | 17:e096e85f6c36 | 30 | #define L3G4200D_FIFO_CTRL_REG 0x2E |
maetugr | 17:e096e85f6c36 | 31 | #define L3G4200D_FIFO_SRC_REG 0x2F |
maetugr | 0:0c4fafa398b4 | 32 | |
maetugr | 17:e096e85f6c36 | 33 | #define L3G4200D_INT1_CFG 0x30 |
maetugr | 17:e096e85f6c36 | 34 | #define L3G4200D_INT1_SRC 0x31 |
maetugr | 17:e096e85f6c36 | 35 | #define L3G4200D_INT1_THS_XH 0x32 |
maetugr | 17:e096e85f6c36 | 36 | #define L3G4200D_INT1_THS_XL 0x33 |
maetugr | 17:e096e85f6c36 | 37 | #define L3G4200D_INT1_THS_YH 0x34 |
maetugr | 17:e096e85f6c36 | 38 | #define L3G4200D_INT1_THS_YL 0x35 |
maetugr | 17:e096e85f6c36 | 39 | #define L3G4200D_INT1_THS_ZH 0x36 |
maetugr | 17:e096e85f6c36 | 40 | #define L3G4200D_INT1_THS_ZL 0x37 |
maetugr | 17:e096e85f6c36 | 41 | #define L3G4200D_INT1_DURATION 0x38 |
maetugr | 0:0c4fafa398b4 | 42 | |
maetugr | 16:74a6531350b5 | 43 | class L3G4200D : public I2C_Sensor |
maetugr | 0:0c4fafa398b4 | 44 | { |
maetugr | 0:0c4fafa398b4 | 45 | public: |
maetugr | 16:74a6531350b5 | 46 | L3G4200D(PinName sda, PinName scl); // constructor, uses I2C_Sensor class |
maetugr | 16:74a6531350b5 | 47 | void read(); // read all axis to array |
maetugr | 16:74a6531350b5 | 48 | float data[3]; // where the measured data is saved |
maetugr | 16:74a6531350b5 | 49 | int readTemp(); // read temperature from sensor |
maetugr | 0:0c4fafa398b4 | 50 | |
maetugr | 0:0c4fafa398b4 | 51 | private: |
maetugr | 17:e096e85f6c36 | 52 | float offset[3]; // offset that's subtracted from every measurement |
maetugr | 0:0c4fafa398b4 | 53 | }; |
maetugr | 0:0c4fafa398b4 | 54 | |
maetugr | 0:0c4fafa398b4 | 55 | #endif |