Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
724 woggle 1
/****************************************************************************
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
 *                                                                          *
6
 *   This program is free software; you can redistribute it and/or modify   *
7
 *   it under the terms of the GNU General Public License as published by   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
20
 
21
/* ##########################################################################
22
 * gain some fake arm compat :)
23
 * ##########################################################################*/
24
#define u8 uint8_t
25
#define s8 int8_t
26
#define u16 uint16_t
27
#define s16 int16_t
28
#define u32 uint32_t
29
#define s32 int32_t
30
 
31
//*****************************************************************************
32
// 
33
#define NUMBER_OF_DEBUG_DATAS 32
34
#define ANALOG_NAME_LENGTH 16
35
 
36
// Version of supported serial protocol 
37
#define MIN_VERSION 7
38
#define MAX_VERSION 10
39
 
40
// Setting index
41
#define SETTING_1       1
42
#define SETTING_2       2
43
#define SETTING_3       3
44
#define SETTING_4       4
45
#define SETTING_5       5
46
#define SETTING_CURRENT 0xff
47
 
48
typedef struct
49
{
50
        unsigned char SWMajor;
51
        unsigned char SWMinor;
52
        unsigned char ProtoMajor;
53
        unsigned char ProtoMinor;
54
        unsigned char SWPatch;
55
        unsigned char Reserved[5];
56
} __attribute__((packed)) Version_t;
57
 
58
/*
59
 * FC Debug Struct
60
 * portions taken and adapted from
61
 * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.h
62
 */
63
typedef struct {
64
        uint8_t Digital[2];
65
        // NC: unsigned; FC: signed !!!!
66
        int16_t Analog[32];     // Debugvalues
67
} __attribute__((packed)) DebugData_t;
68
 
69
typedef struct {
70
        uint8_t line;
71
        uint8_t text[20];
72
} __attribute__((packed)) Display_t;
73
 
74
typedef struct
75
{
76
        char Revision;
77
        char Name[12];
78
        signed char Motor[16][4];
79
} __attribute__((packed)) Mixer_t;
80
 
81
/*
82
 * NaviCtrl OSD Structs
83
 * portions taken and adapted from
84
 * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h
85
 */
86
typedef struct {
87
        s32 Longitude;  // in 1E-7 deg
88
        s32 Latitude;           // in 1E-7 deg
89
        s32 Altitude;           // in mm
90
        u8 Status;                      // validity of data
91
} __attribute__((packed)) GPS_Pos_t;
92
 
93
typedef struct {
94
        s16 Distance;           // distance to target in cm
95
        s16 Bearing;            // course to target in deg
96
} __attribute__((packed)) GPS_PosDev_t;
97
 
98
typedef struct {
99
        u8 Version;                                                     // version of the data structure
100
        GPS_Pos_t CurrentPosition;      // see ubx.h for details
101
        GPS_Pos_t TargetPosition;
102
        GPS_PosDev_t TargetPositionDeviation;
103
        GPS_Pos_t HomePosition;
104
        GPS_PosDev_t HomePositionDeviation;
105
        u8  WaypointIndex;                      // index of current waypoints running from 0 to WaypointNumber-1
106
        u8  WaypointNumber;                     // number of stored waypoints
107
        u8  SatsInUse;                                  // number of satellites used for position solution
108
        s16 Altimeter;                                  // hight according to air pressure
109
        s16 Variometer;                                 // climb(+) and sink(-) rate
110
        u16 FlyingTime;                                 // in seconds
111
        u8  UBat;                                                               // Battery Voltage in 0.1 Volts
112
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
113
        s16 Heading;                                            // current flight direction in ∞ as angle to north
114
        s16     CompassHeading;                 // current compass value in ∞
115
        s8  AngleNick;                                  // current Nick angle in 1∞
116
        s8  AngleRoll;                                  // current Rick angle in 1∞
117
        u8  RC_Quality;                                 // RC_Quality
118
        u8  MKFlags;                                            // Flags from FC
119
        u8  NCFlags;                                            // Flags from NC
120
        u8  Errorcode;                                  // 0 --> okay
121
        u8  OperatingRadius;            // current operation radius around the Home Position in m
122
        s16 TopSpeed;                                           // velocity in vertical direction in cm/s
123
        u8 TargetHoldTime;                      // time in s to stay at the given target, counts down to 0 if target has been reached
124
        u8  Reserve[4];                                 // for future use
125
} __attribute__((packed)) NaviData_t;
126
 
