Rev 489 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 489 | Rev 493 | ||
---|---|---|---|
1 | #ifndef _COMPASS_H |
1 | #ifndef _COMPASS_H |
2 | #define _COMPASS_H |
2 | #define _COMPASS_H |
3 | 3 | ||
4 | // this is the abstract interface for the magnetometer/compass sensor |
4 | // this is the abstract interface for the magnetometer/compass sensor |
5 | // below this there are different special sensors that are supported |
5 | // below this there are different special sensors that are supported |
6 | 6 | ||
7 | typedef struct |
7 | typedef struct |
8 | { |
8 | { |
9 | s16 X; |
9 | s16 X; |
10 | s16 Y; |
10 | s16 Y; |
11 | s16 Z; |
11 | s16 Z; |
12 | } __attribute__((packed)) s16vec_t; |
12 | } __attribute__((packed)) s16vec_t; |
13 | 13 | ||
14 | extern volatile s16vec_t MagVector; // current magnetic field vector |
14 | extern volatile s16vec_t MagVector; // current magnetic field vector |
15 | extern volatile s16vec_t AccVector; // current acceleration vector of compass, not supported by any HW version |
15 | extern volatile s16vec_t AccVector; // current acceleration vector of compass, not supported by any HW version |
- | 16 | extern volatile s16vec_t MagVectorHorizontal; // vector componenents in horizontal projection |
|
16 | extern volatile s16 Compass_Heading; // current heading direction |
17 | extern volatile s16 Compass_Heading; // current heading direction |
17 | extern volatile u8 Compass_CalState; // current calibration state |
18 | extern volatile u8 Compass_CalState; // current calibration state |
18 | extern s32 EarthMagneticField; |
19 | extern s32 EarthMagneticField; |
- | 20 | extern s32 EarthMagneticFieldFiltered; |
|
19 | extern s32 EarthMagneticInclination; |
21 | extern s32 EarthMagneticInclination; |
20 | extern s32 EarthMagneticInclinationFiltered; |
22 | extern s32 EarthMagneticInclinationFiltered; |
21 | extern s32 EarthMagneticInclinationTheoretic; |
23 | extern s32 EarthMagneticInclinationTheoretic; |
22 | extern s32 EarthMagneticFieldFiltered; |
- | |
23 | extern u8 ErrorDisturbedEarthMagnetField; |
24 | extern u8 ErrorDisturbedEarthMagnetField; |
24 | extern s16 EarthMagneticStrengthTheoretic; |
25 | extern s16 EarthMagneticStrengthTheoretic; |
25 | extern s16 Hx, Hy; |
- | |
26 | 26 | ||
27 | #define COMPASS_NONE 0 |
27 | #define COMPASS_NONE 0 |
28 | #define COMPASS_MK3MAG 1 |
28 | #define COMPASS_MK3MAG 1 |
29 | #define COMPASS_NCMAG 2 |
29 | #define COMPASS_NCMAG 2 |
30 | extern u8 Compass_Device; |
30 | extern u8 Compass_Device; |
31 | extern I2C_TypeDef* Compass_I2CPort; |
31 | extern I2C_TypeDef* Compass_I2CPort; |
32 | extern u32 CompassValueErrorCount; |
32 | extern u32 CompassValueErrorCount; |
33 | 33 | ||
34 | void Compass_Init(void); // initialization for compass sensor |
34 | void Compass_Init(void); // initialization for compass sensor |
35 | void Compass_Check(void); // possible check for compass plausibility, called when FC gets calibrates |
35 | void Compass_Check(void); // possible check for compass plausibility, called when FC gets calibrates |
36 | void Compass_Update(void); // updates sensor values, cyclic called |
36 | void Compass_Update(void); // updates sensor values, cyclic called |
37 | void Compass_CalcHeading(void); // calculates heading from magent vector componentes |
37 | void Compass_CalcHeading(void); // calculates heading from magent vector componentes |
38 | void Compass_SetCalState(u8 CalState); // append to CalState queue |
38 | void Compass_SetCalState(u8 CalState); // append to CalState queue |
39 | void Compass_UpdateCalState(void); // process CalState queue |
39 | void Compass_UpdateCalState(void); // process CalState queue |
40 | 40 | ||
41 | #endif // _COMPASS_H |
41 | #endif // _COMPASS_H |
42 | 42 |