Rev 1910 | Rev 1927 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1910 | Rev 1926 | ||
---|---|---|---|
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 | /*PMM*/uint8_t HeightD; |
8 | /*PMM*/uint8_t HeightD; |
9 | /* P */uint8_t MaxHeight; |
9 | /* P */uint8_t MaxHeight; |
10 | /*PMM*/uint8_t HeightP; |
10 | /*PMM*/uint8_t HeightP; |
11 | /* P */uint8_t Height_ACC_Effect; |
11 | /* P */uint8_t Height_ACC_Effect; |
12 | /* P */uint8_t CompassYawEffect; |
12 | /* P */uint8_t CompassYawEffect; |
13 | /* P */uint8_t unnused; |
13 | /* P */uint8_t unnused; |
14 | 14 | ||
15 | /* P */uint8_t GyroPitchP; |
15 | /* P */uint8_t GyroPitchP; |
16 | /* P */uint8_t GyroRollP; |
16 | /* P */uint8_t GyroRollP; |
17 | /* P */uint8_t GyroYawP; |
17 | /* P */uint8_t GyroYawP; |
18 | - | ||
19 | /* P */uint8_t IFactor; |
18 | |
20 | /* P */uint8_t UserParams[8]; |
19 | /* P */uint8_t UserParams[8]; |
21 | /* P */uint8_t ServoPitchControl; |
20 | /* P */uint8_t ServoPitchControl; |
22 | 21 | ||
23 | /* P */uint8_t GyroPitchD; // LoopGasLimit in tool |
22 | /* P */uint8_t GyroPitchD; // LoopGasLimit in tool |
24 | /* P */uint8_t GyroRollD; // AxisCoupling1 in tool |
23 | /* P */uint8_t GyroRollD; // AxisCoupling1 in tool |
25 | /* P */uint8_t GyroYawD; // AxisCoupling2 in tool |
24 | /* P */uint8_t GyroYawD; // AxisCoupling2 in tool |
26 | 25 | ||
27 | /* P */uint8_t AxisCouplingYawCorrection; |
26 | /* P */uint8_t AxisCouplingYawCorrection; |
28 | /* P */uint8_t DynamicStability; |
27 | /* P */uint8_t DynamicStability; |
29 | /* P */uint8_t ExternalControl; |
28 | /* P */uint8_t ExternalControl; |
30 | /*PMM*/uint8_t J16Timing; |
29 | /*PMM*/uint8_t J16Timing; |
31 | /*PMM*/uint8_t J17Timing; |
30 | /*PMM*/uint8_t J17Timing; |
32 | /* P */uint8_t NaviGpsModeControl; |
31 | /* P */uint8_t NaviGpsModeControl; |
33 | /* P */uint8_t NaviGpsGain; |
32 | /* P */uint8_t NaviGpsGain; |
34 | /* P */uint8_t NaviGpsP; |
33 | /* P */uint8_t NaviGpsP; |
35 | /* P */uint8_t NaviGpsI; |
34 | /* P */uint8_t NaviGpsI; |
36 | /* P */uint8_t NaviGpsD; |
35 | /* P */uint8_t NaviGpsD; |
37 | /* P */uint8_t NaviGpsACC; |
36 | /* P */uint8_t NaviGpsACC; |
38 | /*PMM*/uint8_t NaviOperatingRadius; |
37 | /*PMM*/uint8_t NaviOperatingRadius; |
39 | /* P */uint8_t NaviWindCorrection; |
38 | /* P */uint8_t NaviWindCorrection; |
40 | /* P */uint8_t NaviSpeedCompensation; |
39 | /* P */uint8_t NaviSpeedCompensation; |
41 | int8_t KalmanK; |
40 | int8_t KalmanK; |
42 | int8_t KalmanMaxDrift; |
41 | int8_t KalmanMaxDrift; |
43 | int8_t KalmanMaxFusion; |
42 | int8_t KalmanMaxFusion; |
44 | } dynamicParam_t; |
43 | } dynamicParam_t; |
45 | extern dynamicParam_t dynamicParams; |
44 | extern dynamicParam_t dynamicParams; |
46 | 45 | ||
47 | typedef struct { |
46 | typedef struct { |
48 | uint8_t sourceIdx, targetIdx; |
47 | uint8_t sourceIdx, targetIdx; |
49 | uint8_t min, max; |
48 | uint8_t min, max; |
50 | } MMXLATION; |
49 | } MMXLATION; |
51 | 50 | ||
52 | typedef struct { |
51 | typedef struct { |
53 | uint8_t sourceIdx, targetIdx; |
52 | uint8_t sourceIdx, targetIdx; |
54 | } XLATION; |
53 | } XLATION; |
55 | 54 | ||
56 | // values above 250 representing poti1 to poti4 |
55 | // values above 250 representing poti1 to poti4 |
57 | typedef struct { |
56 | typedef struct { |
58 | uint8_t ChannelAssignment[8]; // see upper defines for details |
57 | uint8_t ChannelAssignment[8]; // see upper defines for details |
59 | uint8_t GlobalConfig; // see upper defines for bitcoding |
58 | uint8_t GlobalConfig; // see upper defines for bitcoding |
60 | uint8_t HeightMinGas; // Value : 0-100 |
59 | uint8_t HeightMinGas; // Value : 0-100 |
61 | uint8_t HeightD; // Value : 0-250 |
60 | uint8_t HeightD; // Value : 0-250 |
62 | uint8_t MaxHeight; // Value : 0-32 |
61 | uint8_t MaxHeight; // Value : 0-32 |
63 | uint8_t HeightP; // Value : 0-32 |
62 | uint8_t HeightP; // Value : 0-32 |
64 | uint8_t Height_Gain; // Value : 0-50 |
63 | uint8_t Height_Gain; // Value : 0-50 |
65 | uint8_t Height_ACC_Effect; // Value : 0-250 |
64 | uint8_t Height_ACC_Effect; // Value : 0-250 |
66 | 65 | ||
67 | uint8_t StickElevatorP; // StickP in tool. |
66 | uint8_t StickElevatorP; // StickP in tool. |
68 | uint8_t StickAileronsP; // StickD in tool. |
67 | uint8_t StickAileronsP; // StickD in tool. |
69 | uint8_t StickRudderP; // StickYawP in tool. |
68 | uint8_t StickRudderP; // StickYawP in tool. |
70 | - | ||
71 | uint8_t Unused3; |
- | |
72 | uint8_t Unused4; |
69 | |
73 | uint8_t GyroAccFactor; // Value : 1-64 |
70 | uint8_t GyroAccFactor; // Value : 1-64 |
74 | uint8_t CompassYawEffect; // Value : 0-32 |
71 | uint8_t CompassYawEffect; // Value : 0-32 |
75 | 72 | ||
76 | uint8_t GyroPitchP; // GyroP in tool |
73 | uint8_t GyroPitchP; // GyroP in tool |
77 | uint8_t GyroRollP; // GyroI in tool |
74 | uint8_t GyroRollP; // GyroI in tool |
78 | uint8_t GyroYawP; // GyroD in tool |
75 | uint8_t GyroYawP; // GyroD in tool |
- | 76 | ||
- | 77 | uint8_t UserParams[8]; // Value : 0-250 |
|
79 | 78 | ||
80 | uint8_t LowVoltageWarning; // Value : 0-250 |
- | |
81 | uint8_t Unused5; // Value : 0-250 //Gaswert bei Empüngsverlust |
- | |
82 | uint8_t Unused6; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
- | |
83 | uint8_t Unused7; // |
- | |
84 | uint8_t IFactor; // Value : 0-250 |
- | |
85 | uint8_t UserParams1[4]; // Value : 0-250 |
79 | uint8_t LowVoltageWarning; // Value : 0-250 |
86 | - | ||
87 | uint8_t ControlSigns; |
- | |
88 | uint8_t Unused9; |
- | |
89 | uint8_t Unused10; |
- | |
90 | 80 | ||
91 | uint8_t Unused11; // Value : 0-250 // Anschlag |
- | |
92 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
- | |
93 | - | ||
94 | uint8_t Unused16; |
- | |
95 | uint8_t Unused17; |
81 | uint8_t ControlSigns; |
96 | uint8_t Unused18; |
82 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
97 | 83 | ||
98 | uint8_t GyroPitchD; // LoopGasLimit in tool |
84 | uint8_t GyroPitchD; // LoopGasLimit in tool |
99 | uint8_t GyroRollD; // loopThreshold in tool |
85 | uint8_t GyroRollD; // loopThreshold in tool |
100 | uint8_t GyroYawD; // loopHysteresis in tool |
86 | uint8_t GyroYawD; // loopHysteresis in tool |
101 | - | ||
102 | uint8_t Unused19; |
- | |
103 | uint8_t Unused20; |
87 | |
104 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
88 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
105 | uint8_t DriftComp; // limit for gyrodrift compensation |
- | |
106 | uint8_t Unused21; // PID limit for Attitude controller |
- | |
107 | uint8_t UserParams2[4]; // Value : 0-250 |
89 | uint8_t DriftComp; // limit for gyrodrift compensation |
108 | 90 | ||
109 | uint8_t J16Bitmask; // for the J16 Output |
91 | uint8_t J16Bitmask; // for the J16 Output |
110 | uint8_t J16Timing; // for the J16 Output |
92 | uint8_t J16Timing; // for the J16 Output |
111 | uint8_t J17Bitmask; // for the J17 Output |
93 | uint8_t J17Bitmask; // for the J17 Output |
112 | uint8_t J17Timing; // for the J17 Output |
94 | uint8_t J17Timing; // for the J17 Output |
- | 95 | ||
113 | uint8_t ExternalControl; // for serial Control |
96 | uint8_t ExternalControl; // for serial Control |
114 | uint8_t BitConfig; // see upper defines for bitcoding |
97 | uint8_t BitConfig; // see upper defines for bitcoding |
115 | uint8_t ServoPitchCompInvert; // Value : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
- | |
- | 98 | ||
116 | uint8_t Reserved[4]; |
99 | uint8_t Reserved[4]; |
117 | int8_t Name[12]; |
- | |
118 | } paramset_t; |
100 | } paramset_t; |
119 | 101 | ||
120 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
102 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
121 | 103 | ||
122 | extern paramset_t staticParams; |
104 | extern paramset_t staticParams; |
123 | 105 | ||
124 | typedef struct { |
106 | typedef struct { |
125 | uint8_t Revision; |
107 | uint8_t Revision; |
126 | int8_t Name[12]; |
108 | int8_t Name[12]; |
127 | int8_t Motor[16][4]; |
109 | int8_t Motor[16][4]; |
128 | }__attribute__((packed)) MixerTable_t; |
110 | }__attribute__((packed)) MixerTable_t; |
129 | 111 | ||
130 | extern MixerTable_t Mixer; |
112 | extern MixerTable_t Mixer; |
131 | 113 | ||
132 | // MKFlags |
114 | // MKFlags |
133 | #define MKFLAG_MOTOR_RUN (1<<0) |
115 | #define MKFLAG_MOTOR_RUN (1<<0) |
134 | #define MKFLAG_FLY (1<<1) |
116 | #define MKFLAG_FLY (1<<1) |
135 | #define MKFLAG_CALIBRATE (1<<2) |
117 | #define MKFLAG_CALIBRATE (1<<2) |
136 | #define MKFLAG_START (1<<3) |
118 | #define MKFLAG_START (1<<3) |
137 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
119 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
138 | #define MKFLAG_RESERVE1 (1<<5) |
120 | #define MKFLAG_RESERVE1 (1<<5) |
139 | #define MKFLAG_RESERVE2 (1<<6) |
121 | #define MKFLAG_RESERVE2 (1<<6) |
140 | #define MKFLAG_RESERVE3 (1<<7) |
122 | #define MKFLAG_RESERVE3 (1<<7) |
141 | 123 | ||
142 | // bit mask for staticParams.GlobalConfig |
124 | // bit mask for staticParams.GlobalConfig |
143 | #define CFG_HEIGHT_CONTROL (1<<0) |
125 | #define CFG_HEIGHT_CONTROL (1<<0) |
144 | #define CFG_HEIGHT_SWITCH (1<<1) |
126 | #define CFG_HEIGHT_SWITCH (1<<1) |
145 | #define CFG_HEADING_HOLD (1<<2) |
127 | #define CFG_HEADING_HOLD (1<<2) |
146 | #define CFG_COMPASS_ACTIVE (1<<3) |
128 | #define CFG_COMPASS_ACTIVE (1<<3) |
147 | #define CFG_COMPASS_FIX (1<<4) |
129 | #define CFG_COMPASS_FIX (1<<4) |
148 | #define CFG_GPS_ACTIVE (1<<5) |
130 | #define CFG_GPS_ACTIVE (1<<5) |
149 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
131 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
150 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
132 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
151 | 133 | ||
152 | // bit mask for staticParams.BitConfig |
134 | // bit mask for staticParams.BitConfig |
153 | #define CFG_LOOP_UP (1<<0) |
135 | #define CFG_LOOP_UP (1<<0) |
154 | #define CFG_LOOP_DOWN (1<<1) |
136 | #define CFG_LOOP_DOWN (1<<1) |
155 | #define CFG_LOOP_LEFT (1<<2) |
137 | #define CFG_LOOP_LEFT (1<<2) |
156 | #define CFG_LOOP_RIGHT (1<<3) |
138 | #define CFG_LOOP_RIGHT (1<<3) |
157 | #define CFG_HEIGHT_3SWITCH (1<<4) |
139 | #define CFG_HEIGHT_3SWITCH (1<<4) |
158 | 140 | ||
159 | #define ATMEGA644 0 |
141 | #define ATMEGA644 0 |
160 | #define ATMEGA644P 1 |
142 | #define ATMEGA644P 1 |
161 | #define SYSCLK F_CPU |
143 | #define SYSCLK F_CPU |
162 | 144 | ||
163 | // Not really a part of configuration, but LEDs and HW version test are the same. |
145 | // Not really a part of configuration, but LEDs and HW version test are the same. |
164 | #define RED_OFF {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
146 | #define RED_OFF {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
165 | #define RED_ON {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
147 | #define RED_ON {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
166 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
148 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
167 | #define GRN_OFF {if(BoardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
149 | #define GRN_OFF {if(BoardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
168 | #define GRN_ON {if(BoardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
150 | #define GRN_ON {if(BoardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
169 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
151 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
170 | 152 | ||
171 | // Mixer table |
153 | // Mixer table |
172 | #define MIX_THROTTLE 0 |
154 | #define MIX_THROTTLE 0 |
173 | #define MIX_PITCH 1 |
155 | #define MIX_PITCH 1 |
174 | #define MIX_ROLL 2 |
156 | #define MIX_ROLL 2 |
175 | #define MIX_YAW 3 |
157 | #define MIX_YAW 3 |
176 | 158 | ||
177 | extern volatile uint8_t MKFlags; |
159 | extern volatile uint8_t MKFlags; |
178 | extern int16_t variables[8]; // The "Poti"s. |
160 | extern int16_t variables[8]; // The "Poti"s. |
179 | extern uint8_t BoardRelease; |
161 | extern uint8_t BoardRelease; |
180 | extern uint8_t CPUType; |
162 | extern uint8_t CPUType; |
181 | 163 | ||
182 | void configuration_staticToDynamic(void); |
164 | void configuration_staticToDynamic(void); |
183 | uint8_t getCPUType(void); |
165 | uint8_t getCPUType(void); |
184 | uint8_t getBoardRelease(void); |
166 | uint8_t getBoardRelease(void); |
185 | 167 | ||
186 | #endif // _CONFIGURATION_H |
168 | #endif // _CONFIGURATION_H |
187 | 169 |