Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1734 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
5
 *   Copyright (C) 2011 Harald Bongartz                                      *
6
 *                                                                           *
7
 *   This program is free software; you can redistribute it and/or modify    *
8
 *   it under the terms of the GNU General Public License as published by    *
9
 *   the Free Software Foundation; either version 2 of the License.          *
10
 *                                                                           *
11
 *   This program is distributed in the hope that it will be useful,         *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14
 *   GNU General Public License for more details.                            *
15
 *                                                                           *
16
 *   You should have received a copy of the GNU General Public License       *
17
 *   along with this program; if not, write to the                           *
18
 *   Free Software Foundation, Inc.,                                         *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
20
 *                                                                           *
21
 *                                                                           *
22
 *   Credits to:                                                             *
23
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
24
 *                          http://www.mikrokopter.de                        *
25
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
26
 *   Thomas Kaiser "thkais" for the original project. See                    *
27
 *                          http://www.ft-fanpage.de/mikrokopter/            *
28
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
29
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
30
 *                          http://www.mylifesucks.de/oss/c-osd/             *
31
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
32
 *****************************************************************************/
33
 
34
 
35
#ifndef _MK_DATA_STRUCTS_H
36
#define _MK_DATA_STRUCTS_H
37
 
38
 
39
// FC Version 0.88M
40
#define EEProm_Version  91        // FC EEProm Revision / Struktur FC 0.87
41
#define FC_Version      "0.88m"   //Softwareversion der FC
42
 
43
 
44
#define u8 uint8_t
45
#define s8 int8_t
46
#define u16 uint16_t
47
#define s16 int16_t
48
#define u32 uint32_t
49
#define s32 int32_t
50
 
51
#define NUMBER_OF_DEBUG_DATAS 32
52
#define ANALOG_NAME_LENGTH 16
53
 
54
// Version of supported serial protocol
55
#define MIN_VERSION 7
56
#define MAX_VERSION 10
57
 
58
// Setting index
59
#define SETTING_1       1
60
#define SETTING_2       2
61
#define SETTING_3       3
62
#define SETTING_4       4
63
#define SETTING_5       5
64
#define SETTING_CURRENT 0xff
65
 
66
 
67
// MikroKopter defines
68
// taken from
69
// FC Software eeprom.h
70
//
71
 
72
//GlobalConfig3 aus FC/eeprom.h
73
#define CFG3_NO_SDCARD_NO_START                 0x01
74
#define CFG3_DPH_MAX_RADIUS                     0x02
75
#define CFG3_VARIO_FAILSAFE                     0x04
76
#define CFG3_MOTOR_SWITCH_MODE                  0x08    //FC0.88L 7.5.12
77
#define CFG3_NO_GPSFIX_NO_START                 0x10    //FC0.88L 7.5.12
78
 
79
//GlobalConfig
80
#define CFG_HOEHENREGELUNG                      0x01
81
#define CFG_HOEHEN_SCHALTER                     0x02
82
#define CFG_HEADING_HOLD                        0x04
83
#define CFG_KOMPASS_AKTIV                       0x08
84
#define CFG_KOMPASS_FIX                         0x10
85
#define CFG_GPS_AKTIV                           0x20
86
#define CFG_ACHSENKOPPLUNG_AKTIV                0x40
87
#define CFG_DREHRATEN_BEGRENZER                 0x80
88
 
89
//Bitconfig MAsk
90
#define CFG_LOOP_OBEN                           0x01
91
#define CFG_LOOP_UNTEN                          0x02
92
#define CFG_LOOP_LINKS                          0x04
93
#define CFG_LOOP_RECHTS                         0x08
94
#define CFG_MOTOR_BLINK1                        0x10
95
#define CFG_MOTOR_OFF_LED1                      0x20
96
#define CFG_MOTOR_OFF_LED2                      0x40
97
#define CFG_MOTOR_BLINK2                        0x80
98
 
99
// ExtraConfig
100
#define CFG2_HEIGHT_LIMIT                       0x01
101
#define CFG2_VARIO_BEEP                         0x02
102
#define CFG_SENSITIVE_RC                        0x04
103
#define CFG_3_3V_REFERENCE                      0x08
104
#define CFG_NO_RCOFF_BEEPING                    0x10
105
#define CFG_GPS_AID                             0x20
106
#define CFG_LEARNABLE_CAREFREE                  0x40
107
#define CFG_IGNORE_MAG_ERR_AT_STARTUP           0x80
108
 
