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 |
688 | holgerb | 16 | #define VERSION_MINOR 13 |
731 | holgerb | 17 | #define VERSION_PATCH 5 |
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 | |
699 | holgerb | 38 | #define CAN_SLAVE_COMPATIBLE 1 |
317 | holgerb | 39 | #ifndef FOLLOW_ME |
727 | holgerb | 40 | #define FC_SPI_COMPATIBLE 80 // <------------------ |
317 | holgerb | 41 | #else |
316 | killagreg | 42 | #define FC_SPI_COMPATIBLE 0xFF |
43 | #endif |
||
44 | |||
229 | holgerb | 45 | #define MK3MAG_I2C_COMPATIBLE 3 |
607 | holgerb | 46 | #define MAX_MOTORS 16 // since 2.10 (3.2014) |
241 | killagreg | 47 | |
320 | holgerb | 48 | // FC.StatusFlags |
255 | killagreg | 49 | #define FC_STATUS_MOTOR_RUN 0x01 |
50 | #define FC_STATUS_FLY 0x02 |
||
51 | #define FC_STATUS_CALIBRATE 0x04 |
||
52 | #define FC_STATUS_START 0x08 |
||
53 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
||
54 | #define FC_STATUS_LOWBAT 0x20 |
||
279 | holgerb | 55 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
56 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
||
78 | holgerb | 57 | |
320 | holgerb | 58 | // FC.StatusFlags2 |
294 | holgerb | 59 | #define FC_STATUS2_CAREFREE 0x01 |
60 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
||
322 | holgerb | 61 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
360 | holgerb | 62 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
63 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
||
447 | holgerb | 64 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
699 | holgerb | 65 | #define FC_STATUS2_AUTO_STARTING 0x40 |
66 | #define FC_STATUS2_AUTO_LANDING 0x80 |
||
294 | holgerb | 67 | |
573 | holgerb | 68 | // FC.StatusFlags3 |
616 | holgerb | 69 | #define FC_STATUS3_REDUNDANCE_AKTIVE 0x01 |
573 | holgerb | 70 | #define FC_STATUS3_BOAT 0x02 |
616 | holgerb | 71 | #define FC_STATUS3_REDUNDANCE_ERROR 0x04 |
72 | #define FC_STATUS3_REDUNDANCE_TEST 0x08 |
||
699 | holgerb | 73 | #define FC_STATUS3_NOT_CALIBRATED 0x10 |
74 | #define FC_STATUS3_MOTORS_STOPPED_BY_RC 0x20 |
||
573 | holgerb | 75 | |
595 | holgerb | 76 | #define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80) |
77 | #define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10) |
||
78 | |||
79 | // .NCFlags |
||
80 | #define NC_FLAG_FREE 0x01 |
||
81 | #define NC_FLAG_PH 0x02 |
||
82 | #define NC_FLAG_CH 0x04 |
||
83 | #define NC_FLAG_RANGE_LIMIT 0x08 |
||
84 | #define NC_FLAG_NOSERIALLINK 0x10 |
||
85 | #define NC_FLAG_TARGET_REACHED 0x20 |
||
86 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
||
87 | #define NC_FLAG_GPS_OK 0x80 |
||
88 | |||
89 | |||
90 | // NC calculates |
||
91 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
||
92 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
||
93 | |||
94 | //calculate Back: |
||
95 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
||
96 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
||
97 | |||
707 | holgerb | 98 | // FC.Error[0] |
255 | killagreg | 99 | #define FC_ERROR0_GYRO_NICK 0x01 |
100 | #define FC_ERROR0_GYRO_ROLL 0x02 |
||
101 | #define FC_ERROR0_GYRO_YAW 0x04 |
||
102 | #define FC_ERROR0_ACC_NICK 0x08 |
||
103 | #define FC_ERROR0_ACC_ROLL 0x10 |
||
104 | #define FC_ERROR0_ACC_TOP 0x20 |
||
105 | #define FC_ERROR0_PRESSURE 0x40 |
||
106 | #define FC_ERROR0_CAREFREE 0x80 |
||
107 | |||
707 | holgerb | 108 | // FC.Error[1] |
255 | killagreg | 109 | #define FC_ERROR1_I2C 0x01 |
110 | #define FC_ERROR1_BL_MISSING 0x02 |
||
111 | #define FC_ERROR1_SPI_RX 0x04 |
||
112 | #define FC_ERROR1_PPM 0x08 |
||
113 | #define FC_ERROR1_MIXER 0x10 |
||
707 | holgerb | 114 | #define FC_ERROR1_RC_VOLTAGE 0x20 |
115 | #define FC_ERROR1_ACC_NOT_CAL 0x40 |
||
255 | killagreg | 116 | #define FC_ERROR1_RES3 0x80 |
117 | |||
146 | killagreg | 118 | // NC Errors |
119 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
||
120 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
||
121 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
||
122 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
||
123 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
||
124 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
||
125 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
||
264 | killagreg | 126 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
49 | ingob | 127 | |
625 | holgerb | 128 | //NC_To_FC_Flags |
129 | #define NC_TO_FC_FLYING_RANGE 0x01 |
||
130 | #define NC_TO_FC_EMERGENCY_LANDING 0x02 |
||
131 | #define NC_TO_FC_AUTOSTART 0x04 |
||
132 | #define NC_TO_FC_FAILSAFE_LANDING 0x08 // activates Servos |
||
133 | #define NC_TO_FC_SIMULATION_ACTIVE 0x10 // don't start motors if simulation ist active |
||
134 | |||
350 | holgerb | 135 | //Parameter.GlobalConfig3 |
136 | #define CFG3_NO_SDCARD_NO_START 0x01 |
||
532 | holgerb | 137 | //#define CFG3_DPH_MAX_RADIUS 0x02 |
350 | holgerb | 138 | #define CFG3_VARIO_FAILSAFE 0x04 |
398 | holgerb | 139 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
140 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
||
350 | holgerb | 141 | |
320 | holgerb | 142 | // Parameter.GlobalConfig |
331 | holgerb | 143 | #define FC_CFG_HOEHENREGELUNG 0x01 |
144 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
||
145 | #define FC_CFG_HEADING_HOLD 0x04 |
||
146 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
||
147 | #define FC_CFG_KOMPASS_FIX 0x10 |
||
148 | #define FC_CFG_GPS_AKTIV 0x20 |
||
149 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
||
150 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
||
190 | killagreg | 151 | |
489 | killagreg | 152 | //Parameter.ExtraConfig |
331 | holgerb | 153 | #define CFG2_HEIGHT_LIMIT 0x01 |
154 | #define CFG2_VARIO_BEEP 0x02 |
||
155 | #define CFG_SENSITIVE_RC 0x04 |
||
156 | #define CFG_3_3V_REFERENCE 0x08 |
||
157 | #define CFG_NO_RCOFF_BEEPING 0x10 |
||
158 | #define CFG_GPS_AID 0x20 |
||
159 | #define CFG_TEACHABLE_CAREFREE 0x40 |
||
160 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
||
320 | holgerb | 161 | |
588 | holgerb | 162 | // Parameter.HomeYawMode |
163 | #define NO_CHANGE 0 |
||
164 | #define FRONT_TO_HOME 1 |
||
165 | #define REAR_TO_HOME 2 |
||
166 | #define LIKE_AT_START 3 |
||
167 | |||
587 | holgerb | 168 | // Parameter.ReceiverType defines for the receiver selection |
169 | #define RECEIVER_PPM 0 |
||
170 | #define RECEIVER_SPEKTRUM 1 |
||
171 | #define RECEIVER_SPEKTRUM_HI_RES 2 |
||
172 | #define RECEIVER_SPEKTRUM_LOW_RES 3 |
||
173 | #define RECEIVER_JETI 4 |
||
174 | #define RECEIVER_ACT_DSL 5 |
||
175 | #define RECEIVER_HOTT 6 |
||
176 | #define RECEIVER_SBUS 7 |
||
177 | #define RECEIVER_USER 8 |
||
178 | |||
179 | #define RECEIVER_UNKNOWN 0xFF |
||
180 | |||
190 | killagreg | 181 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
182 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
||
183 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
||
184 | |||
327 | holgerb | 185 | |
186 | #define Poti1 FC.Poti[0] |
||
187 | #define Poti2 FC.Poti[1] |
||
188 | #define Poti3 FC.Poti[2] |
||
189 | #define Poti4 FC.Poti[3] |
||
190 | #define Poti5 FC.Poti[4] |
||
191 | #define Poti6 FC.Poti[5] |
||
192 | #define Poti7 FC.Poti[6] |
||
193 | #define Poti8 FC.Poti[7] |
||
194 | |||
41 | ingob | 195 | extern u16 BeepTime; |
92 | killagreg | 196 | extern u8 NCFlags; |
255 | killagreg | 197 | extern u8 ClearFCStatusFlags; |
41 | ingob | 198 | void Interrupt_Init(void); |
153 | killagreg | 199 | extern s16 GeoMagDec; |
504 | holgerb | 200 | extern u8 NewWPL_Name; |
1 | ingob | 201 | |
699 | holgerb | 202 | #define NOTHING 0 |
203 | #define MASTER 1 |
||
204 | #define SLAVE 2 |
||
205 | extern u8 IamMaster; |
||
206 | |||
505 | holgerb | 207 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
208 | |||
41 | ingob | 209 | typedef struct |
210 | { |
||
211 | u8 ActiveSetting; |
||
212 | u8 User1; |
||
213 | u8 User2; |
||
214 | u8 User3; |
||
215 | u8 User4; |
||
216 | u8 User5; |
||
217 | u8 User6; |
||
218 | u8 User7; |
||
219 | u8 User8; |
||
220 | u8 NaviGpsModeControl; |
||
221 | u8 NaviGpsGain; |
||
222 | u8 NaviGpsP; |
||
223 | u8 NaviGpsI; |
||
224 | u8 NaviGpsD; |
||
56 | holgerb | 225 | u8 NaviGpsPLimit; |
226 | u8 NaviGpsILimit; |
||
227 | u8 NaviGpsDLimit; |
||
41 | ingob | 228 | u8 NaviGpsACC; |
229 | u8 NaviGpsMinSat; |
||
230 | u8 NaviStickThreshold; |
||
532 | holgerb | 231 | u8 NaviMaxFlyingRange; // in 10m |
41 | ingob | 232 | u8 NaviWindCorrection; |
327 | holgerb | 233 | u8 NaviAccCompensation; |
41 | ingob | 234 | u8 NaviSpeedCompensation; |
235 | u8 LowVoltageWarning; |
||
236 | u8 NaviAngleLimitation; |
||
56 | holgerb | 237 | u8 NaviPH_LoginTime; |
544 | holgerb | 238 | u8 OrientationAngle; // where is front - in 15° |
239 | u8 CamOrientation; // direction of the camera in 15° |
||
320 | holgerb | 240 | u8 GlobalConfig; |
241 | u8 ExtraConfig; |
||
321 | holgerb | 242 | u8 ComingHomeAltitude; |
350 | holgerb | 243 | u8 GlobalConfig3; |
516 | holgerb | 244 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
489 | killagreg | 245 | u8 FromFC_LandingSpeed; |
246 | u8 FromFC_LowVoltageHomeActive; |
||
516 | holgerb | 247 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
519 | holgerb | 248 | u8 SingleWpSpeed; |
532 | holgerb | 249 | u8 DescendRange; // in 10m |
250 | u8 MaximumAltitude; // in m |
||
573 | holgerb | 251 | u8 Driftkomp; |
587 | holgerb | 252 | u8 ReceiverType; |
588 | holgerb | 253 | u8 HomeYawMode; |
624 | holgerb | 254 | u8 Speak100m; |
255 | u8 AutoWpEventValue; |
||
646 | holgerb | 256 | u8 FailSafeTime; |
41 | ingob | 257 | } __attribute__((packed)) Param_t; |
1 | ingob | 258 | |
41 | ingob | 259 | typedef struct |
260 | { |
||
261 | s8 StickNick; |
||
262 | s8 StickRoll; |
||
263 | s8 StickYaw; |
||
264 | s8 StickGas; |
||
190 | killagreg | 265 | u8 Poti[8]; |
41 | ingob | 266 | u8 RC_Quality; |
125 | killagreg | 267 | u8 RC_RSSI; |
595 | holgerb | 268 | u16 BAT_Voltage; |
206 | killagreg | 269 | u16 BAT_Current; |
270 | u16 BAT_UsedCapacity; |
||
255 | killagreg | 271 | u8 StatusFlags; |
272 | u8 Error[5]; |
||
294 | holgerb | 273 | u8 StatusFlags2; |
436 | holgerb | 274 | u8 FromFC_SpeakHoTT; |
489 | killagreg | 275 | s16 FromFC_CompassOffset; |
276 | u8 FromFC_DisableDeclination; |
||
573 | holgerb | 277 | u8 StatusFlags3; |
278 | s16 Altimeter; |
||
279 | u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation |
||
280 | u16 AdNeutralNick; |
||
281 | u16 AdNeutralRoll; |
||
282 | u16 AdNeutralYaw; |
||
587 | holgerb | 283 | u16 BoatNeutralNick; |
284 | u16 BoatNeutralRoll; |
||
285 | u16 BoatNeutralYaw; |
||
607 | holgerb | 286 | u8 AutoPhotoDistance; |
489 | killagreg | 287 | } __attribute__((packed)) FC_t; // from FC |
1 | ingob | 288 | |
699 | holgerb | 289 | typedef struct |
290 | { |
||
291 | u8 ErrorCode; |
||
292 | u8 StatusFlags; |
||
293 | u8 StatusFlags2; |
||
294 | u8 StatusFlags3; |
||
295 | u8 NC_To_FC_Flags; |
||
296 | u8 MagnetField; // in % |
||
297 | s16 GyroCompassCorrected; |
||
298 | } __attribute__((packed)) Partner_t; // from FC |
||
299 | |||
300 | extern Partner_t Partner; |
||
41 | ingob | 301 | extern Param_t Parameter; |
78 | holgerb | 302 | extern volatile FC_t FC; |
41 | ingob | 303 | extern s8 ErrorMSG[25]; |
699 | holgerb | 304 | extern s8 PartnerErrorMSG[25]; |
305 | extern u8 ErrorCode,PartnerErrorCode; |
||
41 | ingob | 306 | extern u8 StopNavigation; |
328 | holgerb | 307 | extern u8 ErrorGpsFixLost; |
513 | killagreg | 308 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
378 | holgerb | 309 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
362 | holgerb | 310 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
378 | holgerb | 311 | extern volatile u32 PollingTimeout; |
663 | holgerb | 312 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsNavProcessed, FreqNewGpsData; |
313 | extern u32 TimeSinceMotorStart; |
||
699 | holgerb | 314 | extern u8 NC_To_FC_Flags, NC_To_FC_Autostart; |
514 | holgerb | 315 | extern u16 SD_SettingWaitLED; |
316 | extern u16 SD_PosAccuracy; |
||
317 | extern u16 SD_ComingHomeSpeed; |
||
318 | extern u16 SD_DPH_Speed; |
||
532 | holgerb | 319 | extern u32 MaxWP_Radius_in_m; |
519 | holgerb | 320 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
549 | holgerb | 321 | extern u8 SpeakNextWaypoint; // Speak once when reached |
322 | extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started |
||
699 | holgerb | 323 | extern s16 GyroCompassCorrected; |
324 | extern s16 CompassSetpointCorrected; // The compass setpoint that the FC tries to keep - corrected with the magnetic declination |
||
325 | extern s16 CompassSetpoint; |
||
326 | extern u8 AmountOfMotors; |
||
327 | extern s16 SimulatedDirection; // simulated compass direction |
||
514 | holgerb | 328 | |
549 | holgerb | 329 | |
529 | holgerb | 330 | #define CHECK_ONLY 0 |
331 | #define GET_LICENSE 1 |
||
332 | #define COPY_SD_TO_EE 2 |
||
333 | extern u8 CheckLicense(u8); |
||
334 | |||
681 | holgerb | 335 | // Portpin inputs |
707 | holgerb | 336 | #define PIN6_0 (GPIO6->DR[0x3FC] & 0x01) |
337 | #define PIN6_1 (GPIO6->DR[0x3FC] & 0x02) |
||
338 | #define PIN6_2 (GPIO6->DR[0x3FC] & 0x04) |
||
681 | holgerb | 339 | #define PIN6_3 (GPIO6->DR[0x3FC] & 0x08) |
340 | #define PIN6_4 (GPIO6->DR[0x3FC] & 0x10) |
||
341 | #define PIN6_5 (GPIO6->DR[0x3FC] & 0x20) |
||
342 | |||
707 | holgerb | 343 | #define TRIGGER_PP_INTERN PIN6_0 |
344 | #define TRIGGER_PP_EXTERN PIN6_3 |
||
345 | #define BLITZ_CONNECTED PIN6_4 |
||
681 | holgerb | 346 | |
41 | ingob | 347 | #endif // _MAIN_H |