Rev 317 | Rev 319 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 317 | Rev 318 | ||
---|---|---|---|
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 24 |
16 | #define VERSION_MINOR 25 |
17 | #define VERSION_PATCH 5 |
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 19 |
38 | #define FC_SPI_COMPATIBLE 19 |
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 STATUS FLAGS |
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 STATUS FLAGS2 |
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 | 88 | ||
89 | 89 | ||
90 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
90 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
91 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
91 | #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;} |
92 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
93 | 93 | ||
94 | extern u16 BeepTime; |
94 | extern u16 BeepTime; |
95 | extern u8 NCFlags; |
95 | extern u8 NCFlags; |
96 | extern u8 ClearFCStatusFlags; |
96 | extern u8 ClearFCStatusFlags; |
97 | void Interrupt_Init(void); |
97 | void Interrupt_Init(void); |
98 | extern s16 GeoMagDec; |
98 | extern s16 GeoMagDec; |
99 | 99 | ||
100 | 100 | ||
101 | typedef struct |
101 | typedef struct |
102 | { |
102 | { |
103 | u8 ActiveSetting; |
103 | u8 ActiveSetting; |
104 | u8 User1; |
104 | u8 User1; |
105 | u8 User2; |
105 | u8 User2; |
106 | u8 User3; |
106 | u8 User3; |
107 | u8 User4; |
107 | u8 User4; |
108 | u8 User5; |
108 | u8 User5; |
109 | u8 User6; |
109 | u8 User6; |
110 | u8 User7; |
110 | u8 User7; |
111 | u8 User8; |
111 | u8 User8; |
112 | u8 NaviGpsModeControl; |
112 | u8 NaviGpsModeControl; |
113 | u8 NaviGpsGain; |
113 | u8 NaviGpsGain; |
114 | u8 NaviGpsP; |
114 | u8 NaviGpsP; |
115 | u8 NaviGpsI; |
115 | u8 NaviGpsI; |
116 | u8 NaviGpsD; |
116 | u8 NaviGpsD; |
117 | u8 NaviGpsPLimit; |
117 | u8 NaviGpsPLimit; |
118 | u8 NaviGpsILimit; |
118 | u8 NaviGpsILimit; |
119 | u8 NaviGpsDLimit; |
119 | u8 NaviGpsDLimit; |
120 | u8 NaviGpsACC; |
120 | u8 NaviGpsACC; |
121 | u8 NaviGpsMinSat; |
121 | u8 NaviGpsMinSat; |
122 | u8 NaviStickThreshold; |
122 | u8 NaviStickThreshold; |
123 | u8 NaviOperatingRadius; |
123 | u8 NaviOperatingRadius; |
124 | u8 NaviWindCorrection; |
124 | u8 NaviWindCorrection; |
125 | u8 NaviSpeedCompensation; |
125 | u8 NaviSpeedCompensation; |
126 | u8 LowVoltageWarning; |
126 | u8 LowVoltageWarning; |
127 | u8 NaviAngleLimitation; |
127 | u8 NaviAngleLimitation; |
128 | u8 NaviPH_LoginTime; |
128 | u8 NaviPH_LoginTime; |
129 | } __attribute__((packed)) Param_t; |
129 | } __attribute__((packed)) Param_t; |
130 | 130 | ||
131 | typedef struct |
131 | typedef struct |
132 | { |
132 | { |
133 | s8 StickNick; |
133 | s8 StickNick; |
134 | s8 StickRoll; |
134 | s8 StickRoll; |
135 | s8 StickYaw; |
135 | s8 StickYaw; |
136 | s8 StickGas; |
136 | s8 StickGas; |
137 | u8 Poti[8]; |
137 | u8 Poti[8]; |
138 | u8 Poti5; |
138 | u8 Poti5; |
139 | u8 Poti6; |
139 | u8 Poti6; |
140 | u8 Poti7; |
140 | u8 Poti7; |
141 | u8 Poti8; |
141 | u8 Poti8; |
142 | u8 RC_Quality; |
142 | u8 RC_Quality; |
143 | u8 RC_RSSI; |
143 | u8 RC_RSSI; |
144 | u8 BAT_Voltage; |
144 | u8 BAT_Voltage; |
145 | u16 BAT_Current; |
145 | u16 BAT_Current; |
146 | u16 BAT_UsedCapacity; |
146 | u16 BAT_UsedCapacity; |
147 | u8 StatusFlags; |
147 | u8 StatusFlags; |
148 | u8 Error[5]; |
148 | u8 Error[5]; |
149 | u8 StatusFlags2; |
149 | u8 StatusFlags2; |
150 | } __attribute__((packed)) FC_t; |
150 | } __attribute__((packed)) FC_t; |
151 | 151 | ||
152 | 152 | ||
153 | extern Param_t Parameter; |
153 | extern Param_t Parameter; |
154 | extern volatile FC_t FC; |
154 | extern volatile FC_t FC; |
155 | extern s8 ErrorMSG[25]; |
155 | extern s8 ErrorMSG[25]; |
156 | extern u8 ErrorCode; |
156 | extern u8 ErrorCode; |
157 | extern u8 StopNavigation; |
157 | extern u8 StopNavigation; |
158 | #endif // _MAIN_H |
158 | #endif // _MAIN_H |
159 | 159 |