Subversion Repositories Projects

Rev

Rev 1437 | Rev 1596 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1437 Rev 1468
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje               *
2
 *   Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje               *
3
 *   admiralcascade@gmail.com                                               *
3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
 *                                                                          *
5
 *                                                                          *
6
 *   This program is free software; you can redistribute it and/or modify   *
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   *
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.         *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
19
 ****************************************************************************/
20
 
20
 
21
#ifndef _MK_DATA_STRUCTS_H
21
#ifndef _MK_DATA_STRUCTS_H
22
#define _MK_DATA_STRUCTS_H
22
#define _MK_DATA_STRUCTS_H
23
 
23
 
24
/* ##########################################################################
24
/* ##########################################################################
25
 * gain some fake arm compat :)
25
 * gain some fake arm compat :)
26
 * ##########################################################################*/
26
 * ##########################################################################*/
27
#define u8 uint8_t
27
#define u8 uint8_t
28
#define s8 int8_t
28
#define s8 int8_t
29
#define u16 uint16_t
29
#define u16 uint16_t
30
#define s16 int16_t
30
#define s16 int16_t
31
#define u32 uint32_t
31
#define u32 uint32_t
32
#define s32 int32_t
32
#define s32 int32_t
33
 
33
 
34
/**
34
/**
35
 * MikroKopter Slave-Addresses
35
 * MikroKopter Slave-Addresses
36
 * portions taken and adapted from
36
 * portions taken and adapted from
37
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.22a/mkprotocol.h
37
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.22a/mkprotocol.h
38
 */
38
 */
39
#define ANY_ADDRESS 0
39
#define ANY_ADDRESS 0
40
#define FC_ADDRESS 1
40
#define FC_ADDRESS 1
41
#define NC_ADDRESS 2
41
#define NC_ADDRESS 2
42
#define MK3MAG_ADDRESS 3
42
#define MK3MAG_ADDRESS 3
43
#define MKOSD_ADDRESS 4
43
#define MKOSD_ADDRESS 4
44
#define BL_ADDRESS 5
44
#define BL_ADDRESS 5
45
 
45
 
46
 
46
 
47
/*
47
/*
48
 * FC Debug Struct
48
 * FC Debug Struct
49
 * portions taken and adapted from
49
 * portions taken and adapted from
50
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/uart.h
50
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/uart.h
51
 */
51
 */
52
typedef struct  {
52
typedef struct  {
53
        unsigned char Status[2];
53
        unsigned char Status[2];
54
        signed int Analog[32];    // Debugwerte
54
        signed int Analog[32];    // Debugwerte
55
} __attribute__((packed)) str_DebugOut;
55
} __attribute__((packed)) str_DebugOut;
56
 
56
 
57
typedef struct {
57
typedef struct {
58
        unsigned char SWMajor;
58
        unsigned char SWMajor;
59
        unsigned char SWMinor;
59
        unsigned char SWMinor;
60
        unsigned char ProtoMajor;
60
        unsigned char ProtoMajor;
61
        unsigned char ProtoMinor;
61
        unsigned char ProtoMinor;
62
        unsigned char SWPatch;
62
        unsigned char SWPatch;
63
        unsigned char HardwareError[5];
63
        unsigned char HardwareError[5];
64
} __attribute__((packed)) str_VersionInfo;
64
} __attribute__((packed)) str_VersionInfo;
65
 
65
 
66
/*
66
/*
67
 * NaviCtrl GPS Structs
67
 * NaviCtrl GPS Structs
68
 * portions taken and adapted from
68
 * portions taken and adapted from
69
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.20c/ubx.h
69
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.20c/ubx.h
70
 */
70
 */
71
typedef struct {
71
typedef struct {
72
        s32 Longitude;  // in 1E-7 deg
72
        s32 Longitude;  // in 1E-7 deg
73
        s32 Latitude;   // in 1E-7 deg
73
        s32 Latitude;   // in 1E-7 deg
74
        s32 Altitude;   // in mm
74
        s32 Altitude;   // in mm
75
        u8 Status;// validity of data
75
        u8 Status;// validity of data
76
} __attribute__((packed)) GPS_Pos_t;
76
} __attribute__((packed)) GPS_Pos_t;
77
 
77
 
78
#define INVALID         0x00
78
#define INVALID         0x00
79
#define NEWDATA         0x01
79
#define NEWDATA         0x01
80
#define PROCESSED       0x02
80
#define PROCESSED       0x02
81
 
81
 
82
 
82
 
