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