Rev 1646 | Rev 1821 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1646 | Rev 1775 | ||
---|---|---|---|
1 | #ifndef _CONFIGURATION_H |
1 | #ifndef _CONFIGURATION_H |
2 | #define _CONFIGURATION_H |
2 | #define _CONFIGURATION_H |
3 | 3 | ||
4 | #include <inttypes.h> |
4 | #include <inttypes.h> |
5 | #include <avr/io.h> |
5 | #include <avr/io.h> |
6 | 6 | ||
7 | typedef struct { |
7 | typedef struct { |
8 | uint8_t HeightD; |
8 | /*PMM*/ uint8_t HeightD; |
9 | uint8_t MaxHeight; |
9 | /* P */ uint8_t MaxHeight; |
10 | uint8_t HeightP; |
10 | /*PMM*/ uint8_t HeightP; |
11 | uint8_t Height_ACC_Effect; |
11 | /* P */ uint8_t Height_ACC_Effect; |
12 | uint8_t CompassYawEffect; |
12 | /* P */ uint8_t CompassYawEffect; |
13 | uint8_t GyroD; |
13 | /* P */ uint8_t GyroD; |
14 | uint8_t GyroP; |
14 | /*PMM*/ uint8_t GyroP; |
15 | uint8_t GyroI; |
15 | /* P */ uint8_t GyroI; |
16 | uint8_t StickYawP; |
16 | /* Never used */ uint8_t StickYawP; |
17 | uint8_t IFactor; |
17 | /* P */ uint8_t IFactor; |
18 | uint8_t UserParams[8]; |
18 | /* P */ uint8_t UserParams[8]; |
19 | /* |
- | |
20 | uint8_t UserParam2; |
- | |
21 | uint8_t UserParam3; |
- | |
22 | uint8_t UserParam4; |
- | |
23 | uint8_t UserParam5; |
- | |
24 | uint8_t UserParam6; |
- | |
25 | uint8_t UserParam7; |
- | |
26 | uint8_t UserParam8; |
- | |
27 | */ |
- | |
28 | uint8_t ServoPitchControl; |
19 | /* P */ uint8_t ServoPitchControl; |
29 | uint8_t LoopGasLimit; |
20 | /* P */ uint8_t LoopGasLimit; |
30 | uint8_t AxisCoupling1; |
21 | /* P */ uint8_t AxisCoupling1; |
31 | uint8_t AxisCoupling2; |
22 | /* P */ uint8_t AxisCoupling2; |
32 | uint8_t AxisCouplingYawCorrection; |
23 | /* P */ uint8_t AxisCouplingYawCorrection; |
33 | uint8_t DynamicStability; |
24 | /* P */ uint8_t DynamicStability; |
34 | uint8_t ExternalControl; |
25 | /* P */ uint8_t ExternalControl; |
35 | uint8_t J16Timing; |
26 | /*PMM*/ uint8_t J16Timing; |
36 | uint8_t J17Timing; |
27 | /*PMM*/ uint8_t J17Timing; |
37 | #if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
- | |
38 | uint8_t NaviGpsModeControl; |
28 | /* P */ uint8_t NaviGpsModeControl; |
39 | uint8_t NaviGpsGain; |
29 | /* P */ uint8_t NaviGpsGain; |
40 | uint8_t NaviGpsP; |
30 | /* P */ uint8_t NaviGpsP; |
41 | uint8_t NaviGpsI; |
31 | /* P */ uint8_t NaviGpsI; |
42 | uint8_t NaviGpsD; |
32 | /* P */ uint8_t NaviGpsD; |
43 | uint8_t NaviGpsACC; |
33 | /* P */ uint8_t NaviGpsACC; |
44 | uint8_t NaviOperatingRadius; |
34 | /*PMM*/ uint8_t NaviOperatingRadius; |
45 | uint8_t NaviWindCorrection; |
35 | /* P */ uint8_t NaviWindCorrection; |
46 | uint8_t NaviSpeedCompensation; |
36 | /* P */ uint8_t NaviSpeedCompensation; |
47 | #endif |
- | |
48 | int8_t KalmanK; |
37 | int8_t KalmanK; |
49 | int8_t KalmanMaxDrift; |
38 | int8_t KalmanMaxDrift; |
50 | int8_t KalmanMaxFusion; |
39 | int8_t KalmanMaxFusion; |
51 | } fc_param_t; |
40 | } dynamicParam_t; |
- | 41 | extern dynamicParam_t dynamicParams; |
|
- | 42 | ||
- | 43 | typedef struct { |
|
- | 44 | uint8_t sourceIdx, targetIdx; |
|
- | 45 | uint8_t min, max; |
|
- | 46 | } MMXLATION; |
|
- | 47 | ||
52 | 48 | typedef struct { |
|
- | 49 | uint8_t sourceIdx, targetIdx; |
|
53 | extern fc_param_t dynamicParams; |
50 | } XLATION; |
54 | 51 | ||
55 | // values above 250 representing poti1 to poti4 |
52 | // values above 250 representing poti1 to poti4 |
56 | typedef struct { |
53 | typedef struct { |
57 | uint8_t ChannelAssignment[8]; // see upper defines for details |
54 | uint8_t ChannelAssignment[8]; // see upper defines for details |
58 | uint8_t GlobalConfig; // see upper defines for bitcoding |
55 | uint8_t GlobalConfig; // see upper defines for bitcoding |
59 | uint8_t HeightMinGas; // Value : 0-100 |
56 | uint8_t HeightMinGas; // Value : 0-100 |
60 | uint8_t HeightD; // Value : 0-250 |
57 | uint8_t HeightD; // Value : 0-250 |
61 | uint8_t MaxHeight; // Value : 0-32 |
58 | uint8_t MaxHeight; // Value : 0-32 |
62 | uint8_t HeightP; // Value : 0-32 |
59 | uint8_t HeightP; // Value : 0-32 |
63 | uint8_t Height_Gain; // Value : 0-50 |
60 | uint8_t Height_Gain; // Value : 0-50 |
64 | uint8_t Height_ACC_Effect; // Value : 0-250 |
61 | uint8_t Height_ACC_Effect; // Value : 0-250 |
65 | uint8_t StickP; // Value : 1-6 |
62 | uint8_t StickP; // Value : 1-6 |
66 | uint8_t StickD; // Value : 0-64 |
63 | uint8_t StickD; // Value : 0-64 |
67 | uint8_t StickYawP; // Value : 1-20 |
64 | uint8_t StickYawP; // Value : 1-20 |
68 | uint8_t MinThrottle; // Value : 0-32 |
65 | uint8_t MinThrottle; // Value : 0-32 |
69 | uint8_t MaxThrottle; // Value : 33-250 |
66 | uint8_t MaxThrottle; // Value : 33-250 |
70 | uint8_t GyroAccFactor; // Value : 1-64 |
67 | uint8_t GyroAccFactor; // Value : 1-64 |
71 | uint8_t CompassYawEffect; // Value : 0-32 |
68 | uint8_t CompassYawEffect; // Value : 0-32 |
72 | uint8_t GyroP; // Value : 10-250 |
69 | uint8_t GyroP; // Value : 10-250 |
73 | uint8_t GyroI; // Value : 0-250 |
70 | uint8_t GyroI; // Value : 0-250 |
74 | uint8_t GyroD; // Value : 0-250 |
71 | uint8_t GyroD; // Value : 0-250 |
75 | uint8_t LowVoltageWarning; // Value : 0-250 |
72 | uint8_t LowVoltageWarning; // Value : 0-250 |
76 | uint8_t EmergencyGas; // Value : 0-250 //Gaswert bei Emp�ngsverlust |
73 | uint8_t EmergencyGas; // Value : 0-250 //Gaswert bei Emp�ngsverlust |
77 | uint8_t EmergencyGasDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
74 | uint8_t EmergencyGasDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
78 | uint8_t Unused0; // |
75 | uint8_t Unused0; // |
79 | uint8_t IFactor; // Value : 0-250 |
76 | uint8_t IFactor; // Value : 0-250 |
80 | uint8_t UserParams1[4]; // Value : 0-250 |
77 | uint8_t UserParams1[4]; // Value : 0-250 |
81 | /* |
78 | /* |
82 | uint8_t UserParam2; // Value : 0-250 |
79 | uint8_t UserParam2; // Value : 0-250 |
83 | uint8_t UserParam3; // Value : 0-250 |
80 | uint8_t UserParam3; // Value : 0-250 |
84 | uint8_t UserParam4; // Value : 0-250 |
81 | uint8_t UserParam4; // Value : 0-250 |
85 | */ |
82 | */ |
86 | uint8_t ServoPitchControl; // Value : 0-250 // Stellung des Servos |
83 | uint8_t ServoPitchControl; // Value : 0-250 // Stellung des Servos |
87 | uint8_t ServoPitchComp; // Value : 0-250 // Einfluss Gyro/Servo |
84 | uint8_t ServoPitchComp; // Value : 0-250 // Einfluss Gyro/Servo |
88 | uint8_t ServoPitchMin; // Value : 0-250 // Anschlag |
85 | uint8_t ServoPitchMin; // Value : 0-250 // Anschlag |
89 | uint8_t ServoPitchMax; // Value : 0-250 // Anschlag |
86 | uint8_t ServoPitchMax; // Value : 0-250 // Anschlag |
90 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
87 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
91 | uint8_t LoopGasLimit; // Value: 0-250 max. Gas w�hrend Looping |
88 | uint8_t LoopGasLimit; // Value: 0-250 max. Gas w�hrend Looping |
92 | uint8_t LoopThreshold; // Value: 0-250 Schwelle f�r Stickausschlag |
89 | uint8_t LoopThreshold; // Value: 0-250 Schwelle f�r Stickausschlag |
93 | uint8_t LoopHysteresis; // Value: 0-250 Hysterese f�r Stickausschlag |
90 | uint8_t LoopHysteresis; // Value: 0-250 Hysterese f�r Stickausschlag |
94 | uint8_t AxisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
91 | uint8_t AxisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
95 | uint8_t AxisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
92 | uint8_t AxisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
96 | uint8_t AxisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
93 | uint8_t AxisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
97 | uint8_t AngleTurnOverPitch; // Value: 0-250 180�-Punkt |
94 | uint8_t AngleTurnOverPitch; // Value: 0-250 180�-Punkt |
98 | uint8_t AngleTurnOverRoll; // Value: 0-250 180�-Punkt |
95 | uint8_t AngleTurnOverRoll; // Value: 0-250 180�-Punkt |
99 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
96 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
100 | uint8_t DriftComp; // limit for gyrodrift compensation |
97 | uint8_t DriftComp; // limit for gyrodrift compensation |
101 | uint8_t DynamicStability; // PID limit for Attitude controller |
98 | uint8_t DynamicStability; // PID limit for Attitude controller |
102 | uint8_t UserParams2[4]; // Value : 0-250 |
99 | uint8_t UserParams2[4]; // Value : 0-250 |
103 | /* |
100 | /* |
104 | uint8_t UserParam6; // Value : 0-250 |
101 | uint8_t UserParam6; // Value : 0-250 |
105 | uint8_t UserParam7; // Value : 0-250 |
102 | uint8_t UserParam7; // Value : 0-250 |
106 | uint8_t UserParam8; // Value : 0-250 |
103 | uint8_t UserParam8; // Value : 0-250 |
107 | */ |
104 | */ |
108 | uint8_t J16Bitmask; // for the J16 Output |
105 | uint8_t J16Bitmask; // for the J16 Output |
109 | uint8_t J16Timing; // for the J16 Output |
106 | uint8_t J16Timing; // for the J16 Output |
110 | uint8_t J17Bitmask; // for the J17 Output |
107 | uint8_t J17Bitmask; // for the J17 Output |
111 | uint8_t J17Timing; // for the J17 Output |
108 | uint8_t J17Timing; // for the J17 Output |
112 | uint8_t NaviGpsModeControl; // Parameters for the Naviboard |
109 | uint8_t NaviGpsModeControl; // Parameters for the Naviboard |
113 | uint8_t NaviGpsGain; // overall gain for GPS-PID controller |
110 | uint8_t NaviGpsGain; // overall gain for GPS-PID controller |
114 | uint8_t NaviGpsP; // P gain for GPS-PID controller |
111 | uint8_t NaviGpsP; // P gain for GPS-PID controller |
115 | uint8_t NaviGpsI; // I gain for GPS-PID controller |
112 | uint8_t NaviGpsI; // I gain for GPS-PID controller |
116 | uint8_t NaviGpsD; // D gain for GPS-PID controller |
113 | uint8_t NaviGpsD; // D gain for GPS-PID controller |
117 | uint8_t NaviGpsPLimit; // P limit for GPS-PID controller |
114 | uint8_t NaviGpsPLimit; // P limit for GPS-PID controller |
118 | uint8_t NaviGpsILimit; // I limit for GPS-PID controller |
115 | uint8_t NaviGpsILimit; // I limit for GPS-PID controller |
119 | uint8_t NaviGpsDLimit; // D limit for GPS-PID controller |
116 | uint8_t NaviGpsDLimit; // D limit for GPS-PID controller |
120 | uint8_t NaviGpsACC; // ACC gain for GPS-PID controller |
117 | uint8_t NaviGpsACC; // ACC gain for GPS-PID controller |
121 | uint8_t NaviGpsMinSat; // number of sattelites neccesary for GPS functions |
118 | uint8_t NaviGpsMinSat; // number of sattelites neccesary for GPS functions |
122 | uint8_t NaviStickThreshold; // activation threshild for detection of manual stick movements |
119 | uint8_t NaviStickThreshold; // activation threshild for detection of manual stick movements |
123 | uint8_t NaviWindCorrection; // streng of wind course correction |
120 | uint8_t NaviWindCorrection; // streng of wind course correction |
124 | uint8_t NaviSpeedCompensation; // D gain fefore position hold login |
121 | uint8_t NaviSpeedCompensation; // D gain fefore position hold login |
125 | uint8_t NaviOperatingRadius; // Radius limit in m around start position for GPS flights |
122 | uint8_t NaviOperatingRadius; // Radius limit in m around start position for GPS flights |
126 | uint8_t NaviAngleLimitation; // limitation of attitude angle controlled by the gps algorithm |
123 | uint8_t NaviAngleLimitation; // limitation of attitude angle controlled by the gps algorithm |
127 | uint8_t NaviPHLoginTime; // position hold logintimeout |
124 | uint8_t NaviPHLoginTime; // position hold logintimeout |
128 | uint8_t ExternalControl; // for serial Control |
125 | uint8_t ExternalControl; // for serial Control |
129 | uint8_t BitConfig; // see upper defines for bitcoding |
126 | uint8_t BitConfig; // see upper defines for bitcoding |
130 | uint8_t ServoPitchCompInvert; // Value : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
127 | uint8_t ServoPitchCompInvert; // Value : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
131 | uint8_t Reserved[4]; |
128 | uint8_t Reserved[4]; |
132 | int8_t Name[12]; |
129 | int8_t Name[12]; |
133 | } paramset_t; |
130 | } paramset_t; |
134 | 131 | ||
135 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
132 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
136 | 133 | ||
137 | extern paramset_t staticParams; |
134 | extern paramset_t staticParams; |
138 | 135 | ||
139 | typedef struct { |
136 | typedef struct { |
140 | uint8_t Revision; |
137 | uint8_t Revision; |
141 | int8_t Name[12]; |
138 | int8_t Name[12]; |
142 | int8_t Motor[16][4]; |
139 | int8_t Motor[16][4]; |
143 | } __attribute__((packed)) MixerTable_t; |
140 | } __attribute__((packed)) MixerTable_t; |
144 | 141 | ||
145 | extern MixerTable_t Mixer; |
142 | extern MixerTable_t Mixer; |
146 | 143 | ||
147 | // MKFlags |
144 | // MKFlags |
148 | #define MKFLAG_MOTOR_RUN (1<<0) |
145 | #define MKFLAG_MOTOR_RUN (1<<0) |
149 | #define MKFLAG_FLY (1<<1) |
146 | #define MKFLAG_FLY (1<<1) |
150 | #define MKFLAG_CALIBRATE (1<<2) |
147 | #define MKFLAG_CALIBRATE (1<<2) |
151 | #define MKFLAG_START (1<<3) |
148 | #define MKFLAG_START (1<<3) |
152 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
149 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
153 | #define MKFLAG_RESERVE1 (1<<5) |
150 | #define MKFLAG_RESERVE1 (1<<5) |
154 | #define MKFLAG_RESERVE2 (1<<6) |
151 | #define MKFLAG_RESERVE2 (1<<6) |
155 | #define MKFLAG_RESERVE3 (1<<7) |
152 | #define MKFLAG_RESERVE3 (1<<7) |
156 | 153 | ||
157 | // bit mask for staticParams.GlobalConfig |
154 | // bit mask for staticParams.GlobalConfig |
158 | #define CFG_HEIGHT_CONTROL (1<<0) |
155 | #define CFG_HEIGHT_CONTROL (1<<0) |
159 | #define CFG_HEIGHT_SWITCH (1<<1) |
156 | #define CFG_HEIGHT_SWITCH (1<<1) |
160 | #define CFG_HEADING_HOLD (1<<2) |
157 | #define CFG_HEADING_HOLD (1<<2) |
161 | #define CFG_COMPASS_ACTIVE (1<<3) |
158 | #define CFG_COMPASS_ACTIVE (1<<3) |
162 | #define CFG_COMPASS_FIX (1<<4) |
159 | #define CFG_COMPASS_FIX (1<<4) |
163 | #define CFG_GPS_ACTIVE (1<<5) |
160 | #define CFG_GPS_ACTIVE (1<<5) |
164 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
161 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
165 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
162 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
166 | 163 | ||
167 | // bit mask for ParamSet.BitConfig |
164 | // bit mask for staticParams.BitConfig |
168 | #define CFG_LOOP_UP (1<<0) |
165 | #define CFG_LOOP_UP (1<<0) |
169 | #define CFG_LOOP_DOWN (1<<1) |
166 | #define CFG_LOOP_DOWN (1<<1) |
170 | #define CFG_LOOP_LEFT (1<<2) |
167 | #define CFG_LOOP_LEFT (1<<2) |
171 | #define CFG_LOOP_RIGHT (1<<3) |
168 | #define CFG_LOOP_RIGHT (1<<3) |
172 | #define CFG_HEIGHT_3SWITCH (1<<4) |
169 | #define CFG_HEIGHT_3SWITCH (1<<4) |
173 | 170 | ||
174 | #define ATMEGA644 0 |
171 | #define ATMEGA644 0 |
175 | #define ATMEGA644P 1 |
172 | #define ATMEGA644P 1 |
176 | #define SYSCLK F_CPU |
173 | #define SYSCLK F_CPU |
177 | 174 | ||
178 | // Not really a part of configuration, but heck, LEDs and beepers now have a home. |
175 | // Not really a part of configuration, but heck, LEDs and beepers now have a home. |
179 | #define RED_OFF {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
176 | #define RED_OFF {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
180 | #define RED_ON {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
177 | #define RED_ON {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
181 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
178 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
182 | #define GRN_OFF {if(BoardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
179 | #define GRN_OFF {if(BoardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
183 | #define GRN_ON {if(BoardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
180 | #define GRN_ON {if(BoardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
184 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
181 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
185 | 182 | ||
186 | // Mixer table |
183 | // Mixer table |
187 | #define MIX_THROTTLE 0 |
184 | #define MIX_THROTTLE 0 |
188 | #define MIX_PITCH 1 |
185 | #define MIX_PITCH 1 |
189 | #define MIX_ROLL 2 |
186 | #define MIX_ROLL 2 |
190 | #define MIX_YAW 3 |
187 | #define MIX_YAW 3 |
191 | 188 | ||
192 | extern volatile uint8_t MKFlags; |
189 | extern volatile uint8_t MKFlags; |
193 | extern int16_t variables[8]; |
190 | extern int16_t variables[8]; |
194 | extern uint8_t BoardRelease; |
191 | extern uint8_t BoardRelease; |
195 | extern uint8_t CPUType; |
192 | extern uint8_t CPUType; |
196 | 193 | ||
197 | void configuration_applyVariablesToParams(void); |
194 | void configuration_applyVariablesToParams(void); |
198 | uint8_t getCPUType(void); |
195 | uint8_t getCPUType(void); |
199 | uint8_t getBoardRelease(void); |
196 | uint8_t getBoardRelease(void); |
200 | 197 | ||
201 | // Not really a part of configuration, but heck, LEDs and beepers now have a home. |
198 | // Not really a part of configuration, but heck, LEDs and beepers now have a home. |
202 | void beep(uint16_t millis); |
199 | void beep(uint16_t millis); |
203 | void beepNumber(uint8_t numbeeps); |
200 | void beepNumber(uint8_t numbeeps); |
204 | void beepRCAlarm(void); |
201 | void beepRCAlarm(void); |
205 | void beepI2CAlarm(void); |
202 | void beepI2CAlarm(void); |
206 | void beepBatteryAlarm(void); |
203 | void beepBatteryAlarm(void); |
207 | 204 | ||
208 | #endif // _CONFIGURATION_H |
205 | #endif // _CONFIGURATION_H |
209 | 206 |