Subversion Repositories FlightCtrl

Rev

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