Rev 825 | Rev 833 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 825 | Rev 829 | ||
---|---|---|---|
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 19 |
16 | #define VERSION_MINOR 19 |
17 | #define VERSION_PATCH 2 |
17 | #define VERSION_PATCH 2 |
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 | #define CAN_SLAVE_COMPATIBLE 2 |
38 | #define CAN_SLAVE_COMPATIBLE 2 |
39 | #ifndef FOLLOW_ME |
39 | #ifndef FOLLOW_ME |
40 | #define FC_SPI_COMPATIBLE 87 // <------------------ |
40 | #define FC_SPI_COMPATIBLE 87 // <------------------ |
41 | #else |
41 | #else |
42 | #define FC_SPI_COMPATIBLE 0xFF |
42 | #define FC_SPI_COMPATIBLE 0xFF |
43 | #endif |
43 | #endif |
44 | 44 | ||
45 | #define MK3MAG_I2C_COMPATIBLE 3 |
45 | #define MK3MAG_I2C_COMPATIBLE 3 |
46 | #define MAX_MOTORS 16 // since 2.10 (3.2014) |
46 | #define MAX_MOTORS 16 // since 2.10 (3.2014) |
47 | 47 | ||
48 | // FC.StatusFlags |
48 | // FC.StatusFlags |
49 | #define FC_STATUS_MOTOR_RUN 0x01 |
49 | #define FC_STATUS_MOTOR_RUN 0x01 |
50 | #define FC_STATUS_FLY 0x02 |
50 | #define FC_STATUS_FLY 0x02 |
51 | #define FC_STATUS_CALIBRATE 0x04 |
51 | #define FC_STATUS_CALIBRATE 0x04 |
52 | #define FC_STATUS_START 0x08 |
52 | #define FC_STATUS_START 0x08 |
53 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
53 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
54 | #define FC_STATUS_LOWBAT 0x20 |
54 | #define FC_STATUS_LOWBAT 0x20 |
55 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
55 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
56 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
56 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
57 | 57 | ||
58 | // FC.StatusFlags2 |
58 | // FC.StatusFlags2 |
59 | #define FC_STATUS2_CAREFREE 0x01 |
59 | #define FC_STATUS2_CAREFREE 0x01 |
60 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
60 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
61 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
61 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
62 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
62 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
63 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
63 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
64 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
64 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
65 | #define FC_STATUS2_AUTO_STARTING 0x40 |
65 | #define FC_STATUS2_AUTO_STARTING 0x40 |
66 | #define FC_STATUS2_AUTO_LANDING 0x80 |
66 | #define FC_STATUS2_AUTO_LANDING 0x80 |
67 | 67 | ||
68 | // FC.StatusFlags3 |
68 | // FC.StatusFlags3 |
69 | #define FC_STATUS3_REDUNDANCE_AKTIVE 0x01 |
69 | #define FC_STATUS3_REDUNDANCE_AKTIVE 0x01 |
70 | #define FC_STATUS3_BOAT 0x02 |
70 | #define FC_STATUS3_BOAT 0x02 |
71 | #define FC_STATUS3_REDUNDANCE_ERROR 0x04 |
71 | #define FC_STATUS3_REDUNDANCE_ERROR 0x04 |
72 | #define FC_STATUS3_REDUNDANCE_TEST 0x08 |
72 | #define FC_STATUS3_REDUNDANCE_TEST 0x08 |
73 | #define FC_STATUS3_NOT_CALIBRATED 0x10 |
73 | #define FC_STATUS3_NOT_CALIBRATED 0x10 |
74 | #define FC_STATUS3_MOTORS_STOPPED_BY_RC 0x20 |
74 | #define FC_STATUS3_MOTORS_STOPPED_BY_RC 0x20 |
75 | 75 | ||
76 | 76 | ||
77 | // xxx.OSDStatusFlags (multiple data sets) -> this is the definition in the OSD data structure |
77 | // xxx.OSDStatusFlags (multiple data sets) -> this is the definition in the OSD data structure |
78 | #define OSD_FLAG_CAREFREE 0x01 |
78 | #define OSD_FLAG_CAREFREE 0x01 |
79 | #define OSD_FLAG_ALTITUDE_CONTROL 0x02 |
79 | #define OSD_FLAG_ALTITUDE_CONTROL 0x02 |
80 | #define OSD_FLAG_CALIBRATE 0x04 |
80 | #define OSD_FLAG_CALIBRATE 0x04 |
81 | #define OSD_FLAG_OUT1_ACTIVE 0x08 |
81 | #define OSD_FLAG_OUT1_ACTIVE 0x08 |
82 | #define OSD_FLAG_OUT2_ACTIVE 0x10 |
82 | #define OSD_FLAG_OUT2_ACTIVE 0x10 |
83 | #define OSD_FLAG_LOWBAT 0x20 |
83 | #define OSD_FLAG_LOWBAT 0x20 |
84 | #define OSD_FLAG_VARIO_TRIM_UP 0x40 |
84 | #define OSD_FLAG_VARIO_TRIM_UP 0x40 |
85 | #define OSD_FLAG_VARIO_TRIM_DOWN 0x80 |
85 | #define OSD_FLAG_VARIO_TRIM_DOWN 0x80 |
86 | 86 | ||
87 | // NaviData_Flags.OSDStatusFlags2 (Index:11) -> this is the definition in the OSD data structure |
87 | // NaviData_Flags.OSDStatusFlags2 (Index:11) -> this is the definition in the OSD data structure |
88 | #define OSD2_FLAG_MOTOR_RUN 0x01 |
88 | #define OSD2_FLAG_MOTOR_RUN 0x01 |
89 | #define OSD2_FLAG_FLY 0x02 |
89 | #define OSD2_FLAG_FLY 0x02 |
90 | #define OSD2_FLAG_RC_FAILSAVE_ACTIVE 0x04 |
90 | #define OSD2_FLAG_RC_FAILSAVE_ACTIVE 0x04 |
91 | #define OSD2_FLAG_START 0x08 |
91 | #define OSD2_FLAG_START 0x08 |
92 | #define OSD2_FLAG_EMERGENCY_LANDING 0x10 |
92 | #define OSD2_FLAG_EMERGENCY_LANDING 0x10 |
93 | #define OSD2_FLAG_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
93 | #define OSD2_FLAG_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
94 | #define OSD2_FLAG_AUTO_STARTING 0x40 |
94 | #define OSD2_FLAG_AUTO_STARTING 0x40 |
95 | #define OSD2_FLAG_AUTO_LANDING 0x80 |
95 | #define OSD2_FLAG_AUTO_LANDING 0x80 |
96 | 96 | ||
97 | // NaviData_Home.OSDStatusFlags3 (Index:13 Home-Position) -> use only for flags that change slowly |
97 | // NaviData_Home.OSDStatusFlags3 (Index:13 Home-Position) -> use only for flags that change slowly |
98 | #define OSD_FIX_NONE 0 |
98 | #define OSD_FIX_NONE 0 |
99 | #define OSD_FIX_2D 1 |
99 | #define OSD_FIX_2D 1 |
100 | #define OSD_FIX_3D 2 |
100 | #define OSD_FIX_3D 2 |
101 | #define OSD_FIX_DGPS 3 |
101 | #define OSD_FIX_DGPS 3 |
102 | #define OSD_FIX_RTK_FLOAT 4 |
102 | #define OSD_FIX_RTK_FLOAT 4 |
103 | #define OSD_FIX_RTK_FIX 5 |
103 | #define OSD_FIX_RTK_FIX 5 |
104 | 104 | ||
105 | #define OSD3_FLAG_FIXBIT0 0x01 |
105 | #define OSD3_FLAG_FIXBIT0 0x01 // type of GPS-Fix (see above) |
106 | #define OSD3_FLAG_FIXBIT1 0x02 |
106 | #define OSD3_FLAG_FIXBIT1 0x02 |
107 | #define OSD3_FLAG_FIXBIT2 0x04 |
107 | #define OSD3_FLAG_FIXBIT2 0x04 |
108 | #define OSD3_FLAG_HOTSHOE 0x08 |
108 | #define OSD3_FLAG_HOTSHOE 0x08 // HotShoe connector attached |
- | 109 | #define OSD3_FLAG_BOAT_MODE 0x10 // MK is calibrated in Boat-Mode |
|
109 | #define OSD3_FLAG_BOAT_MODE 0x10 |
110 | #define OSD3_FLAG_MK_IS_READY 0x20 // ready & calibrated |
110 | 111 | ||
111 | // the OSD-Flags are built from the FC status flags. They are combined into new bytes to increse the efficiency in the data protocol |
112 | // the OSD-Flags are built from the FC status flags. They are combined into new bytes to increse the efficiency in the data protocol |
112 | #define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80) |
113 | #define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80) |
113 | #define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10) |
114 | #define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10) |
114 | 115 | ||
115 | // NC calculates |
116 | // NC calculates |
116 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
117 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
117 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
118 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
118 | 119 | ||
119 | //calculate Back: |
120 | //calculate Back: |
120 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
121 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
121 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
122 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
122 | 123 | ||
123 | 124 | ||
124 | // .NCFlags |
125 | // .NCFlags |
125 | #define NC_FLAG_FREE 0x01 |
126 | #define NC_FLAG_FREE 0x01 |
126 | #define NC_FLAG_PH 0x02 |
127 | #define NC_FLAG_PH 0x02 |
127 | #define NC_FLAG_CH 0x04 |
128 | #define NC_FLAG_CH 0x04 |
128 | #define NC_FLAG_RANGE_LIMIT 0x08 |
129 | #define NC_FLAG_RANGE_LIMIT 0x08 |
129 | #define NC_FLAG_NOSERIALLINK 0x10 |
130 | #define NC_FLAG_NOSERIALLINK 0x10 |
130 | #define NC_FLAG_TARGET_REACHED 0x20 |
131 | #define NC_FLAG_TARGET_REACHED 0x20 |
131 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
132 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
132 | #define NC_FLAG_GPS_OK 0x80 |
133 | #define NC_FLAG_GPS_OK 0x80 |
133 | 134 | ||
134 | //IO1_Function |
135 | //IO1_Function |
135 | #define IO1FUNC_PARACHUTE 9 |
136 | #define IO1FUNC_PARACHUTE 9 |
136 | #define IO1FUNC_ERROR_PARACHUTE 255 |
137 | #define IO1FUNC_ERROR_PARACHUTE 255 |
137 | 138 | ||
138 | // NC calculates |
139 | // NC calculates |
139 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
140 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
140 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
141 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
141 | 142 | ||
142 | //calculate Back: |
143 | //calculate Back: |
143 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
144 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
144 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
145 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
145 | 146 | ||
146 | // FC.Error[0] |
147 | // FC.Error[0] |
147 | #define FC_ERROR0_GYRO_NICK 0x01 |
148 | #define FC_ERROR0_GYRO_NICK 0x01 |
148 | #define FC_ERROR0_GYRO_ROLL 0x02 |
149 | #define FC_ERROR0_GYRO_ROLL 0x02 |
149 | #define FC_ERROR0_GYRO_YAW 0x04 |
150 | #define FC_ERROR0_GYRO_YAW 0x04 |
150 | #define FC_ERROR0_ACC_NICK 0x08 |
151 | #define FC_ERROR0_ACC_NICK 0x08 |
151 | #define FC_ERROR0_ACC_ROLL 0x10 |
152 | #define FC_ERROR0_ACC_ROLL 0x10 |
152 | #define FC_ERROR0_ACC_TOP 0x20 |
153 | #define FC_ERROR0_ACC_TOP 0x20 |
153 | #define FC_ERROR0_PRESSURE 0x40 |
154 | #define FC_ERROR0_PRESSURE 0x40 |
154 | #define FC_ERROR0_CAREFREE 0x80 |
155 | #define FC_ERROR0_CAREFREE 0x80 |
155 | 156 | ||
156 | // FC.Error[1] |
157 | // FC.Error[1] |
157 | #define FC_ERROR1_I2C 0x01 |
158 | #define FC_ERROR1_I2C 0x01 |
158 | #define FC_ERROR1_BL_MISSING 0x02 |
159 | #define FC_ERROR1_BL_MISSING 0x02 |
159 | #define FC_ERROR1_SPI_RX 0x04 |
160 | #define FC_ERROR1_SPI_RX 0x04 |
160 | #define FC_ERROR1_PPM 0x08 |
161 | #define FC_ERROR1_PPM 0x08 |
161 | #define FC_ERROR1_MIXER 0x10 |
162 | #define FC_ERROR1_MIXER 0x10 |
162 | #define FC_ERROR1_RC_VOLTAGE 0x20 |
163 | #define FC_ERROR1_RC_VOLTAGE 0x20 |
163 | #define FC_ERROR1_ACC_NOT_CAL 0x40 |
164 | #define FC_ERROR1_ACC_NOT_CAL 0x40 |
164 | #define FC_ERROR1_RES3 0x80 |
165 | #define FC_ERROR1_RES3 0x80 |
165 | 166 | ||
166 | // NC Errors |
167 | // NC Errors |
167 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
168 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
168 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
169 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
169 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
170 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
170 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
171 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
171 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
172 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
172 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
173 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
173 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
174 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
174 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
175 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
175 | 176 | ||
176 | //NC_To_FC_Flags |
177 | //NC_To_FC_Flags |
177 | #define NC_TO_FC_FLYING_RANGE 0x01 |
178 | #define NC_TO_FC_FLYING_RANGE 0x01 |
178 | #define NC_TO_FC_EMERGENCY_LANDING 0x02 |
179 | #define NC_TO_FC_EMERGENCY_LANDING 0x02 |
179 | #define NC_TO_FC_AUTOSTART 0x04 |
180 | #define NC_TO_FC_AUTOSTART 0x04 |
180 | #define NC_TO_FC_FAILSAFE_LANDING 0x08 // activates Servos |
181 | #define NC_TO_FC_FAILSAFE_LANDING 0x08 // activates Servos |
181 | #define NC_TO_FC_SIMULATION_ACTIVE 0x10 // don't start motors if simulation ist active |
182 | #define NC_TO_FC_SIMULATION_ACTIVE 0x10 // don't start motors if simulation ist active |
182 | #define NC_TO_FC_SWITCHOFF_IF_LANDED 0x20 // switch off if MK is on the ground and doesn't further sink |
183 | #define NC_TO_FC_SWITCHOFF_IF_LANDED 0x20 // switch off if MK is on the ground and doesn't further sink |
183 | #define NC_TO_FC_OUTSIDE_FLYZONE 0x40 // for the Beep-Signal |
184 | #define NC_TO_FC_OUTSIDE_FLYZONE 0x40 // for the Beep-Signal |
184 | 185 | ||
185 | //Parameter.GlobalConfig3 |
186 | //Parameter.GlobalConfig3 |
186 | #define CFG3_NO_SDCARD_NO_START 0x01 |
187 | #define CFG3_NO_SDCARD_NO_START 0x01 |
187 | #define CFG3_RISE_FIRST_WAYPOINT 0x02 |
188 | #define CFG3_RISE_FIRST_WAYPOINT 0x02 |
188 | #define CFG3_VARIO_FAILSAFE 0x04 |
189 | #define CFG3_VARIO_FAILSAFE 0x04 |
189 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
190 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
190 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
191 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
191 | #define CFG3_USE_NC_FOR_OUT1 0x20 |
192 | #define CFG3_USE_NC_FOR_OUT1 0x20 |
192 | #define CFG3_SPEAK_ALL 0x40 |
193 | #define CFG3_SPEAK_ALL 0x40 |
193 | #define CFG3_SERVO_NICK_COMP_OFF 0x80 |
194 | #define CFG3_SERVO_NICK_COMP_OFF 0x80 |
194 | 195 | ||
195 | // Parameter.GlobalConfig |
196 | // Parameter.GlobalConfig |
196 | #define FC_CFG_HOEHENREGELUNG 0x01 |
197 | #define FC_CFG_HOEHENREGELUNG 0x01 |
197 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
198 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
198 | #define FC_CFG_HEADING_HOLD 0x04 |
199 | #define FC_CFG_HEADING_HOLD 0x04 |
199 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
200 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
200 | #define FC_CFG_KOMPASS_FIX 0x10 |
201 | #define FC_CFG_KOMPASS_FIX 0x10 |
201 | #define FC_CFG_GPS_AKTIV 0x20 |
202 | #define FC_CFG_GPS_AKTIV 0x20 |
202 | #define CFG_LAND_OUTSIDE_FLYZONE 0x40 |
203 | #define CFG_LAND_OUTSIDE_FLYZONE 0x40 |
203 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
204 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
204 | 205 | ||
205 | //Parameter.ExtraConfig |
206 | //Parameter.ExtraConfig |
206 | #define CFG2_HEIGHT_LIMIT 0x01 |
207 | #define CFG2_HEIGHT_LIMIT 0x01 |
207 | #define CFG2_VARIO_BEEP 0x02 |
208 | #define CFG2_VARIO_BEEP 0x02 |
208 | #define CFG_FLYZONE_REQUIRED 0x04 |
209 | #define CFG_FLYZONE_REQUIRED 0x04 |
209 | #define CFG_3_3V_REFERENCE 0x08 |
210 | #define CFG_3_3V_REFERENCE 0x08 |
210 | #define CFG_NO_RCOFF_BEEPING 0x10 |
211 | #define CFG_NO_RCOFF_BEEPING 0x10 |
211 | #define CFG_GPS_AID 0x20 |
212 | #define CFG_GPS_AID 0x20 |
212 | #define CFG_TEACHABLE_CAREFREE 0x40 |
213 | #define CFG_TEACHABLE_CAREFREE 0x40 |
213 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
214 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
214 | 215 | ||
215 | // Parameter.HomeYawMode |
216 | // Parameter.HomeYawMode |
216 | #define NO_CHANGE 0 |
217 | #define NO_CHANGE 0 |
217 | #define FRONT_TO_HOME 1 |
218 | #define FRONT_TO_HOME 1 |
218 | #define REAR_TO_HOME 2 |
219 | #define REAR_TO_HOME 2 |
219 | #define LIKE_AT_START 3 |
220 | #define LIKE_AT_START 3 |
220 | 221 | ||
221 | // Parameter.ReceiverType defines for the receiver selection |
222 | // Parameter.ReceiverType defines for the receiver selection |
222 | #define RECEIVER_PPM 0 |
223 | #define RECEIVER_PPM 0 |
223 | #define RECEIVER_SPEKTRUM 1 |
224 | #define RECEIVER_SPEKTRUM 1 |
224 | #define RECEIVER_SPEKTRUM_HI_RES 2 |
225 | #define RECEIVER_SPEKTRUM_HI_RES 2 |
225 | #define RECEIVER_SPEKTRUM_LOW_RES 3 |
226 | #define RECEIVER_SPEKTRUM_LOW_RES 3 |
226 | #define RECEIVER_JETI 4 |
227 | #define RECEIVER_JETI 4 |
227 | #define RECEIVER_ACT_DSL 5 |
228 | #define RECEIVER_ACT_DSL 5 |
228 | #define RECEIVER_HOTT 6 |
229 | #define RECEIVER_HOTT 6 |
229 | #define RECEIVER_SBUS 7 |
230 | #define RECEIVER_SBUS 7 |
230 | #define RECEIVER_USER 8 |
231 | #define RECEIVER_USER 8 |
231 | 232 | ||
232 | #define RECEIVER_UNKNOWN 0xFF |
233 | #define RECEIVER_UNKNOWN 0xFF |
233 | 234 | ||
234 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
235 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
235 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
236 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
236 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
237 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
237 | 238 | ||
238 | 239 | ||
239 | #define Poti1 FC.Poti[0] |
240 | #define Poti1 FC.Poti[0] |
240 | #define Poti2 FC.Poti[1] |
241 | #define Poti2 FC.Poti[1] |
241 | #define Poti3 FC.Poti[2] |
242 | #define Poti3 FC.Poti[2] |
242 | #define Poti4 FC.Poti[3] |
243 | #define Poti4 FC.Poti[3] |
243 | #define Poti5 FC.Poti[4] |
244 | #define Poti5 FC.Poti[4] |
244 | #define Poti6 FC.Poti[5] |
245 | #define Poti6 FC.Poti[5] |
245 | #define Poti7 FC.Poti[6] |
246 | #define Poti7 FC.Poti[6] |
246 | #define Poti8 FC.Poti[7] |
247 | #define Poti8 FC.Poti[7] |
247 | 248 | ||
248 | extern s16 LuftdruckTemperaturKompensation, LuftdruckTemperaturOffset; |
249 | extern s16 LuftdruckTemperaturKompensation, LuftdruckTemperaturOffset; |
249 | extern u16 BeepTime; |
250 | extern u16 BeepTime; |
250 | extern u8 NCFlags; |
251 | extern u8 NCFlags; |
251 | extern u8 ClearFCStatusFlags; |
252 | extern u8 ClearFCStatusFlags; |
252 | void Interrupt_Init(void); |
253 | void Interrupt_Init(void); |
253 | extern s16 GeoMagDec; |
254 | extern s16 GeoMagDec; |
254 | extern u8 NewWPL_Name; |
255 | extern u8 NewWPL_Name; |
255 | 256 | ||
256 | #define NOTHING 0 |
257 | #define NOTHING 0 |
257 | #define MASTER 1 |
258 | #define MASTER 1 |
258 | #define SLAVE 2 |
259 | #define SLAVE 2 |
259 | extern u8 IamMaster; |
260 | extern u8 IamMaster; |
260 | 261 | ||
261 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
262 | #define VERSION_SERIAL_MAJOR 11 // do not change! |
262 | 263 | ||
263 | typedef struct |
264 | typedef struct |
264 | { |
265 | { |
265 | u8 ActiveSetting; |
266 | u8 ActiveSetting; |
266 | u8 User1; |
267 | u8 User1; |
267 | u8 User2; |
268 | u8 User2; |
268 | u8 User3; |
269 | u8 User3; |
269 | u8 User4; |
270 | u8 User4; |
270 | u8 User5; |
271 | u8 User5; |
271 | u8 User6; |
272 | u8 User6; |
272 | u8 User7; |
273 | u8 User7; |
273 | u8 User8; |
274 | u8 User8; |
274 | u8 NaviGpsModeControl; |
275 | u8 NaviGpsModeControl; |
275 | u8 NaviGpsGain; |
276 | u8 NaviGpsGain; |
276 | u8 NaviGpsP; |
277 | u8 NaviGpsP; |
277 | u8 NaviGpsI; |
278 | u8 NaviGpsI; |
278 | u8 NaviGpsD; |
279 | u8 NaviGpsD; |
279 | u8 NaviGpsPLimit; |
280 | u8 NaviGpsPLimit; |
280 | u8 NaviGpsILimit; |
281 | u8 NaviGpsILimit; |
281 | u8 NaviGpsDLimit; |
282 | u8 NaviGpsDLimit; |
282 | u8 NaviGpsACC; |
283 | u8 NaviGpsACC; |
283 | u8 NaviGpsMinSat; |
284 | u8 NaviGpsMinSat; |
284 | u8 NaviStickThreshold; |
285 | u8 NaviStickThreshold; |
285 | u8 NaviMaxFlyingRange; // in 10m |
286 | u8 NaviMaxFlyingRange; // in 10m |
286 | u8 NaviWindCorrection; |
287 | u8 NaviWindCorrection; |
287 | u8 NaviAccCompensation; |
288 | u8 NaviAccCompensation; |
288 | u8 NaviSpeedCompensation; |
289 | u8 NaviSpeedCompensation; |
289 | u8 LowVoltageWarning; |
290 | u8 LowVoltageWarning; |
290 | u8 NaviAngleLimitation; |
291 | u8 NaviAngleLimitation; |
291 | u8 NaviPH_LoginTime; |
292 | u8 NaviPH_LoginTime; |
292 | u8 OrientationAngle; // where is front - in 15° |
293 | u8 OrientationAngle; // where is front - in 15° |
293 | u8 CamOrientation; // direction of the camera in 15° |
294 | u8 CamOrientation; // direction of the camera in 15° |
294 | u8 GlobalConfig; |
295 | u8 GlobalConfig; |
295 | u8 ExtraConfig; |
296 | u8 ExtraConfig; |
296 | u8 ComingHomeAltitude; |
297 | u8 ComingHomeAltitude; |
297 | u8 GlobalConfig3; |
298 | u8 GlobalConfig3; |
298 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
299 | u8 AutoPhotoDistance; // Distance between Photo releases (Position) |
299 | u8 FromFC_LandingSpeed; |
300 | u8 FromFC_LandingSpeed; |
300 | u8 FromFC_LowVoltageHomeActive; |
301 | u8 FromFC_LowVoltageHomeActive; |
301 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
302 | u8 AutoPhotoAltitudes; // Distance between Photo releases (Altitudes) |
302 | u8 SingleWpSpeed; |
303 | u8 SingleWpSpeed; |
303 | u8 DescendRange; // in 10m |
304 | u8 DescendRange; // in 10m |
304 | u8 MaximumAltitude; // in m |
305 | u8 MaximumAltitude; // in m |
305 | u8 Driftkomp; |
306 | u8 Driftkomp; |
306 | u8 ReceiverType; |
307 | u8 ReceiverType; |
307 | u8 HomeYawMode; |
308 | u8 HomeYawMode; |
308 | u8 Speak100m; |
309 | u8 Speak100m; |
309 | u8 AutoWpEventValue; |
310 | u8 AutoWpEventValue; |
310 | u8 FailSafeTime; |
311 | u8 FailSafeTime; |
311 | } __attribute__((packed)) Param_t; |
312 | } __attribute__((packed)) Param_t; |
312 | 313 | ||
313 | typedef struct |
314 | typedef struct |
314 | { |
315 | { |
315 | s8 StickNick; |
316 | s8 StickNick; |
316 | s8 StickRoll; |
317 | s8 StickRoll; |
317 | s8 StickYaw; |
318 | s8 StickYaw; |
318 | s8 StickGas; |
319 | s8 StickGas; |
319 | u8 Poti[8]; |
320 | u8 Poti[8]; |
320 | u8 RC_Quality; |
321 | u8 RC_Quality; |
321 | u8 RC_RSSI; |
322 | u8 RC_RSSI; |
322 | u16 BAT_Voltage; |
323 | u16 BAT_Voltage; |
323 | u16 BAT_Current; |
324 | u16 BAT_Current; |
324 | u16 BAT_UsedCapacity; |
325 | u16 BAT_UsedCapacity; |
325 | u8 StatusFlags; |
326 | u8 StatusFlags; |
326 | u8 Error[5]; |
327 | u8 Error[5]; |
327 | u8 StatusFlags2; |
328 | u8 StatusFlags2; |
328 | u8 FromFC_SpeakHoTT; |
329 | u8 FromFC_SpeakHoTT; |
329 | s16 FromFC_CompassOffset; |
330 | s16 FromFC_CompassOffset; |
330 | u8 FromFC_DisableDeclination; |
331 | u8 FromFC_DisableDeclination; |
331 | u8 StatusFlags3; |
332 | u8 StatusFlags3; |
332 | s16 Altimeter_5cm; // devide by 20 to get meters & multiply with 5 to get cm |
333 | s16 Altimeter_5cm; // devide by 20 to get meters & multiply with 5 to get cm |
333 | u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation |
334 | u8 RealStatusFlags; // this is a copy of the status flags -> but not effected by the simulation |
334 | u16 AdNeutralNick; |
335 | u16 AdNeutralNick; |
335 | u16 AdNeutralRoll; |
336 | u16 AdNeutralRoll; |
336 | u16 AdNeutralYaw; |
337 | u16 AdNeutralYaw; |
337 | u16 BoatNeutralNick; |
338 | u16 BoatNeutralNick; |
338 | u16 BoatNeutralRoll; |
339 | u16 BoatNeutralRoll; |
339 | u16 BoatNeutralYaw; |
340 | u16 BoatNeutralYaw; |
340 | u8 AutoPhotoDistance; |
341 | u8 AutoPhotoDistance; |
341 | } __attribute__((packed)) FC_t; // from FC |
342 | } __attribute__((packed)) FC_t; // from FC |
342 | 343 | ||
343 | typedef struct |
344 | typedef struct |
344 | { |
345 | { |
345 | u8 ErrorCode; |
346 | u8 ErrorCode; |
346 | u8 StatusFlags; |
347 | u8 StatusFlags; |
347 | u8 StatusFlags2; |
348 | u8 StatusFlags2; |
348 | u8 StatusFlags3; |
349 | u8 StatusFlags3; |
349 | u8 NC_To_FC_Flags; |
350 | u8 NC_To_FC_Flags; |
350 | u8 MagnetField; // in % |
351 | u8 MagnetField; // in % |
351 | s16 GyroCompassCorrected; |
352 | s16 GyroCompassCorrected; |
352 | } __attribute__((packed)) Partner_t; // from FC |
353 | } __attribute__((packed)) Partner_t; // from FC |
353 | 354 | ||
354 | extern Partner_t Partner; |
355 | extern Partner_t Partner; |
355 | extern Param_t Parameter; |
356 | extern Param_t Parameter; |
356 | extern volatile FC_t FC; |
357 | extern volatile FC_t FC; |
357 | extern s8 ErrorMSG[25]; |
358 | extern s8 ErrorMSG[25]; |
358 | extern s8 PartnerErrorMSG[25]; |
359 | extern s8 PartnerErrorMSG[25]; |
359 | extern u8 ErrorCode,PartnerErrorCode; |
360 | extern u8 ErrorCode,PartnerErrorCode; |
360 | extern u8 StopNavigation; |
361 | extern u8 StopNavigation; |
361 | extern u8 ErrorGpsFixLost; |
362 | extern u8 ErrorGpsFixLost; |
362 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
363 | extern u8 FromFC_LoadWP_List, ToFC_MaxWpListIndex, FromFC_Load_SinglePoint, FromFC_Save_SinglePoint; |
363 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
364 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
364 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
365 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
365 | extern volatile u32 PollingTimeout; |
366 | extern volatile u32 PollingTimeout; |
366 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsNavProcessed, FreqNewGpsData; |
367 | extern u32 CountGpsProcessedIn5Sec,CountNewGpsDataIn5Sec, FreqGpsNavProcessed, FreqNewGpsData; |
367 | extern u32 TimeSinceMotorStart; |
368 | extern u32 TimeSinceMotorStart; |
368 | extern u8 NC_To_FC_Flags, NC_To_FC_Autostart; |
369 | extern u8 NC_To_FC_Flags, NC_To_FC_Autostart; |
369 | extern u16 SD_SettingWaitLED; |
370 | extern u16 SD_SettingWaitLED; |
370 | extern u16 SD_PosAccuracy; |
371 | extern u16 SD_PosAccuracy; |
371 | extern u16 SD_ComingHomeSpeed; |
372 | extern u16 SD_ComingHomeSpeed; |
372 | extern u16 SD_DPH_Speed; |
373 | extern u16 SD_DPH_Speed; |
373 | extern u32 MaxWP_Radius_in_m; |
374 | extern u32 MaxWP_Radius_in_m; |
374 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
375 | extern u8 SpeakWaypointRached; // Speak once as soon as the Points are active |
375 | extern u8 SpeakNextWaypoint; // Speak once when reached |
376 | extern u8 SpeakNextWaypoint; // Speak once when reached |
376 | extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started |
377 | extern u8 NewWaypointsReceived; // when 1: activates the Waypoint list as soon as CH is started |
377 | extern s16 GyroCompassCorrected; |
378 | extern s16 GyroCompassCorrected; |
378 | extern s16 CompassSetpointCorrected; // The compass setpoint that the FC tries to keep - corrected with the magnetic declination |
379 | extern s16 CompassSetpointCorrected; // The compass setpoint that the FC tries to keep - corrected with the magnetic declination |
379 | extern s16 CompassSetpoint; |
380 | extern s16 CompassSetpoint; |
380 | extern u8 AmountOfMotors; |
381 | extern u8 AmountOfMotors; |
381 | extern s16 SimulatedDirection; // simulated compass direction |
382 | extern s16 SimulatedDirection; // simulated compass direction |
382 | extern u16 ToFC_Parachute_Off; // forced Switch off via IO1 |
383 | extern u16 ToFC_Parachute_Off; // forced Switch off via IO1 |
383 | extern u8 IO1_Function; |
384 | extern u8 IO1_Function; |
384 | extern u8 BaroCalState; |
385 | extern u8 BaroCalState; |
385 | extern u8 ErrorOutSideOperationArea; // I am outside the operation polygon area |
386 | extern u8 ErrorOutSideOperationArea; // I am outside the operation polygon area |
386 | extern u8 ShowCalibrationErrorMessage; |
387 | extern u8 ShowCalibrationErrorMessage; |
387 | #define OEM_NAME_LENGHT 16 |
388 | #define OEM_NAME_LENGHT 16 |
388 | extern u8 OEM_String[OEM_NAME_LENGHT+1]; |
389 | extern u8 OEM_String[OEM_NAME_LENGHT+1]; |
389 | extern u8 TryAgain_UBX_Setup; |
390 | extern u8 TryAgain_UBX_Setup; |
390 | 391 | ||
391 | #define CHECK_ONLY 0 |
392 | #define CHECK_ONLY 0 |
392 | #define GET_LICENSE 1 |
393 | #define GET_LICENSE 1 |
393 | #define COPY_SD_TO_EE 2 |
394 | #define COPY_SD_TO_EE 2 |
394 | extern u8 CheckLicense(u8); |
395 | extern u8 CheckLicense(u8); |
395 | 396 | ||
396 | // Portpin inputs |
397 | // Portpin inputs |
397 | #define PIN6_0 (GPIO6->DR[0x3FC] & 0x01) |
398 | #define PIN6_0 (GPIO6->DR[0x3FC] & 0x01) |
398 | #define PIN6_1 (GPIO6->DR[0x3FC] & 0x02) |
399 | #define PIN6_1 (GPIO6->DR[0x3FC] & 0x02) |
399 | #define PIN6_2 (GPIO6->DR[0x3FC] & 0x04) |
400 | #define PIN6_2 (GPIO6->DR[0x3FC] & 0x04) |
400 | #define PIN6_3 (GPIO6->DR[0x3FC] & 0x08) |
401 | #define PIN6_3 (GPIO6->DR[0x3FC] & 0x08) |
401 | #define PIN6_4 (GPIO6->DR[0x3FC] & 0x10) |
402 | #define PIN6_4 (GPIO6->DR[0x3FC] & 0x10) |
402 | #define PIN6_5 (GPIO6->DR[0x3FC] & 0x20) |
403 | #define PIN6_5 (GPIO6->DR[0x3FC] & 0x20) |
403 | 404 | ||
404 | #define TRIGGER_PP_INTERN PIN6_0 |
405 | #define TRIGGER_PP_INTERN PIN6_0 |
405 | #define TRIGGER_PP_EXTERN PIN6_3 |
406 | #define TRIGGER_PP_EXTERN PIN6_3 |
406 | #define BLITZ_CONNECTED PIN6_4 |
407 | #define BLITZ_CONNECTED PIN6_4 |
407 | #define IO1_INPUT PIN6_5 |
408 | #define IO1_INPUT PIN6_5 |
408 | #define DELAY(ms) { u32 delay; delay = SetDelay(ms); while(!CheckDelay(delay));} |
409 | #define DELAY(ms) { u32 delay; delay = SetDelay(ms); while(!CheckDelay(delay));} |
409 | 410 | ||
410 | #endif // _MAIN_H |
411 | #endif // _MAIN_H |
411 | 412 |