Subversion Repositories NaviCtrl

Rev

Rev 639 | 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
 
458 holgerb 15
#define VERSION_MAJOR   2
631 holgerb 16
#define VERSION_MINOR   10
639 holgerb 17
#define VERSION_PATCH   2
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
 
317 holgerb 38
#ifndef FOLLOW_ME
616 holgerb 39
#define FC_SPI_COMPATIBLE               75      //   <------------------
317 holgerb 40
#else
316 killagreg 41
#define FC_SPI_COMPATIBLE               0xFF
42
#endif
43
 
229 holgerb 44
#define MK3MAG_I2C_COMPATIBLE   3
607 holgerb 45
#define MAX_MOTORS 16     // since 2.10 (3.2014)
241 killagreg 46
 
320 holgerb 47
// FC.StatusFlags
255 killagreg 48
#define FC_STATUS_MOTOR_RUN                             0x01
49
#define FC_STATUS_FLY                                   0x02
50
#define FC_STATUS_CALIBRATE                             0x04
51
#define FC_STATUS_START                                 0x08
52
#define FC_STATUS_EMERGENCY_LANDING             0x10
53
#define FC_STATUS_LOWBAT                                0x20
279 holgerb 54
#define FC_STATUS_VARIO_TRIM_UP                 0x40
55
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
78 holgerb 56
 
320 holgerb 57
// FC.StatusFlags2
294 holgerb 58
#define FC_STATUS2_CAREFREE                 0x01
59
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
322 holgerb 60
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
360 holgerb 61
#define FC_STATUS2_OUT1_ACTIVE                  0x08
62
#define FC_STATUS2_OUT2_ACTIVE                  0x10
447 holgerb 63
#define FC_STATUS2_WAIT_FOR_TAKEOFF             0x20   // Motor Running, but still on the ground
294 holgerb 64
 
573 holgerb 65
// FC.StatusFlags3 
616 holgerb 66
#define FC_STATUS3_REDUNDANCE_AKTIVE        0x01
573 holgerb 67
#define FC_STATUS3_BOAT                         0x02
616 holgerb 68
#define FC_STATUS3_REDUNDANCE_ERROR                     0x04
69
#define FC_STATUS3_REDUNDANCE_TEST                      0x08
573 holgerb 70
 
595 holgerb 71
#define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80)
72
#define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10)
73
 
74
// .NCFlags
75
#define NC_FLAG_FREE                    0x01
76
#define NC_FLAG_PH                              0x02
77
#define NC_FLAG_CH                              0x04
78
#define NC_FLAG_RANGE_LIMIT             0x08
79
#define NC_FLAG_NOSERIALLINK    0x10
80
#define NC_FLAG_TARGET_REACHED  0x20
81
#define NC_FLAG_MANUAL_CONTROL  0x40
82
#define NC_FLAG_GPS_OK                  0x80
83
 
84
 
85
// NC calculates
86
//OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2);
87
//OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2);
88
 
89
//calculate Back:
90
//FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1);
91
//FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2);
92
 
255 killagreg 93
// FC ERRORS FLAGS
94
#define FC_ERROR0_GYRO_NICK     0x01
95
#define FC_ERROR0_GYRO_ROLL     0x02
96
#define FC_ERROR0_GYRO_YAW              0x04
97
#define FC_ERROR0_ACC_NICK              0x08
98
#define FC_ERROR0_ACC_ROLL              0x10
99
#define FC_ERROR0_ACC_TOP               0x20
100
#define FC_ERROR0_PRESSURE              0x40
101
#define FC_ERROR0_CAREFREE              0x80
102
 
103
#define FC_ERROR1_I2C                   0x01
104
#define FC_ERROR1_BL_MISSING    0x02
105
#define FC_ERROR1_SPI_RX                0x04
106
#define FC_ERROR1_PPM                   0x08
107
#define FC_ERROR1_MIXER                 0x10
108
#define FC_ERROR1_RES1                  0x20
109
#define FC_ERROR1_RES2                  0x40
110
#define FC_ERROR1_RES3                  0x80
111
 
146 killagreg 112
// NC Errors
113
#define NCERR_FLAG_FC_COMPATIBLE                        0x00000001
114
#define NCERR_FLAG_MK3MAG_COMPATIBLE            0x00000002
115
#define NCERR_FLAG_FC_COMMUNICATION                     0x00000004
116
#define NCERR_FLAG_MK3MAG_COMMUNICATION         0x00000008
117
#define NCERR_FLAG_MKGPS_COMMUNICATION          0x00000010
118
#define NCERR_FLAG_BAD_COMPASS_HEADING          0x00000020
119
#define NCERR_FLAG_RC_SIGNAL_LOST                       0x00000040
264 killagreg 120
#define NCERR_FLAG_EEPROM_NOT_FOUND                     0x00000080
49 ingob 121
 
