Rev 311 | Rev 316 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 311 | Rev 314 | ||
---|---|---|---|
1 | #ifndef _MAIN_H |
1 | #ifndef _MAIN_H |
2 | #define _MAIN_H |
2 | #define _MAIN_H |
- | 3 | ||
- | 4 | ||
- | 5 | //#define FOLLOW_ME |
|
- | 6 | ||
- | 7 | #ifdef FOLLOW_ME |
|
- | 8 | extern u8 TransmitAlsoToFC; |
|
- | 9 | #endif |
|
3 | 10 | ||
4 | //----------------------- |
11 | //----------------------- |
5 | //#define DEBUG 0 |
12 | //#define DEBUG 0 |
6 | //----------------------- |
13 | //----------------------- |
7 | 14 | ||
8 | #define VERSION_MAJOR 0 |
15 | #define VERSION_MAJOR 0 |
9 | #define VERSION_MINOR 24 |
16 | #define VERSION_MINOR 24 |
10 | #define VERSION_PATCH 4 |
17 | #define VERSION_PATCH 4 |
11 | // 0 = A |
18 | // 0 = A |
12 | // 1 = B |
19 | // 1 = B |
13 | // 2 = C |
20 | // 2 = C |
14 | // 3 = D |
21 | // 3 = D |
15 | // 4 = E |
22 | // 4 = E |
16 | // 5 = F |
23 | // 5 = F |
17 | // 6 = G |
24 | // 6 = G |
18 | // 7 = H |
25 | // 7 = H |
19 | // 8 = I |
26 | // 8 = I |
20 | // 9 = J |
27 | // 9 = J |
21 | // 10 = k |
28 | // 10 = k |
22 | // 11 = L |
29 | // 11 = L |
23 | // 12 = M |
30 | // 12 = M |
24 | // 13 = N |
31 | // 13 = N |
25 | // 14 = o |
32 | // 14 = o |
26 | 33 | ||
27 | #define VERSION_SERIAL_MAJOR 11 |
34 | #define VERSION_SERIAL_MAJOR 11 |
28 | #define VERSION_SERIAL_MINOR 0 |
35 | #define VERSION_SERIAL_MINOR 0 |
29 | 36 | ||
30 | #define FC_SPI_COMPATIBLE 19 |
37 | #define FC_SPI_COMPATIBLE 19 |
31 | #define MK3MAG_I2C_COMPATIBLE 3 |
38 | #define MK3MAG_I2C_COMPATIBLE 3 |
32 | 39 | ||
33 | // FC STATUS FLAGS |
40 | // FC STATUS FLAGS |
34 | #define FC_STATUS_MOTOR_RUN 0x01 |
41 | #define FC_STATUS_MOTOR_RUN 0x01 |
35 | #define FC_STATUS_FLY 0x02 |
42 | #define FC_STATUS_FLY 0x02 |
36 | #define FC_STATUS_CALIBRATE 0x04 |
43 | #define FC_STATUS_CALIBRATE 0x04 |
37 | #define FC_STATUS_START 0x08 |
44 | #define FC_STATUS_START 0x08 |
38 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
45 | #define FC_STATUS_EMERGENCY_LANDING 0x10 |
39 | #define FC_STATUS_LOWBAT 0x20 |
46 | #define FC_STATUS_LOWBAT 0x20 |
40 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
47 | #define FC_STATUS_VARIO_TRIM_UP 0x40 |
41 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
48 | #define FC_STATUS_VARIO_TRIM_DOWN 0x80 |
42 | 49 | ||
43 | // FC STATUS FLAGS2 |
50 | // FC STATUS FLAGS2 |
44 | #define FC_STATUS2_CAREFREE 0x01 |
51 | #define FC_STATUS2_CAREFREE 0x01 |
45 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
52 | #define FC_STATUS2_ALTITUDE_CONTROL 0x02 |
46 | 53 | ||
47 | 54 | ||
48 | // FC ERRORS FLAGS |
55 | // FC ERRORS FLAGS |
49 | #define FC_ERROR0_GYRO_NICK 0x01 |
56 | #define FC_ERROR0_GYRO_NICK 0x01 |
50 | #define FC_ERROR0_GYRO_ROLL 0x02 |
57 | #define FC_ERROR0_GYRO_ROLL 0x02 |
51 | #define FC_ERROR0_GYRO_YAW 0x04 |
58 | #define FC_ERROR0_GYRO_YAW 0x04 |
52 | #define FC_ERROR0_ACC_NICK 0x08 |
59 | #define FC_ERROR0_ACC_NICK 0x08 |
53 | #define FC_ERROR0_ACC_ROLL 0x10 |
60 | #define FC_ERROR0_ACC_ROLL 0x10 |
54 | #define FC_ERROR0_ACC_TOP 0x20 |
61 | #define FC_ERROR0_ACC_TOP 0x20 |
55 | #define FC_ERROR0_PRESSURE 0x40 |
62 | #define FC_ERROR0_PRESSURE 0x40 |
56 | #define FC_ERROR0_CAREFREE 0x80 |
63 | #define FC_ERROR0_CAREFREE 0x80 |
57 | 64 | ||
58 | #define FC_ERROR1_I2C 0x01 |
65 | #define FC_ERROR1_I2C 0x01 |
59 | #define FC_ERROR1_BL_MISSING 0x02 |
66 | #define FC_ERROR1_BL_MISSING 0x02 |
60 | #define FC_ERROR1_SPI_RX 0x04 |
67 | #define FC_ERROR1_SPI_RX 0x04 |
61 | #define FC_ERROR1_PPM 0x08 |
68 | #define FC_ERROR1_PPM 0x08 |
62 | #define FC_ERROR1_MIXER 0x10 |
69 | #define FC_ERROR1_MIXER 0x10 |
63 | #define FC_ERROR1_RES1 0x20 |
70 | #define FC_ERROR1_RES1 0x20 |
64 | #define FC_ERROR1_RES2 0x40 |
71 | #define FC_ERROR1_RES2 0x40 |
65 | #define FC_ERROR1_RES3 0x80 |
72 | #define FC_ERROR1_RES3 0x80 |
66 | 73 | ||
67 | // NC Errors |
74 | // NC Errors |
68 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
75 | #define NCERR_FLAG_FC_COMPATIBLE 0x00000001 |
69 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
76 | #define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002 |
70 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
77 | #define NCERR_FLAG_FC_COMMUNICATION 0x00000004 |
71 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
78 | #define NCERR_FLAG_MK3MAG_COMMUNICATION 0x00000008 |
72 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
79 | #define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
73 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
80 | #define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
74 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
81 | #define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
75 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
82 | #define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
76 | 83 | ||
77 | 84 | ||
78 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
85 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
79 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
86 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
80 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
87 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
81 | 88 | ||
82 | extern u16 BeepTime; |
89 | extern u16 BeepTime; |
83 | extern u8 NCFlags; |
90 | extern u8 NCFlags; |
84 | extern u8 ClearFCStatusFlags; |
91 | extern u8 ClearFCStatusFlags; |
85 | void Interrupt_Init(void); |
92 | void Interrupt_Init(void); |
86 | extern s16 GeoMagDec; |
93 | extern s16 GeoMagDec; |
87 | 94 | ||
88 | 95 | ||
89 | typedef struct |
96 | typedef struct |
90 | { |
97 | { |
91 | u8 ActiveSetting; |
98 | u8 ActiveSetting; |
92 | u8 User1; |
99 | u8 User1; |
93 | u8 User2; |
100 | u8 User2; |
94 | u8 User3; |
101 | u8 User3; |
95 | u8 User4; |
102 | u8 User4; |
96 | u8 User5; |
103 | u8 User5; |
97 | u8 User6; |
104 | u8 User6; |
98 | u8 User7; |
105 | u8 User7; |
99 | u8 User8; |
106 | u8 User8; |
100 | u8 NaviGpsModeControl; |
107 | u8 NaviGpsModeControl; |
101 | u8 NaviGpsGain; |
108 | u8 NaviGpsGain; |
102 | u8 NaviGpsP; |
109 | u8 NaviGpsP; |
103 | u8 NaviGpsI; |
110 | u8 NaviGpsI; |
104 | u8 NaviGpsD; |
111 | u8 NaviGpsD; |
105 | u8 NaviGpsPLimit; |
112 | u8 NaviGpsPLimit; |
106 | u8 NaviGpsILimit; |
113 | u8 NaviGpsILimit; |
107 | u8 NaviGpsDLimit; |
114 | u8 NaviGpsDLimit; |
108 | u8 NaviGpsACC; |
115 | u8 NaviGpsACC; |
109 | u8 NaviGpsMinSat; |
116 | u8 NaviGpsMinSat; |
110 | u8 NaviStickThreshold; |
117 | u8 NaviStickThreshold; |
111 | u8 NaviOperatingRadius; |
118 | u8 NaviOperatingRadius; |
112 | u8 NaviWindCorrection; |
119 | u8 NaviWindCorrection; |
113 | u8 NaviSpeedCompensation; |
120 | u8 NaviSpeedCompensation; |
114 | u8 LowVoltageWarning; |
121 | u8 LowVoltageWarning; |
115 | u8 NaviAngleLimitation; |
122 | u8 NaviAngleLimitation; |
116 | u8 NaviPH_LoginTime; |
123 | u8 NaviPH_LoginTime; |
117 | } __attribute__((packed)) Param_t; |
124 | } __attribute__((packed)) Param_t; |
118 | 125 | ||
119 | typedef struct |
126 | typedef struct |
120 | { |
127 | { |
121 | s8 StickNick; |
128 | s8 StickNick; |
122 | s8 StickRoll; |
129 | s8 StickRoll; |
123 | s8 StickYaw; |
130 | s8 StickYaw; |
124 | s8 StickGas; |
131 | s8 StickGas; |
125 | u8 Poti[8]; |
132 | u8 Poti[8]; |
126 | u8 Poti5; |
133 | u8 Poti5; |
127 | u8 Poti6; |
134 | u8 Poti6; |
128 | u8 Poti7; |
135 | u8 Poti7; |
129 | u8 Poti8; |
136 | u8 Poti8; |
130 | u8 RC_Quality; |
137 | u8 RC_Quality; |
131 | u8 RC_RSSI; |
138 | u8 RC_RSSI; |
132 | u8 BAT_Voltage; |
139 | u8 BAT_Voltage; |
133 | u16 BAT_Current; |
140 | u16 BAT_Current; |
134 | u16 BAT_UsedCapacity; |
141 | u16 BAT_UsedCapacity; |
135 | u8 StatusFlags; |
142 | u8 StatusFlags; |
136 | u8 Error[5]; |
143 | u8 Error[5]; |
137 | u8 StatusFlags2; |
144 | u8 StatusFlags2; |
138 | } __attribute__((packed)) FC_t; |
145 | } __attribute__((packed)) FC_t; |
139 | 146 | ||
140 | 147 | ||
141 | extern Param_t Parameter; |
148 | extern Param_t Parameter; |
142 | extern volatile FC_t FC; |
149 | extern volatile FC_t FC; |
143 | extern s8 ErrorMSG[25]; |
150 | extern s8 ErrorMSG[25]; |
144 | extern u8 ErrorCode; |
151 | extern u8 ErrorCode; |
145 | extern u8 StopNavigation; |
152 | extern u8 StopNavigation; |
146 | #endif // _MAIN_H |
153 | #endif // _MAIN_H |
147 | 154 |