109
// bit mask for ParamSet.Config0
110
#define CFG0_AIRPRESS_SENSOR                    0x01
111
#define CFG0_HEIGHT_SWITCH                      0x02
112
#define CFG0_HEADING_HOLD                       0x04
113
#define CFG0_COMPASS_ACTIVE                     0x08
114
#define CFG0_COMPASS_FIX                        0x10
115
#define CFG0_GPS_ACTIVE                         0x20
116
#define CFG0_AXIS_COUPLING_ACTIVE               0x40
117
#define CFG0_ROTARY_RATE_LIMITER                0x80
118
 
119
// defines for the receiver selection
120
#define RECEIVER_PPM                            0
121
#define RECEIVER_SPEKTRUM                       1
122
#define RECEIVER_SPEKTRUM_HI_RES                2
123
#define RECEIVER_SPEKTRUM_LOW_RES               3
124
#define RECEIVER_JETI                           4
125
#define RECEIVER_ACT_DSL                        5
126
#define RECEIVER_HOTT                           6
127
#define RECEIVER_SBUS                           7
128
#define RECEIVER_USER                           8
129
#define RECEIVER_UNKNOWN                        0xFF
130
 
131
// MikroKopter Flags
132
// taken from
133
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.73d%2Ffc.h
134
//alt 0.86
135
//#define FCFLAG_MOTOR_RUN    0x01
136
//#define FCFLAG_FLY          0x02
137
//#define FCFLAG_CALIBRATE    0x04
138
//#define FCFLAG_START        0x08
139
//#define FCFLAG_NOTLANDUNG   0x10
140
//#define FCFLAG_LOWBAT       0x20
141
//#define FCFLAG_SPI_RX_ERR   0x40
142
//#define FCFLAG_I2CERR       0x80
143
// FC_StatusFlags 0.88
144
#define FC_STATUS_MOTOR_RUN                     0x01
145
#define FC_STATUS_FLY                           0x02
146
#define FC_STATUS_CALIBRATE                     0x04
147
#define FC_STATUS_START                         0x08
148
#define FC_STATUS_EMERGENCY_LANDING             0x10
149
#define FC_STATUS_LOWBAT                        0x20
150
#define FC_STATUS_VARIO_TRIM_UP                 0x40
151
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
152
 
153
// FC_StatusFlags2
154
#define FC_STATUS2_CAREFREE                     0x01
155
#define FC_STATUS2_ALTITUDE_CONTROL             0x02
156
#define FC_STATUS2_RC_FAILSAVE_ACTIVE           0x04
157
#define FC_STATUS2_OUT1_ACTIVE                  0x08
158
#define FC_STATUS2_OUT2_ACTIVE                  0x10
159
 
160
// NaviCtrl Flags
161
// taken from
162
// http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h
163
//
164
#define NC_FLAG_FREE                            0x01
165
#define NC_FLAG_PH                              0x02
166
#define NC_FLAG_CH                              0x04
167
#define NC_FLAG_RANGE_LIMIT                     0x08
168
#define NC_FLAG_NOSERIALLINK                    0x10
169
#define NC_FLAG_TARGET_REACHED                  0x20
170
#define NC_FLAG_MANUAL_CONTROL                  0x40
171
#define NC_FLAG_GPS_OK                          0x80
172
 
173
typedef struct
174
{
175
        unsigned char SWMajor;
176
        unsigned char SWMinor;
177
        unsigned char ProtoMajor;
178
        unsigned char ProtoMinor;
179
        unsigned char SWPatch;
180
        unsigned char HardwareError[5];
181
} __attribute__((packed)) Version_t;
182
 
183
 
184
// FC Debug Struct
185
// portions taken and adapted from
186
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.h
187
//
188
typedef struct // 0.86
189
{
190
        uint8_t Digital[2];
191
        // NC: unsigned; FC: signed !!!!
192
        int16_t Analog[32];     // Debugvalues
193
} __attribute__((packed)) DebugData_t;
194
 
195
//******************************************************************
196
// uart1.h NC 0.87, zur Zeit hier nicht verwendet 28.01.2012 CB
197
 
198
#define AMPEL_FC                0x01
199
#define AMPEL_BL                0x02
200
#define AMPEL_NC                0x04
201
#define AMPEL_COMPASS           0x08
202
 
