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 |
573 | holgerb | 16 | #define VERSION_MINOR 7 |
576 | holgerb | 17 | #define VERSION_PATCH 3 |
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 |
573 | holgerb | 39 | #define FC_SPI_COMPATIBLE 71 // <------------------ |
317 | holgerb | 40 | #else |
316 | killagreg | 41 | #define FC_SPI_COMPATIBLE 0xFF |
42 | #endif |
||
43 | |||
229 | holgerb | 44 | #define MK3MAG_I2C_COMPATIBLE 3 |
241 | killagreg | 45 | |
320 | holgerb | 46 | // FC.StatusFlags |
255 | killagreg | 47 | #define FC_STATUS_MOTOR_RUN 0x01 |
48 | #define FC_STATUS_FLY 0x02 |
||
49 | #define FC_STATUS_CALIBRATE 0x04 |
||
50 | #define FC_STATUS_START 0x08 |
||
51 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
||
52 | #define FC_STATUS_LOWBAT 0x20 |
||
279 | holgerb | 53 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
54 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
||
78 | holgerb | 55 | |
320 | holgerb | 56 | // FC.StatusFlags2 |
294 | holgerb | 57 | #define FC_STATUS2_CAREFREE 0x01 |
58 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
||
322 | holgerb | 59 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
360 | holgerb | 60 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
61 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
||
447 | holgerb | 62 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
294 | holgerb | 63 | |
573 | holgerb | 64 | // FC.StatusFlags3 |
65 | #define FC_STATUS3_REDUNDANCE 0x01 |
||
66 | #define FC_STATUS3_BOAT 0x02 |
||
67 | |||
255 | killagreg | 68 | // FC ERRORS FLAGS |
69 | #define FC_ERROR0_GYRO_NICK 0x01 |
||
70 | #define FC_ERROR0_GYRO_ROLL 0x02 |
||
71 | #define FC_ERROR0_GYRO_YAW 0x04 |
||
72 | #define FC_ERROR0_ACC_NICK 0x08 |
||
73 | #define FC_ERROR0_ACC_ROLL 0x10 |
||
74 | #define FC_ERROR0_ACC_TOP 0x20 |
||
75 | #define FC_ERROR0_PRESSURE 0x40 |
||
76 | #define FC_ERROR0_CAREFREE 0x80 |
||
77 | |||
78 | #define FC_ERROR1_I2C 0x01 |
||
79 | #define FC_ERROR1_BL_MISSING 0x02 |
||
80 | #define FC_ERROR1_SPI_RX 0x04 |
||
81 | #define FC_ERROR1_PPM 0x08 |
||
82 | #define FC_ERROR1_MIXER 0x10 |
||
83 | #define FC_ERROR1_RES1 0x20 |
||
84 | #define FC_ERROR1_RES2 0x40 |
||
85 | #define FC_ERROR1_RES3 0x80 |
||
86 | |||
146 | killagreg | 87 | // NC Errors |
88 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
||
89 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
||
90 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
||
91 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
||
92 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
||
93 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
||
94 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
||
264 | killagreg | 95 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
49 | ingob | 96 | |
350 | holgerb | 97 | //Parameter.GlobalConfig3 |
98 | #define CFG3_NO_SDCARD_NO_START 0x01 |
||
532 | holgerb | 99 | //#define CFG3_DPH_MAX_RADIUS 0x02 |
350 | holgerb | 100 | #define CFG3_VARIO_FAILSAFE 0x04 |
398 | holgerb | 101 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
102 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
||
350 | holgerb | 103 | |
320 | holgerb | 104 | // Parameter.GlobalConfig |
331 | holgerb | 105 | #define FC_CFG_HOEHENREGELUNG 0x01 |
106 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
||
107 | #define FC_CFG_HEADING_HOLD 0x04 |
||
108 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
||
109 | #define FC_CFG_KOMPASS_FIX 0x10 |
||
110 | #define FC_CFG_GPS_AKTIV 0x20 |
||
111 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
||
112 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
||
190 | killagreg | 113 | |
489 | killagreg | 114 | //Parameter.ExtraConfig |
331 | holgerb | 115 | #define CFG2_HEIGHT_LIMIT 0x01 |
116 | #define CFG2_VARIO_BEEP 0x02 |
||
117 | #define CFG_SENSITIVE_RC 0x04 |
||
118 | #define CFG_3_3V_REFERENCE 0x08 |
||
119 | #define CFG_NO_RCOFF_BEEPING 0x10 |
||
120 | #define CFG_GPS_AID 0x20 |
||
121 | #define CFG_TEACHABLE_CAREFREE 0x40 |
||
122 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
||
320 | holgerb | 123 | |
190 | killagreg | 124 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
125 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
||
126 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
||
127 | |||
327 | holgerb | 128 | |
129 | #define Poti1 FC.Poti[0] |
||
130 | #define Poti2 FC.Poti[1] |
||
131 | #define Poti3 FC.Poti[2] |
||
132 | #define Poti4 FC.Poti[3] |
||
133 | #define Poti5 FC.Poti[4] |
||
134 | #define Poti6 FC.Poti[5] |
||
135 | #define Poti7 FC.Poti[6] |
||
136 | #define Poti8 FC.Poti[7] |
||
137 | |||
41 | ingob | 138 | extern u16 BeepTime; |
92 | killagreg | 139 | extern u8 NCFlags; |
255 | killagreg | 140 | extern u8 ClearFCStatusFlags; |
41 | ingob | 141 | void Interrupt_Init(void); |
153 | killagreg | 142 | extern s16 GeoMagDec; |
504 | holgerb | 143 | extern u8 NewWPL_Name; |
1 | ingob | 144 | |
505 | holgerb | 145 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
146 | |||
41 | ingob | 147 | typedef struct |
148 | { |
||
149 | u8 ActiveSetting; |
||
150 | u8 User1; |
||
151 | u8 User2; |
||
152 | u8 User3; |
||
153 | u8 User4; |
||
154 | u8 User5; |
||
155 | u8 User6; |
||
156 | u8 User7; |
||
157 | u8 User8; |
||
158 | u8 NaviGpsModeControl; |
||
159 | u8 NaviGpsGain; |
||
160 | u8 NaviGpsP; |
||
161 | u8 NaviGpsI; |
||
162 | u8 NaviGpsD; |
||
56 | holgerb | 163 | u8 NaviGpsPLimit; |
164 | u8 NaviGpsILimit; |
||
165 | u8 NaviGpsDLimit; |
||
41 | ingob | 166 | u8 NaviGpsACC; |
167 | u8 NaviGpsMinSat; |
||
168 | u8 NaviStickThreshold; |
||
532 | holgerb | 169 | u8 NaviMaxFlyingRange; // in 10m |
41 | ingob | 170 | u8 NaviWindCorrection; |
327 | holgerb | 171 | u8 NaviAccCompensation; |
41 | ingob | 172 | u8 NaviSpeedCompensation; |
173 | u8 LowVoltageWarning; |
||
174 | u8 NaviAngleLimitation; |
||
56 | holgerb | 175 | u8 NaviPH_LoginTime; |
544 | holgerb | 176 | u8 OrientationAngle; // where is front - in 15° |
177 | u8 CamOrientation; // direction of the camera in 15° |
||
320 | holgerb | 178 | u8 GlobalConfig; |
179 | u8 ExtraConfig; |
||
321 | holgerb | 180 | u8 ComingHomeAltitude; |
350 | holgerb | 181 | u8 GlobalConfig3; |
516 | holgerb | 182 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
489 | killagreg | 183 | u8 FromFC_LandingSpeed; |
184 | u8 FromFC_LowVoltageHomeActive; |
||
516 | holgerb | 185 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
519 | holgerb | 186 | u8 SingleWpSpeed; |
532 | holgerb | 187 | u8 DescendRange; // in 10m |
188 | u8 MaximumAltitude; // in m |
||
573 | holgerb | 189 | u8 Driftkomp; |
41 | ingob | 190 | } __attribute__((packed)) Param_t; |
1 | ingob | 191 | |
41 | ingob | 192 | typedef struct |
193 | { |
||
194 | s8 StickNick; |
||
195 | s8 StickRoll; |
||
196 | s8 StickYaw; |
||
197 | s8 StickGas; |
||
190 | killagreg | 198 | u8 Poti[8]; |
41 | ingob | 199 | u8 RC_Quality; |
125 | killagreg | 200 | u8 RC_RSSI; |
206 | killagreg | 201 | u8 BAT_Voltage; |
202 | u16 BAT_Current; |
||
203 | u16 BAT_UsedCapacity; |
||
255 | killagreg | 204 | u8 StatusFlags; |
205 | u8 Error[5]; |
||
294 | holgerb | 206 | u8 StatusFlags2; |
436 | holgerb | 207 | u8 FromFC_SpeakHoTT; |
489 | killagreg | 208 | s16 FromFC_CompassOffset; |
209 | u8 FromFC_DisableDeclination; |
||
573 | holgerb | 210 | u8 StatusFlags3; |
211 | s16 Altimeter; |
||
212 | u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation |
||
213 | u16 AdNeutralNick; |
||
214 | u16 AdNeutralRoll; |
||
215 | u16 AdNeutralYaw; |
||
489 | killagreg | 216 | } __attribute__((packed)) FC_t; // from FC |
1 | ingob | 217 | |
41 | ingob | 218 | extern Param_t Parameter; |
78 | holgerb | 219 | extern volatile FC_t FC; |
41 | ingob | 220 | extern s8 ErrorMSG[25]; |
241 | killagreg | 221 | extern u8 ErrorCode; |
41 | ingob | 222 | extern u8 StopNavigation; |
328 | holgerb | 223 | extern u8 ErrorGpsFixLost; |
513 | killagreg | 224 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
378 | holgerb | 225 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
362 | holgerb | 226 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
378 | holgerb | 227 | extern volatile u32 PollingTimeout; |
457 | holgerb | 228 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsProcessedIn5Sec, FreqNewGpsDataIn5Sec; |
362 | holgerb | 229 | |
514 | holgerb | 230 | extern u16 SD_SettingWaitLED; |
231 | extern u16 SD_PosAccuracy; |
||
232 | extern u16 SD_ComingHomeSpeed; |
||
233 | extern u16 SD_DPH_Speed; |
||
532 | holgerb | 234 | extern u32 MaxWP_Radius_in_m; |
519 | holgerb | 235 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
549 | holgerb | 236 | extern u8 SpeakNextWaypoint; // Speak once when reached |
237 | extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started |
||
514 | holgerb | 238 | |
549 | holgerb | 239 | |
529 | holgerb | 240 | #define CHECK_ONLY 0 |
241 | #define GET_LICENSE 1 |
||
242 | #define COPY_SD_TO_EE 2 |
||
243 | extern u8 CheckLicense(u8); |
||
244 | |||
41 | ingob | 245 | #endif // _MAIN_H |