Rev 517 | Rev 529 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 517 | Rev 519 | ||
---|---|---|---|
1 | #ifndef _MAIN_H |
1 | #ifndef _MAIN_H |
2 | #define _MAIN_H |
2 | #define _MAIN_H |
3 | 3 | ||
4 | 4 | ||
5 | //#define FOLLOW_ME |
5 | //#define FOLLOW_ME |
6 | 6 | ||
7 | #ifdef FOLLOW_ME |
7 | #ifdef FOLLOW_ME |
8 | extern u8 TransmitAlsoToFC; |
8 | extern u8 TransmitAlsoToFC; |
9 | #endif |
9 | #endif |
10 | 10 | ||
11 | //----------------------- |
11 | //----------------------- |
12 | //#define DEBUG 0 |
12 | //#define DEBUG 0 |
13 | //----------------------- |
13 | //----------------------- |
14 | 14 | ||
15 | #define VERSION_MAJOR 2 |
15 | #define VERSION_MAJOR 2 |
16 | #define VERSION_MINOR 5 |
16 | #define VERSION_MINOR 5 |
17 | #define VERSION_PATCH 3 |
17 | #define VERSION_PATCH 4 |
18 | // 0 = A |
18 | // 0 = A |
19 | // 1 = B |
19 | // 1 = B |
20 | // 2 = C |
20 | // 2 = C |
21 | // 3 = D |
21 | // 3 = D |
22 | // 4 = E |
22 | // 4 = E |
23 | // 5 = F |
23 | // 5 = F |
24 | // 6 = G |
24 | // 6 = G |
25 | // 7 = H |
25 | // 7 = H |
26 | // 8 = I |
26 | // 8 = I |
27 | // 9 = J |
27 | // 9 = J |
28 | // 10 = k |
28 | // 10 = k |
29 | // 11 = L |
29 | // 11 = L |
30 | // 12 = M |
30 | // 12 = M |
31 | // 13 = N |
31 | // 13 = N |
32 | // 14 = O |
32 | // 14 = O |
33 | // 15 = P |
33 | // 15 = P |
34 | // 16 = Q |
34 | // 16 = Q |
35 | // 17 = R |
35 | // 17 = R |
36 | // 18 = S |
36 | // 18 = S |
37 | 37 | ||
38 | #ifndef FOLLOW_ME |
38 | #ifndef FOLLOW_ME |
39 | #define FC_SPI_COMPATIBLE 64 // <------------------ |
39 | #define FC_SPI_COMPATIBLE 65 // <------------------ |
40 | #else |
40 | #else |
41 | #define FC_SPI_COMPATIBLE 0xFF |
41 | #define FC_SPI_COMPATIBLE 0xFF |
42 | #endif |
42 | #endif |
43 | 43 | ||
44 | #define MK3MAG_I2C_COMPATIBLE 3 |
44 | #define MK3MAG_I2C_COMPATIBLE 3 |
45 | 45 | ||
46 | // FC.StatusFlags |
46 | // FC.StatusFlags |
47 | #define FC_STATUS_MOTOR_RUN 0x01 |
47 | #define FC_STATUS_MOTOR_RUN 0x01 |
48 | #define FC_STATUS_FLY 0x02 |
48 | #define FC_STATUS_FLY 0x02 |
49 | #define FC_STATUS_CALIBRATE 0x04 |
49 | #define FC_STATUS_CALIBRATE 0x04 |
50 | #define FC_STATUS_START 0x08 |
50 | #define FC_STATUS_START 0x08 |
51 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
51 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
52 | #define FC_STATUS_LOWBAT 0x20 |
52 | #define FC_STATUS_LOWBAT 0x20 |
53 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
53 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
54 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
54 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
55 | 55 | ||
56 | // FC.StatusFlags2 |
56 | // FC.StatusFlags2 |
57 | #define FC_STATUS2_CAREFREE 0x01 |
57 | #define FC_STATUS2_CAREFREE 0x01 |
58 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
58 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
59 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
59 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
60 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
60 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
61 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
61 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
62 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
62 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
63 | 63 | ||
64 | // FC ERRORS FLAGS |
64 | // FC ERRORS FLAGS |
65 | #define FC_ERROR0_GYRO_NICK 0x01 |
65 | #define FC_ERROR0_GYRO_NICK 0x01 |
66 | #define FC_ERROR0_GYRO_ROLL 0x02 |
66 | #define FC_ERROR0_GYRO_ROLL 0x02 |
67 | #define FC_ERROR0_GYRO_YAW 0x04 |
67 | #define FC_ERROR0_GYRO_YAW 0x04 |
68 | #define FC_ERROR0_ACC_NICK 0x08 |
68 | #define FC_ERROR0_ACC_NICK 0x08 |
69 | #define FC_ERROR0_ACC_ROLL 0x10 |
69 | #define FC_ERROR0_ACC_ROLL 0x10 |
70 | #define FC_ERROR0_ACC_TOP 0x20 |
70 | #define FC_ERROR0_ACC_TOP 0x20 |
71 | #define FC_ERROR0_PRESSURE 0x40 |
71 | #define FC_ERROR0_PRESSURE 0x40 |
72 | #define FC_ERROR0_CAREFREE 0x80 |
72 | #define FC_ERROR0_CAREFREE 0x80 |
73 | 73 | ||
74 | #define FC_ERROR1_I2C 0x01 |
74 | #define FC_ERROR1_I2C 0x01 |
75 | #define FC_ERROR1_BL_MISSING 0x02 |
75 | #define FC_ERROR1_BL_MISSING 0x02 |
76 | #define FC_ERROR1_SPI_RX 0x04 |
76 | #define FC_ERROR1_SPI_RX 0x04 |
77 | #define FC_ERROR1_PPM 0x08 |
77 | #define FC_ERROR1_PPM 0x08 |
78 | #define FC_ERROR1_MIXER 0x10 |
78 | #define FC_ERROR1_MIXER 0x10 |
79 | #define FC_ERROR1_RES1 0x20 |
79 | #define FC_ERROR1_RES1 0x20 |
80 | #define FC_ERROR1_RES2 0x40 |
80 | #define FC_ERROR1_RES2 0x40 |
81 | #define FC_ERROR1_RES3 0x80 |
81 | #define FC_ERROR1_RES3 0x80 |
82 | 82 | ||
83 | // NC Errors |
83 | // NC Errors |
84 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
84 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
85 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
85 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
86 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
86 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
87 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
87 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
88 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
88 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
89 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
89 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
90 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
90 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
91 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
91 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
92 | 92 | ||
93 | //Parameter.GlobalConfig3 |
93 | //Parameter.GlobalConfig3 |
94 | #define CFG3_NO_SDCARD_NO_START 0x01 |
94 | #define CFG3_NO_SDCARD_NO_START 0x01 |
95 | #define CFG3_DPH_MAX_RADIUS 0x02 |
95 | #define CFG3_DPH_MAX_RADIUS 0x02 |
96 | #define CFG3_VARIO_FAILSAFE 0x04 |
96 | #define CFG3_VARIO_FAILSAFE 0x04 |
97 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
97 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
98 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
98 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
99 | 99 | ||
100 | // Parameter.GlobalConfig |
100 | // Parameter.GlobalConfig |
101 | #define FC_CFG_HOEHENREGELUNG 0x01 |
101 | #define FC_CFG_HOEHENREGELUNG 0x01 |
102 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
102 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
103 | #define FC_CFG_HEADING_HOLD 0x04 |
103 | #define FC_CFG_HEADING_HOLD 0x04 |
104 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
104 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
105 | #define FC_CFG_KOMPASS_FIX 0x10 |
105 | #define FC_CFG_KOMPASS_FIX 0x10 |
106 | #define FC_CFG_GPS_AKTIV 0x20 |
106 | #define FC_CFG_GPS_AKTIV 0x20 |
107 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
107 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
108 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
108 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
109 | 109 | ||
110 | //Parameter.ExtraConfig |
110 | //Parameter.ExtraConfig |
111 | #define CFG2_HEIGHT_LIMIT 0x01 |
111 | #define CFG2_HEIGHT_LIMIT 0x01 |
112 | #define CFG2_VARIO_BEEP 0x02 |
112 | #define CFG2_VARIO_BEEP 0x02 |
113 | #define CFG_SENSITIVE_RC 0x04 |
113 | #define CFG_SENSITIVE_RC 0x04 |
114 | #define CFG_3_3V_REFERENCE 0x08 |
114 | #define CFG_3_3V_REFERENCE 0x08 |
115 | #define CFG_NO_RCOFF_BEEPING 0x10 |
115 | #define CFG_NO_RCOFF_BEEPING 0x10 |
116 | #define CFG_GPS_AID 0x20 |
116 | #define CFG_GPS_AID 0x20 |
117 | #define CFG_TEACHABLE_CAREFREE 0x40 |
117 | #define CFG_TEACHABLE_CAREFREE 0x40 |
118 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
118 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
119 | 119 | ||
120 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
120 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
121 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
121 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
122 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
122 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
123 | 123 | ||
124 | 124 | ||
125 | #define Poti1 FC.Poti[0] |
125 | #define Poti1 FC.Poti[0] |
126 | #define Poti2 FC.Poti[1] |
126 | #define Poti2 FC.Poti[1] |
127 | #define Poti3 FC.Poti[2] |
127 | #define Poti3 FC.Poti[2] |
128 | #define Poti4 FC.Poti[3] |
128 | #define Poti4 FC.Poti[3] |
129 | #define Poti5 FC.Poti[4] |
129 | #define Poti5 FC.Poti[4] |
130 | #define Poti6 FC.Poti[5] |
130 | #define Poti6 FC.Poti[5] |
131 | #define Poti7 FC.Poti[6] |
131 | #define Poti7 FC.Poti[6] |
132 | #define Poti8 FC.Poti[7] |
132 | #define Poti8 FC.Poti[7] |
133 | 133 | ||
134 | extern u16 BeepTime; |
134 | extern u16 BeepTime; |
135 | extern u8 NCFlags; |
135 | extern u8 NCFlags; |
136 | extern u8 ClearFCStatusFlags; |
136 | extern u8 ClearFCStatusFlags; |
137 | void Interrupt_Init(void); |
137 | void Interrupt_Init(void); |
138 | extern s16 GeoMagDec; |
138 | extern s16 GeoMagDec; |
139 | extern u8 NewWPL_Name; |
139 | extern u8 NewWPL_Name; |
140 | 140 | ||
141 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
141 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
142 | #define VERSION_SERIAL_MINOR 0 |
142 | #define VERSION_SERIAL_MINOR 0 |
143 | 143 | ||
144 | typedef struct |
144 | typedef struct |
145 | { |
145 | { |
146 | u8 ActiveSetting; |
146 | u8 ActiveSetting; |
147 | u8 User1; |
147 | u8 User1; |
148 | u8 User2; |
148 | u8 User2; |
149 | u8 User3; |
149 | u8 User3; |
150 | u8 User4; |
150 | u8 User4; |
151 | u8 User5; |
151 | u8 User5; |
152 | u8 User6; |
152 | u8 User6; |
153 | u8 User7; |
153 | u8 User7; |
154 | u8 User8; |
154 | u8 User8; |
155 | u8 NaviGpsModeControl; |
155 | u8 NaviGpsModeControl; |
156 | u8 NaviGpsGain; |
156 | u8 NaviGpsGain; |
157 | u8 NaviGpsP; |
157 | u8 NaviGpsP; |
158 | u8 NaviGpsI; |
158 | u8 NaviGpsI; |
159 | u8 NaviGpsD; |
159 | u8 NaviGpsD; |
160 | u8 NaviGpsPLimit; |
160 | u8 NaviGpsPLimit; |
161 | u8 NaviGpsILimit; |
161 | u8 NaviGpsILimit; |
162 | u8 NaviGpsDLimit; |
162 | u8 NaviGpsDLimit; |
163 | u8 NaviGpsACC; |
163 | u8 NaviGpsACC; |
164 | u8 NaviGpsMinSat; |
164 | u8 NaviGpsMinSat; |
165 | u8 NaviStickThreshold; |
165 | u8 NaviStickThreshold; |
166 | u8 NaviOperatingRadius; |
166 | u8 NaviOperatingRadius; |
167 | u8 NaviWindCorrection; |
167 | u8 NaviWindCorrection; |
168 | u8 NaviAccCompensation; |
168 | u8 NaviAccCompensation; |
169 | u8 NaviSpeedCompensation; |
169 | u8 NaviSpeedCompensation; |
170 | u8 LowVoltageWarning; |
170 | u8 LowVoltageWarning; |
171 | u8 NaviAngleLimitation; |
171 | u8 NaviAngleLimitation; |
172 | u8 NaviPH_LoginTime; |
172 | u8 NaviPH_LoginTime; |
173 | u8 OrientationAngle; |
173 | u8 OrientationAngle; |
174 | u8 GlobalConfig; |
174 | u8 GlobalConfig; |
175 | u8 ExtraConfig; |
175 | u8 ExtraConfig; |
176 | u8 ComingHomeAltitude; |
176 | u8 ComingHomeAltitude; |
177 | u8 GlobalConfig3; |
177 | u8 GlobalConfig3; |
178 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
178 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
179 | u8 FromFC_LandingSpeed; |
179 | u8 FromFC_LandingSpeed; |
180 | u8 FromFC_LowVoltageHomeActive; |
180 | u8 FromFC_LowVoltageHomeActive; |
181 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
181 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
- | 182 | u8 SingleWpSpeed; |
|
182 | } __attribute__((packed)) Param_t; |
183 | } __attribute__((packed)) Param_t; |
183 | 184 | ||
184 | typedef struct |
185 | typedef struct |
185 | { |
186 | { |
186 | s8 StickNick; |
187 | s8 StickNick; |
187 | s8 StickRoll; |
188 | s8 StickRoll; |
188 | s8 StickYaw; |
189 | s8 StickYaw; |
189 | s8 StickGas; |
190 | s8 StickGas; |
190 | u8 Poti[8]; |
191 | u8 Poti[8]; |
191 | u8 RC_Quality; |
192 | u8 RC_Quality; |
192 | u8 RC_RSSI; |
193 | u8 RC_RSSI; |
193 | u8 BAT_Voltage; |
194 | u8 BAT_Voltage; |
194 | u16 BAT_Current; |
195 | u16 BAT_Current; |
195 | u16 BAT_UsedCapacity; |
196 | u16 BAT_UsedCapacity; |
196 | u8 StatusFlags; |
197 | u8 StatusFlags; |
197 | u8 Error[5]; |
198 | u8 Error[5]; |
198 | u8 StatusFlags2; |
199 | u8 StatusFlags2; |
199 | u8 FromFC_SpeakHoTT; |
200 | u8 FromFC_SpeakHoTT; |
200 | s16 FromFC_CompassOffset; |
201 | s16 FromFC_CompassOffset; |
201 | u8 FromFC_DisableDeclination; |
202 | u8 FromFC_DisableDeclination; |
202 | } __attribute__((packed)) FC_t; // from FC |
203 | } __attribute__((packed)) FC_t; // from FC |
203 | 204 | ||
204 | 205 | ||
205 | extern Param_t Parameter; |
206 | extern Param_t Parameter; |
206 | extern volatile FC_t FC; |
207 | extern volatile FC_t FC; |
207 | extern s8 ErrorMSG[25]; |
208 | extern s8 ErrorMSG[25]; |
208 | extern u8 ErrorCode; |
209 | extern u8 ErrorCode; |
209 | extern u8 StopNavigation; |
210 | extern u8 StopNavigation; |
210 | extern u8 ErrorGpsFixLost; |
211 | extern u8 ErrorGpsFixLost; |
211 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
212 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
212 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
213 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
213 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
214 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
214 | extern volatile u32 PollingTimeout; |
215 | extern volatile u32 PollingTimeout; |
215 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsProcessedIn5Sec, FreqNewGpsDataIn5Sec; |
216 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsProcessedIn5Sec, FreqNewGpsDataIn5Sec; |
216 | 217 | ||
217 | extern u16 SD_SettingWaitLED; |
218 | extern u16 SD_SettingWaitLED; |
218 | extern u16 SD_PosAccuracy; |
219 | extern u16 SD_PosAccuracy; |
219 | extern u16 SD_ComingHomeSpeed; |
220 | extern u16 SD_ComingHomeSpeed; |
220 | extern u16 SD_DPH_Speed; |
221 | extern u16 SD_DPH_Speed; |
221 | extern u32 MaxRadius_in_m; |
222 | extern u32 MaxRadius_in_m; |
- | 223 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
|
- | 224 | extern u8 SpeakNextWaypoint; // Speak once when reached |
|
222 | 225 | ||
223 | #endif // _MAIN_H |
226 | #endif // _MAIN_H |
224 | 227 |