Subversion Repositories FlightCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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