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