Subversion Repositories Projects

Rev

Rev 1992 | Rev 2039 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
331 cascade 1
/****************************************************************************
1866 - 2
 *   Copyright (C) 2009-2013 by Claas Anders "CaScAdE" Rathje               *
331 cascade 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
 
762 - 21
#ifndef _MK_DATA_STRUCTS_H
22
#define _MK_DATA_STRUCTS_H
23
 
331 cascade 24
/* ##########################################################################
25
 * gain some fake arm compat :)
26
 * ##########################################################################*/
27
#define u8 uint8_t
28
#define s8 int8_t
29
#define u16 uint16_t
30
#define s16 int16_t
31
#define u32 uint32_t
32
#define s32 int32_t
33
 
832 - 34
/**
35
 * MikroKopter Slave-Addresses
36
 * portions taken and adapted from
37
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.22a/mkprotocol.h
38
 */
39
#define ANY_ADDRESS 0
40
#define FC_ADDRESS 1
41
#define NC_ADDRESS 2
42
#define MK3MAG_ADDRESS 3
43
#define MKOSD_ADDRESS 4
44
#define BL_ADDRESS 5
45
 
331 cascade 46
/*
47
 * FC Debug Struct
48
 * portions taken and adapted from
1591 - 49
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.88e/uart.h
331 cascade 50
 */
1992 - 51
typedef struct {
52
    unsigned char Status[2];
53
    signed int Analog[32]; // Debugwerte
783 - 54
} __attribute__((packed)) str_DebugOut;
331 cascade 55
 
677 cascade 56
typedef struct {
1992 - 57
    unsigned char SWMajor;
58
    unsigned char SWMinor;
59
    unsigned char ProtoMajor;
60
    unsigned char ProtoMinor;
61
    unsigned char SWPatch;
62
    unsigned char HardwareError[5];
783 - 63
} __attribute__((packed)) str_VersionInfo;
677 cascade 64
 
331 cascade 65
/*
783 - 66
 * NaviCtrl GPS Structs
761 - 67
 * portions taken and adapted from
783 - 68
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.20c/ubx.h
331 cascade 69
 */
70
typedef struct {
1992 - 71
    s32 Longitude; // in 1E-7 deg
72
    s32 Latitude; // in 1E-7 deg
73
    s32 Altitude; // in mm
74
    u8 Status; // validity of data
761 - 75
} __attribute__((packed)) GPS_Pos_t;
1992 - 76
 
761 - 77
#define INVALID         0x00
78
#define NEWDATA         0x01
79
#define PROCESSED       0x02
331 cascade 80
 
783 - 81
/*
82
 * NaviCtrl OSD Structs
83
 * portions taken and adapted from
941 - 84
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.24b/uart1.h
783 - 85
 */
761 - 86
typedef struct {
1992 - 87
    u16 Distance; // distance to target in dm
88
    s16 Bearing; // course to target in deg
331 cascade 89
} __attribute__((packed)) GPS_PosDev_t;
90
 
91
typedef struct {
1992 - 92
    u8 Version; // version of the data structure
93
    GPS_Pos_t CurrentPosition; // see ubx.h for details
94
    GPS_Pos_t TargetPosition;
95
    GPS_PosDev_t TargetPositionDeviation;
96
    GPS_Pos_t HomePosition;
97
    GPS_PosDev_t HomePositionDeviation;
98
    u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1
99
    u8 WaypointNumber; // number of stored waypoints
100
    u8 SatsInUse; // number of satellites used for position solution
101
    s16 Altimeter; // hight according to air pressure
102
    s16 Variometer; // climb(+) and sink(-) rate
103
    u16 FlyingTime; // in seconds
104
    u8 UBat; // Battery Voltage in 0.1 Volts
105
    u16 GroundSpeed; // speed over ground in cm/s (2D)
106
    s16 Heading; // current flight direction in ° as angle to north
107
    s16 CompassHeading; // current compass value in °
108
    s8 AngleNick; // current Nick angle in 1°
109
    s8 AngleRoll; // current Rick angle in 1°
110
    u8 RC_Quality; // RC_Quality
111
    u8 FCFlags; // Flags from FC
112
    u8 NCFlags; // Flags from NC
113
    u8 Errorcode; // 0 --> okay
114
    u8 OperatingRadius; // current operation radius around the Home Position in m
115
    s16 TopSpeed; // velocity in vertical direction in cm/s
116
    u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached
117
    u8 FCStatusFlags2; // StatusFlags2 (since version 5 added)
118
    s16 SetpointAltitude; // setpoint for altitude
119
    u8 Gas; // for future use
120
    u16 Current; // actual current in 0.1A steps
121
    u16 UsedCapacity; // used capacity in mAh
331 cascade 122
} __attribute__((packed)) NaviData_t;
123
 
783 - 124
#define NC_FLAG_FREE                    0x01
125
#define NC_FLAG_PH                              0x02
126
#define NC_FLAG_CH                              0x04
127
#define NC_FLAG_RANGE_LIMIT             0x08
128
#define NC_FLAG_NOSERIALLINK    0x10
129
#define NC_FLAG_TARGET_REACHED  0x20
130
#define NC_FLAG_MANUAL_CONTROL  0x40
832 - 131
#define NC_FLAG_GPS_OK                  0x80
728 cascade 132
 
