Subversion Repositories NaviCtrl

Rev

Rev 450 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 ingob 1
#ifndef _MAIN_H
2
#define _MAIN_H
1 ingob 3
 
314 killagreg 4
 
318 holgerb 5
//#define FOLLOW_ME
314 killagreg 6
 
7
#ifdef FOLLOW_ME
8
extern u8 TransmitAlsoToFC;
9
#endif
10
 
250 ingob 11
//-----------------------
434 holgerb 12
//#define DEBUG 0
250 ingob 13
//-----------------------
14
 
41 ingob 15
#define VERSION_MAJOR   0
438 holgerb 16
#define VERSION_MINOR   30
450 holgerb 17
#define VERSION_PATCH   7
283 holgerb 18
// 0 = A
19
// 1 = B
20
// 2 = C
21
// 3 = D
22
// 4 = E
23
// 5 = F
24
// 6 = G
25
// 7 = H
26
// 8 = I
287 holgerb 27
// 9 = J
290 holgerb 28
// 10 = k
291 holgerb 29
// 11 = L
294 holgerb 30
// 12 = M
298 holgerb 31
// 13 = N
338 holgerb 32
// 14 = O
33
// 15 = P
34
// 16 = Q
35
// 17 = R
339 holgerb 36
// 18 = S
1 ingob 37
 
400 holgerb 38
#define VERSION_SERIAL_MAJOR    11
193 killagreg 39
#define VERSION_SERIAL_MINOR    0
73 killagreg 40
 
317 holgerb 41
#ifndef FOLLOW_ME
447 holgerb 42
#define FC_SPI_COMPATIBLE               53
317 holgerb 43
#else
316 killagreg 44
#define FC_SPI_COMPATIBLE               0xFF
45
#endif
46
 
229 holgerb 47
#define MK3MAG_I2C_COMPATIBLE   3
241 killagreg 48
 
320 holgerb 49
// FC.StatusFlags
255 killagreg 50
#define FC_STATUS_MOTOR_RUN                             0x01
51
#define FC_STATUS_FLY                                   0x02
52
#define FC_STATUS_CALIBRATE                             0x04
53
#define FC_STATUS_START                                 0x08
54
#define FC_STATUS_EMERGENCY_LANDING             0x10
55
#define FC_STATUS_LOWBAT                                0x20
279 holgerb 56
#define FC_STATUS_VARIO_TRIM_UP                 0x40
57
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
78 holgerb 58
 
320 holgerb 59
// FC.StatusFlags2
294 holgerb 60
#define FC_STATUS2_CAREFREE                 0x01
61
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
322 holgerb 62
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
360 holgerb 63
#define FC_STATUS2_OUT1_ACTIVE                  0x08
64
#define FC_STATUS2_OUT2_ACTIVE                  0x10
447 holgerb 65
#define FC_STATUS2_WAIT_FOR_TAKEOFF             0x20   // Motor Running, but still on the ground
294 holgerb 66
 
255 killagreg 67
// FC ERRORS FLAGS
68
#define FC_ERROR0_GYRO_NICK     0x01
69
#define FC_ERROR0_GYRO_ROLL     0x02
70
#define FC_ERROR0_GYRO_YAW              0x04
71
#define FC_ERROR0_ACC_NICK              0x08
72
#define FC_ERROR0_ACC_ROLL              0x10
73
#define FC_ERROR0_ACC_TOP               0x20
74
#define FC_ERROR0_PRESSURE              0x40
75
#define FC_ERROR0_CAREFREE              0x80
76
 
77
#define FC_ERROR1_I2C                   0x01
78
#define FC_ERROR1_BL_MISSING    0x02
79
#define FC_ERROR1_SPI_RX                0x04
80
#define FC_ERROR1_PPM                   0x08
81
#define FC_ERROR1_MIXER                 0x10
82
#define FC_ERROR1_RES1                  0x20
83
#define FC_ERROR1_RES2                  0x40
84
#define FC_ERROR1_RES3                  0x80
85
 
146 killagreg 86
// NC Errors
87
#define NCERR_FLAG_FC_COMPATIBLE                        0x00000001
88
#define NCERR_FLAG_MK3MAG_COMPATIBLE            0x00000002
89
#define NCERR_FLAG_FC_COMMUNICATION                     0x00000004
90
#define NCERR_FLAG_MK3MAG_COMMUNICATION         0x00000008
91
#define NCERR_FLAG_MKGPS_COMMUNICATION          0x00000010
92
#define NCERR_FLAG_BAD_COMPASS_HEADING          0x00000020
93
#define NCERR_FLAG_RC_SIGNAL_LOST                       0x00000040
264 killagreg 94
#define NCERR_FLAG_EEPROM_NOT_FOUND                     0x00000080
49 ingob 95
 
350 holgerb 96
//Parameter.GlobalConfig3
97
#define CFG3_NO_SDCARD_NO_START                 0x01
98
#define CFG3_DPH_MAX_RADIUS                     0x02
99
#define CFG3_VARIO_FAILSAFE                     0x04
398 holgerb 100
#define CFG3_MOTOR_SWITCH_MODE                  0x08
101
#define CFG3_NO_GPSFIX_NO_START                 0x10
350 holgerb 102
 