83
/*
83
/*
84
 * NaviCtrl OSD Structs
84
 * NaviCtrl OSD Structs
85
 * portions taken and adapted from
85
 * portions taken and adapted from
86
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.24b/uart1.h
86
 * http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.24b/uart1.h
87
 */
87
 */
88
typedef struct {
88
typedef struct {
89
        u16 Distance;                                   // distance to target in dm
89
        u16 Distance;                                   // distance to target in dm
90
        s16 Bearing;                                    // course to target in deg
90
        s16 Bearing;                                    // course to target in deg
91
} __attribute__((packed)) GPS_PosDev_t;
91
} __attribute__((packed)) GPS_PosDev_t;
92
 
92
 
93
typedef struct {
93
typedef struct {
94
        u8 Version;                                             // version of the data structure
94
        u8 Version;                                             // version of the data structure
95
        GPS_Pos_t CurrentPosition;                              // see ubx.h for details
95
        GPS_Pos_t CurrentPosition;                              // see ubx.h for details
96
        GPS_Pos_t TargetPosition;
96
        GPS_Pos_t TargetPosition;
97
        GPS_PosDev_t TargetPositionDeviation;
97
        GPS_PosDev_t TargetPositionDeviation;
98
        GPS_Pos_t HomePosition;
98
        GPS_Pos_t HomePosition;
99
        GPS_PosDev_t HomePositionDeviation;
99
        GPS_PosDev_t HomePositionDeviation;
100
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
100
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
101
        u8  WaypointNumber;                             // number of stored waypoints
101
        u8  WaypointNumber;                             // number of stored waypoints
102
        u8  SatsInUse;                                  // number of satellites used for position solution
102
        u8  SatsInUse;                                  // number of satellites used for position solution
103
        s16 Altimeter;                                  // hight according to air pressure
103
        s16 Altimeter;                                  // hight according to air pressure
104
        s16 Variometer;                                 // climb(+) and sink(-) rate
104
        s16 Variometer;                                 // climb(+) and sink(-) rate
105
        u16 FlyingTime;                                 // in seconds
105
        u16 FlyingTime;                                 // in seconds
106
        u8  UBat;                                       // Battery Voltage in 0.1 Volts
106
        u8  UBat;                                       // Battery Voltage in 0.1 Volts
107
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
107
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
108
        s16 Heading;                                    // current flight direction in ° as angle to north
108
        s16 Heading;                                    // current flight direction in ° as angle to north
109
        s16 CompassHeading;                             // current compass value in °
109
        s16 CompassHeading;                             // current compass value in °
110
        s8  AngleNick;                                  // current Nick angle in 1°
110
        s8  AngleNick;                                  // current Nick angle in 1°
111
        s8  AngleRoll;                                  // current Rick angle in 1°
111
        s8  AngleRoll;                                  // current Rick angle in 1°
112
        u8  RC_Quality;                                 // RC_Quality
112
        u8  RC_Quality;                                 // RC_Quality
113
        u8  FCFlags;                                    // Flags from FC
113
        u8  FCFlags;                                    // Flags from FC
114
        u8  NCFlags;                                    // Flags from NC
114
        u8  NCFlags;                                    // Flags from NC
115
        u8  Errorcode;                                  // 0 --> okay
115
        u8  Errorcode;                                  // 0 --> okay
116
        u8  OperatingRadius;                            // current operation radius around the Home Position in m
116
        u8  OperatingRadius;                            // current operation radius around the Home Position in m
117
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
117
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
118
        u8  TargetHoldTime;                             // time in s to stay at the given target, counts down to 0 if target has been reached
118
        u8  TargetHoldTime;                             // time in s to stay at the given target, counts down to 0 if target has been reached
119
        u8  FCStatusFlags2;                             // StatusFlags2 (since version 5 added)
119
        u8  FCStatusFlags2;                             // StatusFlags2 (since version 5 added)
120
        s16 SetpointAltitude;                           // setpoint for altitude
120
        s16 SetpointAltitude;                           // setpoint for altitude
121
        u8  Gas;                                        // for future use
121
        u8  Gas;                                        // for future use
122
        u16 Current;                                    // actual current in 0.1A steps
122
        u16 Current;                                    // actual current in 0.1A steps
123
        u16 UsedCapacity;                               // used capacity in mAh
123
        u16 UsedCapacity;                               // used capacity in mAh
124
} __attribute__((packed)) NaviData_t;
124
} __attribute__((packed)) NaviData_t;
125
 
125
 
