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