Subversion Repositories NaviCtrl

Rev

Rev 339 | Rev 342 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 339 Rev 340
1
#ifndef _MAIN_H
1
#ifndef _MAIN_H
2
#define _MAIN_H
2
#define _MAIN_H
3
 
3
 
4
 
4
 
5
//#define FOLLOW_ME
5
//#define FOLLOW_ME
6
 
6
 
7
#ifdef FOLLOW_ME
7
#ifdef FOLLOW_ME
8
extern u8 TransmitAlsoToFC;
8
extern u8 TransmitAlsoToFC;
9
#endif
9
#endif
10
 
10
 
11
//-----------------------
11
//-----------------------
12
//#define DEBUG 0
12
//#define DEBUG 0
13
//-----------------------
13
//-----------------------
14
 
14
 
15
#define VERSION_MAJOR   0
15
#define VERSION_MAJOR   0
16
#define VERSION_MINOR   26
16
#define VERSION_MINOR   26
17
#define VERSION_PATCH   0
17
#define VERSION_PATCH   1
18
// 0 = A
18
// 0 = A
19
// 1 = B
19
// 1 = B
20
// 2 = C
20
// 2 = C
21
// 3 = D
21
// 3 = D
22
// 4 = E
22
// 4 = E
23
// 5 = F
23
// 5 = F
24
// 6 = G
24
// 6 = G
25
// 7 = H
25
// 7 = H
26
// 8 = I
26
// 8 = I
27
// 9 = J
27
// 9 = J
28
// 10 = k
28
// 10 = k
29
// 11 = L
29
// 11 = L
30
// 12 = M
30
// 12 = M
31
// 13 = N
31
// 13 = N
32
// 14 = O
32
// 14 = O
33
// 15 = P
33
// 15 = P
34
// 16 = Q
34
// 16 = Q
35
// 17 = R
35
// 17 = R
36
// 18 = S
36
// 18 = S
37
 
37
 
38
#define VERSION_SERIAL_MAJOR    11
38
#define VERSION_SERIAL_MAJOR    11
39
#define VERSION_SERIAL_MINOR    0
39
#define VERSION_SERIAL_MINOR    0
40
 
40
 
41
#ifndef FOLLOW_ME
41
#ifndef FOLLOW_ME
42
#define FC_SPI_COMPATIBLE               26
42
#define FC_SPI_COMPATIBLE               26
43
#else
43
#else
44
#define FC_SPI_COMPATIBLE               0xFF
44
#define FC_SPI_COMPATIBLE               0xFF
45
#endif
45
#endif
46
 
46
 
47
#define MK3MAG_I2C_COMPATIBLE   3
47
#define MK3MAG_I2C_COMPATIBLE   3
48
 
48
 
49
// FC.StatusFlags
49
// FC.StatusFlags
50
#define FC_STATUS_MOTOR_RUN                             0x01
50
#define FC_STATUS_MOTOR_RUN                             0x01
51
#define FC_STATUS_FLY                                   0x02
51
#define FC_STATUS_FLY                                   0x02
52
#define FC_STATUS_CALIBRATE                             0x04
52
#define FC_STATUS_CALIBRATE                             0x04
53
#define FC_STATUS_START                                 0x08
53
#define FC_STATUS_START                                 0x08
54
#define FC_STATUS_EMERGENCY_LANDING             0x10
54
#define FC_STATUS_EMERGENCY_LANDING             0x10
55
#define FC_STATUS_LOWBAT                                0x20
55
#define FC_STATUS_LOWBAT                                0x20
56
#define FC_STATUS_VARIO_TRIM_UP                 0x40
56
#define FC_STATUS_VARIO_TRIM_UP                 0x40
57
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
57
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
58
 
58
 
59
// FC.StatusFlags2
59
// FC.StatusFlags2
60
#define FC_STATUS2_CAREFREE                 0x01
60
#define FC_STATUS2_CAREFREE                 0x01
61
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
61
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
62
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
62
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
63
 
63
 
64
 
64
 
65
// FC ERRORS FLAGS
65
// FC ERRORS FLAGS
66
#define FC_ERROR0_GYRO_NICK     0x01
66
#define FC_ERROR0_GYRO_NICK     0x01
67
#define FC_ERROR0_GYRO_ROLL     0x02
67
#define FC_ERROR0_GYRO_ROLL     0x02
68
#define FC_ERROR0_GYRO_YAW              0x04
68
#define FC_ERROR0_GYRO_YAW              0x04
69
#define FC_ERROR0_ACC_NICK              0x08
69
#define FC_ERROR0_ACC_NICK              0x08
70
#define FC_ERROR0_ACC_ROLL              0x10
70
#define FC_ERROR0_ACC_ROLL              0x10
71
#define FC_ERROR0_ACC_TOP               0x20
71
#define FC_ERROR0_ACC_TOP               0x20
72
#define FC_ERROR0_PRESSURE              0x40
72
#define FC_ERROR0_PRESSURE              0x40
73
#define FC_ERROR0_CAREFREE              0x80
73
#define FC_ERROR0_CAREFREE              0x80
74
 
74
 
