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