126
#define NC_FLAG_FREE                    0x01
126
#define NC_FLAG_FREE                    0x01
127
#define NC_FLAG_PH                              0x02
127
#define NC_FLAG_PH                              0x02
128
#define NC_FLAG_CH                              0x04
128
#define NC_FLAG_CH                              0x04
129
#define NC_FLAG_RANGE_LIMIT             0x08
129
#define NC_FLAG_RANGE_LIMIT             0x08
130
#define NC_FLAG_NOSERIALLINK    0x10
130
#define NC_FLAG_NOSERIALLINK    0x10
131
#define NC_FLAG_TARGET_REACHED  0x20
131
#define NC_FLAG_TARGET_REACHED  0x20
132
#define NC_FLAG_MANUAL_CONTROL  0x40
132
#define NC_FLAG_MANUAL_CONTROL  0x40
133
#define NC_FLAG_GPS_OK                  0x80
133
#define NC_FLAG_GPS_OK                  0x80
134
 
134
 
135
/*
135
/*
136
 * MikroKopter Flags
136
 * MikroKopter Flags
137
 * portions taken and adapted from
137
 * portions taken and adapted from
138
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/fc.h
138
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/fc.h
139
 */
139
 */
140
#define FCFLAG_MOTOR_RUN        0x01
140
#define FCFLAG_MOTOR_RUN        0x01
141
#define FCFLAG_FLY              0x02
141
#define FCFLAG_FLY              0x02
142
#define FCFLAG_CALIBRATE        0x04
142
#define FCFLAG_CALIBRATE        0x04
143
#define FCFLAG_START            0x08
143
#define FCFLAG_START            0x08
144
#define FCFLAG_NOTLANDUNG       0x10
144
#define FCFLAG_NOTLANDUNG       0x10
145
#define FCFLAG_LOWBAT           0x20
145
#define FCFLAG_LOWBAT           0x20
146
#define FCFLAG_VARIO_TRIM_UP    0x40
146
#define FCFLAG_VARIO_TRIM_UP    0x40
147
#define FCFLAG_VARIO_TRIM_DOWN  0x80
147
#define FCFLAG_VARIO_TRIM_DOWN  0x80
148
 
148
 
149
// FC STATUS FLAGS2
149
// FC STATUS FLAGS2
150
#define FC_STATUS2_CAREFREE                 0x01
150
#define FC_STATUS2_CAREFREE                 0x01
151
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
151
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
152
 
152
 
153
#define DEFEKT_G_NICK           0x01
153
#define DEFEKT_G_NICK           0x01
154
#define DEFEKT_G_ROLL           0x02
154
#define DEFEKT_G_ROLL           0x02
155
#define DEFEKT_G_GIER           0x04
155
#define DEFEKT_G_GIER           0x04
156
#define DEFEKT_A_NICK           0x08
156
#define DEFEKT_A_NICK           0x08
157
#define DEFEKT_A_ROLL           0x10
157
#define DEFEKT_A_ROLL           0x10
158
#define DEFEKT_A_Z              0x20
158
#define DEFEKT_A_Z              0x20
159
#define DEFEKT_PRESSURE         0x40
159
#define DEFEKT_PRESSURE         0x40
160
#define DEFEKT_CAREFREE_ERR 0x80
160
#define DEFEKT_CAREFREE_ERR 0x80
161
 
161
 
162
#define DEFEKT_I2C              0x01
162
#define DEFEKT_I2C              0x01
163
#define DEFEKT_BL_MISSING       0x02
163
#define DEFEKT_BL_MISSING       0x02
164
#define DEFEKT_SPI_RX_ERR       0x04
164
#define DEFEKT_SPI_RX_ERR       0x04
165
#define DEFEKT_PPM_ERR          0x08
165
#define DEFEKT_PPM_ERR          0x08
166
#define DEFEKT_MIXER_ERR    0x10
166
#define DEFEKT_MIXER_ERR    0x10
167
 
167
 
168
 
168
 
169
/*
169
/*
170
 * MikroKopter config struct
170
 * MikroKopter config struct
171
 * portions taken and adapted from
171
 * portions taken and adapted from
172
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/eeprom.h
172
 * http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.86d/eeprom.h
173
 */
173
 */
174
typedef struct {
174
typedef struct {
277
} __attribute__((packed)) paramset_t;
281
} __attribute__((packed)) paramset_t;
278
 
282
 
279
typedef struct {
283
typedef struct {
280
        u8 SettingsIndex;
284
        u8 SettingsIndex;
281
        paramset_t param;
285
        paramset_t param;
282
} __attribute__((packed)) paramset_serial;
286
} __attribute__((packed)) paramset_serial;
283
 
287
 
284
#endif
288
#endif
285
 
289