75
#define FC_ERROR1_I2C                   0x01
75
#define FC_ERROR1_I2C                   0x01
76
#define FC_ERROR1_BL_MISSING    0x02
76
#define FC_ERROR1_BL_MISSING    0x02
77
#define FC_ERROR1_SPI_RX                0x04
77
#define FC_ERROR1_SPI_RX                0x04
78
#define FC_ERROR1_PPM                   0x08
78
#define FC_ERROR1_PPM                   0x08
79
#define FC_ERROR1_MIXER                 0x10
79
#define FC_ERROR1_MIXER                 0x10
80
#define FC_ERROR1_RES1                  0x20
80
#define FC_ERROR1_RES1                  0x20
81
#define FC_ERROR1_RES2                  0x40
81
#define FC_ERROR1_RES2                  0x40
82
#define FC_ERROR1_RES3                  0x80
82
#define FC_ERROR1_RES3                  0x80
83
 
83
 
84
// NC Errors
84
// NC Errors
85
#define NCERR_FLAG_FC_COMPATIBLE                        0x00000001
85
#define NCERR_FLAG_FC_COMPATIBLE                        0x00000001
86
#define NCERR_FLAG_MK3MAG_COMPATIBLE            0x00000002
86
#define NCERR_FLAG_MK3MAG_COMPATIBLE            0x00000002
87
#define NCERR_FLAG_FC_COMMUNICATION                     0x00000004
87
#define NCERR_FLAG_FC_COMMUNICATION                     0x00000004
88
#define NCERR_FLAG_MK3MAG_COMMUNICATION         0x00000008
88
#define NCERR_FLAG_MK3MAG_COMMUNICATION         0x00000008
89
#define NCERR_FLAG_MKGPS_COMMUNICATION          0x00000010
89
#define NCERR_FLAG_MKGPS_COMMUNICATION          0x00000010
90
#define NCERR_FLAG_BAD_COMPASS_HEADING          0x00000020
90
#define NCERR_FLAG_BAD_COMPASS_HEADING          0x00000020
91
#define NCERR_FLAG_RC_SIGNAL_LOST                       0x00000040
91
#define NCERR_FLAG_RC_SIGNAL_LOST                       0x00000040
92
#define NCERR_FLAG_EEPROM_NOT_FOUND                     0x00000080
92
#define NCERR_FLAG_EEPROM_NOT_FOUND                     0x00000080
93
 
93
 
94
// Parameter.GlobalConfig
94
// Parameter.GlobalConfig
95
#define FC_CFG_HOEHENREGELUNG           0x01
95
#define FC_CFG_HOEHENREGELUNG           0x01
96
#define FC_CFG_HOEHEN_SCHALTER          0x02
96
#define FC_CFG_HOEHEN_SCHALTER          0x02
97
#define FC_CFG_HEADING_HOLD             0x04
97
#define FC_CFG_HEADING_HOLD             0x04
98
#define FC_CFG_KOMPASS_AKTIV            0x08
98
#define FC_CFG_KOMPASS_AKTIV            0x08
99
#define FC_CFG_KOMPASS_FIX              0x10
99
#define FC_CFG_KOMPASS_FIX              0x10
100
#define FC_CFG_GPS_AKTIV                0x20
100
#define FC_CFG_GPS_AKTIV                0x20
101
#define FC_CFG_ACHSENKOPPLUNG_AKTIV     0x40
101
#define FC_CFG_ACHSENKOPPLUNG_AKTIV     0x40
102
#define FC_CFG_DREHRATEN_BEGRENZER      0x80
102
#define FC_CFG_DREHRATEN_BEGRENZER      0x80
103
 
103
 
104
//Parameter.ExtraConfig 
104
//Parameter.ExtraConfig 
105
#define CFG2_HEIGHT_LIMIT                       0x01
105
#define CFG2_HEIGHT_LIMIT                       0x01
106
#define CFG2_VARIO_BEEP                         0x02
106
#define CFG2_VARIO_BEEP                         0x02
107
#define CFG_SENSITIVE_RC                        0x04
107
#define CFG_SENSITIVE_RC                        0x04
108
#define CFG_3_3V_REFERENCE                      0x08
108
#define CFG_3_3V_REFERENCE                      0x08
109
#define CFG_NO_RCOFF_BEEPING                    0x10
109
#define CFG_NO_RCOFF_BEEPING                    0x10
110
#define CFG_GPS_AID                             0x20
110
#define CFG_GPS_AID                             0x20
111
#define CFG_TEACHABLE_CAREFREE                  0x40
111
#define CFG_TEACHABLE_CAREFREE                  0x40
112
#define CFG_IGNORE_MAG_ERR_AT_STARTUP   0x80
112
#define CFG_IGNORE_MAG_ERR_AT_STARTUP   0x80
113
 
113
 
114
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
114
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
115
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
115
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
116
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
116
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
117
 
117
 
118
 
118
 
