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