Rev 2025 | Rev 2102 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2025 | Rev 2099 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | #define _CONFIGURATION_H |
2 | #define _CONFIGURATION_H |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | #include <inttypes.h> |
4 | #include <inttypes.h> |
Line -... | Line 5... | ||
- | 5 | #include <avr/io.h> |
|
- | 6 | ||
- | 7 | #define MAX_CHANNELS 10 |
|
- | 8 | #define MAX_MOTORS 12 |
|
- | 9 | ||
- | 10 | // bitmask for VersionInfo_t.HardwareError[0] |
|
- | 11 | #define FC_ERROR0_GYRO_PITCH 0x01 |
|
- | 12 | #define FC_ERROR0_GYRO_ROLL 0x02 |
|
- | 13 | #define FC_ERROR0_GYRO_YAW 0x04 |
|
- | 14 | #define FC_ERROR0_ACC_X 0x08 |
|
- | 15 | #define FC_ERROR0_ACC_Y 0x10 |
|
- | 16 | #define FC_ERROR0_ACC_Z 0x20 |
|
- | 17 | #define FC_ERROR0_PRESSURE 0x40 |
|
- | 18 | #define FC_ERROR1_RES0 0x80 |
|
- | 19 | // bitmask for VersionInfo_t.HardwareError[1] |
|
- | 20 | #define FC_ERROR1_I2C 0x01 |
|
- | 21 | #define FC_ERROR1_BL_MISSING 0x02 |
|
- | 22 | #define FC_ERROR1_SPI_RX 0x04 |
|
- | 23 | #define FC_ERROR1_PPM 0x08 |
|
- | 24 | #define FC_ERROR1_MIXER 0x10 |
|
- | 25 | #define FC_ERROR1_RES1 0x20 |
|
- | 26 | #define FC_ERROR1_RES2 0x40 |
|
5 | #include <avr/io.h> |
27 | #define FC_ERROR1_RES3 0x80 |
6 | 28 | ||
7 | typedef struct { |
29 | typedef struct { |
8 | /*PMM*/uint8_t HeightD; |
30 | uint8_t SWMajor; |
9 | /* P */uint8_t MaxHeight; |
31 | uint8_t SWMinor; |
- | 32 | uint8_t protoMajor; |
|
10 | /*PMM*/uint8_t HeightP; |
33 | uint8_t protoMinor; |
- | 34 | uint8_t SWPatch; |
|
- | 35 | uint8_t hardwareErrors[5]; |
|
- | 36 | }__attribute__((packed)) VersionInfo_t; |
|
11 | /* P */uint8_t Height_ACC_Effect; |
37 | |
- | 38 | extern VersionInfo_t versionInfo; |
|
12 | /* P */uint8_t CompassYawEffect; |
39 | |
13 | 40 | typedef struct { |
|
14 | /* P */uint8_t GyroPitchP; |
41 | /*PMM*/uint8_t gyroPitchD; |
15 | /* P */uint8_t GyroRollP; |
42 | /* P */uint8_t gyroRollD; |
16 | /* P */uint8_t GyroYawP; |
43 | /* P */uint8_t gyroYawD; |
17 | 44 | ||
18 | /* P */uint8_t UserParams[8]; |
45 | // Control |
- | 46 | /* P */uint8_t externalControl; |
|
- | 47 | ||
19 | /* P */uint8_t ServoPitchControl; |
48 | // Height control |
20 | 49 | /*PMM*/uint8_t heightP; |
|
21 | /* P */uint8_t GyroPitchD; // LoopGasLimit in tool |
50 | /* P */uint8_t heightI; |
22 | /* P */uint8_t GyroRollD; // AxisCoupling1 in tool |
51 | /*PMM*/uint8_t heightD; |
- | 52 | /* P */uint8_t heightSetting; |
|
23 | /* P */uint8_t GyroYawD; // AxisCoupling2 in tool |
53 | |
24 | 54 | // Output and servo |
|
- | 55 | /*PMM*/uint8_t output0Timing; |
|
- | 56 | /*PMM*/uint8_t output1Timing; |
|
- | 57 | ||
25 | /* P */uint8_t ExternalControl; |
58 | uint8_t servoManualControl[2]; |
26 | /*PMM*/uint8_t J16Timing; |
59 | |
- | 60 | /* P */uint8_t userParams[8]; |
|
27 | /*PMM*/uint8_t J17Timing; |
61 | } DynamicParams_t; |
Line 28... | Line 62... | ||
28 | } dynamicParam_t; |
62 | |
29 | extern dynamicParam_t dynamicParams; |
63 | extern volatile DynamicParams_t dynamicParams; |
30 | 64 | ||
31 | typedef struct { |
65 | typedef struct { |
Line -... | Line 66... | ||
- | 66 | uint8_t sourceIdx, targetIdx; |
|
32 | uint8_t sourceIdx, targetIdx; |
67 | uint8_t min, max; |
33 | uint8_t min, max; |
68 | } MMXLATION; |
34 | } MMXLATION; |
69 | |
- | 70 | /* |
|
Line 35... | Line -... | ||
35 | - | ||
36 | typedef struct { |
71 | typedef struct { |
37 | uint8_t sourceIdx, targetIdx; |
- | |
38 | } XLATION; |
- | |
39 | - | ||
40 | // values above 250 representing poti1 to poti4 |
72 | uint8_t sourceIdx, targetIdx; |
41 | typedef struct { |
73 | } XLATION; |
42 | uint8_t ChannelAssignment[8]; // see upper defines for details |
74 | */ |
43 | uint8_t GlobalConfig; // see upper defines for bitcoding |
- | |
44 | uint8_t HeightMinGas; // Value : 0-100 |
- | |
Line -... | Line 75... | ||
- | 75 | ||
45 | uint8_t HeightD; // Value : 0-250 |
76 | typedef struct { |
46 | uint8_t MaxHeight; // Value : 0-32 |
77 | uint8_t channels[MAX_CHANNELS]; |
- | 78 | } channelMap_t; |
|
47 | uint8_t HeightP; // Value : 0-32 |
79 | extern channelMap_t channelMap; |
Line -... | Line 80... | ||
- | 80 | ||
48 | uint8_t Height_Gain; // Value : 0-50 |
81 | typedef struct { |
- | 82 | char name[12]; |
|
Line -... | Line 83... | ||
- | 83 | int8_t motor[MAX_MOTORS][4]; |
|
- | 84 | }__attribute__((packed)) mixerMatrix_t; |
|
49 | uint8_t Height_ACC_Effect; // Value : 0-250 |
85 | extern mixerMatrix_t mixerMatrix; |
50 | 86 | ||
- | 87 | typedef struct { |
|
- | 88 | int16_t offsets[3]; |
|
- | 89 | } sensorOffset_t; |
|
Line 51... | Line 90... | ||
51 | uint8_t StickElevatorP; |
90 | |
Line -... | Line 91... | ||
- | 91 | typedef struct { |
|
52 | uint8_t StickAileronsP; |
92 | uint8_t manualControl; |
53 | uint8_t StickRudderP; |
93 | uint8_t stabilizationFactor; |
54 | 94 | uint8_t minValue; |
|
Line -... | Line 95... | ||
- | 95 | uint8_t maxValue; |
|
- | 96 | uint8_t flags; |
|
- | 97 | } servo_t; |
|
- | 98 | ||
- | 99 | #define SERVO_STABILIZATION_REVERSE 1 |
|
- | 100 | ||
- | 101 | typedef struct { |
|
- | 102 | uint8_t bitmask; |
|
- | 103 | uint8_t timing; |
|
- | 104 | } output_flash_t; |
|
55 | uint8_t PIDGyroFilter;// Value: 1-8 |
105 | |
- | 106 | typedef struct { |
|
- | 107 | uint8_t gyroQuadrant; |
|
- | 108 | uint8_t accQuadrant; |
|
- | 109 | uint8_t imuReversedFlags; |
|
- | 110 | ||
- | 111 | uint8_t gyroPIDFilterConstant; |
|
Line 56... | Line 112... | ||
56 | 112 | uint8_t gyroDWindowLength; |
|
Line -... | Line 113... | ||
- | 113 | uint8_t gyroDFilterConstant; |
|
- | 114 | uint8_t accFilterConstant; |
|
57 | uint8_t DGyroFilter; // Value: 1-8 |
115 | |
58 | uint8_t attitudeGyroFilter; // Value: 1-8 |
116 | uint8_t zerothOrderCorrection; |
Line 59... | Line 117... | ||
59 | 117 | uint8_t rateTolerance; |
|
60 | uint8_t accFilter; |
118 | |
61 | 119 | uint8_t gyroActivityDamping; |
|
Line 62... | Line 120... | ||
62 | uint8_t GyroPitchP; |
120 | uint8_t driftCompDivider; // 1/k (Koppel_ACC_Wirkung) |
63 | uint8_t GyroRollP; |
- | |
Line -... | Line 121... | ||
- | 121 | uint8_t driftCompLimit; // limit for gyrodrift compensation |
|
64 | uint8_t GyroYawP; |
122 | } IMUConfig_t; |
65 | 123 | ||
66 | uint8_t UserParams[8]; // Value : 0-250 |
124 | extern IMUConfig_t IMUConfig; |
Line 67... | Line -... | ||
67 | - | ||
68 | uint8_t LowVoltageWarning; // Value : 0-250 |
125 | |
69 | 126 | // values above 250 representing poti1 to poti4 |
|
70 | uint8_t servoDirections; |
127 | typedef struct { |
Line 71... | Line 128... | ||
71 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
128 | // Global bitflags |
72 | 129 | uint8_t bitConfig; // see upper defines for bitcoding |
|
- | 130 | ||
Line -... | Line 131... | ||
- | 131 | // uint8_t axisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
|
73 | uint8_t GyroPitchD; |
132 | // uint8_t axisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
- | 133 | // uint8_t axisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
|
Line 74... | Line 134... | ||
74 | uint8_t GyroRollD; |
134 | |
Line 75... | Line 135... | ||
75 | uint8_t GyroYawD; |
135 | uint8_t levelCorrection[2]; |
- | 136 | ||
76 | 137 | // Control |
|
77 | uint8_t zerothOrderGyroCorrectionZAccLimit; |
138 | uint8_t gyroPitchP; |
- | 139 | uint8_t gyroPitchI; |
|
- | 140 | uint8_t gyroPitchD; |
|
- | 141 | ||
78 | uint8_t zerothOrderGyroCorrectionFactorx1000; |
142 | uint8_t gyroRollP; |
79 | 143 | uint8_t gyroRollI; |
|
- | 144 | uint8_t gyroRollD; |
|
Line -... | Line 145... | ||
- | 145 | ||
- | 146 | uint8_t gyroYawP; |
|
- | 147 | uint8_t gyroYawI; |
|
- | 148 | uint8_t gyroYawD; |
|
- | 149 | ||
- | 150 | uint8_t stickIElevator; |
|
- | 151 | uint8_t stickIAilerons; |
|
- | 152 | uint8_t stickIRudder; |
|
- | 153 | ||
- | 154 | uint8_t externalControl; // for serial Control |
|
- | 155 | ||
- | 156 | uint8_t IFactor; |
|
80 | uint8_t secondOrderGyroCorrectionDivisor; |
157 | |
Line 81... | Line 158... | ||
81 | uint8_t secondOrderGyroCorrectionLimit; |
158 | uint8_t batteryVoltageWarning; |
82 | uint8_t CompassYawEffect; // Value : 0-32 |
159 | uint8_t emergencyThrottle; |
83 | 160 | uint8_t emergencyFlightDuration; |
|
84 | uint8_t J16Bitmask; // for the J16 Output |
161 | |
85 | uint8_t J16Timing; // for the J16 Output |
162 | // Servos |
86 | uint8_t J17Bitmask; // for the J17 Output |
163 | uint8_t servoCount; |
87 | uint8_t J17Timing; // for the J17 Output |
164 | uint8_t servoManualMaxSpeed; |
88 | 165 | servo_t servoConfigurations[2]; // [PITCH, ROLL] |
|
89 | uint8_t ExternalControl; // for serial Control |
166 | |
Line 90... | Line 167... | ||
90 | } paramset_t; |
167 | // Outputs |
91 | 168 | output_flash_t outputFlash[2]; |
|
92 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
169 | uint8_t outputDebugMask; |
93 | 170 | uint8_t outputFlags; |
|
94 | extern paramset_t staticParams; |
171 | |
95 | 172 | // User params |
|
96 | typedef struct { |
173 | uint8_t userParams[8]; |
97 | uint8_t Revision; |
174 | |
98 | int8_t Name[12]; |
175 | // Name |
99 | int8_t Motor[16][4]; |
176 | char name[12]; |
100 | }__attribute__((packed)) MixerTable_t; |
177 | } ParamSet_t; |
101 | 178 | ||
102 | extern MixerTable_t Mixer; |
179 | extern ParamSet_t staticParams; |
103 | 180 | ||
Line 104... | Line 181... | ||
104 | // MKFlags |
181 | // MKFlags |
105 | #define MKFLAG_MOTOR_RUN (1<<0) |
182 | #define MKFLAG_MOTOR_RUN (1<<0) |
106 | #define MKFLAG_FLY (1<<1) |
183 | //#define MKFLAG_FLY (1<<1) |
Line 107... | Line 184... | ||
107 | #define MKFLAG_CALIBRATE (1<<2) |
184 | #define MKFLAG_CALIBRATE (1<<2) |
108 | #define MKFLAG_START (1<<3) |
185 | #define MKFLAG_START (1<<3) |
109 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
186 | #define MKFLAG_EMERGENCY_FLIGHT (1<<4) |
110 | #define MKFLAG_RESERVE1 (1<<5) |
187 | #define MKFLAG_LOWBAT (1<<5) |
111 | #define MKFLAG_RESERVE2 (1<<6) |
188 | #define MKFLAG_RESERVE2 (1<<6) |
112 | #define MKFLAG_RESERVE3 (1<<7) |
189 | #define MKFLAG_RESERVE3 (1<<7) |
113 | 190 | ||
Line 114... | Line 191... | ||
114 | // bit mask for staticParams.GlobalConfig |
191 | // bit mask for staticParams.bitConfig |
115 | #define CFG_HEIGHT_CONTROL (1<<0) |
192 | #define CFG_SIMPLE_HEIGHT_CONTROL (1<<0) |
116 | #define CFG_HEIGHT_SWITCH (1<<1) |
193 | #define CFG_SIMPLE_HC_HOLD_SWITCH (1<<1) |
117 | #define CFG_HEADING_HOLD (1<<2) |
194 | #define CFG_HEADING_HOLD (1<<2) |
118 | #define CFG_COMPASS_ACTIVE (1<<3) |
195 | #define CFG_COMPASS_ENABLED (1<<3) |
Line -... | Line 196... | ||
- | 196 | #define CFG_UNUSED (1<<4) |
|
- | 197 | #define CFG_NAVI_ENABLED (1<<5) |
|
119 | #define CFG_COMPASS_FIX (1<<4) |
198 | #define CFG_AXIS_COUPLING_ENABLED (1<<6) |
- | 199 | #define CFG_GYRO_SATURATION_PREVENTION (1<<7) |
|
120 | #define CFG_GPS_ACTIVE (1<<5) |
200 | |
121 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
201 | #define IMU_REVERSE_GYRO_PR (1<<0) |
122 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
202 | #define IMU_REVERSE_GYRO_YAW (1<<1) |
Line -... | Line 203... | ||
- | 203 | #define IMU_REVERSE_ACC_XY (1<<2) |
|
- | 204 | #define IMU_REVERSE_ACC_Z (1<<3) |
|
- | 205 | ||
- | 206 | #define ATMEGA644 0 |
|
- | 207 | #define ATMEGA644P 1 |
|
- | 208 | #define SYSCLK F_CPU |
|
- | 209 | ||
- | 210 | // Not really a part of configuration, but LEDs and HW s test are the same. |
|
- | 211 | #define RED_OFF {if((boardRelease == 10) || (boardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
|
- | 212 | #define RED_ON {if((boardRelease == 10) || (boardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
|
123 | 213 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
|
- | 214 | #define GRN_OFF {if(boardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
|
124 | // bit mask for staticParams.ServoDirections |
215 | #define GRN_ON {if(boardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
125 | #define SERVO_DIRECTION_ELEVATOR (1<<0) |
216 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
Line -... | Line 217... | ||
- | 217 | ||
- | 218 | // Mixer table |
|
126 | #define SERVO_DIRECTION_AILERONS (1<<1) |
219 | #define MIX_THROTTLE 0 |