Go to most recent revision | Details | 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 |
581 | holgerb | 16 | #define VERSION_MINOR 9 |
624 | holgerb | 17 | #define VERSION_PATCH 8 |
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 | |
350 | holgerb | 122 | //Parameter.GlobalConfig3 |
123 | #define CFG3_NO_SDCARD_NO_START 0x01 |
||
532 | holgerb | 124 | //#define CFG3_DPH_MAX_RADIUS 0x02 |
350 | holgerb | 125 | #define CFG3_VARIO_FAILSAFE 0x04 |
398 | holgerb | 126 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
127 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
||
350 | holgerb | 128 | |
320 | holgerb | 129 | // Parameter.GlobalConfig |
331 | holgerb | 130 | #define FC_CFG_HOEHENREGELUNG 0x01 |
131 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
||
132 | #define FC_CFG_HEADING_HOLD 0x04 |
||
133 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
||
134 | #define FC_CFG_KOMPASS_FIX 0x10 |
||
135 | #define FC_CFG_GPS_AKTIV 0x20 |
||
136 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
||
137 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
||
190 | killagreg | 138 | |
489 | killagreg | 139 | //Parameter.ExtraConfig |
331 | holgerb | 140 | #define CFG2_HEIGHT_LIMIT 0x01 |
141 | #define CFG2_VARIO_BEEP 0x02 |
||
142 | #define CFG_SENSITIVE_RC 0x04 |
||
143 | #define CFG_3_3V_REFERENCE 0x08 |
||
144 | #define CFG_NO_RCOFF_BEEPING 0x10 |
||
145 | #define CFG_GPS_AID 0x20 |
||
146 | #define CFG_TEACHABLE_CAREFREE 0x40 |
||
147 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
||
320 | holgerb | 148 | |
588 | holgerb | 149 | // Parameter.HomeYawMode |
150 | #define NO_CHANGE 0 |
||
151 | #define FRONT_TO_HOME 1 |
||
152 | #define REAR_TO_HOME 2 |
||
153 | #define LIKE_AT_START 3 |
||
154 | |||
587 | holgerb | 155 | // Parameter.ReceiverType defines for the receiver selection |
156 | #define RECEIVER_PPM 0 |
||
157 | #define RECEIVER_SPEKTRUM 1 |
||
158 | #define RECEIVER_SPEKTRUM_HI_RES 2 |
||
159 | #define RECEIVER_SPEKTRUM_LOW_RES 3 |
||
160 | #define RECEIVER_JETI 4 |
||
161 | #define RECEIVER_ACT_DSL 5 |
||
162 | #define RECEIVER_HOTT 6 |
||
163 | #define RECEIVER_SBUS 7 |
||
164 | #define RECEIVER_USER 8 |
||
165 | |||
166 | #define RECEIVER_UNKNOWN 0xFF |
||
167 | |||
190 | killagreg | 168 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
169 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
||
170 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
||
171 | |||
327 | holgerb | 172 | |
173 | #define Poti1 FC.Poti[0] |
||
174 | #define Poti2 FC.Poti[1] |
||
175 | #define Poti3 FC.Poti[2] |
||
176 | #define Poti4 FC.Poti[3] |
||
177 | #define Poti5 FC.Poti[4] |
||
178 | #define Poti6 FC.Poti[5] |
||
179 | #define Poti7 FC.Poti[6] |
||
180 | #define Poti8 FC.Poti[7] |
||
181 | |||
41 | ingob | 182 | extern u16 BeepTime; |
92 | killagreg | 183 | extern u8 NCFlags; |
255 | killagreg | 184 | extern u8 ClearFCStatusFlags; |
41 | ingob | 185 | void Interrupt_Init(void); |
153 | killagreg | 186 | extern s16 GeoMagDec; |
504 | holgerb | 187 | extern u8 NewWPL_Name; |
1 | ingob | 188 | |
505 | holgerb | 189 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
190 | |||
41 | ingob | 191 | typedef struct |
192 | { |
||
193 | u8 ActiveSetting; |
||
194 | u8 User1; |
||
195 | u8 User2; |
||
196 | u8 User3; |
||
197 | u8 User4; |
||
198 | u8 User5; |
||
199 | u8 User6; |
||
200 | u8 User7; |
||
201 | u8 User8; |
||
202 | u8 NaviGpsModeControl; |
||
203 | u8 NaviGpsGain; |
||
204 | u8 NaviGpsP; |
||
205 | u8 NaviGpsI; |
||
206 | u8 NaviGpsD; |
||
56 | holgerb | 207 | u8 NaviGpsPLimit; |
208 | u8 NaviGpsILimit; |
||
209 | u8 NaviGpsDLimit; |
||
41 | ingob | 210 | u8 NaviGpsACC; |
211 | u8 NaviGpsMinSat; |
||
212 | u8 NaviStickThreshold; |
||
532 | holgerb | 213 | u8 NaviMaxFlyingRange; // in 10m |
41 | ingob | 214 | u8 NaviWindCorrection; |
327 | holgerb | 215 | u8 NaviAccCompensation; |
41 | ingob | 216 | u8 NaviSpeedCompensation; |
217 | u8 LowVoltageWarning; |
||
218 | u8 NaviAngleLimitation; |
||
56 | holgerb | 219 | u8 NaviPH_LoginTime; |
544 | holgerb | 220 | u8 OrientationAngle; // where is front - in 15° |
221 | u8 CamOrientation; // direction of the camera in 15° |
||
320 | holgerb | 222 | u8 GlobalConfig; |
223 | u8 ExtraConfig; |
||
321 | holgerb | 224 | u8 ComingHomeAltitude; |
350 | holgerb | 225 | u8 GlobalConfig3; |
516 | holgerb | 226 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
489 | killagreg | 227 | u8 FromFC_LandingSpeed; |
228 | u8 FromFC_LowVoltageHomeActive; |
||
516 | holgerb | 229 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
519 | holgerb | 230 | u8 SingleWpSpeed; |
532 | holgerb | 231 | u8 DescendRange; // in 10m |
232 | u8 MaximumAltitude; // in m |
||
573 | holgerb | 233 | u8 Driftkomp; |
587 | holgerb | 234 | u8 ReceiverType; |
588 | holgerb | 235 | u8 HomeYawMode; |
624 | holgerb | 236 | u8 Speak100m; |
237 | u8 AutoWpEventValue; |
||
41 | ingob | 238 | } __attribute__((packed)) Param_t; |
1 | ingob | 239 | |
41 | ingob | 240 | typedef struct |
241 | { |
||
242 | s8 StickNick; |
||
243 | s8 StickRoll; |
||
244 | s8 StickYaw; |
||
245 | s8 StickGas; |
||
190 | killagreg | 246 | u8 Poti[8]; |
41 | ingob | 247 | u8 RC_Quality; |
125 | killagreg | 248 | u8 RC_RSSI; |
595 | holgerb | 249 | u16 BAT_Voltage; |
206 | killagreg | 250 | u16 BAT_Current; |
251 | u16 BAT_UsedCapacity; |
||
255 | killagreg | 252 | u8 StatusFlags; |
253 | u8 Error[5]; |
||
294 | holgerb | 254 | u8 StatusFlags2; |
436 | holgerb | 255 | u8 FromFC_SpeakHoTT; |
489 | killagreg | 256 | s16 FromFC_CompassOffset; |
257 | u8 FromFC_DisableDeclination; |
||
573 | holgerb | 258 | u8 StatusFlags3; |
259 | s16 Altimeter; |
||
260 | u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation |
||
261 | u16 AdNeutralNick; |
||
262 | u16 AdNeutralRoll; |
||
263 | u16 AdNeutralYaw; |
||
587 | holgerb | 264 | u16 BoatNeutralNick; |
265 | u16 BoatNeutralRoll; |
||
266 | u16 BoatNeutralYaw; |
||
607 | holgerb | 267 | u8 AutoPhotoDistance; |
489 | killagreg | 268 | } __attribute__((packed)) FC_t; // from FC |
1 | ingob | 269 | |
41 | ingob | 270 | extern Param_t Parameter; |
78 | holgerb | 271 | extern volatile FC_t FC; |
41 | ingob | 272 | extern s8 ErrorMSG[25]; |
241 | killagreg | 273 | extern u8 ErrorCode; |
41 | ingob | 274 | extern u8 StopNavigation; |
328 | holgerb | 275 | extern u8 ErrorGpsFixLost; |
513 | killagreg | 276 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
378 | holgerb | 277 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
362 | holgerb | 278 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
378 | holgerb | 279 | extern volatile u32 PollingTimeout; |
457 | holgerb | 280 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsProcessedIn5Sec, FreqNewGpsDataIn5Sec; |
362 | holgerb | 281 | |
514 | holgerb | 282 | extern u16 SD_SettingWaitLED; |
283 | extern u16 SD_PosAccuracy; |
||
284 | extern u16 SD_ComingHomeSpeed; |
||
285 | extern u16 SD_DPH_Speed; |
||
532 | holgerb | 286 | extern u32 MaxWP_Radius_in_m; |
519 | holgerb | 287 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
549 | holgerb | 288 | extern u8 SpeakNextWaypoint; // Speak once when reached |
289 | extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started |
||
514 | holgerb | 290 | |
549 | holgerb | 291 | |
529 | holgerb | 292 | #define CHECK_ONLY 0 |
293 | #define GET_LICENSE 1 |
||
294 | #define COPY_SD_TO_EE 2 |
||
295 | extern u8 CheckLicense(u8); |
||
296 | |||
41 | ingob | 297 | #endif // _MAIN_H |