Rev 440 | Rev 448 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 440 | Rev 447 | ||
---|---|---|---|
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 0 |
15 | #define VERSION_MAJOR 0 |
16 | #define VERSION_MINOR 30 |
16 | #define VERSION_MINOR 30 |
17 | #define VERSION_PATCH 1 |
17 | #define VERSION_PATCH 5 |
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 VERSION_SERIAL_MAJOR 11 |
38 | #define VERSION_SERIAL_MAJOR 11 |
39 | #define VERSION_SERIAL_MINOR 0 |
39 | #define VERSION_SERIAL_MINOR 0 |
40 | 40 | ||
41 | #ifndef FOLLOW_ME |
41 | #ifndef FOLLOW_ME |
42 | #define FC_SPI_COMPATIBLE 52 |
42 | #define FC_SPI_COMPATIBLE 53 |
43 | #else |
43 | #else |
44 | #define FC_SPI_COMPATIBLE 0xFF |
44 | #define FC_SPI_COMPATIBLE 0xFF |
45 | #endif |
45 | #endif |
46 | 46 | ||
47 | #define MK3MAG_I2C_COMPATIBLE 3 |
47 | #define MK3MAG_I2C_COMPATIBLE 3 |
48 | 48 | ||
49 | // FC.StatusFlags |
49 | // FC.StatusFlags |
50 | #define FC_STATUS_MOTOR_RUN 0x01 |
50 | #define FC_STATUS_MOTOR_RUN 0x01 |
51 | #define FC_STATUS_FLY 0x02 |
51 | #define FC_STATUS_FLY 0x02 |
52 | #define FC_STATUS_CALIBRATE 0x04 |
52 | #define FC_STATUS_CALIBRATE 0x04 |
53 | #define FC_STATUS_START 0x08 |
53 | #define FC_STATUS_START 0x08 |
54 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
54 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
55 | #define FC_STATUS_LOWBAT 0x20 |
55 | #define FC_STATUS_LOWBAT 0x20 |
56 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
56 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
57 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
57 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
58 | 58 | ||
59 | // FC.StatusFlags2 |
59 | // FC.StatusFlags2 |
60 | #define FC_STATUS2_CAREFREE 0x01 |
60 | #define FC_STATUS2_CAREFREE 0x01 |
61 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
61 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
62 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
62 | #define FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
63 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
63 | #define FC_STATUS2_OUT1_ACTIVE 0x08 |
64 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
64 | #define FC_STATUS2_OUT2_ACTIVE 0x10 |
- | 65 | #define FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
|
65 | 66 | ||
66 | // FC ERRORS FLAGS |
67 | // FC ERRORS FLAGS |
67 | #define FC_ERROR0_GYRO_NICK 0x01 |
68 | #define FC_ERROR0_GYRO_NICK 0x01 |
68 | #define FC_ERROR0_GYRO_ROLL 0x02 |
69 | #define FC_ERROR0_GYRO_ROLL 0x02 |
69 | #define FC_ERROR0_GYRO_YAW 0x04 |
70 | #define FC_ERROR0_GYRO_YAW 0x04 |
70 | #define FC_ERROR0_ACC_NICK 0x08 |
71 | #define FC_ERROR0_ACC_NICK 0x08 |
71 | #define FC_ERROR0_ACC_ROLL 0x10 |
72 | #define FC_ERROR0_ACC_ROLL 0x10 |
72 | #define FC_ERROR0_ACC_TOP 0x20 |
73 | #define FC_ERROR0_ACC_TOP 0x20 |
73 | #define FC_ERROR0_PRESSURE 0x40 |
74 | #define FC_ERROR0_PRESSURE 0x40 |
74 | #define FC_ERROR0_CAREFREE 0x80 |
75 | #define FC_ERROR0_CAREFREE 0x80 |
75 | 76 | ||
76 | #define FC_ERROR1_I2C 0x01 |
77 | #define FC_ERROR1_I2C 0x01 |
77 | #define FC_ERROR1_BL_MISSING 0x02 |
78 | #define FC_ERROR1_BL_MISSING 0x02 |
78 | #define FC_ERROR1_SPI_RX 0x04 |
79 | #define FC_ERROR1_SPI_RX 0x04 |
79 | #define FC_ERROR1_PPM 0x08 |
80 | #define FC_ERROR1_PPM 0x08 |
80 | #define FC_ERROR1_MIXER 0x10 |
81 | #define FC_ERROR1_MIXER 0x10 |
81 | #define FC_ERROR1_RES1 0x20 |
82 | #define FC_ERROR1_RES1 0x20 |
82 | #define FC_ERROR1_RES2 0x40 |
83 | #define FC_ERROR1_RES2 0x40 |
83 | #define FC_ERROR1_RES3 0x80 |
84 | #define FC_ERROR1_RES3 0x80 |
84 | 85 | ||
85 | // NC Errors |
86 | // NC Errors |
86 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
87 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
87 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
88 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
88 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
89 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
89 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
90 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
90 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
91 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
91 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
92 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
92 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
93 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
93 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
94 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
94 | 95 | ||
95 | //Parameter.GlobalConfig3 |
96 | //Parameter.GlobalConfig3 |
96 | #define CFG3_NO_SDCARD_NO_START 0x01 |
97 | #define CFG3_NO_SDCARD_NO_START 0x01 |
97 | #define CFG3_DPH_MAX_RADIUS 0x02 |
98 | #define CFG3_DPH_MAX_RADIUS 0x02 |
98 | #define CFG3_VARIO_FAILSAFE 0x04 |
99 | #define CFG3_VARIO_FAILSAFE 0x04 |
99 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
100 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
100 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
101 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
101 | 102 | ||
102 | // Parameter.GlobalConfig |
103 | // Parameter.GlobalConfig |
103 | #define FC_CFG_HOEHENREGELUNG 0x01 |
104 | #define FC_CFG_HOEHENREGELUNG 0x01 |
104 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
105 | #define FC_CFG_HOEHEN_SCHALTER 0x02 |
105 | #define FC_CFG_HEADING_HOLD 0x04 |
106 | #define FC_CFG_HEADING_HOLD 0x04 |
106 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
107 | #define FC_CFG_KOMPASS_AKTIV 0x08 |
107 | #define FC_CFG_KOMPASS_FIX 0x10 |
108 | #define FC_CFG_KOMPASS_FIX 0x10 |
108 | #define FC_CFG_GPS_AKTIV 0x20 |
109 | #define FC_CFG_GPS_AKTIV 0x20 |
109 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
110 | #define FC_CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
110 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
111 | #define FC_CFG_DREHRATEN_BEGRENZER 0x80 |
111 | 112 | ||
112 | //Parameter.ExtraConfig |
113 | //Parameter.ExtraConfig |
113 | #define CFG2_HEIGHT_LIMIT 0x01 |
114 | #define CFG2_HEIGHT_LIMIT 0x01 |
114 | #define CFG2_VARIO_BEEP 0x02 |
115 | #define CFG2_VARIO_BEEP 0x02 |
115 | #define CFG_SENSITIVE_RC 0x04 |
116 | #define CFG_SENSITIVE_RC 0x04 |
116 | #define CFG_3_3V_REFERENCE 0x08 |
117 | #define CFG_3_3V_REFERENCE 0x08 |
117 | #define CFG_NO_RCOFF_BEEPING 0x10 |
118 | #define CFG_NO_RCOFF_BEEPING 0x10 |
118 | #define CFG_GPS_AID 0x20 |
119 | #define CFG_GPS_AID 0x20 |
119 | #define CFG_TEACHABLE_CAREFREE 0x40 |
120 | #define CFG_TEACHABLE_CAREFREE 0x40 |
120 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
121 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
121 | 122 | ||
122 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
123 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
123 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
124 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
124 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
125 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
125 | 126 | ||
126 | 127 | ||
127 | #define Poti1 FC.Poti[0] |
128 | #define Poti1 FC.Poti[0] |
128 | #define Poti2 FC.Poti[1] |
129 | #define Poti2 FC.Poti[1] |
129 | #define Poti3 FC.Poti[2] |
130 | #define Poti3 FC.Poti[2] |
130 | #define Poti4 FC.Poti[3] |
131 | #define Poti4 FC.Poti[3] |
131 | #define Poti5 FC.Poti[4] |
132 | #define Poti5 FC.Poti[4] |
132 | #define Poti6 FC.Poti[5] |
133 | #define Poti6 FC.Poti[5] |
133 | #define Poti7 FC.Poti[6] |
134 | #define Poti7 FC.Poti[6] |
134 | #define Poti8 FC.Poti[7] |
135 | #define Poti8 FC.Poti[7] |
135 | 136 | ||
136 | extern u16 BeepTime; |
137 | extern u16 BeepTime; |
137 | extern u8 NCFlags; |
138 | extern u8 NCFlags; |
138 | extern u8 ClearFCStatusFlags; |
139 | extern u8 ClearFCStatusFlags; |
139 | void Interrupt_Init(void); |
140 | void Interrupt_Init(void); |
140 | extern s16 GeoMagDec; |
141 | extern s16 GeoMagDec; |
141 | 142 | ||
142 | typedef struct |
143 | typedef struct |
143 | { |
144 | { |
144 | u8 ActiveSetting; |
145 | u8 ActiveSetting; |
145 | u8 User1; |
146 | u8 User1; |
146 | u8 User2; |
147 | u8 User2; |
147 | u8 User3; |
148 | u8 User3; |
148 | u8 User4; |
149 | u8 User4; |
149 | u8 User5; |
150 | u8 User5; |
150 | u8 User6; |
151 | u8 User6; |
151 | u8 User7; |
152 | u8 User7; |
152 | u8 User8; |
153 | u8 User8; |
153 | u8 NaviGpsModeControl; |
154 | u8 NaviGpsModeControl; |
154 | u8 NaviGpsGain; |
155 | u8 NaviGpsGain; |
155 | u8 NaviGpsP; |
156 | u8 NaviGpsP; |
156 | u8 NaviGpsI; |
157 | u8 NaviGpsI; |
157 | u8 NaviGpsD; |
158 | u8 NaviGpsD; |
158 | u8 NaviGpsPLimit; |
159 | u8 NaviGpsPLimit; |
159 | u8 NaviGpsILimit; |
160 | u8 NaviGpsILimit; |
160 | u8 NaviGpsDLimit; |
161 | u8 NaviGpsDLimit; |
161 | u8 NaviGpsACC; |
162 | u8 NaviGpsACC; |
162 | u8 NaviGpsMinSat; |
163 | u8 NaviGpsMinSat; |
163 | u8 NaviStickThreshold; |
164 | u8 NaviStickThreshold; |
164 | u8 NaviOperatingRadius; |
165 | u8 NaviOperatingRadius; |
165 | u8 NaviWindCorrection; |
166 | u8 NaviWindCorrection; |
166 | u8 NaviAccCompensation; |
167 | u8 NaviAccCompensation; |
167 | u8 NaviSpeedCompensation; |
168 | u8 NaviSpeedCompensation; |
168 | u8 LowVoltageWarning; |
169 | u8 LowVoltageWarning; |
169 | u8 NaviAngleLimitation; |
170 | u8 NaviAngleLimitation; |
170 | u8 NaviPH_LoginTime; |
171 | u8 NaviPH_LoginTime; |
171 | u8 OrientationAngle; |
172 | u8 OrientationAngle; |
172 | u8 GlobalConfig; |
173 | u8 GlobalConfig; |
173 | u8 ExtraConfig; |
174 | u8 ExtraConfig; |
174 | u8 ComingHomeAltitude; |
175 | u8 ComingHomeAltitude; |
175 | u8 GlobalConfig3; |
176 | u8 GlobalConfig3; |
176 | u8 NaviOut1Parameter; // Distance between Photo releases |
177 | u8 NaviOut1Parameter; // Distance between Photo releases |
177 | } __attribute__((packed)) Param_t; |
178 | } __attribute__((packed)) Param_t; |
178 | 179 | ||
179 | typedef struct |
180 | typedef struct |
180 | { |
181 | { |
181 | s8 StickNick; |
182 | s8 StickNick; |
182 | s8 StickRoll; |
183 | s8 StickRoll; |
183 | s8 StickYaw; |
184 | s8 StickYaw; |
184 | s8 StickGas; |
185 | s8 StickGas; |
185 | u8 Poti[8]; |
186 | u8 Poti[8]; |
186 | u8 RC_Quality; |
187 | u8 RC_Quality; |
187 | u8 RC_RSSI; |
188 | u8 RC_RSSI; |
188 | u8 BAT_Voltage; |
189 | u8 BAT_Voltage; |
189 | u16 BAT_Current; |
190 | u16 BAT_Current; |
190 | u16 BAT_UsedCapacity; |
191 | u16 BAT_UsedCapacity; |
191 | u8 StatusFlags; |
192 | u8 StatusFlags; |
192 | u8 Error[5]; |
193 | u8 Error[5]; |
193 | u8 StatusFlags2; |
194 | u8 StatusFlags2; |
194 | u8 FromFC_SpeakHoTT; |
195 | u8 FromFC_SpeakHoTT; |
195 | } __attribute__((packed)) FC_t; |
196 | } __attribute__((packed)) FC_t; |
196 | 197 | ||
197 | 198 | ||
198 | extern Param_t Parameter; |
199 | extern Param_t Parameter; |
199 | extern volatile FC_t FC; |
200 | extern volatile FC_t FC; |
200 | extern s8 ErrorMSG[25]; |
201 | extern s8 ErrorMSG[25]; |
201 | extern u8 ErrorCode; |
202 | extern u8 ErrorCode; |
202 | extern u8 StopNavigation; |
203 | extern u8 StopNavigation; |
203 | extern u8 ErrorGpsFixLost; |
204 | extern u8 ErrorGpsFixLost; |
204 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
205 | extern volatile u32 SPIWatchDog; // stop Navigation if this goes to zero |
205 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
206 | extern volatile u32 SD_WatchDog; // stop Logging if this goes to zero |
206 | extern volatile u32 PollingTimeout; |
207 | extern volatile u32 PollingTimeout; |
207 | 208 | ||
208 | #endif // _MAIN_H |
209 | #endif // _MAIN_H |
209 | 210 |