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@21:c2a2e7cbabdd, 2012-11-17 (annotated)
- Committer:
- maetugr
- Date:
- Sat Nov 17 11:49:21 2012 +0000
- Revision:
- 21:c2a2e7cbabdd
- Parent:
- 20:e116e596e540
Erster Flugtest, noch nicht stabil!
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 | 20:e116e596e540 | 9 | #define L3G4200D_I2C_ADDRESS 0xD0 |
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 | 18:c8c09a3913ba | 47 | virtual void read(); // read all axis from register to array data |
maetugr | 21:c2a2e7cbabdd | 48 | void calibrate(); // calibrate the gyro (get an offset while not moving) |
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 | 20:e116e596e540 | 53 | virtual void readraw(); |
maetugr | 0:0c4fafa398b4 | 54 | }; |
maetugr | 0:0c4fafa398b4 | 55 | |
maetugr | 0:0c4fafa398b4 | 56 | #endif |