Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2751 | - | 1 | #ifndef _EEPROM_H |
2 | #define _EEPROM_H |
||
3 | |||
4 | #include <inttypes.h> |
||
5 | #include "twimaster.h" |
||
6 | |||
7 | #define EEPARAM_REVISION 105 // is count up, if paramater stucture has changed (compatibility) |
||
8 | #define EEMIXER_REVISION 1 // is count up, if mixer stucture has changed (compatibility) |
||
9 | |||
10 | #define EEPROM_ADR_PARAM_BEGIN 0 |
||
11 | #define EE_DUMMY 0 // Byte |
||
12 | #define PID_EE_REVISION 1 // byte |
||
13 | #define PID_ACTIVE_SET 2 // byte |
||
14 | #define PID_PRESSURE_OFFSET 3 // byte |
||
15 | |||
16 | #define PID_ACC_NICK 4 // word |
||
17 | #define PID_ACC_ROLL 6 // word |
||
18 | #define PID_ACC_TOP 8 // word |
||
19 | |||
20 | #define PID_FLIGHT_MINUTES_TOTAL 10 // word |
||
21 | #define PID_FLIGHT_MINUTES 14 // word |
||
22 | |||
23 | #define PID_SPEAK_HOTT_CFG 16 // Byte |
||
24 | #define PID_HARDWARE_VERSION 17 // Byte |
||
25 | |||
26 | #define PID_GYRO_NICK 18 // word |
||
27 | #define PID_GYRO_ROLL 20 // word |
||
28 | #define PID_GYRO_YAW 22 // word |
||
29 | |||
30 | #define EEPROM_ADR_CHANNELS 80 // 80 - 93, 12 bytes + 1 byte crc |
||
31 | #define EEPROM_ADR_PARAMSET 100 // 100 - 770, 5 * 134 bytes (V1.06) |
||
32 | #define EEPROM_ADR_MIXERTABLE 1000 // 1000 - 1078, 78 bytes |
||
33 | //#define EEPROM_ADR_BLCONFIG 1200 // 1200 - 1296, 12 * 8 bytes |
||
34 | |||
35 | #define MIX_GAS 0 |
||
36 | #define MIX_NICK 1 |
||
37 | #define MIX_ROLL 2 |
||
38 | #define MIX_YAW 3 |
||
39 | |||
40 | typedef struct |
||
41 | { |
||
42 | uint8_t Revision; |
||
43 | int8_t Name[12]; |
||
44 | int8_t Motor[16][4]; |
||
45 | uint8_t crc; |
||
46 | } __attribute__((packed)) MixerTable_t; |
||
47 | |||
48 | extern MixerTable_t Mixer; |
||
49 | extern uint8_t RequiredMotors; |
||
50 | |||
51 | //GlobalConfig3 |
||
52 | #define CFG3_NO_SDCARD_NO_START 0x01 |
||
53 | //#define CFG3_DPH_MAX_RADIUS 0x02 |
||
54 | #define CFG3_VARIO_FAILSAFE 0x04 |
||
55 | #define CFG3_MOTOR_SWITCH_MODE 0x08 |
||
56 | #define CFG3_NO_GPSFIX_NO_START 0x10 |
||
57 | #define CFG3_USE_NC_FOR_OUT1 0x20 |
||
58 | #define CFG3_SPEAK_ALL 0x40 |
||
59 | #define CFG3_SERVO_NICK_COMP_OFF 0x80 |
||
60 | |||
61 | //GlobalConfig |
||
62 | #define CFG_HOEHENREGELUNG 0x01 |
||
63 | #define CFG_HOEHEN_SCHALTER 0x02 |
||
64 | #define CFG_HEADING_HOLD 0x04 |
||
65 | #define CFG_KOMPASS_AKTIV 0x08 |
||
66 | #define CFG_KOMPASS_FIX 0x10 |
||
67 | #define CFG_GPS_AKTIV 0x20 |
||
68 | #define CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
||
69 | #define CFG_DREHRATEN_BEGRENZER 0x80 |
||
70 | |||
71 | //BitConfig |
||
72 | #define CFG_LOOP_OBEN 0x01 |
||
73 | #define CFG_LOOP_UNTEN 0x02 |
||
74 | #define CFG_LOOP_LINKS 0x04 |
||
75 | #define CFG_LOOP_RECHTS 0x08 |
||
76 | #define CFG_MOTOR_BLINK1 0x10 |
||
77 | #define CFG_MOTOR_OFF_LED1 0x20 |
||
78 | #define CFG_MOTOR_OFF_LED2 0x40 |
||
79 | #define CFG_MOTOR_BLINK2 0x80 |
||
80 | |||
81 | // ExtraConfig |
||
82 | #define CFG2_HEIGHT_LIMIT 0x01 |
||
83 | #define CFG2_VARIO_BEEP 0x02 |
||
84 | //#define CFG_SENSITIVE_RC 0x04 |
||
85 | #define CFG_3_3V_REFERENCE 0x08 |
||
86 | #define CFG_NO_RCOFF_BEEPING 0x10 |
||
87 | #define CFG_GPS_AID 0x20 |
||
88 | #define CFG_LEARNABLE_CAREFREE 0x40 |
||
89 | #define CFG_IGNORE_MAG_ERR_AT_STARTUP 0x80 |
||
90 | |||
91 | // bitcoding for EE_Parameter.ServoCompInvert |
||
92 | #define SERVO_NICK_INV 0x01 |
||
93 | #define SERVO_ROLL_INV 0x02 |
||
94 | #define SERVO_RELATIVE 0x04 // direct poti control or relative moving of the servo value |
||
95 | #define CH_DIRECTION_1 0x08 |
||
96 | #define CH_DIRECTION_2 0x10 |
||
97 | |||
98 | //CH Orientation ServoBits 0x08 0x10 |
||
99 | // --> no change 0 0 |
||
100 | // --> front to starting point 0 1 |
||
101 | // --> rear to to starting point 1 0 |
||
102 | //-> start orientation 1 1 |
||
103 | |||
104 | // defines for the receiver selection |
||
105 | #define RECEIVER_PPM 0 |
||
106 | #define RECEIVER_SPEKTRUM 1 |
||
107 | #define RECEIVER_SPEKTRUM_HI_RES 2 |
||
108 | #define RECEIVER_SPEKTRUM_LOW_RES 3 |
||
109 | #define RECEIVER_JETI 4 |
||
110 | #define RECEIVER_ACT_DSL 5 |
||
111 | #define RECEIVER_HOTT 6 |
||
112 | #define RECEIVER_SBUS 7 |
||
113 | #define RECEIVER_MLINK 8 |
||
114 | #define RECEIVER_USER 9 |
||
115 | |||
116 | #define RECEIVER_UNKNOWN 0xFF |
||
117 | |||
118 | // defines for lookup ParamSet.ChannelAssignment |
||
119 | #define K_NICK 0 |
||
120 | #define K_ROLL 1 |
||
121 | #define K_GAS 2 |
||
122 | #define K_GIER 3 |
||
123 | #define K_POTI1 4 |
||
124 | #define K_POTI2 5 |
||
125 | #define K_POTI3 6 |
||
126 | #define K_POTI4 7 |
||
127 | #define K_POTI5 8 |
||
128 | #define K_POTI6 9 |
||
129 | #define K_POTI7 10 |
||
130 | #define K_POTI8 11 |
||
131 | |||
132 | |||
133 | // values above 247 representing poti1 to poti8 |
||
134 | // poti1 = 255 |
||
135 | // poti2 = 254 |
||
136 | // poti3 = 253 |
||
137 | // poti4 = 252 |
||
138 | // poti5 = 251 |
||
139 | // poti6 = 250 |
||
140 | // poti7 = 249 |
||
141 | // poti8 = 248 |
||
142 | |||
143 | |||
144 | typedef struct |
||
145 | { |
||
146 | unsigned char Revision; |
||
147 | unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
||
148 | unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
||
149 | unsigned char Hoehe_MinGas; // Wert : 0-100 |
||
150 | unsigned char Luftdruck_D; // Wert : 0-250 |
||
151 | unsigned char HoeheChannel; // Wert : 0-32 |
||
152 | unsigned char Hoehe_P; // Wert : 0-32 |
||
153 | unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
||
154 | unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
||
155 | unsigned char Hoehe_HoverBand; // Wert : 0-250 |
||
156 | unsigned char Hoehe_TiltCompensation; // Wert : 0-250 |
||
157 | unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250 |
||
158 | unsigned char Stick_P; // Wert : 1-6 |
||
159 | unsigned char Stick_D; // Wert : 0-64 |
||
160 | unsigned char StickGier_P; // Wert : 1-20 |
||
161 | unsigned char Gas_Min; // Wert : 0-32 |
||
162 | unsigned char Gas_Max; // Wert : 33-250 |
||
163 | unsigned char GyroAccFaktor; // Wert : 1-64 |
||
164 | unsigned char KompassWirkung; // Wert : 0-32 |
||
165 | unsigned char Gyro_P; // Wert : 10-250 |
||
166 | unsigned char Gyro_I; // Wert : 0-250 |
||
167 | unsigned char Gyro_D; // Wert : 0-250 |
||
168 | unsigned char Gyro_Gier_P; // Wert : 10-250 |
||
169 | unsigned char Gyro_Gier_I; // Wert : 0-250 |
||
170 | unsigned char Gyro_Stability; // Wert : 0-16 |
||
171 | unsigned char UnterspannungsWarnung; // Wert : 0-250 |
||
172 | unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
||
173 | unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
||
174 | unsigned char Receiver; // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D |
||
175 | unsigned char I_Faktor; // Wert : 0-250 |
||
176 | unsigned char UserParam1; // Wert : 0-250 |
||
177 | unsigned char UserParam2; // Wert : 0-250 |
||
178 | unsigned char UserParam3; // Wert : 0-250 |
||
179 | unsigned char UserParam4; // Wert : 0-250 |
||
180 | unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
||
181 | unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
||
182 | unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
||
183 | unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
||
184 | //--- Seit V0.75 |
||
185 | unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
||
186 | unsigned char ServoRollComp; // Wert : 0-250 |
||
187 | unsigned char ServoRollMin; // Wert : 0-250 |
||
188 | unsigned char ServoRollMax; // Wert : 0-250 |
||
189 | //--- |
||
190 | unsigned char ServoNickRefresh; // Speed of the Servo |
||
191 | unsigned char ServoManualControlSpeed;// |
||
192 | unsigned char CamOrientation; // |
||
193 | unsigned char Servo3; // Value or mapping of the Servo Output |
||
194 | unsigned char Servo4; // Value or mapping of the Servo Output |
||
195 | unsigned char Servo5; // Value or mapping of the Servo Output |
||
196 | unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
||
197 | unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
||
198 | unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
||
199 | unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
||
200 | unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
||
201 | unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
||
202 | unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
||
203 | unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
||
204 | unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
||
205 | unsigned char Driftkomp; |
||
206 | unsigned char DynamicStability; |
||
207 | unsigned char UserParam5; // Wert : 0-250 |
||
208 | unsigned char UserParam6; // Wert : 0-250 |
||
209 | unsigned char UserParam7; // Wert : 0-250 |
||
210 | unsigned char UserParam8; // Wert : 0-250 |
||
211 | //---Output --------------------------------------------- |
||
212 | unsigned char J16Bitmask; // for the J16 Output |
||
213 | unsigned char J16Timing; // for the J16 Output |
||
214 | unsigned char J17Bitmask; // for the J17 Output |
||
215 | unsigned char J17Timing; // for the J17 Output |
||
216 | // seit version V0.75c |
||
217 | unsigned char WARN_J16_Bitmask; // for the J16 Output |
||
218 | unsigned char WARN_J17_Bitmask; // for the J17 Output |
||
219 | //---NaviCtrl--------------------------------------------- |
||
220 | unsigned char AutoPhotoDistance; // Auto Photo |
||
221 | unsigned char NaviGpsModeChannel; // Parameters for the Naviboard |
||
222 | unsigned char NaviGpsGain; |
||
223 | unsigned char NaviGpsP; |
||
224 | unsigned char NaviGpsI; |
||
225 | unsigned char NaviGpsD; |
||
226 | unsigned char NaviGpsPLimit; |
||
227 | unsigned char NaviGpsILimit; |
||
228 | unsigned char NaviGpsDLimit; |
||
229 | unsigned char NaviGpsA; |
||
230 | unsigned char NaviGpsMinSat; |
||
231 | unsigned char NaviStickThreshold; |
||
232 | unsigned char NaviWindCorrection; |
||
233 | unsigned char NaviAccCompensation; // New since 0.86 -> was: SpeedCompensation |
||
234 | unsigned char NaviMaxFlyingRange; // in 10m |
||
235 | unsigned char NaviAngleLimitation; |
||
236 | unsigned char NaviPH_LoginTime; |
||
237 | unsigned char NaviDescendRange; |
||
238 | //---Ext.Ctrl--------------------------------------------- |
||
239 | unsigned char ExternalControl; // for serial Control |
||
240 | //---CareFree--------------------------------------------- |
||
241 | unsigned char OrientationAngle; // Where is the front-direction? |
||
242 | unsigned char CareFreeChannel; // switch for CareFree |
||
243 | unsigned char MotorSafetySwitch; |
||
244 | unsigned char MotorSmooth; |
||
245 | unsigned char ComingHomeAltitude; |
||
246 | unsigned char FailSafeTime; |
||
247 | unsigned char MaxAltitude; |
||
248 | unsigned char FailsafeChannel; // if the value of this channel is > 100, the MK reports "RC-Lost" |
||
249 | unsigned char ServoFilterNick; |
||
250 | unsigned char ServoFilterRoll; |
||
251 | unsigned char Servo3OnValue; |
||
252 | unsigned char Servo3OffValue; |
||
253 | unsigned char Servo4OnValue; |
||
254 | unsigned char Servo4OffValue; |
||
255 | unsigned char ServoFS_Pos[5]; |
||
256 | unsigned char StartLandChannel; |
||
257 | unsigned char LandingSpeed; |
||
258 | unsigned char CompassOffset; |
||
259 | unsigned char AutoLandingVoltage; // in 0,1V 0 -> disabled |
||
260 | unsigned char ComingHomeVoltage; // in 0,1V 0 -> disabled |
||
261 | unsigned char AutoPhotoAtitudes; |
||
262 | unsigned char SingleWpSpeed; |
||
263 | unsigned char LandingPulse; |
||
264 | //------------------------------------------------ |
||
265 | unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
||
266 | unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll, 0x04 = relative moving // WICHTIG!!! am Ende lassen |
||
267 | unsigned char ExtraConfig; // bitcodiert |
||
268 | unsigned char GlobalConfig3; // bitcodiert |
||
269 | char Name[12]; |
||
270 | unsigned char crc; // must be the last byte! |
||
271 | } paramset_t; // 134 bytes (V1.06) |
||
272 | |||
273 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
||
274 | |||
275 | extern paramset_t EE_Parameter; |
||
276 | |||
277 | extern uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len); |
||
278 | |||
279 | extern void ParamSet_Init(void); |
||
280 | extern void SetDefaultParameter(uint8_t set, uint8_t restore_channels); |
||
281 | |||
282 | extern uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber); |
||
283 | extern uint8_t ParamSet_WriteToEEProm(uint8_t setnumber); |
||
284 | |||
285 | extern uint8_t GetActiveParamSet(void); |
||
286 | extern void SetActiveParamSet(uint8_t setnumber); |
||
287 | |||
288 | extern uint8_t MixerTable_ReadFromEEProm(void); |
||
289 | extern uint8_t MixerTable_WriteToEEProm(void); |
||
290 | |||
291 | extern uint8_t GetParamByte(uint16_t param_id); |
||
292 | extern void SetParamByte(uint16_t param_id, uint8_t value); |
||
293 | extern uint16_t GetParamWord(uint16_t param_id); |
||
294 | extern void SetParamWord(uint16_t param_id, uint16_t value); |
||
295 | |||
296 | |||
297 | #endif //_EEPROM_H |