331 cascade 133
/*
134
 * MikroKopter Flags
783 - 135
 * portions taken and adapted from
136
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/fc.h
331 cascade 137
 */
734 cascade 138
#define FCFLAG_MOTOR_RUN        0x01
139
#define FCFLAG_FLY              0x02
140
#define FCFLAG_CALIBRATE        0x04
141
#define FCFLAG_START            0x08
142
#define FCFLAG_NOTLANDUNG       0x10
143
#define FCFLAG_LOWBAT           0x20
832 - 144
#define FCFLAG_VARIO_TRIM_UP    0x40
145
#define FCFLAG_VARIO_TRIM_DOWN  0x80
407 cascade 146
 
941 - 147
// FC STATUS FLAGS2
148
#define FC_STATUS2_CAREFREE                 0x01
149
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
150
 
783 - 151
#define DEFEKT_G_NICK           0x01
152
#define DEFEKT_G_ROLL           0x02
153
#define DEFEKT_G_GIER           0x04
154
#define DEFEKT_A_NICK           0x08
155
#define DEFEKT_A_ROLL           0x10
156
#define DEFEKT_A_Z              0x20
157
#define DEFEKT_PRESSURE         0x40
158
#define DEFEKT_CAREFREE_ERR 0x80
734 cascade 159
 
783 - 160
#define DEFEKT_I2C              0x01
161
#define DEFEKT_BL_MISSING       0x02
162
#define DEFEKT_SPI_RX_ERR       0x04
163
#define DEFEKT_PPM_ERR          0x08
164
#define DEFEKT_MIXER_ERR    0x10
165
 
407 cascade 166
/*
783 - 167
 * MikroKopter config struct
168
 * portions taken and adapted from
1992 - 169
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.90j/eeprom.h
407 cascade 170
 */