127
/*
128
 * MikroKopter Flags
129
 * taken from
130
 * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.73d%2Ffc.h
131
 */
132
#define FLAG_MOTOR_RUN  1
133
#define FLAG_FLY        2
134
#define FLAG_CALIBRATE  4
135
#define FLAG_START      8
136
#define FLAG_NOTLANDUNG 16
137
#define FLAG_LOWBAT                     32
138
 
139
/*
140
 * NaviCtrl Flags
141
 * taken from
142
 * http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h
143
 */
144
#define NC_FLAG_FREE                                            0x01
145
#define NC_FLAG_PH                                                      0x02
146
#define NC_FLAG_CH                                                      0x04
147
#define NC_FLAG_RANGE_LIMIT                     0x08
148
#define NC_FLAG_NOSERIALLINK            0x10
149
#define NC_FLAG_TARGET_REACHED  0x20
150
#define NC_FLAG_MANUAL_CONTROL  0x40
151
#define NC_FLAG_8                                                               0x80
152
 
153
typedef struct
154
{
155
        unsigned char Kanalbelegung[8];       // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3
156
        unsigned char GlobalConfig;           // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv
157
        unsigned char Hoehe_MinGas;           // Wert : 0-100
158
        unsigned char Luftdruck_D;            // Wert : 0-250
159
        unsigned char MaxHoehe;               // Wert : 0-32
160
        unsigned char Hoehe_P;                // Wert : 0-32
161
        unsigned char Hoehe_Verstaerkung;     // Wert : 0-50
162
        unsigned char Hoehe_ACC_Wirkung;      // Wert : 0-250
163
        unsigned char Hoehe_HoverBand;        // Wert : 0-250
164
        unsigned char Hoehe_GPS_Z;            // Wert : 0-250
165
        unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250
166
        unsigned char Stick_P;                // Wert : 1-6
167
        unsigned char Stick_D;                // Wert : 0-64
168
        unsigned char Gier_P;                 // Wert : 1-20
169
        unsigned char Gas_Min;                // Wert : 0-32
170
        unsigned char Gas_Max;                // Wert : 33-250
171
        unsigned char GyroAccFaktor;          // Wert : 1-64
172
        unsigned char KompassWirkung;         // Wert : 0-32
173
        unsigned char Gyro_P;                 // Wert : 10-250
174
        unsigned char Gyro_I;                 // Wert : 0-250
175
        unsigned char Gyro_D;                 // Wert : 0-250
176
        unsigned char Gyro_Gier_P;            // Wert : 10-250
177
        unsigned char Gyro_Gier_I;            // Wert : 0-250
178
        unsigned char UnterspannungsWarnung;  // Wert : 0-250
179
        unsigned char NotGas;                 // Wert : 0-250     //Gaswert bei Empängsverlust
180
        unsigned char NotGasZeit;             // Wert : 0-250     // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen
181
        unsigned char UfoAusrichtung;         // X oder + Formation
182
        unsigned char I_Faktor;               // Wert : 0-250
183
        unsigned char UserParam1;             // Wert : 0-250
184
        unsigned char UserParam2;             // Wert : 0-250
185
        unsigned char UserParam3;             // Wert : 0-250
186
        unsigned char UserParam4;             // Wert : 0-250
187
        unsigned char ServoNickControl;       // Wert : 0-250     // Stellung des Servos
188
        unsigned char ServoNickComp;          // Wert : 0-250     // Einfluss Gyro/Servo
189
        unsigned char ServoNickMin;           // Wert : 0-250     // Anschlag
190
        unsigned char ServoNickMax;           // Wert : 0-250     // Anschlag
191
                                                                                                                                                                //--- Seit V0.75
192
        unsigned char ServoRollControl;       // Wert : 0-250     // Stellung des Servos
193
        unsigned char ServoRollComp;          // Wert : 0-250
194
        unsigned char ServoRollMin;           // Wert : 0-250
195
        unsigned char ServoRollMax;           // Wert : 0-250
196
                                                                                                                                                                //---
197
        unsigned char ServoNickRefresh;       //
198
        unsigned char LoopGasLimit;           // Wert: 0-250  max. Gas während Looping
199
        unsigned char LoopThreshold;          // Wert: 0-250  Schwelle für Stickausschlag
200
        unsigned char LoopHysterese;          // Wert: 0-250  Hysterese für Stickausschlag
201
        unsigned char AchsKopplung1;          // Wert: 0-250  Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung)
202
        unsigned char AchsKopplung2;          // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
203
        unsigned char CouplingYawCorrection;  // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
204
        unsigned char WinkelUmschlagNick;     // Wert: 0-250  180°-Punkt
205
        unsigned char WinkelUmschlagRoll;     // Wert: 0-250  180°-Punkt
206
        unsigned char GyroAccAbgleich;        // 1/k  (Koppel_ACC_Wirkung)
207
        unsigned char Driftkomp;
208
        unsigned char DynamicStability;
209
        unsigned char UserParam5;             // Wert : 0-250
210
        unsigned char UserParam6;             // Wert : 0-250
211
        unsigned char UserParam7;             // Wert : 0-250
212
        unsigned char UserParam8;             // Wert : 0-250
213
                                                                                                                                                                //---Output ---------------------------------------------
214
        unsigned char J16Bitmask;             // for the J16 Output
215
        unsigned char J16Timing;              // for the J16 Output
216
        unsigned char J17Bitmask;             // for the J17 Output
217
        unsigned char J17Timing;              // for the J17 Output
218
                                                                                                                                                                // seit version V0.75c
219
        unsigned char WARN_J16_Bitmask;       // for the J16 Output
220
        unsigned char WARN_J17_Bitmask;       // for the J17 Output
221
                                                                                                                                                                //---NaviCtrl---------------------------------------------
222
        unsigned char NaviGpsModeControl;     // Parameters for the Naviboard
223
        unsigned char NaviGpsGain;
224
        unsigned char NaviGpsP;
225
        unsigned char NaviGpsI;
226
        unsigned char NaviGpsD;
227
        unsigned char NaviGpsPLimit;
228
        unsigned char NaviGpsILimit;
229
        unsigned char NaviGpsDLimit;
230
        unsigned char NaviGpsACC;
231
        unsigned char NaviGpsMinSat;
232
        unsigned char NaviStickThreshold;
233
        unsigned char NaviWindCorrection;
234
        unsigned char NaviSpeedCompensation;
235
        unsigned char NaviOperatingRadius;
236
        unsigned char NaviAngleLimitation;
237
        unsigned char NaviPH_LoginTime;
238
        //---Ext.Ctrl---------------------------------------------
239
        unsigned char ExternalControl;        // for serial Control
240
                                                                                                                                                                //------------------------------------------------
241
        unsigned char BitConfig;          // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
242
        unsigned char ServoCompInvert;    // //  0x01 = Nick, 0x02 = Roll   0 oder 1  // WICHTIG!!! am Ende lassen
243
        unsigned char ExtraConfig;        // bitcodiert
244
        char Name[12];
245
} __attribute__((packed)) mk_param_struct_t;
246
#define  STRUCT_PARAM_LAENGE  sizeof(mk_param_struct_t)