625 holgerb 122
//NC_To_FC_Flags
123
#define NC_TO_FC_FLYING_RANGE           0x01
124
#define NC_TO_FC_EMERGENCY_LANDING      0x02
125
#define NC_TO_FC_AUTOSTART                      0x04
126
#define NC_TO_FC_FAILSAFE_LANDING       0x08 // activates Servos
127
#define NC_TO_FC_SIMULATION_ACTIVE      0x10 // don't start motors if simulation ist active
128
 
350 holgerb 129
//Parameter.GlobalConfig3
130
#define CFG3_NO_SDCARD_NO_START                 0x01
532 holgerb 131
//#define CFG3_DPH_MAX_RADIUS                   0x02
350 holgerb 132
#define CFG3_VARIO_FAILSAFE                     0x04
398 holgerb 133
#define CFG3_MOTOR_SWITCH_MODE                  0x08
134
#define CFG3_NO_GPSFIX_NO_START                 0x10
350 holgerb 135
 
320 holgerb 136
// Parameter.GlobalConfig
331 holgerb 137
#define FC_CFG_HOEHENREGELUNG           0x01
138
#define FC_CFG_HOEHEN_SCHALTER          0x02
139
#define FC_CFG_HEADING_HOLD             0x04
140
#define FC_CFG_KOMPASS_AKTIV            0x08
141
#define FC_CFG_KOMPASS_FIX              0x10
142
#define FC_CFG_GPS_AKTIV                0x20
143
#define FC_CFG_ACHSENKOPPLUNG_AKTIV     0x40
144
#define FC_CFG_DREHRATEN_BEGRENZER      0x80
190 killagreg 145
 
489 killagreg 146
//Parameter.ExtraConfig
331 holgerb 147
#define CFG2_HEIGHT_LIMIT                       0x01
148
#define CFG2_VARIO_BEEP                         0x02
149
#define CFG_SENSITIVE_RC                        0x04
150
#define CFG_3_3V_REFERENCE                      0x08
151
#define CFG_NO_RCOFF_BEEPING                    0x10
152
#define CFG_GPS_AID                             0x20
153
#define CFG_TEACHABLE_CAREFREE                  0x40
154
#define CFG_IGNORE_MAG_ERR_AT_STARTUP   0x80
320 holgerb 155
 
588 holgerb 156
// Parameter.HomeYawMode
157
#define NO_CHANGE               0
158
#define FRONT_TO_HOME   1
159
#define REAR_TO_HOME    2
160
#define LIKE_AT_START   3
161
 
587 holgerb 162
// Parameter.ReceiverType defines for the receiver selection
163
#define RECEIVER_PPM                            0
164
#define RECEIVER_SPEKTRUM                       1
165
#define RECEIVER_SPEKTRUM_HI_RES        2
166
#define RECEIVER_SPEKTRUM_LOW_RES       3
167
#define RECEIVER_JETI                           4
168
#define RECEIVER_ACT_DSL                        5
169
#define RECEIVER_HOTT                           6
170
#define RECEIVER_SBUS                           7
171
#define RECEIVER_USER                           8
172
 
173
#define RECEIVER_UNKNOWN                        0xFF
174
 
190 killagreg 175
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
176
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
177
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
178
 
327 holgerb 179
 
180
#define Poti1  FC.Poti[0]
181
#define Poti2  FC.Poti[1]
182
#define Poti3  FC.Poti[2]
183
#define Poti4  FC.Poti[3]
184
#define Poti5  FC.Poti[4]
185
#define Poti6  FC.Poti[5]
186
#define Poti7  FC.Poti[6]
187
#define Poti8  FC.Poti[7]
188
 
41 ingob 189
extern u16 BeepTime;
92 killagreg 190
extern u8  NCFlags;
255 killagreg 191
extern u8 ClearFCStatusFlags;
41 ingob 192
void Interrupt_Init(void);
153 killagreg 193
extern s16 GeoMagDec;
504 holgerb 194
extern u8 NewWPL_Name;
1 ingob 195
 
505 holgerb 196
#define VERSION_SERIAL_MAJOR    11 // do not change!
197
 
