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