Rev 1964 | Rev 1969 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1964 | Rev 1965 | ||
---|---|---|---|
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 | #define MAX_CHANNELS 10 |
7 | #define MAX_CHANNELS 10 |
8 | #define MAX_MOTORS 12 |
8 | #define MAX_MOTORS 12 |
9 | 9 | ||
10 | typedef struct { |
10 | typedef struct { |
11 | // IMU |
11 | // IMU |
12 | /*PMM*/uint8_t gyroP; |
12 | /*PMM*/uint8_t gyroP; |
13 | /* P */uint8_t gyroD; |
13 | /* P */uint8_t gyroD; |
14 | /* P */uint8_t gyroI; |
14 | /* P */uint8_t gyroI; |
15 | /* P */uint8_t IFactor; |
15 | /* P */uint8_t IFactor; |
16 | uint8_t yawIFactor; |
16 | uint8_t yawIFactor; |
17 | /* P */uint8_t compassYawEffect; |
17 | /* P */uint8_t compassYawEffect; |
18 | 18 | ||
19 | // Control |
19 | // Control |
20 | /* P */uint8_t externalControl; |
20 | /* P */uint8_t externalControl; |
21 | 21 | ||
22 | /* P */uint8_t axisCoupling1; |
22 | /* P */uint8_t axisCoupling1; |
23 | /* P */uint8_t axisCoupling2; |
23 | /* P */uint8_t axisCoupling2; |
24 | /* P */uint8_t axisCouplingYawCorrection; |
24 | /* P */uint8_t axisCouplingYawCorrection; |
25 | /* P */uint8_t dynamicStability; |
25 | /* P */uint8_t dynamicStability; |
26 | uint8_t maxControlActivityForAcc; |
26 | uint8_t maxControlActivityForAcc; |
27 | 27 | ||
28 | // Height control |
28 | // Height control |
29 | /*PMM*/uint8_t heightP; |
29 | /*PMM*/uint8_t heightP; |
30 | /*PMM*/uint8_t heightD; |
30 | /*PMM*/uint8_t heightD; |
31 | /* P */uint8_t heightSetting; |
31 | /* P */uint8_t heightSetting; |
32 | /* P */uint8_t heightACCEffect; |
32 | /* P */uint8_t heightACCEffect; |
33 | 33 | ||
34 | uint8_t attitudeControl; |
34 | uint8_t attitudeControl; |
35 | 35 | ||
36 | // The rest... |
36 | // The rest... |
37 | /* P */uint8_t userParams[8]; |
37 | /* P */uint8_t userParams[8]; |
38 | /*PMM*/uint8_t output0Timing; |
38 | /*PMM*/uint8_t output0Timing; |
39 | /*PMM*/uint8_t output1Timing; |
39 | /*PMM*/uint8_t output1Timing; |
40 | 40 | ||
41 | uint8_t servoManualControl[2]; |
41 | uint8_t servoManualControl[2]; |
42 | 42 | ||
43 | uint8_t motorSmoothing; |
43 | uint8_t motorSmoothing; |
44 | } dynamicParam_t; |
44 | } dynamicParam_t; |
45 | 45 | ||
46 | extern dynamicParam_t dynamicParams; |
46 | extern dynamicParam_t dynamicParams; |
47 | 47 | ||
48 | typedef struct { |
48 | typedef struct { |
49 | uint8_t sourceIdx, targetIdx; |
49 | uint8_t sourceIdx, targetIdx; |
50 | uint8_t min, max; |
50 | uint8_t min, max; |
51 | } MMXLATION; |
51 | } MMXLATION; |
52 | 52 | ||
53 | typedef struct { |
53 | typedef struct { |
54 | uint8_t sourceIdx, targetIdx; |
54 | uint8_t sourceIdx, targetIdx; |
55 | } XLATION; |
55 | } XLATION; |
56 | 56 | ||
57 | typedef struct { |
57 | typedef struct { |
58 | uint8_t channels[MAX_CHANNELS]; |
58 | uint8_t channels[MAX_CHANNELS]; |
59 | } channelMap_t; |
59 | } channelMap_t; |
60 | extern channelMap_t channelMap; |
60 | extern channelMap_t channelMap; |
61 | 61 | ||
62 | typedef struct { |
62 | typedef struct { |
63 | int8_t name[12]; |
63 | int8_t name[12]; |
64 | int8_t motor[MAX_MOTORS][4]; |
64 | int8_t motor[MAX_MOTORS][4]; |
65 | }__attribute__((packed)) mixerMatrix_t; |
65 | }__attribute__((packed)) mixerMatrix_t; |
66 | extern mixerMatrix_t mixerMatrix; |
66 | extern mixerMatrix_t mixerMatrix; |
67 | 67 | ||
68 | typedef struct { |
68 | typedef struct { |
- | 69 | int16_t offsets[3]; |
|
- | 70 | } sensorOffset_t; |
|
- | 71 | ||
- | 72 | typedef struct { |
|
69 | uint8_t manualControl; |
73 | uint8_t manualControl; |
70 | uint8_t compensationFactor; |
74 | uint8_t compensationFactor; |
71 | uint8_t minValue; |
75 | uint8_t minValue; |
72 | uint8_t maxValue; |
76 | uint8_t maxValue; |
73 | uint8_t flags; |
77 | uint8_t flags; |
74 | } servo_t; |
78 | } servo_t; |
75 | 79 | ||
76 | typedef struct { |
80 | typedef struct { |
77 | uint8_t bitmask; |
81 | uint8_t bitmask; |
78 | uint8_t timing; |
82 | uint8_t timing; |
79 | } output_flash_t; |
83 | } output_flash_t; |
80 | 84 | ||
81 | // values above 250 representing poti1 to poti4 |
85 | // values above 250 representing poti1 to poti4 |
82 | typedef struct { |
86 | typedef struct { |
83 | // Global bitflags |
87 | // Global bitflags |
84 | uint8_t bitConfig; // see upper defines for bitcoding |
88 | uint8_t bitConfig; // see upper defines for bitcoding |
85 | 89 | ||
86 | // Height Control |
90 | // Height Control |
87 | uint8_t heightP; // Value : 0-32 |
91 | uint8_t heightP; // Value : 0-32 |
88 | uint8_t heightD; // Value : 0-250 |
92 | uint8_t heightD; // Value : 0-250 |
89 | uint8_t heightSetting; // Value : 0-32 |
93 | uint8_t heightSetting; // Value : 0-32 |
90 | uint8_t heightControlMaxThrottleChange; // Value : 0-100 |
94 | uint8_t heightControlMaxThrottleChange; // Value : 0-100 |
91 | uint8_t heightSlewRate; // Value : 0-50 |
95 | uint8_t heightSlewRate; // Value : 0-50 |
92 | uint8_t heightACCEffect; // Value : 0-250 |
96 | uint8_t heightACCEffect; // Value : 0-250 |
93 | 97 | ||
94 | // Attitude Control |
98 | // Attitude Control |
95 | uint8_t attitudeControl; |
99 | uint8_t attitudeControl; |
96 | 100 | ||
97 | // Control |
101 | // Control |
98 | uint8_t stickP; // Value : 1-6 |
102 | uint8_t stickP; // Value : 1-6 |
99 | uint8_t stickD; // Value : 0-64 |
103 | uint8_t stickD; // Value : 0-64 |
100 | uint8_t stickYawP; // Value : 1-20 |
104 | uint8_t stickYawP; // Value : 1-20 |
101 | uint8_t stickThrottleD; |
105 | uint8_t stickThrottleD; |
102 | uint8_t minThrottle; // Value : 0-32 |
106 | uint8_t minThrottle; // Value : 0-32 |
103 | uint8_t maxThrottle; // Value : 33-250 |
107 | uint8_t maxThrottle; // Value : 33-250 |
104 | uint8_t externalControl; // for serial Control |
108 | uint8_t externalControl; // for serial Control |
105 | uint8_t maxControlActivityForAcc; |
109 | uint8_t maxControlActivityForAcc; |
106 | 110 | ||
107 | // IMU |
111 | // IMU |
108 | uint8_t gyroPIDFilterConstant; |
112 | uint8_t gyroPIDFilterConstant; |
109 | uint8_t gyroATTFilterConstant; |
113 | uint8_t gyroATTFilterConstant; |
110 | uint8_t gyroDFilterConstant; |
114 | uint8_t gyroDFilterConstant; |
111 | uint8_t accFilterConstant; |
115 | uint8_t accFilterConstant; |
112 | 116 | ||
113 | uint8_t gyroP; // Value : 10-250 |
117 | uint8_t gyroP; // Value : 10-250 |
114 | uint8_t gyroI; // Value : 0-250 |
118 | uint8_t gyroI; // Value : 0-250 |
115 | uint8_t gyroD; // Value : 0-250 |
119 | uint8_t gyroD; // Value : 0-250 |
116 | 120 | ||
117 | uint8_t zerothOrderCorrection; // Value : 1-64 |
121 | uint8_t zerothOrderCorrection; // Value : 1-64 |
118 | uint8_t driftCompDivider; // 1/k (Koppel_ACC_Wirkung) |
122 | uint8_t driftCompDivider; // 1/k (Koppel_ACC_Wirkung) |
119 | uint8_t driftCompLimit; // limit for gyrodrift compensation |
123 | uint8_t driftCompLimit; // limit for gyrodrift compensation |
120 | 124 | ||
121 | uint8_t axisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
125 | uint8_t axisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
122 | uint8_t axisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
126 | uint8_t axisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
123 | uint8_t axisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
127 | uint8_t axisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
124 | 128 | ||
125 | uint8_t dynamicStability; // PID limit for Attitude controller |
129 | uint8_t dynamicStability; // PID limit for Attitude controller |
126 | uint8_t IFactor; // Value : 0-250 |
130 | uint8_t IFactor; // Value : 0-250 |
127 | uint8_t yawIFactor; |
131 | uint8_t yawIFactor; |
128 | uint8_t compassYawEffect; // Value : 0-32 |
132 | uint8_t compassYawEffect; // Value : 0-32 |
129 | 133 | ||
130 | // Servos |
134 | // Servos |
131 | servo_t servoConfigurations[2]; // [PITCH, ROLL] |
135 | servo_t servoConfigurations[2]; // [PITCH, ROLL] |
132 | uint8_t servoCount; |
136 | uint8_t servoCount; |
133 | 137 | ||
134 | // Battery warning and emergency flight |
138 | // Battery warning and emergency flight |
135 | uint8_t batteryVoltageWarning; // Value : 0-250 |
139 | uint8_t batteryVoltageWarning; // Value : 0-250 |
136 | uint8_t emergencyThrottle; // Value : 0-250 //Gaswert bei Emp�ngsverlust /* |
140 | uint8_t emergencyThrottle; // Value : 0-250 //Gaswert bei Emp�ngsverlust /* |
137 | uint8_t emergencyFlightDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
141 | uint8_t emergencyFlightDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
138 | 142 | ||
139 | // Outputs |
143 | // Outputs |
140 | output_flash_t outputFlash[2]; |
144 | output_flash_t outputFlash[2]; |
141 | uint8_t outputDebugMask; |
145 | uint8_t outputDebugMask; |
142 | uint8_t outputOptions; |
146 | uint8_t outputOptions; |
143 | 147 | ||
144 | // User params |
148 | // User params |
145 | uint8_t userParams[8]; // Value : 0-250 |
149 | uint8_t userParams[8]; // Value : 0-250 |
146 | 150 | ||
147 | // Name |
151 | // Name |
148 | uint8_t name[12]; |
152 | uint8_t name[12]; |
149 | } paramset_t; |
153 | } paramset_t; |
150 | extern paramset_t staticParams; |
154 | extern paramset_t staticParams; |
151 | 155 | ||
152 | // MKFlags |
156 | // MKFlags |
153 | #define MKFLAG_MOTOR_RUN (1<<0) |
157 | #define MKFLAG_MOTOR_RUN (1<<0) |
154 | #define MKFLAG_FLY (1<<1) |
158 | #define MKFLAG_FLY (1<<1) |
155 | #define MKFLAG_CALIBRATE (1<<2) |
159 | #define MKFLAG_CALIBRATE (1<<2) |
156 | #define MKFLAG_START (1<<3) |
160 | #define MKFLAG_START (1<<3) |
157 | #define MKFLAG_EMERGENCY_FLIGHT (1<<4) |
161 | #define MKFLAG_EMERGENCY_FLIGHT (1<<4) |
158 | #define MKFLAG_RESERVE1 (1<<5) |
162 | #define MKFLAG_RESERVE1 (1<<5) |
159 | #define MKFLAG_RESERVE2 (1<<6) |
163 | #define MKFLAG_RESERVE2 (1<<6) |
160 | #define MKFLAG_RESERVE3 (1<<7) |
164 | #define MKFLAG_RESERVE3 (1<<7) |
161 | 165 | ||
162 | // bit mask for staticParams.bitConfig |
166 | // bit mask for staticParams.bitConfig |
163 | #define CFG_SIMPLE_HEIGHT_CONTROL (1<<0) |
167 | #define CFG_SIMPLE_HEIGHT_CONTROL (1<<0) |
164 | #define CFG_SIMPLE_HC_HOLD_SWITCH (1<<1) |
168 | #define CFG_SIMPLE_HC_HOLD_SWITCH (1<<1) |
165 | #define CFG_HEADING_HOLD (1<<2) |
169 | #define CFG_HEADING_HOLD (1<<2) |
166 | #define CFG_COMPASS_ACTIVE (1<<3) |
170 | #define CFG_COMPASS_ACTIVE (1<<3) |
167 | #define CFG_COMPASS_FIX (1<<4) |
171 | #define CFG_COMPASS_FIX (1<<4) |
168 | #define CFG_GPS_ACTIVE (1<<5) |
172 | #define CFG_GPS_ACTIVE (1<<5) |
169 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
173 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
170 | #define CFG_GYRO_SATURATION_PREVENTION (1<<7) |
174 | #define CFG_GYRO_SATURATION_PREVENTION (1<<7) |
171 | 175 | ||
172 | #define ATMEGA644 0 |
176 | #define ATMEGA644 0 |
173 | #define ATMEGA644P 1 |
177 | #define ATMEGA644P 1 |
174 | #define SYSCLK F_CPU |
178 | #define SYSCLK F_CPU |
175 | 179 | ||
176 | // Not really a part of configuration, but LEDs and HW version test are the same. |
180 | // Not really a part of configuration, but LEDs and HW version test are the same. |
177 | #define RED_OFF {if((boardRelease == 10) || (boardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
181 | #define RED_OFF {if((boardRelease == 10) || (boardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
178 | #define RED_ON {if((boardRelease == 10) || (boardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
182 | #define RED_ON {if((boardRelease == 10) || (boardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
179 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
183 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
180 | #define GRN_OFF {if(boardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
184 | #define GRN_OFF {if(boardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
181 | #define GRN_ON {if(boardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
185 | #define GRN_ON {if(boardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
182 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
186 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
183 | 187 | ||
184 | // Mixer table |
188 | // Mixer table |
185 | #define MIX_THROTTLE 0 |
189 | #define MIX_THROTTLE 0 |
186 | #define MIX_PITCH 1 |
190 | #define MIX_PITCH 1 |
187 | #define MIX_ROLL 2 |
191 | #define MIX_ROLL 2 |
188 | #define MIX_YAW 3 |
192 | #define MIX_YAW 3 |
189 | 193 | ||
190 | #define VARIABLE_COUNT 8 |
194 | #define VARIABLE_COUNT 8 |
191 | 195 | ||
192 | extern volatile uint8_t MKFlags; |
196 | extern volatile uint8_t MKFlags; |
193 | extern uint8_t requiredMotors; |
197 | extern uint8_t requiredMotors; |
194 | extern int16_t variables[VARIABLE_COUNT]; // The "Poti"s. |
198 | extern int16_t variables[VARIABLE_COUNT]; // The "Poti"s. |
195 | extern uint8_t boardRelease; |
199 | extern uint8_t boardRelease; |
196 | extern uint8_t CPUType; |
200 | extern uint8_t CPUType; |
197 | 201 | ||
198 | extern volatile uint8_t MKFlags; |
202 | extern volatile uint8_t MKFlags; |
199 | extern uint16_t isFlying; |
203 | extern uint16_t isFlying; |
200 | 204 | ||
201 | void channelMap_default(void); |
205 | void channelMap_default(void); |
202 | void paramSet_default(uint8_t setnumber); |
206 | void paramSet_default(uint8_t setnumber); |
203 | void mixerMatrix_default(void); |
207 | void mixerMatrix_default(void); |
204 | 208 | ||
205 | void configuration_applyVariablesToParams(void); |
209 | void configuration_applyVariablesToParams(void); |
206 | uint8_t getCPUType(void); |
210 | uint8_t getCPUType(void); |
207 | uint8_t getBoardRelease(void); |
211 | uint8_t getBoardRelease(void); |
208 | 212 | ||
209 | #endif // _CONFIGURATION_H |
213 | #endif // _CONFIGURATION_H |
210 | 214 |