41 ingob 198
typedef struct
199
{
200
        u8 ActiveSetting;
201
        u8 User1;
202
        u8 User2;
203
        u8 User3;
204
        u8 User4;
205
        u8 User5;
206
        u8 User6;
207
        u8 User7;
208
        u8 User8;
209
        u8 NaviGpsModeControl;
210
        u8 NaviGpsGain;
211
        u8 NaviGpsP;
212
        u8 NaviGpsI;
213
        u8 NaviGpsD;
56 holgerb 214
        u8 NaviGpsPLimit;
215
        u8 NaviGpsILimit;
216
        u8 NaviGpsDLimit;
41 ingob 217
        u8 NaviGpsACC;
218
        u8 NaviGpsMinSat;
219
        u8 NaviStickThreshold;
532 holgerb 220
        u8 NaviMaxFlyingRange; // in 10m
41 ingob 221
        u8 NaviWindCorrection;
327 holgerb 222
        u8 NaviAccCompensation;
41 ingob 223
        u8 NaviSpeedCompensation;
224
        u8 LowVoltageWarning;
225
        u8 NaviAngleLimitation;
56 holgerb 226
        u8 NaviPH_LoginTime;
544 holgerb 227
        u8 OrientationAngle; // where is front - in 15°
228
        u8 CamOrientation;       // direction of the camera in 15°
320 holgerb 229
        u8 GlobalConfig;
230
        u8 ExtraConfig;
321 holgerb 231
        u8 ComingHomeAltitude;
350 holgerb 232
        u8 GlobalConfig3;
516 holgerb 233
        u8 AutoPhotoDistance; // Distance between Photo releases (Position)
489 killagreg 234
        u8 FromFC_LandingSpeed;
235
        u8 FromFC_LowVoltageHomeActive;
516 holgerb 236
        u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes)
519 holgerb 237
        u8 SingleWpSpeed;
532 holgerb 238
        u8 DescendRange; // in 10m
239
        u8 MaximumAltitude; // in m
573 holgerb 240
        u8 Driftkomp;
587 holgerb 241
        u8 ReceiverType;
588 holgerb 242
        u8 HomeYawMode;
624 holgerb 243
        u8 Speak100m;
244
        u8 AutoWpEventValue;
41 ingob 245
} __attribute__((packed)) Param_t;
1 ingob 246
 
41 ingob 247
typedef struct
248
{
249
        s8 StickNick;
250
        s8 StickRoll;
251
        s8 StickYaw;
252
        s8 StickGas;
190 killagreg 253
        u8 Poti[8];
41 ingob 254
        u8 RC_Quality;
125 killagreg 255
        u8 RC_RSSI;
595 holgerb 256
        u16 BAT_Voltage;
206 killagreg 257
        u16 BAT_Current;
258
        u16 BAT_UsedCapacity;
255 killagreg 259
        u8 StatusFlags;
260
        u8 Error[5];
294 holgerb 261
        u8 StatusFlags2;
436 holgerb 262
        u8 FromFC_SpeakHoTT;
489 killagreg 263
        s16 FromFC_CompassOffset;
264
        u8 FromFC_DisableDeclination;
573 holgerb 265
        u8 StatusFlags3;
266
        s16 Altimeter;
267
        u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation
268
        u16 AdNeutralNick;
269
        u16 AdNeutralRoll;
270
        u16 AdNeutralYaw;
587 holgerb 271
        u16 BoatNeutralNick;
272
        u16 BoatNeutralRoll;
273
        u16 BoatNeutralYaw;
607 holgerb 274
        u8 AutoPhotoDistance;
489 killagreg 275
} __attribute__((packed)) FC_t; // from FC
1 ingob 276
 
41 ingob 277
extern Param_t Parameter;
78 holgerb 278
extern volatile FC_t FC;
41 ingob 279
extern s8 ErrorMSG[25];
241 killagreg 280
extern u8 ErrorCode;
41 ingob 281
extern u8 StopNavigation;
328 holgerb 282
extern u8 ErrorGpsFixLost;
513 killagreg 283
extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint;
378 holgerb 284
extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero
362 holgerb 285
extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero
378 holgerb 286
extern volatile u32 PollingTimeout;
457 holgerb 287
extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsProcessedIn5Sec, FreqNewGpsDataIn5Sec;
362 holgerb 288
 
514 holgerb 289
extern u16 SD_SettingWaitLED;
290
extern u16 SD_PosAccuracy;
291
extern u16 SD_ComingHomeSpeed;
292
extern u16 SD_DPH_Speed;
532 holgerb 293
extern u32 MaxWP_Radius_in_m;
519 holgerb 294
extern u8 SpeakWaypointRached;  // Speak once as soon as the Points are active
549 holgerb 295
extern u8 SpeakNextWaypoint;    // Speak once when reached
296
extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started
514 holgerb 297
 
549 holgerb 298
 
529 holgerb 299
#define CHECK_ONLY     0
300
#define GET_LICENSE    1
301
#define COPY_SD_TO_EE  2
302
extern u8 CheckLicense(u8);
303
 
41 ingob 304
#endif // _MAIN_H