203
 
204
typedef struct  //0.87
205
{
206
        u8 StatusGreen;
207
        u8 StatusRed;
208
        u16 Analog[32];    // Debugwerte
209
} __attribute__((packed)) DebugOut_t;
210
//******************************************************************
211
 
212
 
213
// NaviCtrl OSD Structs
214
// portions taken and adapted from
215
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h
216
//
217
 
218
typedef struct  //NC uart1.h
219
{
220
        s16 AngleNick;  // in 0.1 deg
221
        s16 AngleRoll;   // in 0.1 deg
222
        s16 Heading;    // in 0.1 deg
223
        u8 StickNick;
224
        u8 StickRoll;
225
        u8 StickYaw;
226
        u8 StickGas;
227
        u8 reserve[4];
228
} __attribute__((packed)) Data3D_t;
229
 
230
 
231
 
232
typedef struct
233
{
234
        s32 Longitude;          // in 1E-7 deg
235
        s32 Latitude;           // in 1E-7 deg
236
        s32 Altitude;           // in mm
237
        u8 Status;                      // validity of data
238
} __attribute__((packed)) GPS_Pos_t;
239
 
240
 
241
typedef struct
242
{
243
        u16 Distance;           // distance to target in cm
244
        s16 Bearing;            // course to target in deg
245
} __attribute__((packed)) GPS_PosDev_t;
246
 
247
 
248
// aus NC waypoint.h
249
typedef struct
250
{
251
        GPS_Pos_t Position;             // the gps position of the waypoint, see ubx.h for details
252
        s16 Heading;                    // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List
253
        u8  ToleranceRadius;            // in meters, if the MK is within that range around the target, then the next target is triggered
254
        u8  HoldTime;                   // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered
255
        u8  Event_Flag;                 // future implementation
256
        u8  Index;                      // to indentify different waypoints, workaround for bad communications PC <-> NC
257
        u8  Type;                               // typeof Waypoint
258
        u8  WP_EventChannelValue;       //
259
        u8  AltitudeRate;               // rate to change the setpoint
260
        u8  Speed;                      // rate to change the Position
261
        u8  CamAngle;                   // Camera servo angle
262
        u8  reserve[6];                 // reserve
263
} __attribute__((packed)) Point_t;
264
 
265
 
266
// NaviCtrl struct
267
// taken from
268
// http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h
269
//
270
#define NAVIDATA_VERSION 5
271
 
272
typedef struct
273
{
274
        u8 Version;                                     // version of the data structure
275
        GPS_Pos_t CurrentPosition;                      // see ubx.h for details
276
        GPS_Pos_t TargetPosition;
277
        GPS_PosDev_t TargetPositionDeviation;
278
        GPS_Pos_t HomePosition;
279
        GPS_PosDev_t HomePositionDeviation;
280
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
281
        u8  WaypointNumber;                             // number of stored waypoints
282
        u8  SatsInUse;                                  // number of satellites used for position solution
283
        s16 Altimeter;                                  // hight according to air pressure
284
        s16 Variometer;                                 // climb(+) and sink(-) rate
285
        u16 FlyingTime;                                 // in seconds
286
        u8  UBat;                                       // Battery Voltage in 0.1 Volts
287
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
288
        s16 Heading;                                    // current flight direction in ° as angle to north
289
        s16 CompassHeading;                             // current compass value in °
290
        s8  AngleNick;                                  // current Nick angle in 1°
291
        s8  AngleRoll;                                  // current Rick angle in 1°
292
        u8  RC_Quality;                                 // RC_Quality
293
        u8  FCStatusFlags;                              // Flags from FC
294
        u8  NCFlags;                                    // Flags from NC
295
        u8  Errorcode;                                  // 0 --> okay
296
        u8  OperatingRadius;                            // current operation radius around the Home Position in m
297
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
298
        u8  TargetHoldTime;                             // time in s to stay at the given target, counts down to 0 if target has been reached
299
        u8  FCStatusFlags2;                             // StatusFlags2 (since version 5 added)
300
        s16 SetpointAltitude;                           // setpoint for altitude
301
        u8  Gas;                                        // for future use
302
        u16 Current;                                    // actual current in 0.1A steps
303
        u16 UsedCapacity;                               // used capacity in mAh
304
} __attribute__((packed)) NaviData_t;
305
 
306
 
