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