Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1538 | killagreg | 1 | #ifndef _EEPROM_H |
2 | #define _EEPROM_H |
||
3 | |||
4 | #include <inttypes.h> |
||
5 | |||
6 | #define EEPROM_ADR_PARAM_BEGIN 0 |
||
7 | #define PID_PARAM_REVISION 1 // byte |
||
8 | #define PID_ACTIVE_SET 2 // byte |
||
9 | #define PID_PRESSURE_OFFSET 3 // byte |
||
10 | |||
11 | #define PID_ACC_NICK 4 // word |
||
12 | #define PID_ACC_ROLL 6 // word |
||
13 | #define PID_ACC_TOP 8 // word |
||
14 | |||
15 | #define PID_FLIGHT_MINUTES_TOTAL 10 // word |
||
16 | #define PID_FLIGHT_MINUTES 14 // word |
||
17 | |||
18 | #ifdef USE_KILLAGREG |
||
19 | #define PID_MM3_X_OFF 31 // byte |
||
20 | #define PID_MM3_Y_OFF 32 // byte |
||
21 | #define PID_MM3_Z_OFF 33 // byte |
||
22 | #define PID_MM3_X_RANGE 34 // word |
||
23 | #define PID_MM3_Y_RANGE 36 // word |
||
24 | #define PID_MM3_Z_RANGE 38 // word |
||
25 | #endif |
||
26 | |||
27 | |||
28 | #define EEPROM_ADR_CHANNELS 80 // 8 bytes |
||
29 | |||
30 | #define EEPROM_ADR_PARAMSET_LENGTH 98 // word |
||
31 | #define EEPROM_ADR_PARAMSET_BEGIN 100 |
||
32 | |||
33 | |||
34 | #define EEPROM_ADR_MIXER_TABLE 1000 // 1000 - 1076 |
||
35 | |||
36 | |||
37 | #define MIX_GAS 0 |
||
38 | #define MIX_NICK 1 |
||
39 | #define MIX_ROLL 2 |
||
40 | #define MIX_YAW 3 |
||
41 | |||
42 | typedef struct |
||
43 | { |
||
44 | uint8_t Revision; |
||
45 | int8_t Name[12]; |
||
46 | int8_t Motor[16][4]; |
||
47 | } __attribute__((packed)) MixerTable_t; |
||
48 | |||
49 | extern MixerTable_t Mixer; |
||
50 | |||
51 | |||
52 | // bit mask for ParamSet.Config0 |
||
53 | #define CFG0_AIRPRESS_SENSOR 0x01 |
||
54 | #define CFG0_HEIGHT_SWITCH 0x02 |
||
55 | #define CFG0_HEADING_HOLD 0x04 |
||
56 | #define CFG0_COMPASS_ACTIVE 0x08 |
||
57 | #define CFG0_COMPASS_FIX 0x10 |
||
58 | #define CFG0_GPS_ACTIVE 0x20 |
||
59 | #define CFG0_AXIS_COUPLING_ACTIVE 0x40 |
||
60 | #define CFG0_ROTARY_RATE_LIMITER 0x80 |
||
61 | |||
62 | // bit mask for ParamSet.Config1 |
||
63 | #define CFG1_LOOP_UP 0x01 |
||
64 | #define CFG1_LOOP_DOWN 0x02 |
||
65 | #define CFG1_LOOP_LEFT 0x04 |
||
66 | #define CFG1_LOOP_RIGHT 0x08 |
||
67 | #define CFG1_MOTOR_BLINK 0x10 |
||
68 | #define CFG1_MOTOR_OFF_LED1 0x20 |
||
69 | #define CFG1_MOTOR_OFF_LED2 0x40 |
||
70 | #define CFG1_RES4 0x80 |
||
71 | |||
72 | // bit mask for ParamSet.Config2 |
||
73 | #define CFG2_HEIGHT_LIMIT 0x01 |
||
74 | #define CFG2_VARIO_BEEP 0x02 |
||
75 | #define CFG2_SENSITIVE_RC 0x04 |
||
76 | #define CFG2_RES1 0x08 |
||
77 | #define CFG2_RES2 0x10 |
||
78 | #define CFG2_RES3 0x20 |
||
79 | #define CFG2_RES4 0x40 |
||
80 | #define CFG2_RES5 0x80 |
||
81 | |||
82 | // defines for lookup ParamSet.ChannelAssignment |
||
83 | #define CH_NICK 0 |
||
84 | #define CH_ROLL 1 |
||
85 | #define CH_GAS 2 |
||
86 | #define CH_YAW 3 |
||
87 | #define CH_POTI1 4 |
||
88 | #define CH_POTI2 5 |
||
89 | #define CH_POTI3 6 |
||
90 | #define CH_POTI4 7 |
||
91 | |||
92 | #define EEPARAM_REVISION 80 // is count up, if paramater stucture has changed (compatibility) |
||
93 | #define EEMIXER_REVISION 1 // is count up, if mixer stucture has changed (compatibility) |
||
94 | |||
95 | // values above 250 representing poti1 to poti4 |
||
96 | typedef struct |
||
97 | { |
||
98 | uint8_t ChannelAssignment[8]; // see upper defines for details |
||
99 | uint8_t Config0; // see upper defines for bitcoding |
||
100 | uint8_t HeightMinGas; // Value : 0-100 |
||
101 | uint8_t HeightD; // Value : 0-250 |
||
102 | uint8_t MaxHeight; // Value : 0-32 |
||
103 | uint8_t HeightP; // Value : 0-32 |
||
104 | uint8_t Height_Gain; // Value : 0-50 |
||
105 | uint8_t Height_ACC_Effect; // Value : 0-250 |
||
106 | uint8_t Height_HoverBand; // Value : 0-250 |
||
107 | uint8_t Height_GPS_Z; // Value : 0-250 |
||
108 | uint8_t Height_StickNeutralPoint; // Value : 0-250 |
||
109 | uint8_t StickP; // Value : 1-6 |
||
110 | uint8_t StickD; // Value : 0-64 |
||
111 | uint8_t StickYawP; // Value : 1-20 |
||
112 | uint8_t GasMin; // Value : 0-32 |
||
113 | uint8_t GasMax; // Value : 33-250 |
||
114 | uint8_t GyroAccFactor; // Value : 1-64 |
||
115 | uint8_t CompassYawEffect; // Value : 0-32 |
||
116 | uint8_t GyroP; // Value : 10-250 |
||
117 | uint8_t GyroI; // Value : 0-250 |
||
118 | uint8_t GyroD; // Value : 0-250 |
||
119 | uint8_t GyroYawP; // Value : 10-250 |
||
120 | uint8_t GyroYawI; // Value : 0-250 |
||
121 | uint8_t LowVoltageWarning; // Value : 0-250 |
||
122 | uint8_t EmergencyGas; // Value : 0-250 //Gaswert bei Empängsverlust |
||
123 | uint8_t EmergencyGasDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
||
124 | uint8_t UfoArrangement; // x or + Formation |
||
125 | uint8_t IFactor; // Value : 0-250 |
||
126 | uint8_t UserParam1; // Value : 0-250 |
||
127 | uint8_t UserParam2; // Value : 0-250 |
||
128 | uint8_t UserParam3; // Value : 0-250 |
||
129 | uint8_t UserParam4; // Value : 0-250 |
||
130 | uint8_t ServoNickControl; // Value : 0-250 // Stellung des Nick Servos |
||
131 | uint8_t ServoNickComp; // Value : 0-250 // Einfluss Nick-Gyro/Servo |
||
132 | uint8_t ServoNickMin; // Value : 0-250 // Anschlag |
||
133 | uint8_t ServoNickMax; // Value : 0-250 // Anschlag |
||
134 | uint8_t ServoRollControl; // Value : 0-250 // Stellung des Roll Servos |
||
135 | uint8_t ServoRollComp; // Value : 0-250 // Einfluss Roll-Gyro/Servo |
||
136 | uint8_t ServoRollMin; // Value : 0-250 // Anschlag |
||
137 | uint8_t ServoRollMax; // Value : 0-250 // Anschlag |
||
138 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
||
139 | uint8_t LoopGasLimit; // Value: 0-250 max. Gas während Looping |
||
140 | uint8_t LoopThreshold; // Value: 0-250 Schwelle für Stickausschlag |
||
141 | uint8_t LoopHysteresis; // Value: 0-250 Hysterese für Stickausschlag |
||
142 | // Axis coupling |
||
143 | uint8_t AxisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
||
144 | uint8_t AxisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
||
145 | uint8_t AxisCouplingYawCorrection; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
||
146 | uint8_t AngleTurnOverNick; // Value: 0-250 180°-Punkt |
||
147 | uint8_t AngleTurnOverRoll; // Value: 0-250 180°-Punkt |
||
148 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
||
149 | uint8_t DriftComp; // limit for gyrodrift compensation |
||
150 | uint8_t DynamicStability; // PID limit for Attitude controller |
||
151 | uint8_t UserParam5; // Value : 0-250 |
||
152 | uint8_t UserParam6; // Value : 0-250 |
||
153 | uint8_t UserParam7; // Value : 0-250 |
||
154 | uint8_t UserParam8; // Value : 0-250´ |
||
155 | // Output |
||
156 | uint8_t J16Bitmask; // for the J16 Output |
||
157 | uint8_t J16Timing; // for the J16 Output |
||
158 | uint8_t J17Bitmask; // for the J17 Output |
||
159 | uint8_t J17Timing; // for the J17 Output |
||
160 | uint8_t J16Bitmask_Warning; // for the J16 Outout |
||
161 | uint8_t J17Bitmask_Warning; // for the J17 Outout |
||
162 | // NaviCtrl |
||
163 | uint8_t NaviGpsModeControl; // Parameters for the Naviboard |
||
164 | uint8_t NaviGpsGain; // overall gain for GPS-PID controller |
||
165 | uint8_t NaviGpsP; // P gain for GPS-PID controller |
||
166 | uint8_t NaviGpsI; // I gain for GPS-PID controller |
||
167 | uint8_t NaviGpsD; // D gain for GPS-PID controller |
||
168 | uint8_t NaviGpsPLimit; // P limit for GPS-PID controller |
||
169 | uint8_t NaviGpsILimit; // I limit for GPS-PID controller |
||
170 | uint8_t NaviGpsDLimit; // D limit for GPS-PID controller |
||
171 | uint8_t NaviGpsACC; // ACC gain for GPS-PID controller |
||
172 | uint8_t NaviGpsMinSat; // number of sattelites neccesary for GPS functions |
||
173 | uint8_t NaviStickThreshold; // activation threshild for detection of manual stick movements |
||
174 | uint8_t NaviWindCorrection; // streng of wind course correction |
||
175 | uint8_t NaviSpeedCompensation; // D gain fefore position hold login |
||
176 | uint8_t NaviOperatingRadius; // Radius limit in m around start position for GPS flights |
||
177 | uint8_t NaviAngleLimitation; // limitation of attitude angle controlled by the gps algorithm |
||
178 | uint8_t NaviPHLoginTime; // position hold logintimeout |
||
179 | // extern control |
||
180 | uint8_t ExternalControl; // for serial control |
||
181 | // config |
||
182 | uint8_t Config1; // see upper defines for bitcoding |
||
183 | uint8_t ServoCompInvert; // Bitfield: 0x01 = Nick invert, 0x02 = Roll invert // WICHTIG!!! am Ende lassen |
||
184 | uint8_t Config2; // see upper defines for bitcoding |
||
185 | int8_t Name[12]; |
||
186 | } paramset_t; |
||
187 | |||
188 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
||
189 | |||
190 | extern paramset_t ParamSet; |
||
191 | |||
192 | extern void ParamSet_Init(void); |
||
193 | extern void ParamSet_ReadFromEEProm(uint8_t setnumber); |
||
194 | extern void ParamSet_WriteToEEProm(uint8_t setnumber); |
||
195 | extern uint8_t GetActiveParamSet(void); |
||
196 | extern void SetActiveParamSet(uint8_t setnumber); |
||
197 | |||
198 | extern uint8_t MixerTable_ReadFromEEProm(void); |
||
199 | extern uint8_t MixerTable_WriteToEEProm(void); |
||
200 | |||
201 | |||
202 | extern uint8_t GetParamByte(uint16_t param_id); |
||
203 | extern void SetParamByte(uint16_t param_id, uint8_t value); |
||
204 | extern uint16_t GetParamWord(uint16_t param_id); |
||
205 | extern void SetParamWord(uint16_t param_id, uint16_t value); |
||
206 | |||
207 | |||
208 | #endif //_EEPROM_H |