Rev 1622 | Rev 1654 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1622 | Rev 1652 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
3 | // + Nur für den privaten Gebrauch |
3 | // + Nur für den privaten Gebrauch |
4 | // + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
4 | // + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
5 | // + www.MikroKopter.com |
5 | // + www.MikroKopter.com |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
7 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
8 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
8 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
9 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
9 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
10 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
10 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
11 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
11 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
12 | // + Verkauf von Luftbildaufnahmen, usw. |
12 | // + Verkauf von Luftbildaufnahmen, usw. |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
14 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
15 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
15 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
17 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
18 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
18 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
19 | // + eindeutig als Ursprung verlinkt werden |
19 | // + eindeutig als Ursprung verlinkt werden |
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
21 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
21 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
22 | // + Benutzung auf eigene Gefahr |
22 | // + Benutzung auf eigene Gefahr |
23 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
23 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
24 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
25 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
25 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
26 | // + mit unserer Zustimmung zulässig |
26 | // + mit unserer Zustimmung zulässig |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
28 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
30 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
31 | // + this list of conditions and the following disclaimer. |
31 | // + this list of conditions and the following disclaimer. |
32 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
32 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
33 | // + from this software without specific prior written permission. |
33 | // + from this software without specific prior written permission. |
34 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
34 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
35 | // + for non-commercial use (directly or indirectly) |
35 | // + for non-commercial use (directly or indirectly) |
36 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
36 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
37 | // + with our written permission |
37 | // + with our written permission |
38 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
38 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
39 | // + clearly linked as origin |
39 | // + clearly linked as origin |
40 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
40 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
41 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
41 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
42 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
42 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
43 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
44 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
44 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
45 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
45 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
46 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
46 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
47 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
47 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
48 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
48 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
49 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
49 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
50 | // + POSSIBILITY OF SUCH DAMAGE. |
50 | // + POSSIBILITY OF SUCH DAMAGE. |
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
52 | 52 | ||
53 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
53 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
54 | // + Contant Values |
54 | // + Contant Values |
55 | // + 0-250 -> normale Values |
55 | // + 0-250 -> normale Values |
56 | // + 251 -> Poti1 |
56 | // + 251 -> Poti1 |
57 | // + 252 -> Poti2 |
57 | // + 252 -> Poti2 |
58 | // + 253 -> Poti3 |
58 | // + 253 -> Poti3 |
59 | // + 254 -> Poti4 |
59 | // + 254 -> Poti4 |
60 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
60 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
61 | 61 | ||
62 | #ifndef EEMEM |
62 | #ifndef EEMEM |
63 | #define EEMEM __attribute__ ((section (".eeprom"))) |
63 | #define EEMEM __attribute__ ((section (".eeprom"))) |
64 | #endif |
64 | #endif |
65 | 65 | ||
66 | 66 | ||
67 | #include <avr/eeprom.h> |
67 | #include <avr/eeprom.h> |
68 | #include <string.h> |
68 | #include <string.h> |
69 | #include "eeprom.h" |
69 | #include "eeprom.h" |
70 | #include "uart.h" |
70 | #include "uart.h" |
71 | #include "led.h" |
71 | #include "led.h" |
72 | #include "main.h" |
72 | #include "main.h" |
73 | #include "fc.h" |
73 | #include "fc.h" |
74 | 74 | ||
75 | paramset_t EE_Parameter; |
75 | paramset_t EE_Parameter; |
76 | MixerTable_t Mixer; |
76 | MixerTable_t Mixer; |
77 | 77 | ||
78 | 78 | ||
79 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
79 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
80 | { |
80 | { |
81 | uint8_t crc = 0xAA; |
81 | uint8_t crc = 0xAA; |
82 | uint16_t i; |
82 | uint16_t i; |
83 | 83 | ||
84 | for(i=0; i<len; i++) |
84 | for(i=0; i<len; i++) |
85 | { |
85 | { |
86 | crc += pBuffer[i]; |
86 | crc += pBuffer[i]; |
87 | } |
87 | } |
88 | return crc; |
88 | return crc; |
89 | } |
89 | } |
90 | 90 | ||
91 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
91 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
92 | { |
92 | { |
93 | uint8_t crc = 0xAA; |
93 | uint8_t crc = 0xAA; |
94 | uint16_t off; |
94 | uint16_t off; |
95 | 95 | ||
96 | for(off=0; off<len; off++) |
96 | for(off=0; off<len; off++) |
97 | { |
97 | { |
98 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
98 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
99 | } |
99 | } |
100 | return crc; |
100 | return crc; |
101 | } |
101 | } |
102 | 102 | ||
103 | void ParamSet_DefaultStickMapping(void) |
103 | void ParamSet_DefaultStickMapping(void) |
104 | { |
104 | { |
105 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
105 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
106 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
106 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
107 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
107 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
108 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
108 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
109 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
109 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
110 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
110 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
111 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
111 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
112 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
112 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
113 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
113 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
114 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
114 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
115 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
115 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
116 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
116 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
117 | } |
117 | } |
118 | 118 | ||
119 | 119 | ||
120 | /***************************************************/ |
120 | /***************************************************/ |
121 | /* Default Values for parameter set 1 */ |
121 | /* Default Values for parameter set 1 */ |
122 | /***************************************************/ |
122 | /***************************************************/ |
123 | void ParamSet_DefaultSet1(void) // sport |
123 | void ParamSet_DefaultSet1(void) // sport |
124 | { |
124 | { |
125 | EE_Parameter.Revision = EEPARAM_REVISION; |
125 | EE_Parameter.Revision = EEPARAM_REVISION; |
126 | 126 | ||
127 | if(PlatinenVersion >= 20) |
127 | if(PlatinenVersion >= 20) |
128 | { |
128 | { |
129 | EE_Parameter.Gyro_D = 5; |
129 | EE_Parameter.Gyro_D = 5; |
130 | EE_Parameter.Driftkomp = 0; |
130 | EE_Parameter.Driftkomp = 0; |
131 | EE_Parameter.GyroAccFaktor = 27; |
131 | EE_Parameter.GyroAccFaktor = 27; |
132 | EE_Parameter.WinkelUmschlagNick = 78; |
132 | EE_Parameter.WinkelUmschlagNick = 78; |
133 | EE_Parameter.WinkelUmschlagRoll = 78; |
133 | EE_Parameter.WinkelUmschlagRoll = 78; |
134 | } |
134 | } |
135 | else |
135 | else |
136 | { |
136 | { |
137 | EE_Parameter.Gyro_D = 3; |
137 | EE_Parameter.Gyro_D = 3; |
138 | EE_Parameter.Driftkomp = 32; |
138 | EE_Parameter.Driftkomp = 32; |
139 | EE_Parameter.GyroAccFaktor = 30; |
139 | EE_Parameter.GyroAccFaktor = 30; |
140 | EE_Parameter.WinkelUmschlagNick = 85; |
140 | EE_Parameter.WinkelUmschlagNick = 85; |
141 | EE_Parameter.WinkelUmschlagRoll = 85; |
141 | EE_Parameter.WinkelUmschlagRoll = 85; |
142 | } |
142 | } |
143 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
143 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
144 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
144 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
145 | EE_Parameter.Hoehe_MinGas = 30; |
145 | EE_Parameter.Hoehe_MinGas = 30; |
146 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
146 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
147 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
147 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
148 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
148 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
149 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
149 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
150 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
150 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
151 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
151 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
152 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
152 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
153 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
153 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
154 | EE_Parameter.Stick_P = 14; // Wert : 1-6 |
154 | EE_Parameter.Stick_P = 14; // Wert : 1-6 |
155 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
155 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
156 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
156 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
157 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
157 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
158 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
158 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
159 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
159 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
160 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
160 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
161 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
161 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
162 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
162 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
163 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
163 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
164 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
164 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
165 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
165 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
166 | EE_Parameter.NotGasZeit = 30; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
166 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
167 | EE_Parameter.I_Faktor = 32; |
167 | EE_Parameter.I_Faktor = 32; |
168 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
168 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
169 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
169 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
170 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
170 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
171 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
171 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
176 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
176 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
177 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
177 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
178 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
178 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
179 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
179 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
180 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
180 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
181 | EE_Parameter.ServoNickRefresh = 6; |
181 | EE_Parameter.ServoNickRefresh = 6; |
182 | EE_Parameter.Servo3 = 125; |
182 | EE_Parameter.Servo3 = 125; |
183 | EE_Parameter.Servo4 = 125; |
183 | EE_Parameter.Servo4 = 125; |
184 | EE_Parameter.Servo5 = 125; |
184 | EE_Parameter.Servo5 = 125; |
185 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
185 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
186 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
186 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
187 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
187 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
188 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
188 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
189 | EE_Parameter.LoopGasLimit = 50; |
189 | EE_Parameter.LoopGasLimit = 50; |
190 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
190 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
191 | EE_Parameter.LoopHysterese = 50; |
191 | EE_Parameter.LoopHysterese = 50; |
192 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
192 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
193 | EE_Parameter.AchsKopplung1 = 90; |
193 | EE_Parameter.AchsKopplung1 = 90; |
194 | EE_Parameter.AchsKopplung2 = 80; |
194 | EE_Parameter.AchsKopplung2 = 80; |
195 | EE_Parameter.CouplingYawCorrection = 1; |
195 | EE_Parameter.CouplingYawCorrection = 1; |
196 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
196 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
197 | EE_Parameter.DynamicStability = 100; |
197 | EE_Parameter.DynamicStability = 100; |
198 | EE_Parameter.J16Bitmask = 95; |
198 | EE_Parameter.J16Bitmask = 95; |
199 | EE_Parameter.J17Bitmask = 243; |
199 | EE_Parameter.J17Bitmask = 243; |
200 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
200 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
201 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
201 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
202 | EE_Parameter.J16Timing = 15; |
202 | EE_Parameter.J16Timing = 15; |
203 | EE_Parameter.J17Timing = 15; |
203 | EE_Parameter.J17Timing = 15; |
204 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
204 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
205 | EE_Parameter.NaviGpsGain = 100; |
205 | EE_Parameter.NaviGpsGain = 100; |
206 | EE_Parameter.NaviGpsP = 90; |
206 | EE_Parameter.NaviGpsP = 90; |
207 | EE_Parameter.NaviGpsI = 90; |
207 | EE_Parameter.NaviGpsI = 90; |
208 | EE_Parameter.NaviGpsD = 90; |
208 | EE_Parameter.NaviGpsD = 90; |
209 | EE_Parameter.NaviGpsPLimit = 75; |
209 | EE_Parameter.NaviGpsPLimit = 75; |
210 | EE_Parameter.NaviGpsILimit = 75; |
210 | EE_Parameter.NaviGpsILimit = 75; |
211 | EE_Parameter.NaviGpsDLimit = 75; |
211 | EE_Parameter.NaviGpsDLimit = 75; |
212 | EE_Parameter.NaviGpsACC = 0; |
212 | EE_Parameter.NaviGpsACC = 0; |
213 | EE_Parameter.NaviGpsMinSat = 6; |
213 | EE_Parameter.NaviGpsMinSat = 6; |
214 | EE_Parameter.NaviStickThreshold = 8; |
214 | EE_Parameter.NaviStickThreshold = 8; |
215 | EE_Parameter.NaviWindCorrection = 90; |
215 | EE_Parameter.NaviWindCorrection = 90; |
216 | EE_Parameter.NaviSpeedCompensation = 30; |
216 | EE_Parameter.NaviSpeedCompensation = 30; |
217 | EE_Parameter.NaviOperatingRadius = 100; |
217 | EE_Parameter.NaviOperatingRadius = 100; |
218 | EE_Parameter.NaviAngleLimitation = 100; |
218 | EE_Parameter.NaviAngleLimitation = 100; |
219 | EE_Parameter.NaviPH_LoginTime = 4; |
219 | EE_Parameter.NaviPH_LoginTime = 4; |
220 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
220 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
221 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
221 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
222 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
222 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
223 | } |
223 | } |
224 | 224 | ||
225 | 225 | ||
226 | /***************************************************/ |
226 | /***************************************************/ |
227 | /* Default Values for parameter set 2 */ |
227 | /* Default Values for parameter set 2 */ |
228 | /***************************************************/ |
228 | /***************************************************/ |
229 | void ParamSet_DefaultSet2(void) // normal |
229 | void ParamSet_DefaultSet2(void) // normal |
230 | { |
230 | { |
231 | EE_Parameter.Revision = EEPARAM_REVISION; |
231 | EE_Parameter.Revision = EEPARAM_REVISION; |
232 | 232 | ||
233 | if(PlatinenVersion >= 20) |
233 | if(PlatinenVersion >= 20) |
234 | { |
234 | { |
235 | EE_Parameter.Gyro_D = 5; |
235 | EE_Parameter.Gyro_D = 5; |
236 | EE_Parameter.Driftkomp = 0; |
236 | EE_Parameter.Driftkomp = 0; |
237 | EE_Parameter.GyroAccFaktor = 27; |
237 | EE_Parameter.GyroAccFaktor = 27; |
238 | EE_Parameter.WinkelUmschlagNick = 78; |
238 | EE_Parameter.WinkelUmschlagNick = 78; |
239 | EE_Parameter.WinkelUmschlagRoll = 78; |
239 | EE_Parameter.WinkelUmschlagRoll = 78; |
240 | } |
240 | } |
241 | else |
241 | else |
242 | { |
242 | { |
243 | EE_Parameter.Gyro_D = 3; |
243 | EE_Parameter.Gyro_D = 3; |
244 | EE_Parameter.Driftkomp = 32; |
244 | EE_Parameter.Driftkomp = 32; |
245 | EE_Parameter.GyroAccFaktor = 30; |
245 | EE_Parameter.GyroAccFaktor = 30; |
246 | EE_Parameter.WinkelUmschlagNick = 85; |
246 | EE_Parameter.WinkelUmschlagNick = 85; |
247 | EE_Parameter.WinkelUmschlagRoll = 85; |
247 | EE_Parameter.WinkelUmschlagRoll = 85; |
248 | } |
248 | } |
249 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
249 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
250 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
250 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
251 | EE_Parameter.Hoehe_MinGas = 30; |
251 | EE_Parameter.Hoehe_MinGas = 30; |
252 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
252 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
253 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
253 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
254 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
254 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
255 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
255 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
256 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
256 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
257 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
257 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
258 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
258 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
259 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
259 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
260 | EE_Parameter.Stick_P = 10; // Wert : 1-6 |
260 | EE_Parameter.Stick_P = 10; // Wert : 1-6 |
261 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
261 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
262 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
262 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
263 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
263 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
264 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
264 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
265 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
265 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
266 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
266 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
267 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
267 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
268 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
268 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
269 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
269 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
270 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
270 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
271 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
271 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
272 | EE_Parameter.NotGasZeit = 30; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
272 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
273 | EE_Parameter.I_Faktor = 32; |
273 | EE_Parameter.I_Faktor = 32; |
274 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
274 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
275 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
275 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
276 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
276 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
277 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
277 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
278 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
278 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
279 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
279 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
280 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
280 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
282 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
282 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
283 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
283 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
284 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
284 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
285 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
285 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
286 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
286 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
287 | EE_Parameter.ServoNickRefresh = 6; |
287 | EE_Parameter.ServoNickRefresh = 6; |
288 | EE_Parameter.Servo3 = 125; |
288 | EE_Parameter.Servo3 = 125; |
289 | EE_Parameter.Servo4 = 125; |
289 | EE_Parameter.Servo4 = 125; |
290 | EE_Parameter.Servo5 = 125; |
290 | EE_Parameter.Servo5 = 125; |
291 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
291 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
292 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
292 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
293 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
293 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
294 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
294 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
295 | EE_Parameter.LoopGasLimit = 50; |
295 | EE_Parameter.LoopGasLimit = 50; |
296 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
296 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
297 | EE_Parameter.LoopHysterese = 50; |
297 | EE_Parameter.LoopHysterese = 50; |
298 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
298 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
299 | EE_Parameter.AchsKopplung1 = 90; |
299 | EE_Parameter.AchsKopplung1 = 90; |
300 | EE_Parameter.AchsKopplung2 = 80; |
300 | EE_Parameter.AchsKopplung2 = 80; |
301 | EE_Parameter.CouplingYawCorrection = 60; |
301 | EE_Parameter.CouplingYawCorrection = 60; |
302 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
302 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
303 | EE_Parameter.DynamicStability = 75; |
303 | EE_Parameter.DynamicStability = 75; |
304 | EE_Parameter.J16Bitmask = 95; |
304 | EE_Parameter.J16Bitmask = 95; |
305 | EE_Parameter.J17Bitmask = 243; |
305 | EE_Parameter.J17Bitmask = 243; |
306 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
306 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
307 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
307 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
308 | EE_Parameter.J16Timing = 20; |
308 | EE_Parameter.J16Timing = 20; |
309 | EE_Parameter.J17Timing = 20; |
309 | EE_Parameter.J17Timing = 20; |
310 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
310 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
311 | EE_Parameter.NaviGpsGain = 100; |
311 | EE_Parameter.NaviGpsGain = 100; |
312 | EE_Parameter.NaviGpsP = 90; |
312 | EE_Parameter.NaviGpsP = 90; |
313 | EE_Parameter.NaviGpsI = 90; |
313 | EE_Parameter.NaviGpsI = 90; |
314 | EE_Parameter.NaviGpsD = 90; |
314 | EE_Parameter.NaviGpsD = 90; |
315 | EE_Parameter.NaviGpsPLimit = 75; |
315 | EE_Parameter.NaviGpsPLimit = 75; |
316 | EE_Parameter.NaviGpsILimit = 75; |
316 | EE_Parameter.NaviGpsILimit = 75; |
317 | EE_Parameter.NaviGpsDLimit = 75; |
317 | EE_Parameter.NaviGpsDLimit = 75; |
318 | EE_Parameter.NaviGpsACC = 0; |
318 | EE_Parameter.NaviGpsACC = 0; |
319 | EE_Parameter.NaviGpsMinSat = 6; |
319 | EE_Parameter.NaviGpsMinSat = 6; |
320 | EE_Parameter.NaviStickThreshold = 8; |
320 | EE_Parameter.NaviStickThreshold = 8; |
321 | EE_Parameter.NaviWindCorrection = 90; |
321 | EE_Parameter.NaviWindCorrection = 90; |
322 | EE_Parameter.NaviSpeedCompensation = 30; |
322 | EE_Parameter.NaviSpeedCompensation = 30; |
323 | EE_Parameter.NaviOperatingRadius = 100; |
323 | EE_Parameter.NaviOperatingRadius = 100; |
324 | EE_Parameter.NaviAngleLimitation = 100; |
324 | EE_Parameter.NaviAngleLimitation = 100; |
325 | EE_Parameter.NaviPH_LoginTime = 4; |
325 | EE_Parameter.NaviPH_LoginTime = 4; |
326 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
326 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
327 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
327 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
328 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
328 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
329 | } |
329 | } |
330 | 330 | ||
331 | 331 | ||
332 | /***************************************************/ |
332 | /***************************************************/ |
333 | /* Default Values for parameter set 3 */ |
333 | /* Default Values for parameter set 3 */ |
334 | /***************************************************/ |
334 | /***************************************************/ |
335 | void ParamSet_DefaultSet3(void) // beginner |
335 | void ParamSet_DefaultSet3(void) // beginner |
336 | { |
336 | { |
337 | EE_Parameter.Revision = EEPARAM_REVISION; |
337 | EE_Parameter.Revision = EEPARAM_REVISION; |
338 | if(PlatinenVersion >= 20) |
338 | if(PlatinenVersion >= 20) |
339 | { |
339 | { |
340 | EE_Parameter.Gyro_D = 5; |
340 | EE_Parameter.Gyro_D = 5; |
341 | EE_Parameter.Driftkomp = 0; |
341 | EE_Parameter.Driftkomp = 0; |
342 | EE_Parameter.GyroAccFaktor = 27; |
342 | EE_Parameter.GyroAccFaktor = 27; |
343 | EE_Parameter.WinkelUmschlagNick = 78; |
343 | EE_Parameter.WinkelUmschlagNick = 78; |
344 | EE_Parameter.WinkelUmschlagRoll = 78; |
344 | EE_Parameter.WinkelUmschlagRoll = 78; |
345 | } |
345 | } |
346 | else |
346 | else |
347 | { |
347 | { |
348 | EE_Parameter.Gyro_D = 3; |
348 | EE_Parameter.Gyro_D = 3; |
349 | EE_Parameter.Driftkomp = 32; |
349 | EE_Parameter.Driftkomp = 32; |
350 | EE_Parameter.GyroAccFaktor = 30; |
350 | EE_Parameter.GyroAccFaktor = 30; |
351 | EE_Parameter.WinkelUmschlagNick = 85; |
351 | EE_Parameter.WinkelUmschlagNick = 85; |
352 | EE_Parameter.WinkelUmschlagRoll = 85; |
352 | EE_Parameter.WinkelUmschlagRoll = 85; |
353 | } |
353 | } |
354 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
354 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
355 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
355 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
356 | EE_Parameter.Hoehe_MinGas = 30; |
356 | EE_Parameter.Hoehe_MinGas = 30; |
357 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
357 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
358 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
358 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
359 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
359 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
360 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
360 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
361 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
361 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
362 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
362 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
363 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
363 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
364 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
364 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
365 | EE_Parameter.Stick_P = 8; // Wert : 1-6 |
365 | EE_Parameter.Stick_P = 8; // Wert : 1-6 |
366 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
366 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
367 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
367 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
368 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
368 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
369 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
369 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
370 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
370 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
371 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
371 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
372 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
372 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
373 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
373 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
374 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
374 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
375 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
375 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
376 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
376 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
377 | EE_Parameter.NotGasZeit = 20; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
377 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
378 | EE_Parameter.I_Faktor = 16; |
378 | EE_Parameter.I_Faktor = 16; |
379 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
379 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
380 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
380 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
381 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
381 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
382 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
382 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
383 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
383 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
384 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
384 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
385 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
385 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
386 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
386 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
387 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
387 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
388 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
388 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
389 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
389 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
390 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
390 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
391 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
391 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
392 | EE_Parameter.ServoNickRefresh = 6; |
392 | EE_Parameter.ServoNickRefresh = 6; |
393 | EE_Parameter.Servo3 = 125; |
393 | EE_Parameter.Servo3 = 125; |
394 | EE_Parameter.Servo4 = 125; |
394 | EE_Parameter.Servo4 = 125; |
395 | EE_Parameter.Servo5 = 125; |
395 | EE_Parameter.Servo5 = 125; |
396 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
396 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
397 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
397 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
398 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
398 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
399 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
399 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
400 | EE_Parameter.LoopGasLimit = 50; |
400 | EE_Parameter.LoopGasLimit = 50; |
401 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
401 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
402 | EE_Parameter.LoopHysterese = 50; |
402 | EE_Parameter.LoopHysterese = 50; |
403 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
403 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
404 | EE_Parameter.AchsKopplung1 = 90; |
404 | EE_Parameter.AchsKopplung1 = 90; |
405 | EE_Parameter.AchsKopplung2 = 80; |
405 | EE_Parameter.AchsKopplung2 = 80; |
406 | EE_Parameter.CouplingYawCorrection = 70; |
406 | EE_Parameter.CouplingYawCorrection = 70; |
407 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
407 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
408 | EE_Parameter.DynamicStability = 50; |
408 | EE_Parameter.DynamicStability = 50; |
409 | EE_Parameter.J16Bitmask = 95; |
409 | EE_Parameter.J16Bitmask = 95; |
410 | EE_Parameter.J17Bitmask = 243; |
410 | EE_Parameter.J17Bitmask = 243; |
411 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
411 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
412 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
412 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
413 | EE_Parameter.J16Timing = 30; |
413 | EE_Parameter.J16Timing = 30; |
414 | EE_Parameter.J17Timing = 30; |
414 | EE_Parameter.J17Timing = 30; |
415 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
415 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
416 | EE_Parameter.NaviGpsGain = 100; |
416 | EE_Parameter.NaviGpsGain = 100; |
417 | EE_Parameter.NaviGpsP = 90; |
417 | EE_Parameter.NaviGpsP = 90; |
418 | EE_Parameter.NaviGpsI = 90; |
418 | EE_Parameter.NaviGpsI = 90; |
419 | EE_Parameter.NaviGpsD = 90; |
419 | EE_Parameter.NaviGpsD = 90; |
420 | EE_Parameter.NaviGpsPLimit = 75; |
420 | EE_Parameter.NaviGpsPLimit = 75; |
421 | EE_Parameter.NaviGpsILimit = 75; |
421 | EE_Parameter.NaviGpsILimit = 75; |
422 | EE_Parameter.NaviGpsDLimit = 75; |
422 | EE_Parameter.NaviGpsDLimit = 75; |
423 | EE_Parameter.NaviGpsACC = 0; |
423 | EE_Parameter.NaviGpsACC = 0; |
424 | EE_Parameter.NaviGpsMinSat = 6; |
424 | EE_Parameter.NaviGpsMinSat = 6; |
425 | EE_Parameter.NaviStickThreshold = 8; |
425 | EE_Parameter.NaviStickThreshold = 8; |
426 | EE_Parameter.NaviWindCorrection = 90; |
426 | EE_Parameter.NaviWindCorrection = 90; |
427 | EE_Parameter.NaviSpeedCompensation = 30; |
427 | EE_Parameter.NaviSpeedCompensation = 30; |
428 | EE_Parameter.NaviOperatingRadius = 100; |
428 | EE_Parameter.NaviOperatingRadius = 100; |
429 | EE_Parameter.NaviAngleLimitation = 100; |
429 | EE_Parameter.NaviAngleLimitation = 100; |
430 | EE_Parameter.NaviPH_LoginTime = 4; |
430 | EE_Parameter.NaviPH_LoginTime = 4; |
431 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
431 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
432 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
432 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
433 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
433 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
434 | } |
434 | } |
435 | 435 | ||
436 | /***************************************************/ |
436 | /***************************************************/ |
437 | /* Read Parameter from EEPROM as byte */ |
437 | /* Read Parameter from EEPROM as byte */ |
438 | /***************************************************/ |
438 | /***************************************************/ |
439 | uint8_t GetParamByte(uint16_t param_id) |
439 | uint8_t GetParamByte(uint16_t param_id) |
440 | { |
440 | { |
441 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
441 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
442 | } |
442 | } |
443 | 443 | ||
444 | /***************************************************/ |
444 | /***************************************************/ |
445 | /* Write Parameter to EEPROM as byte */ |
445 | /* Write Parameter to EEPROM as byte */ |
446 | /***************************************************/ |
446 | /***************************************************/ |
447 | void SetParamByte(uint16_t param_id, uint8_t value) |
447 | void SetParamByte(uint16_t param_id, uint8_t value) |
448 | { |
448 | { |
449 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
449 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
450 | } |
450 | } |
451 | 451 | ||
452 | /***************************************************/ |
452 | /***************************************************/ |
453 | /* Read Parameter from EEPROM as word */ |
453 | /* Read Parameter from EEPROM as word */ |
454 | /***************************************************/ |
454 | /***************************************************/ |
455 | uint16_t GetParamWord(uint16_t param_id) |
455 | uint16_t GetParamWord(uint16_t param_id) |
456 | { |
456 | { |
457 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
457 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
458 | } |
458 | } |
459 | 459 | ||
460 | /***************************************************/ |
460 | /***************************************************/ |
461 | /* Write Parameter to EEPROM as word */ |
461 | /* Write Parameter to EEPROM as word */ |
462 | /***************************************************/ |
462 | /***************************************************/ |
463 | void SetParamWord(uint16_t param_id, uint16_t value) |
463 | void SetParamWord(uint16_t param_id, uint16_t value) |
464 | { |
464 | { |
465 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
465 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
466 | } |
466 | } |
467 | 467 | ||
468 | /***************************************************/ |
468 | /***************************************************/ |
469 | /* Read Parameter Set from EEPROM */ |
469 | /* Read Parameter Set from EEPROM */ |
470 | /***************************************************/ |
470 | /***************************************************/ |
471 | // number [1..5] |
471 | // number [1..5] |
472 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
472 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
473 | { |
473 | { |
474 | uint8_t crc; |
474 | uint8_t crc; |
475 | uint16_t eeaddr; |
475 | uint16_t eeaddr; |
476 | 476 | ||
477 | // range the setnumber |
477 | // range the setnumber |
478 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
478 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
479 | 479 | ||
480 | // calculate eeprom addr |
480 | // calculate eeprom addr |
481 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
481 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
482 | 482 | ||
483 | // calculate checksum from eeprom |
483 | // calculate checksum from eeprom |
484 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
484 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
485 | 485 | ||
486 | // check crc |
486 | // check crc |
487 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
487 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
488 | 488 | ||
489 | // check revision |
489 | // check revision |
490 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
490 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
491 | 491 | ||
492 | // read paramset from eeprom |
492 | // read paramset from eeprom |
493 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
493 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
494 | LED_Init(); |
494 | LED_Init(); |
495 | return 1; |
495 | return 1; |
496 | } |
496 | } |
497 | 497 | ||
498 | /***************************************************/ |
498 | /***************************************************/ |
499 | /* Write Parameter Set to EEPROM */ |
499 | /* Write Parameter Set to EEPROM */ |
500 | /***************************************************/ |
500 | /***************************************************/ |
501 | // number [1..5] |
501 | // number [1..5] |
502 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
502 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
503 | { |
503 | { |
504 | uint8_t crc; |
504 | uint8_t crc; |
505 | 505 | ||
506 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
506 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
507 | { |
507 | { |
508 | if(setnumber > 5) setnumber = 5; |
508 | if(setnumber > 5) setnumber = 5; |
509 | if(setnumber < 1) return 0; |
509 | if(setnumber < 1) return 0; |
510 | 510 | ||
511 | // update checksum |
511 | // update checksum |
512 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
512 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
513 | 513 | ||
514 | // write paramset to eeprom |
514 | // write paramset to eeprom |
515 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
515 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
516 | 516 | ||
517 | // backup channel settings to separate block in eeprom |
517 | // backup channel settings to separate block in eeprom |
518 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
518 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
519 | 519 | ||
520 | // write crc of channel block to eeprom |
520 | // write crc of channel block to eeprom |
521 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
521 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
522 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
522 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
523 | 523 | ||
524 | // update active settings number |
524 | // update active settings number |
525 | SetActiveParamSet(setnumber); |
525 | SetActiveParamSet(setnumber); |
526 | LED_Init(); |
526 | LED_Init(); |
527 | return 1; |
527 | return 1; |
528 | } |
528 | } |
529 | // wrong revision |
529 | // wrong revision |
530 | return 0; |
530 | return 0; |
531 | } |
531 | } |
532 | 532 | ||
533 | /***************************************************/ |
533 | /***************************************************/ |
534 | /* Read MixerTable from EEPROM */ |
534 | /* Read MixerTable from EEPROM */ |
535 | /***************************************************/ |
535 | /***************************************************/ |
536 | uint8_t MixerTable_ReadFromEEProm(void) |
536 | uint8_t MixerTable_ReadFromEEProm(void) |
537 | { |
537 | { |
538 | uint8_t crc; |
538 | uint8_t crc; |
539 | 539 | ||
540 | // calculate checksum in eeprom |
540 | // calculate checksum in eeprom |
541 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
541 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
542 | 542 | ||
543 | // check crc |
543 | // check crc |
544 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
544 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
545 | 545 | ||
546 | // check revision |
546 | // check revision |
547 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
547 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
548 | 548 | ||
549 | // read mixer table |
549 | // read mixer table |
550 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
550 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
551 | return 1; |
551 | return 1; |
552 | } |
552 | } |
553 | 553 | ||
554 | /***************************************************/ |
554 | /***************************************************/ |
555 | /* Write Mixer Table to EEPROM */ |
555 | /* Write Mixer Table to EEPROM */ |
556 | /***************************************************/ |
556 | /***************************************************/ |
557 | uint8_t MixerTable_WriteToEEProm(void) |
557 | uint8_t MixerTable_WriteToEEProm(void) |
558 | { |
558 | { |
559 | if(Mixer.Revision == EEMIXER_REVISION) |
559 | if(Mixer.Revision == EEMIXER_REVISION) |
560 | { |
560 | { |
561 | // update crc |
561 | // update crc |
562 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
562 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
563 | 563 | ||
564 | // write to eeprom |
564 | // write to eeprom |
565 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
565 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
566 | return 1; |
566 | return 1; |
567 | } |
567 | } |
568 | else return 0; |
568 | else return 0; |
569 | } |
569 | } |
570 | 570 | ||
571 | /***************************************************/ |
571 | /***************************************************/ |
572 | /* Default Values for Mixer Table */ |
572 | /* Default Values for Mixer Table */ |
573 | /***************************************************/ |
573 | /***************************************************/ |
574 | void MixerTable_Default(void) // Quadro |
574 | void MixerTable_Default(void) // Quadro |
575 | { |
575 | { |
576 | uint8_t i; |
576 | uint8_t i; |
577 | 577 | ||
578 | Mixer.Revision = EEMIXER_REVISION; |
578 | Mixer.Revision = EEMIXER_REVISION; |
579 | // clear mixer table |
579 | // clear mixer table |
580 | for(i = 0; i < 16; i++) |
580 | for(i = 0; i < 16; i++) |
581 | { |
581 | { |
582 | Mixer.Motor[i][MIX_GAS] = 0; |
582 | Mixer.Motor[i][MIX_GAS] = 0; |
583 | Mixer.Motor[i][MIX_NICK] = 0; |
583 | Mixer.Motor[i][MIX_NICK] = 0; |
584 | Mixer.Motor[i][MIX_ROLL] = 0; |
584 | Mixer.Motor[i][MIX_ROLL] = 0; |
585 | Mixer.Motor[i][MIX_YAW] = 0; |
585 | Mixer.Motor[i][MIX_YAW] = 0; |
586 | } |
586 | } |
587 | // default = Quadro |
587 | // default = Quadro |
588 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
588 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
589 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
589 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
590 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
590 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
591 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
591 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
592 | memcpy(Mixer.Name, "Quadro\0", 7); |
592 | memcpy(Mixer.Name, "Quadro\0", 7); |
593 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
593 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
594 | } |
594 | } |
595 | 595 | ||
596 | 596 | ||
597 | /***************************************************/ |
597 | /***************************************************/ |
598 | /* Get active parameter set */ |
598 | /* Get active parameter set */ |
599 | /***************************************************/ |
599 | /***************************************************/ |
600 | uint8_t GetActiveParamSet(void) |
600 | uint8_t GetActiveParamSet(void) |
601 | { |
601 | { |
602 | uint8_t setnumber; |
602 | uint8_t setnumber; |
603 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
603 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
604 | if(setnumber > 5) |
604 | if(setnumber > 5) |
605 | { |
605 | { |
606 | setnumber = 3; |
606 | setnumber = 3; |
607 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
607 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
608 | } |
608 | } |
609 | return(setnumber); |
609 | return(setnumber); |
610 | } |
610 | } |
611 | 611 | ||
612 | /***************************************************/ |
612 | /***************************************************/ |
613 | /* Set active parameter set */ |
613 | /* Set active parameter set */ |
614 | /***************************************************/ |
614 | /***************************************************/ |
615 | void SetActiveParamSet(uint8_t setnumber) |
615 | void SetActiveParamSet(uint8_t setnumber) |
616 | { |
616 | { |
617 | if(setnumber > 5) setnumber = 5; |
617 | if(setnumber > 5) setnumber = 5; |
618 | if(setnumber < 1) setnumber = 1; |
618 | if(setnumber < 1) setnumber = 1; |
619 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
619 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
620 | } |
620 | } |
621 | 621 | ||
622 | /***************************************************/ |
622 | /***************************************************/ |
623 | /* Initialize EEPROM Parameter Sets */ |
623 | /* Initialize EEPROM Parameter Sets */ |
624 | /***************************************************/ |
624 | /***************************************************/ |
625 | void ParamSet_Init(void) |
625 | void ParamSet_Init(void) |
626 | { |
626 | { |
627 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
627 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
628 | 628 | ||
629 | 629 | ||
630 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
630 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
631 | { |
631 | { |
632 | ee_default = 1; // software update or forced by mktool |
632 | ee_default = 1; // software update or forced by mktool |
633 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
633 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
634 | } |
634 | } |
635 | 635 | ||
636 | 636 | ||
637 | // 1st check for a valid channel backup in eeprom |
637 | // 1st check for a valid channel backup in eeprom |
638 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
638 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
639 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
639 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
640 | 640 | ||
641 | 641 | ||
642 | // parameter check |
642 | // parameter check |
643 | 643 | ||
644 | // check all 5 parameter settings |
644 | // check all 5 parameter settings |
645 | for (i = 1;i < 6; i++) |
645 | for (i = 1;i < 6; i++) |
646 | { |
646 | { |
647 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
647 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
648 | { |
648 | { |
649 | bad_params = 1; |
649 | bad_params = 1; |
650 | printf("\n\rGenerating default Parameter Set %d",i); |
650 | printf("\n\rGenerating default Parameter Set %d",i); |
651 | switch(i) |
651 | switch(i) |
652 | { |
652 | { |
653 | case 1: |
653 | case 1: |
654 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
654 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
655 | break; |
655 | break; |
656 | case 2: |
656 | case 2: |
657 | ParamSet_DefaultSet2(); // Kamera |
657 | ParamSet_DefaultSet2(); // Kamera |
658 | break; |
658 | break; |
659 | case 3: |
659 | case 3: |
660 | ParamSet_DefaultSet3(); // Beginner |
660 | ParamSet_DefaultSet3(); // Beginner |
661 | break; |
661 | break; |
662 | default: |
662 | default: |
663 | ParamSet_DefaultSet2(); // Kamera |
663 | ParamSet_DefaultSet2(); // Kamera |
664 | break; |
664 | break; |
665 | } |
665 | } |
666 | if(channel_backup) // if we have an channel mapping backup in eeprom |
666 | if(channel_backup) // if we have an channel mapping backup in eeprom |
667 | { // restore it from eeprom |
667 | { // restore it from eeprom |
668 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
668 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
669 | } |
669 | } |
670 | else |
670 | else |
671 | { // use default mapping |
671 | { // use default mapping |
672 | ParamSet_DefaultStickMapping(); |
672 | ParamSet_DefaultStickMapping(); |
673 | } |
673 | } |
674 | ParamSet_WriteToEEProm(i); |
674 | ParamSet_WriteToEEProm(i); |
675 | } |
675 | } |
676 | } |
676 | } |
677 | if(bad_params) // at least one of the parameter settings were invalid |
677 | if(bad_params) // at least one of the parameter settings were invalid |
678 | { |
678 | { |
679 | // default-Setting is parameter set 3 |
679 | // default-Setting is parameter set 3 |
680 | SetActiveParamSet(3); |
680 | SetActiveParamSet(3); |
681 | } |
681 | } |
682 | 682 | ||
683 | 683 | ||
684 | // read active parameter set to ParamSet stucture |
684 | // read active parameter set to ParamSet stucture |
685 | i = GetActiveParamSet(); |
685 | i = GetActiveParamSet(); |
686 | ParamSet_ReadFromEEProm(i); |
686 | ParamSet_ReadFromEEProm(i); |
687 | printf("\n\rUsing Parameter Set %d", i); |
687 | printf("\n\rUsing Parameter Set %d", i); |
688 | 688 | ||
689 | // load mixer table |
689 | // load mixer table |
690 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
690 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
691 | { |
691 | { |
692 | printf("\n\rGenerating default Mixer Table"); |
692 | printf("\n\rGenerating default Mixer Table"); |
693 | MixerTable_Default(); // Quadro |
693 | MixerTable_Default(); // Quadro |
694 | MixerTable_WriteToEEProm(); |
694 | MixerTable_WriteToEEProm(); |
695 | } |
695 | } |
696 | // determine motornumber |
696 | // determine motornumber |
697 | RequiredMotors = 0; |
697 | RequiredMotors = 0; |
698 | for(i = 0; i < 16; i++) |
698 | for(i = 0; i < 16; i++) |
699 | { |
699 | { |
700 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
700 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
701 | } |
701 | } |
702 | 702 | ||
703 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
703 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
704 | printf("\n\r=============================="); |
704 | printf("\n\r=============================="); |
705 | } |
705 | } |
706 | 706 |