307
typedef struct
308
{
309
        uint8_t Version;                        // the version of the BL (0 = old)
310
        uint8_t SetPoint;                       // written by attitude controller
311
        uint8_t SetPointLowerBits;      // for higher Resolution of new BLs
312
        uint8_t State;                          // 7 bit for I2C error counter, highest bit indicates if motor is present
313
        uint8_t ReadMode;                       // select data to read
314
        // the following bytes must be exactly in that order!
315
        uint8_t Current;                        // in 0.1 A steps, read back from BL
316
        uint8_t MaxPWM;                         // read back from BL -> is less than 255 if BL is in current limit, not running (250) or starting (40)
317
        int8_t  Temperature;            // old BL-Ctrl will return a 255 here, the new version the temp. in �C
318
} __attribute__((packed)) MotorData_t;
319
 
320
typedef struct
321
{
322
        uint8_t Revision;                       // must be BL_REVISION
323
        uint8_t SetMask;                        // settings mask
324
        uint8_t PwmScaling;                     // maximum value of control pwm, acts like a thrust limit
325
        uint8_t CurrentLimit;           // current limit in A
326
        uint8_t TempLimit;                      // in �C
327
        uint8_t CurrentScaling;         // scaling factor for current measurement
328
        uint8_t BitConfig;                      // see defines above
329
        uint8_t crc;                            // checksum
330
}  __attribute__((packed)) BLConfig_t;
331
 
332
 
