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