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