119
#define Poti1  FC.Poti[0]
119
#define Poti1  FC.Poti[0]
120
#define Poti2  FC.Poti[1]
120
#define Poti2  FC.Poti[1]
121
#define Poti3  FC.Poti[2]
121
#define Poti3  FC.Poti[2]
122
#define Poti4  FC.Poti[3]
122
#define Poti4  FC.Poti[3]
123
#define Poti5  FC.Poti[4]
123
#define Poti5  FC.Poti[4]
124
#define Poti6  FC.Poti[5]
124
#define Poti6  FC.Poti[5]
125
#define Poti7  FC.Poti[6]
125
#define Poti7  FC.Poti[6]
126
#define Poti8  FC.Poti[7]
126
#define Poti8  FC.Poti[7]
127
 
127
 
128
extern u16 BeepTime;
128
extern u16 BeepTime;
129
extern u8  NCFlags;
129
extern u8  NCFlags;
130
extern u8 ClearFCStatusFlags;
130
extern u8 ClearFCStatusFlags;
131
void Interrupt_Init(void);
131
void Interrupt_Init(void);
132
extern s16 GeoMagDec;
132
extern s16 GeoMagDec;
133
 
133
 
134
typedef struct
134
typedef struct
135
{
135
{
136
        u8 ActiveSetting;
136
        u8 ActiveSetting;
137
        u8 User1;
137
        u8 User1;
138
        u8 User2;
138
        u8 User2;
139
        u8 User3;
139
        u8 User3;
140
        u8 User4;
140
        u8 User4;
141
        u8 User5;
141
        u8 User5;
142
        u8 User6;
142
        u8 User6;
143
        u8 User7;
143
        u8 User7;
144
        u8 User8;
144
        u8 User8;
145
        u8 NaviGpsModeControl;
145
        u8 NaviGpsModeControl;
146
        u8 NaviGpsGain;
146
        u8 NaviGpsGain;
147
        u8 NaviGpsP;
147
        u8 NaviGpsP;
148
        u8 NaviGpsI;
148
        u8 NaviGpsI;
149
        u8 NaviGpsD;
149
        u8 NaviGpsD;
150
        u8 NaviGpsPLimit;
150
        u8 NaviGpsPLimit;
151
        u8 NaviGpsILimit;
151
        u8 NaviGpsILimit;
152
        u8 NaviGpsDLimit;
152
        u8 NaviGpsDLimit;
153
        u8 NaviGpsACC;
153
        u8 NaviGpsACC;
154
        u8 NaviGpsMinSat;
154
        u8 NaviGpsMinSat;
155
        u8 NaviStickThreshold;
155
        u8 NaviStickThreshold;
156
        u8 NaviOperatingRadius;
156
        u8 NaviOperatingRadius;
157
        u8 NaviWindCorrection;
157
        u8 NaviWindCorrection;
158
        u8 NaviAccCompensation;
158
        u8 NaviAccCompensation;
159
        u8 NaviSpeedCompensation;
159
        u8 NaviSpeedCompensation;
160
        u8 LowVoltageWarning;
160
        u8 LowVoltageWarning;
161
        u8 NaviAngleLimitation;
161
        u8 NaviAngleLimitation;
162
        u8 NaviPH_LoginTime;
162
        u8 NaviPH_LoginTime;
163
        u8 OrientationAngle;
163
        u8 OrientationAngle;
164
        u8 GlobalConfig;
164
        u8 GlobalConfig;
165
        u8 ExtraConfig;
165
        u8 ExtraConfig;
166
        u8 ComingHomeAltitude;
166
        u8 ComingHomeAltitude;
167
} __attribute__((packed)) Param_t;
167
} __attribute__((packed)) Param_t;
168
 
168
 
169
typedef struct
169
typedef struct
170
{
170
{
171
        s8 StickNick;
171
        s8 StickNick;
172
        s8 StickRoll;
172
        s8 StickRoll;
173
        s8 StickYaw;
173
        s8 StickYaw;
174
        s8 StickGas;
174
        s8 StickGas;
175
        u8 Poti[8];
175
        u8 Poti[8];
176
        u8 RC_Quality;
176
        u8 RC_Quality;
177
        u8 RC_RSSI;
177
        u8 RC_RSSI;
178
        u8 BAT_Voltage;
178
        u8 BAT_Voltage;
179
        u16 BAT_Current;
179
        u16 BAT_Current;
180
        u16 BAT_UsedCapacity;
180
        u16 BAT_UsedCapacity;
181
        u8 StatusFlags;
181
        u8 StatusFlags;
182
        u8 Error[5];
182
        u8 Error[5];
183
        u8 StatusFlags2;
183
        u8 StatusFlags2;
184
} __attribute__((packed)) FC_t;
184
} __attribute__((packed)) FC_t;
185
 
185
 
186
 
186
 
187
extern Param_t Parameter;
187
extern Param_t Parameter;
188
extern volatile FC_t FC;
188
extern volatile FC_t FC;
189
extern s8 ErrorMSG[25];
189
extern s8 ErrorMSG[25];
190
extern u8 ErrorCode;
190
extern u8 ErrorCode;
191
extern u8 StopNavigation;
191
extern u8 StopNavigation;
192
extern u8 ErrorGpsFixLost;
192
extern u8 ErrorGpsFixLost;
193
#endif // _MAIN_H
193
#endif // _MAIN_H
194
 
194