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