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