333
// Aus FC eeprom.h
334
//
335
typedef struct
336
{
337
  unsigned char Revision;
338
  unsigned char Kanalbelegung[12];       // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3
339
  unsigned char GlobalConfig;           // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv
340
  unsigned char Hoehe_MinGas;           // Wert : 0-100
341
  unsigned char Luftdruck_D;            // Wert : 0-250
342
  unsigned char MaxHoehe;               // Wert : 0-32
343
  unsigned char Hoehe_P;                // Wert : 0-32
344
  unsigned char Hoehe_Verstaerkung;     // Wert : 0-50
345
  unsigned char Hoehe_ACC_Wirkung;      // Wert : 0-250
346
  unsigned char Hoehe_HoverBand;        // Wert : 0-250
347
  unsigned char Hoehe_GPS_Z;            // Wert : 0-250
348
  unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250
349
  unsigned char Stick_P;                // Wert : 1-6
350
  unsigned char Stick_D;                // Wert : 0-64
351
  unsigned char StickGier_P;            // Wert : 1-20
352
  unsigned char Gas_Min;                // Wert : 0-32
353
  unsigned char Gas_Max;                // Wert : 33-250
354
  unsigned char GyroAccFaktor;          // Wert : 1-64
355
  unsigned char KompassWirkung;         // Wert : 0-32
356
  unsigned char Gyro_P;                 // Wert : 10-250
357
  unsigned char Gyro_I;                 // Wert : 0-250
358
  unsigned char Gyro_D;                 // Wert : 0-250
359
  unsigned char Gyro_Gier_P;            // Wert : 10-250
360
  unsigned char Gyro_Gier_I;            // Wert : 0-250
361
  unsigned char Gyro_Stability;         // Wert : 0-16
362
  unsigned char UnterspannungsWarnung;  // Wert : 0-250
363
  unsigned char NotGas;                 // Wert : 0-250     //Gaswert bei EmpÀngsverlust
364
  unsigned char NotGasZeit;             // Wert : 0-250     // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen
365
  unsigned char Receiver;                   // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D
366
  unsigned char I_Faktor;               // Wert : 0-250
367
  unsigned char UserParam1;             // Wert : 0-250
368
  unsigned char UserParam2;             // Wert : 0-250
369
  unsigned char UserParam3;             // Wert : 0-250
370
  unsigned char UserParam4;             // Wert : 0-250
371
  unsigned char ServoNickControl;       // Wert : 0-250     // Stellung des Servos
372
  unsigned char ServoNickComp;          // Wert : 0-250     // Einfluss Gyro/Servo
373
  unsigned char ServoNickMin;           // Wert : 0-250     // Anschlag
374
  unsigned char ServoNickMax;           // Wert : 0-250     // Anschlag
375
  //--- Seit V0.75
376
  unsigned char ServoRollControl;       // Wert : 0-250     // Stellung des Servos
377
  unsigned char ServoRollComp;          // Wert : 0-250
378
  unsigned char ServoRollMin;           // Wert : 0-250
379
  unsigned char ServoRollMax;           // Wert : 0-250
380
  //---
381
  unsigned char ServoNickRefresh;       // Speed of the Servo
382
unsigned char ServoManualControlSpeed;//
383
unsigned char CamOrientation;         //
384
  unsigned char Servo3;                    // Value or mapping of the Servo Output
385
  unsigned char Servo4;                            // Value or mapping of the Servo Output
386
  unsigned char Servo5;                            // Value or mapping of the Servo Output
387
  unsigned char LoopGasLimit;           // Wert: 0-250  max. Gas wÀhrend Looping
388
  unsigned char LoopThreshold;          // Wert: 0-250  Schwelle fÃŒr Stickausschlag
389
  unsigned char LoopHysterese;          // Wert: 0-250  Hysterese fÃŒr Stickausschlag
390
  unsigned char AchsKopplung1;          // Wert: 0-250  Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung)
391
  unsigned char AchsKopplung2;          // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
392
  unsigned char CouplingYawCorrection;  // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
393
  unsigned char WinkelUmschlagNick;     // Wert: 0-250  180°-Punkt
394
  unsigned char WinkelUmschlagRoll;     // Wert: 0-250  180°-Punkt
395
  unsigned char GyroAccAbgleich;        // 1/k  (Koppel_ACC_Wirkung)
396
  unsigned char Driftkomp;
397
  unsigned char DynamicStability;
398
  unsigned char UserParam5;             // Wert : 0-250
399
  unsigned char UserParam6;             // Wert : 0-250
400
  unsigned char UserParam7;             // Wert : 0-250
401
  unsigned char UserParam8;             // Wert : 0-250
402
  //---Output ---------------------------------------------
403
  unsigned char J16Bitmask;             // for the J16 Output
404
  unsigned char J16Timing;              // for the J16 Output
405
  unsigned char J17Bitmask;             // for the J17 Output
406
  unsigned char J17Timing;              // for the J17 Output
407
  // seit version V0.75c
408
  unsigned char WARN_J16_Bitmask;       // for the J16 Output
409
  unsigned char WARN_J17_Bitmask;       // for the J17 Output
410
  //---NaviCtrl---------------------------------------------
411
  unsigned char NaviGpsModeControl;     // Parameters for the Naviboard
412
  unsigned char NaviGpsGain;
413
  unsigned char NaviGpsP;
414
  unsigned char NaviGpsI;
415
  unsigned char NaviGpsD;
416
  unsigned char NaviGpsPLimit;
417
  unsigned char NaviGpsILimit;
418
  unsigned char NaviGpsDLimit;
419
  unsigned char NaviGpsACC;
420
  unsigned char NaviGpsMinSat;
421
  unsigned char NaviStickThreshold;
422
  unsigned char NaviWindCorrection;
423
  unsigned char NaviAccCompensation;    // New since 0.86 -> was: SpeedCompensation
424
  unsigned char NaviOperatingRadius;
425
  unsigned char NaviAngleLimitation;
426
  unsigned char NaviPH_LoginTime;
427
  //---Ext.Ctrl---------------------------------------------
428
  unsigned char ExternalControl;         // for serial Control
429
  //---CareFree---------------------------------------------
430
  unsigned char OrientationAngle;        // Where is the front-direction?
431
  unsigned char CareFreeModeControl;         // switch for CareFree
432
  unsigned char MotorSafetySwitch;
433
  unsigned char MotorSmooth;
434
  unsigned char ComingHomeAltitude;
435
  unsigned char FailSafeTime;
436
  unsigned char MaxAltitude;
437
  unsigned char FailsafeChannel;         // if the value of this channel is > 100, the MK reports "RC-Lost"
438
  unsigned char ServoFilterNick;
439
  unsigned char ServoFilterRoll;
440
  //------------------------------------------------
441
  unsigned char BitConfig;          // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
442
  unsigned char ServoCompInvert;    // //  0x01 = Nick, 0x02 = Roll   0 oder 1  // WICHTIG!!! am Ende lassen
443
  unsigned char ExtraConfig;        // bitcodiert
444
  unsigned char GlobalConfig3;      // bitcodiert
445
  char Name[12];
446
  unsigned char crc;                                // must be the last byte!                                   // MUST BE THE LAST BYTE!
447
} __attribute__((packed)) mk_param_struct_t;
448
 
449
#endif