Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 640 → Rev 641

/tags/V2.10c/compass.h
0,0 → 1,41
#ifndef _COMPASS_H
#define _COMPASS_H
 
// this is the abstract interface for the magnetometer/compass sensor
// below this there are different special sensors that are supported
 
typedef struct
{
s16 X;
s16 Y;
s16 Z;
} __attribute__((packed)) s16vec_t;
 
extern volatile s16vec_t MagVector; // current magnetic field vector
extern volatile s16vec_t AccVector; // current acceleration vector of compass, not supported by any HW version
extern volatile s16vec_t MagVectorHorizontal; // vector componenents in horizontal projection
extern volatile s16 Compass_Heading; // current heading direction
extern volatile u8 Compass_CalState; // current calibration state
extern s32 EarthMagneticField;
extern s32 EarthMagneticFieldFiltered;
extern s32 EarthMagneticInclination;
extern s32 EarthMagneticInclinationFiltered;
extern s32 EarthMagneticInclinationTheoretic;
extern u8 ErrorDisturbedEarthMagnetField;
extern s16 EarthMagneticStrengthTheoretic;
 
#define COMPASS_NONE 0
#define COMPASS_MK3MAG 1
#define COMPASS_NCMAG 2
extern u8 Compass_Device;
extern I2C_TypeDef* Compass_I2CPort;
extern u32 CompassValueErrorCount;
 
void Compass_Init(void); // initialization for compass sensor
void Compass_Check(void); // possible check for compass plausibility, called when FC gets calibrates
void Compass_Update(void); // updates sensor values, cyclic called
void Compass_CalcHeading(void); // calculates heading from magent vector componentes
void Compass_SetCalState(u8 CalState); // append to CalState queue
void Compass_UpdateCalState(void); // process CalState queue
 
#endif // _COMPASS_H