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