320 holgerb 103
// Parameter.GlobalConfig
331 holgerb 104
#define FC_CFG_HOEHENREGELUNG           0x01
105
#define FC_CFG_HOEHEN_SCHALTER          0x02
106
#define FC_CFG_HEADING_HOLD             0x04
107
#define FC_CFG_KOMPASS_AKTIV            0x08
108
#define FC_CFG_KOMPASS_FIX              0x10
109
#define FC_CFG_GPS_AKTIV                0x20
110
#define FC_CFG_ACHSENKOPPLUNG_AKTIV     0x40
111
#define FC_CFG_DREHRATEN_BEGRENZER      0x80
190 killagreg 112
 
331 holgerb 113
//Parameter.ExtraConfig 
114
#define CFG2_HEIGHT_LIMIT                       0x01
115
#define CFG2_VARIO_BEEP                         0x02
116
#define CFG_SENSITIVE_RC                        0x04
117
#define CFG_3_3V_REFERENCE                      0x08
118
#define CFG_NO_RCOFF_BEEPING                    0x10
119
#define CFG_GPS_AID                             0x20
120
#define CFG_TEACHABLE_CAREFREE                  0x40
121
#define CFG_IGNORE_MAG_ERR_AT_STARTUP   0x80
320 holgerb 122
 
190 killagreg 123
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
124
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
125
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
126
 
327 holgerb 127
 
128
#define Poti1  FC.Poti[0]
129
#define Poti2  FC.Poti[1]
130
#define Poti3  FC.Poti[2]
131
#define Poti4  FC.Poti[3]
132
#define Poti5  FC.Poti[4]
133
#define Poti6  FC.Poti[5]
134
#define Poti7  FC.Poti[6]
135
#define Poti8  FC.Poti[7]
136
 
41 ingob 137
extern u16 BeepTime;
92 killagreg 138
extern u8  NCFlags;
255 killagreg 139
extern u8 ClearFCStatusFlags;
41 ingob 140
void Interrupt_Init(void);
153 killagreg 141
extern s16 GeoMagDec;
1 ingob 142
 
41 ingob 143
typedef struct
144
{
145
        u8 ActiveSetting;
146
        u8 User1;
147
        u8 User2;
148
        u8 User3;
149
        u8 User4;
150
        u8 User5;
151
        u8 User6;
152
        u8 User7;
153
        u8 User8;
154
        u8 NaviGpsModeControl;
155
        u8 NaviGpsGain;
156
        u8 NaviGpsP;
157
        u8 NaviGpsI;
158
        u8 NaviGpsD;
56 holgerb 159
        u8 NaviGpsPLimit;
160
        u8 NaviGpsILimit;
161
        u8 NaviGpsDLimit;
41 ingob 162
        u8 NaviGpsACC;
163
        u8 NaviGpsMinSat;
164
        u8 NaviStickThreshold;
165
        u8 NaviOperatingRadius;
166
        u8 NaviWindCorrection;
327 holgerb 167
        u8 NaviAccCompensation;
41 ingob 168
        u8 NaviSpeedCompensation;
169
        u8 LowVoltageWarning;
170
        u8 NaviAngleLimitation;
56 holgerb 171
        u8 NaviPH_LoginTime;
320 holgerb 172
        u8 OrientationAngle;
173
        u8 GlobalConfig;
174
        u8 ExtraConfig;
321 holgerb 175
        u8 ComingHomeAltitude;
350 holgerb 176
        u8 GlobalConfig3;
419 holgerb 177
        u8 NaviOut1Parameter; // Distance between Photo releases
41 ingob 178
} __attribute__((packed)) Param_t;
1 ingob 179
 
41 ingob 180
typedef struct
181
{
182
        s8 StickNick;
183
        s8 StickRoll;
184
        s8 StickYaw;
185
        s8 StickGas;
190 killagreg 186
        u8 Poti[8];
41 ingob 187
        u8 RC_Quality;
125 killagreg 188
        u8 RC_RSSI;
206 killagreg 189
        u8 BAT_Voltage;
190
        u16 BAT_Current;
191
        u16 BAT_UsedCapacity;
255 killagreg 192
        u8 StatusFlags;
193
        u8 Error[5];
294 holgerb 194
        u8 StatusFlags2;
436 holgerb 195
        u8 FromFC_SpeakHoTT;
41 ingob 196
} __attribute__((packed)) FC_t;
1 ingob 197
 
242 killagreg 198
 
41 ingob 199
extern Param_t Parameter;
78 holgerb 200
extern volatile FC_t FC;
41 ingob 201
extern s8 ErrorMSG[25];
241 killagreg 202
extern u8 ErrorCode;
41 ingob 203
extern u8 StopNavigation;
328 holgerb 204
extern u8 ErrorGpsFixLost;
378 holgerb 205
extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero
362 holgerb 206
extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero
378 holgerb 207
extern volatile u32 PollingTimeout;
362 holgerb 208
 
41 ingob 209
#endif // _MAIN_H