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