783 - 171
typedef struct {
1992 - 172
    unsigned char Revision;
173
    unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3
174
    unsigned char GlobalConfig; // 0x01=Hhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv
175
    unsigned char Hoehe_MinGas; // Wert : 0-100
176
    unsigned char Luftdruck_D; // Wert : 0-250
177
    unsigned char MaxHoehe; // Wert : 0-32
178
    unsigned char Hoehe_P; // Wert : 0-32
179
    unsigned char Hoehe_Verstaerkung; // Wert : 0-50
180
    unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250
181
    unsigned char Hoehe_HoverBand; // Wert : 0-250
182
    unsigned char Hoehe_GPS_Z; // Wert : 0-250
183
    unsigned char Hoehe_StickNeutralPoint; // Wert : 0-250
184
    unsigned char Stick_P; // Wert : 1-6
185
    unsigned char Stick_D; // Wert : 0-64
186
    unsigned char StickGier_P; // Wert : 1-20
187
    unsigned char Gas_Min; // Wert : 0-32
188
    unsigned char Gas_Max; // Wert : 33-250
189
    unsigned char GyroAccFaktor; // Wert : 1-64
190
    unsigned char KompassWirkung; // Wert : 0-32
191
    unsigned char Gyro_P; // Wert : 10-250
192
    unsigned char Gyro_I; // Wert : 0-250
193
    unsigned char Gyro_D; // Wert : 0-250
194
    unsigned char Gyro_Gier_P; // Wert : 10-250
195
    unsigned char Gyro_Gier_I; // Wert : 0-250
196
    unsigned char Gyro_Stability; // Wert : 0-16
197
    unsigned char UnterspannungsWarnung; // Wert : 0-250
198
    unsigned char NotGas; // Wert : 0-250     //Gaswert bei Empngsverlust
199
    unsigned char NotGasZeit; // Wert : 0-250     // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen
200
    unsigned char Receiver; // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D
201
    unsigned char I_Faktor; // Wert : 0-250
202
    unsigned char UserParam1; // Wert : 0-250
203
    unsigned char UserParam2; // Wert : 0-250
204
    unsigned char UserParam3; // Wert : 0-250
205
    unsigned char UserParam4; // Wert : 0-250
206
    unsigned char ServoNickControl; // Wert : 0-250     // Stellung des Servos
207
    unsigned char ServoNickComp; // Wert : 0-250     // Einfluss Gyro/Servo
208
    unsigned char ServoNickMin; // Wert : 0-250     // Anschlag
209
    unsigned char ServoNickMax; // Wert : 0-250     // Anschlag
210
    //--- Seit V0.75
211
    unsigned char ServoRollControl; // Wert : 0-250     // Stellung des Servos
212
    unsigned char ServoRollComp; // Wert : 0-250
213
    unsigned char ServoRollMin; // Wert : 0-250
214
    unsigned char ServoRollMax; // Wert : 0-250
215
    //---
216
    unsigned char ServoNickRefresh; // Speed of the Servo
217
    unsigned char ServoManualControlSpeed; //
218
    unsigned char CamOrientation; //
219
    unsigned char Servo3; // Value or mapping of the Servo Output
220
    unsigned char Servo4; // Value or mapping of the Servo Output
221
    unsigned char Servo5; // Value or mapping of the Servo Output
222
    unsigned char LoopGasLimit; // Wert: 0-250  max. Gas whrend Looping
223
    unsigned char LoopThreshold; // Wert: 0-250  Schwelle fr Stickausschlag
224
    unsigned char LoopHysterese; // Wert: 0-250  Hysterese fr Stickausschlag
225
    unsigned char AchsKopplung1; // Wert: 0-250  Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung)
226
    unsigned char AchsKopplung2; // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
227
    unsigned char CouplingYawCorrection; // Wert: 0-250  Faktor, mit dem Nick und Roll verkoppelt werden
228
    unsigned char WinkelUmschlagNick; // Wert: 0-250  180-Punkt
229
    unsigned char WinkelUmschlagRoll; // Wert: 0-250  180-Punkt
230
    unsigned char GyroAccAbgleich; // 1/k  (Koppel_ACC_Wirkung)
231
    unsigned char Driftkomp;
232
    unsigned char DynamicStability;
233
    unsigned char UserParam5; // Wert : 0-250
234
    unsigned char UserParam6; // Wert : 0-250
235
    unsigned char UserParam7; // Wert : 0-250
236
    unsigned char UserParam8; // Wert : 0-250
237
    //---Output ---------------------------------------------
238
    unsigned char J16Bitmask; // for the J16 Output
239
    unsigned char J16Timing; // for the J16 Output
240
    unsigned char J17Bitmask; // for the J17 Output
241
    unsigned char J17Timing; // for the J17 Output
242
    // seit version V0.75c
243
    unsigned char WARN_J16_Bitmask; // for the J16 Output
244
    unsigned char WARN_J17_Bitmask; // for the J17 Output
245
    //---NaviCtrl---------------------------------------------
246
    unsigned char NaviOut1Parameter; // for the J16 Output
247
    unsigned char NaviGpsModeControl; // Parameters for the Naviboard
248
    unsigned char NaviGpsGain;
249
    unsigned char NaviGpsP;
250
    unsigned char NaviGpsI;
251
    unsigned char NaviGpsD;
252
    unsigned char NaviGpsPLimit;
253
    unsigned char NaviGpsILimit;
254
    unsigned char NaviGpsDLimit;
255
    unsigned char NaviGpsACC;
256
    unsigned char NaviGpsMinSat;
257
    unsigned char NaviStickThreshold;
258
    unsigned char NaviWindCorrection;
259
    unsigned char NaviAccCompensation; // New since 0.86 -> was: SpeedCompensation
260
    unsigned char NaviOperatingRadius;
261
    unsigned char NaviAngleLimitation;
262
    unsigned char NaviPH_LoginTime;
263
    //---Ext.Ctrl---------------------------------------------
264
    unsigned char ExternalControl; // for serial Control
265
    //---CareFree---------------------------------------------
266
    unsigned char OrientationAngle; // Where is the front-direction?
267
    unsigned char CareFreeModeControl; // switch for CareFree
268
    unsigned char MotorSafetySwitch;
269
    unsigned char MotorSmooth;
270
    unsigned char ComingHomeAltitude;
271
    unsigned char FailSafeTime;
272
    unsigned char MaxAltitude;
273
    unsigned char FailsafeChannel; // if the value of this channel is > 100, the MK reports "RC-Lost"
274
    unsigned char ServoFilterNick;
275
    unsigned char ServoFilterRoll;
2000 - 276
        unsigned char StartLandChannel;
277
        unsigned char LandingSpeed;
1992 - 278
    //------------------------------------------------
279
    unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
280
    unsigned char ServoCompInvert; // //  0x01 = Nick, 0x02 = Roll, 0x04 = relative moving // WICHTIG!!! am Ende lassen
281
    unsigned char ExtraConfig; // bitcodiert
282
    unsigned char GlobalConfig3; // bitcodiert
283
    char Name[12];
284
    unsigned char crc; // must be the last byte!
285
} paramset_t;
407 cascade 286
 
783 - 287
typedef struct {
1992 - 288
    u8 SettingsIndex;
289
    paramset_t param;
783 - 290
} __attribute__((packed)) paramset_serial;
407 cascade 291
 
1801 - 292
/*
293
 * MikroKopter 3D-Data struct
294
 * portions taken and adapted from
295
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.28o%2Fuart1.h
296
 */
297
typedef struct {
1992 - 298
    s16 AngleNick; // in 0.1 deg
299
    s16 AngleRoll; // in 0.1 deg
300
    s16 Heading; // in 0.1 deg
1801 - 301
    u8 StickNick;
302
    u8 StickRoll;
303
    u8 StickYaw;
304
    u8 StickGas;
305
    u8 reserve[4];
306
} __attribute__((packed)) Data3D_t;
307
 
308
extern Data3D_t Data3D;
309
 
2000 - 310
#endif