Rev 1654 | Rev 1662 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1654 | Rev 1657 | ||
---|---|---|---|
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 | #include "twimaster.h" |
|
74 | 75 | ||
75 | paramset_t EE_Parameter; |
76 | paramset_t EE_Parameter; |
76 | MixerTable_t Mixer; |
77 | MixerTable_t Mixer; |
77 | uint8_t RequiredMotors; |
78 | uint8_t RequiredMotors; |
- | 79 | BLConfig_t BLConfig[MAX_MOTORS]; |
|
78 | 80 | ||
79 | 81 | ||
80 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
82 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
81 | { |
83 | { |
82 | uint8_t crc = 0xAA; |
84 | uint8_t crc = 0xAA; |
83 | uint16_t i; |
85 | uint16_t i; |
84 | 86 | ||
85 | for(i=0; i<len; i++) |
87 | for(i=0; i<len; i++) |
86 | { |
88 | { |
87 | crc += pBuffer[i]; |
89 | crc += pBuffer[i]; |
88 | } |
90 | } |
89 | return crc; |
91 | return crc; |
90 | } |
92 | } |
91 | 93 | ||
92 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
94 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
93 | { |
95 | { |
94 | uint8_t crc = 0xAA; |
96 | uint8_t crc = 0xAA; |
95 | uint16_t off; |
97 | uint16_t off; |
96 | 98 | ||
97 | for(off=0; off<len; off++) |
99 | for(off=0; off<len; off++) |
98 | { |
100 | { |
99 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
101 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
100 | } |
102 | } |
101 | return crc; |
103 | return crc; |
102 | } |
104 | } |
103 | 105 | ||
104 | void ParamSet_DefaultStickMapping(void) |
106 | void ParamSet_DefaultStickMapping(void) |
105 | { |
107 | { |
106 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
108 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
107 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
109 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
108 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
110 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
109 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
111 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
110 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
112 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
111 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
113 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
112 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
114 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
113 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
115 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
114 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
116 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
115 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
117 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
116 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
118 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
117 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
119 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
118 | } |
120 | } |
119 | 121 | ||
120 | 122 | ||
121 | /***************************************************/ |
123 | /***************************************************/ |
122 | /* Default Values for parameter set 1 */ |
124 | /* Default Values for parameter set 1 */ |
123 | /***************************************************/ |
125 | /***************************************************/ |
124 | void ParamSet_DefaultSet1(void) // sport |
126 | void ParamSet_DefaultSet1(void) // sport |
125 | { |
127 | { |
126 | EE_Parameter.Revision = EEPARAM_REVISION; |
128 | EE_Parameter.Revision = EEPARAM_REVISION; |
127 | 129 | ||
128 | if(PlatinenVersion >= 20) |
130 | if(PlatinenVersion >= 20) |
129 | { |
131 | { |
130 | EE_Parameter.Gyro_D = 5; |
132 | EE_Parameter.Gyro_D = 5; |
131 | EE_Parameter.Driftkomp = 0; |
133 | EE_Parameter.Driftkomp = 0; |
132 | EE_Parameter.GyroAccFaktor = 27; |
134 | EE_Parameter.GyroAccFaktor = 27; |
133 | EE_Parameter.WinkelUmschlagNick = 78; |
135 | EE_Parameter.WinkelUmschlagNick = 78; |
134 | EE_Parameter.WinkelUmschlagRoll = 78; |
136 | EE_Parameter.WinkelUmschlagRoll = 78; |
135 | } |
137 | } |
136 | else |
138 | else |
137 | { |
139 | { |
138 | EE_Parameter.Gyro_D = 3; |
140 | EE_Parameter.Gyro_D = 3; |
139 | EE_Parameter.Driftkomp = 32; |
141 | EE_Parameter.Driftkomp = 32; |
140 | EE_Parameter.GyroAccFaktor = 30; |
142 | EE_Parameter.GyroAccFaktor = 30; |
141 | EE_Parameter.WinkelUmschlagNick = 85; |
143 | EE_Parameter.WinkelUmschlagNick = 85; |
142 | EE_Parameter.WinkelUmschlagRoll = 85; |
144 | EE_Parameter.WinkelUmschlagRoll = 85; |
143 | } |
145 | } |
144 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
146 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
145 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
147 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
146 | EE_Parameter.Hoehe_MinGas = 30; |
148 | EE_Parameter.Hoehe_MinGas = 30; |
147 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
149 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
148 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
150 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
149 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
151 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
150 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
152 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
151 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
153 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
152 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
154 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
153 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
155 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
154 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
156 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
155 | EE_Parameter.Stick_P = 14; // Wert : 1-6 |
157 | EE_Parameter.Stick_P = 14; // Wert : 1-6 |
156 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
158 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
157 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
159 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
158 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
160 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
159 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
161 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
160 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
162 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
161 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
163 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
162 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
164 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
163 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
165 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
164 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
166 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
165 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
167 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
166 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
168 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
167 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
169 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
168 | EE_Parameter.I_Faktor = 32; |
170 | EE_Parameter.I_Faktor = 32; |
169 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
171 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
170 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
171 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
176 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
177 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
176 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
178 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
177 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
179 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
178 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
180 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
179 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
181 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
180 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
182 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
181 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
183 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
182 | EE_Parameter.ServoNickRefresh = 6; |
184 | EE_Parameter.ServoNickRefresh = 6; |
183 | EE_Parameter.Servo3 = 125; |
185 | EE_Parameter.Servo3 = 125; |
184 | EE_Parameter.Servo4 = 125; |
186 | EE_Parameter.Servo4 = 125; |
185 | EE_Parameter.Servo5 = 125; |
187 | EE_Parameter.Servo5 = 125; |
186 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
188 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
187 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
189 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
188 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
190 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
189 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
191 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
190 | EE_Parameter.LoopGasLimit = 50; |
192 | EE_Parameter.LoopGasLimit = 50; |
191 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
193 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
192 | EE_Parameter.LoopHysterese = 50; |
194 | EE_Parameter.LoopHysterese = 50; |
193 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
195 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
194 | EE_Parameter.AchsKopplung1 = 90; |
196 | EE_Parameter.AchsKopplung1 = 90; |
195 | EE_Parameter.AchsKopplung2 = 80; |
197 | EE_Parameter.AchsKopplung2 = 80; |
196 | EE_Parameter.CouplingYawCorrection = 1; |
198 | EE_Parameter.CouplingYawCorrection = 1; |
197 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
199 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
198 | EE_Parameter.DynamicStability = 100; |
200 | EE_Parameter.DynamicStability = 100; |
199 | EE_Parameter.J16Bitmask = 95; |
201 | EE_Parameter.J16Bitmask = 95; |
200 | EE_Parameter.J17Bitmask = 243; |
202 | EE_Parameter.J17Bitmask = 243; |
201 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
203 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
202 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
204 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
203 | EE_Parameter.J16Timing = 15; |
205 | EE_Parameter.J16Timing = 15; |
204 | EE_Parameter.J17Timing = 15; |
206 | EE_Parameter.J17Timing = 15; |
205 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
207 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
206 | EE_Parameter.NaviGpsGain = 100; |
208 | EE_Parameter.NaviGpsGain = 100; |
207 | EE_Parameter.NaviGpsP = 90; |
209 | EE_Parameter.NaviGpsP = 90; |
208 | EE_Parameter.NaviGpsI = 90; |
210 | EE_Parameter.NaviGpsI = 90; |
209 | EE_Parameter.NaviGpsD = 90; |
211 | EE_Parameter.NaviGpsD = 90; |
210 | EE_Parameter.NaviGpsPLimit = 75; |
212 | EE_Parameter.NaviGpsPLimit = 75; |
211 | EE_Parameter.NaviGpsILimit = 75; |
213 | EE_Parameter.NaviGpsILimit = 75; |
212 | EE_Parameter.NaviGpsDLimit = 75; |
214 | EE_Parameter.NaviGpsDLimit = 75; |
213 | EE_Parameter.NaviGpsACC = 0; |
215 | EE_Parameter.NaviGpsACC = 0; |
214 | EE_Parameter.NaviGpsMinSat = 6; |
216 | EE_Parameter.NaviGpsMinSat = 6; |
215 | EE_Parameter.NaviStickThreshold = 8; |
217 | EE_Parameter.NaviStickThreshold = 8; |
216 | EE_Parameter.NaviWindCorrection = 90; |
218 | EE_Parameter.NaviWindCorrection = 90; |
217 | EE_Parameter.NaviSpeedCompensation = 30; |
219 | EE_Parameter.NaviSpeedCompensation = 30; |
218 | EE_Parameter.NaviOperatingRadius = 100; |
220 | EE_Parameter.NaviOperatingRadius = 100; |
219 | EE_Parameter.NaviAngleLimitation = 100; |
221 | EE_Parameter.NaviAngleLimitation = 100; |
220 | EE_Parameter.NaviPH_LoginTime = 4; |
222 | EE_Parameter.NaviPH_LoginTime = 4; |
221 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
223 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
222 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
224 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
223 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
225 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
224 | } |
226 | } |
225 | 227 | ||
226 | 228 | ||
227 | /***************************************************/ |
229 | /***************************************************/ |
228 | /* Default Values for parameter set 2 */ |
230 | /* Default Values for parameter set 2 */ |
229 | /***************************************************/ |
231 | /***************************************************/ |
230 | void ParamSet_DefaultSet2(void) // normal |
232 | void ParamSet_DefaultSet2(void) // normal |
231 | { |
233 | { |
232 | EE_Parameter.Revision = EEPARAM_REVISION; |
234 | EE_Parameter.Revision = EEPARAM_REVISION; |
233 | 235 | ||
234 | if(PlatinenVersion >= 20) |
236 | if(PlatinenVersion >= 20) |
235 | { |
237 | { |
236 | EE_Parameter.Gyro_D = 5; |
238 | EE_Parameter.Gyro_D = 5; |
237 | EE_Parameter.Driftkomp = 0; |
239 | EE_Parameter.Driftkomp = 0; |
238 | EE_Parameter.GyroAccFaktor = 27; |
240 | EE_Parameter.GyroAccFaktor = 27; |
239 | EE_Parameter.WinkelUmschlagNick = 78; |
241 | EE_Parameter.WinkelUmschlagNick = 78; |
240 | EE_Parameter.WinkelUmschlagRoll = 78; |
242 | EE_Parameter.WinkelUmschlagRoll = 78; |
241 | } |
243 | } |
242 | else |
244 | else |
243 | { |
245 | { |
244 | EE_Parameter.Gyro_D = 3; |
246 | EE_Parameter.Gyro_D = 3; |
245 | EE_Parameter.Driftkomp = 32; |
247 | EE_Parameter.Driftkomp = 32; |
246 | EE_Parameter.GyroAccFaktor = 30; |
248 | EE_Parameter.GyroAccFaktor = 30; |
247 | EE_Parameter.WinkelUmschlagNick = 85; |
249 | EE_Parameter.WinkelUmschlagNick = 85; |
248 | EE_Parameter.WinkelUmschlagRoll = 85; |
250 | EE_Parameter.WinkelUmschlagRoll = 85; |
249 | } |
251 | } |
250 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
252 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
251 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
253 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
252 | EE_Parameter.Hoehe_MinGas = 30; |
254 | EE_Parameter.Hoehe_MinGas = 30; |
253 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
255 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
254 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
256 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
255 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
257 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
256 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
258 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
257 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
259 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
258 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
260 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
259 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
261 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
260 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
262 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
261 | EE_Parameter.Stick_P = 10; // Wert : 1-6 |
263 | EE_Parameter.Stick_P = 10; // Wert : 1-6 |
262 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
264 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
263 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
265 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
264 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
266 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
265 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
267 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
266 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
268 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
267 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
269 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
268 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
270 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
269 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
271 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
270 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
272 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
271 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
273 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
272 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
274 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
273 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
275 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
274 | EE_Parameter.I_Faktor = 32; |
276 | EE_Parameter.I_Faktor = 32; |
275 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
277 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
276 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
278 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
277 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
279 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
278 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
280 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
279 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
280 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
282 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
283 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
282 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
284 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
283 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
285 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
284 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
286 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
285 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
287 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
286 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
288 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
287 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
289 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
288 | EE_Parameter.ServoNickRefresh = 6; |
290 | EE_Parameter.ServoNickRefresh = 6; |
289 | EE_Parameter.Servo3 = 125; |
291 | EE_Parameter.Servo3 = 125; |
290 | EE_Parameter.Servo4 = 125; |
292 | EE_Parameter.Servo4 = 125; |
291 | EE_Parameter.Servo5 = 125; |
293 | EE_Parameter.Servo5 = 125; |
292 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
294 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
293 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
295 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
294 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
296 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
295 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
297 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
296 | EE_Parameter.LoopGasLimit = 50; |
298 | EE_Parameter.LoopGasLimit = 50; |
297 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
299 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
298 | EE_Parameter.LoopHysterese = 50; |
300 | EE_Parameter.LoopHysterese = 50; |
299 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
301 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
300 | EE_Parameter.AchsKopplung1 = 90; |
302 | EE_Parameter.AchsKopplung1 = 90; |
301 | EE_Parameter.AchsKopplung2 = 80; |
303 | EE_Parameter.AchsKopplung2 = 80; |
302 | EE_Parameter.CouplingYawCorrection = 60; |
304 | EE_Parameter.CouplingYawCorrection = 60; |
303 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
305 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
304 | EE_Parameter.DynamicStability = 75; |
306 | EE_Parameter.DynamicStability = 75; |
305 | EE_Parameter.J16Bitmask = 95; |
307 | EE_Parameter.J16Bitmask = 95; |
306 | EE_Parameter.J17Bitmask = 243; |
308 | EE_Parameter.J17Bitmask = 243; |
307 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
309 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
308 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
310 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
309 | EE_Parameter.J16Timing = 20; |
311 | EE_Parameter.J16Timing = 20; |
310 | EE_Parameter.J17Timing = 20; |
312 | EE_Parameter.J17Timing = 20; |
311 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
313 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
312 | EE_Parameter.NaviGpsGain = 100; |
314 | EE_Parameter.NaviGpsGain = 100; |
313 | EE_Parameter.NaviGpsP = 90; |
315 | EE_Parameter.NaviGpsP = 90; |
314 | EE_Parameter.NaviGpsI = 90; |
316 | EE_Parameter.NaviGpsI = 90; |
315 | EE_Parameter.NaviGpsD = 90; |
317 | EE_Parameter.NaviGpsD = 90; |
316 | EE_Parameter.NaviGpsPLimit = 75; |
318 | EE_Parameter.NaviGpsPLimit = 75; |
317 | EE_Parameter.NaviGpsILimit = 75; |
319 | EE_Parameter.NaviGpsILimit = 75; |
318 | EE_Parameter.NaviGpsDLimit = 75; |
320 | EE_Parameter.NaviGpsDLimit = 75; |
319 | EE_Parameter.NaviGpsACC = 0; |
321 | EE_Parameter.NaviGpsACC = 0; |
320 | EE_Parameter.NaviGpsMinSat = 6; |
322 | EE_Parameter.NaviGpsMinSat = 6; |
321 | EE_Parameter.NaviStickThreshold = 8; |
323 | EE_Parameter.NaviStickThreshold = 8; |
322 | EE_Parameter.NaviWindCorrection = 90; |
324 | EE_Parameter.NaviWindCorrection = 90; |
323 | EE_Parameter.NaviSpeedCompensation = 30; |
325 | EE_Parameter.NaviSpeedCompensation = 30; |
324 | EE_Parameter.NaviOperatingRadius = 100; |
326 | EE_Parameter.NaviOperatingRadius = 100; |
325 | EE_Parameter.NaviAngleLimitation = 100; |
327 | EE_Parameter.NaviAngleLimitation = 100; |
326 | EE_Parameter.NaviPH_LoginTime = 4; |
328 | EE_Parameter.NaviPH_LoginTime = 4; |
327 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
329 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
328 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
330 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
329 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
331 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
330 | } |
332 | } |
331 | 333 | ||
332 | 334 | ||
333 | /***************************************************/ |
335 | /***************************************************/ |
334 | /* Default Values for parameter set 3 */ |
336 | /* Default Values for parameter set 3 */ |
335 | /***************************************************/ |
337 | /***************************************************/ |
336 | void ParamSet_DefaultSet3(void) // beginner |
338 | void ParamSet_DefaultSet3(void) // beginner |
337 | { |
339 | { |
338 | EE_Parameter.Revision = EEPARAM_REVISION; |
340 | EE_Parameter.Revision = EEPARAM_REVISION; |
339 | if(PlatinenVersion >= 20) |
341 | if(PlatinenVersion >= 20) |
340 | { |
342 | { |
341 | EE_Parameter.Gyro_D = 5; |
343 | EE_Parameter.Gyro_D = 5; |
342 | EE_Parameter.Driftkomp = 0; |
344 | EE_Parameter.Driftkomp = 0; |
343 | EE_Parameter.GyroAccFaktor = 27; |
345 | EE_Parameter.GyroAccFaktor = 27; |
344 | EE_Parameter.WinkelUmschlagNick = 78; |
346 | EE_Parameter.WinkelUmschlagNick = 78; |
345 | EE_Parameter.WinkelUmschlagRoll = 78; |
347 | EE_Parameter.WinkelUmschlagRoll = 78; |
346 | } |
348 | } |
347 | else |
349 | else |
348 | { |
350 | { |
349 | EE_Parameter.Gyro_D = 3; |
351 | EE_Parameter.Gyro_D = 3; |
350 | EE_Parameter.Driftkomp = 32; |
352 | EE_Parameter.Driftkomp = 32; |
351 | EE_Parameter.GyroAccFaktor = 30; |
353 | EE_Parameter.GyroAccFaktor = 30; |
352 | EE_Parameter.WinkelUmschlagNick = 85; |
354 | EE_Parameter.WinkelUmschlagNick = 85; |
353 | EE_Parameter.WinkelUmschlagRoll = 85; |
355 | EE_Parameter.WinkelUmschlagRoll = 85; |
354 | } |
356 | } |
355 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
357 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
356 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
358 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC |
357 | EE_Parameter.Hoehe_MinGas = 30; |
359 | EE_Parameter.Hoehe_MinGas = 30; |
358 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
360 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
359 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
361 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
360 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
362 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
361 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
363 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-247 |
362 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
364 | EE_Parameter.Hoehe_HoverBand = 5; // Wert : 0-247 |
363 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
365 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
364 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
366 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
365 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
367 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
366 | EE_Parameter.Stick_P = 8; // Wert : 1-6 |
368 | EE_Parameter.Stick_P = 8; // Wert : 1-6 |
367 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
369 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
368 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
370 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
369 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
371 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
370 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
372 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
371 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
373 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
372 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
374 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
373 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
375 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
374 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
376 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
375 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
377 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
376 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
378 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
377 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
379 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
378 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
380 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
379 | EE_Parameter.I_Faktor = 16; |
381 | EE_Parameter.I_Faktor = 16; |
380 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
382 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
381 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
383 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
382 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
384 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
383 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
385 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
384 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
386 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
385 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
387 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
386 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
388 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
387 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
389 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
388 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
390 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
389 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
391 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
390 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
392 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
391 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
393 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
392 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
394 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
393 | EE_Parameter.ServoNickRefresh = 6; |
395 | EE_Parameter.ServoNickRefresh = 6; |
394 | EE_Parameter.Servo3 = 125; |
396 | EE_Parameter.Servo3 = 125; |
395 | EE_Parameter.Servo4 = 125; |
397 | EE_Parameter.Servo4 = 125; |
396 | EE_Parameter.Servo5 = 125; |
398 | EE_Parameter.Servo5 = 125; |
397 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
399 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
398 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
400 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
399 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
401 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
400 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
402 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
401 | EE_Parameter.LoopGasLimit = 50; |
403 | EE_Parameter.LoopGasLimit = 50; |
402 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
404 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
403 | EE_Parameter.LoopHysterese = 50; |
405 | EE_Parameter.LoopHysterese = 50; |
404 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
406 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
405 | EE_Parameter.AchsKopplung1 = 90; |
407 | EE_Parameter.AchsKopplung1 = 90; |
406 | EE_Parameter.AchsKopplung2 = 80; |
408 | EE_Parameter.AchsKopplung2 = 80; |
407 | EE_Parameter.CouplingYawCorrection = 70; |
409 | EE_Parameter.CouplingYawCorrection = 70; |
408 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
410 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
409 | EE_Parameter.DynamicStability = 50; |
411 | EE_Parameter.DynamicStability = 50; |
410 | EE_Parameter.J16Bitmask = 95; |
412 | EE_Parameter.J16Bitmask = 95; |
411 | EE_Parameter.J17Bitmask = 243; |
413 | EE_Parameter.J17Bitmask = 243; |
412 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
414 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
413 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
415 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
414 | EE_Parameter.J16Timing = 30; |
416 | EE_Parameter.J16Timing = 30; |
415 | EE_Parameter.J17Timing = 30; |
417 | EE_Parameter.J17Timing = 30; |
416 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
418 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
417 | EE_Parameter.NaviGpsGain = 100; |
419 | EE_Parameter.NaviGpsGain = 100; |
418 | EE_Parameter.NaviGpsP = 90; |
420 | EE_Parameter.NaviGpsP = 90; |
419 | EE_Parameter.NaviGpsI = 90; |
421 | EE_Parameter.NaviGpsI = 90; |
420 | EE_Parameter.NaviGpsD = 90; |
422 | EE_Parameter.NaviGpsD = 90; |
421 | EE_Parameter.NaviGpsPLimit = 75; |
423 | EE_Parameter.NaviGpsPLimit = 75; |
422 | EE_Parameter.NaviGpsILimit = 75; |
424 | EE_Parameter.NaviGpsILimit = 75; |
423 | EE_Parameter.NaviGpsDLimit = 75; |
425 | EE_Parameter.NaviGpsDLimit = 75; |
424 | EE_Parameter.NaviGpsACC = 0; |
426 | EE_Parameter.NaviGpsACC = 0; |
425 | EE_Parameter.NaviGpsMinSat = 6; |
427 | EE_Parameter.NaviGpsMinSat = 6; |
426 | EE_Parameter.NaviStickThreshold = 8; |
428 | EE_Parameter.NaviStickThreshold = 8; |
427 | EE_Parameter.NaviWindCorrection = 90; |
429 | EE_Parameter.NaviWindCorrection = 90; |
428 | EE_Parameter.NaviSpeedCompensation = 30; |
430 | EE_Parameter.NaviSpeedCompensation = 30; |
429 | EE_Parameter.NaviOperatingRadius = 100; |
431 | EE_Parameter.NaviOperatingRadius = 100; |
430 | EE_Parameter.NaviAngleLimitation = 100; |
432 | EE_Parameter.NaviAngleLimitation = 100; |
431 | EE_Parameter.NaviPH_LoginTime = 4; |
433 | EE_Parameter.NaviPH_LoginTime = 4; |
432 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
434 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
433 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
435 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
434 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
436 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
435 | } |
437 | } |
436 | 438 | ||
437 | /***************************************************/ |
439 | /***************************************************/ |
438 | /* Read Parameter from EEPROM as byte */ |
440 | /* Read Parameter from EEPROM as byte */ |
439 | /***************************************************/ |
441 | /***************************************************/ |
440 | uint8_t GetParamByte(uint16_t param_id) |
442 | uint8_t GetParamByte(uint16_t param_id) |
441 | { |
443 | { |
442 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
444 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
443 | } |
445 | } |
444 | 446 | ||
445 | /***************************************************/ |
447 | /***************************************************/ |
446 | /* Write Parameter to EEPROM as byte */ |
448 | /* Write Parameter to EEPROM as byte */ |
447 | /***************************************************/ |
449 | /***************************************************/ |
448 | void SetParamByte(uint16_t param_id, uint8_t value) |
450 | void SetParamByte(uint16_t param_id, uint8_t value) |
449 | { |
451 | { |
450 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
452 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
451 | } |
453 | } |
452 | 454 | ||
453 | /***************************************************/ |
455 | /***************************************************/ |
454 | /* Read Parameter from EEPROM as word */ |
456 | /* Read Parameter from EEPROM as word */ |
455 | /***************************************************/ |
457 | /***************************************************/ |
456 | uint16_t GetParamWord(uint16_t param_id) |
458 | uint16_t GetParamWord(uint16_t param_id) |
457 | { |
459 | { |
458 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
460 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
459 | } |
461 | } |
460 | 462 | ||
461 | /***************************************************/ |
463 | /***************************************************/ |
462 | /* Write Parameter to EEPROM as word */ |
464 | /* Write Parameter to EEPROM as word */ |
463 | /***************************************************/ |
465 | /***************************************************/ |
464 | void SetParamWord(uint16_t param_id, uint16_t value) |
466 | void SetParamWord(uint16_t param_id, uint16_t value) |
465 | { |
467 | { |
466 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
468 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
467 | } |
469 | } |
468 | 470 | ||
469 | /***************************************************/ |
471 | /***************************************************/ |
470 | /* Read Parameter Set from EEPROM */ |
472 | /* Read Parameter Set from EEPROM */ |
471 | /***************************************************/ |
473 | /***************************************************/ |
472 | // number [1..5] |
474 | // number [1..5] |
473 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
475 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
474 | { |
476 | { |
475 | uint8_t crc; |
477 | uint8_t crc; |
476 | uint16_t eeaddr; |
478 | uint16_t eeaddr; |
477 | 479 | ||
478 | // range the setnumber |
480 | // range the setnumber |
479 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
481 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
480 | 482 | ||
481 | // calculate eeprom addr |
483 | // calculate eeprom addr |
482 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
484 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
483 | 485 | ||
484 | // calculate checksum from eeprom |
486 | // calculate checksum from eeprom |
485 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
487 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
486 | 488 | ||
487 | // check crc |
489 | // check crc |
488 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
490 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
489 | 491 | ||
490 | // check revision |
492 | // check revision |
491 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
493 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
492 | 494 | ||
493 | // read paramset from eeprom |
495 | // read paramset from eeprom |
494 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
496 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
495 | LED_Init(); |
497 | LED_Init(); |
496 | return 1; |
498 | return 1; |
497 | } |
499 | } |
498 | 500 | ||
499 | /***************************************************/ |
501 | /***************************************************/ |
500 | /* Write Parameter Set to EEPROM */ |
502 | /* Write Parameter Set to EEPROM */ |
501 | /***************************************************/ |
503 | /***************************************************/ |
502 | // number [1..5] |
504 | // number [1..5] |
503 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
505 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
504 | { |
506 | { |
505 | uint8_t crc; |
507 | uint8_t crc; |
506 | 508 | ||
507 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
509 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
508 | { |
510 | { |
509 | if(setnumber > 5) setnumber = 5; |
511 | if(setnumber > 5) setnumber = 5; |
510 | if(setnumber < 1) return 0; |
512 | if(setnumber < 1) return 0; |
511 | 513 | ||
512 | // update checksum |
514 | // update checksum |
513 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
515 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
514 | 516 | ||
515 | // write paramset to eeprom |
517 | // write paramset to eeprom |
516 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
518 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
517 | 519 | ||
518 | // backup channel settings to separate block in eeprom |
520 | // backup channel settings to separate block in eeprom |
519 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
521 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
520 | 522 | ||
521 | // write crc of channel block to eeprom |
523 | // write crc of channel block to eeprom |
522 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
524 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
523 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
525 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
524 | 526 | ||
525 | // update active settings number |
527 | // update active settings number |
526 | SetActiveParamSet(setnumber); |
528 | SetActiveParamSet(setnumber); |
527 | LED_Init(); |
529 | LED_Init(); |
528 | return 1; |
530 | return 1; |
529 | } |
531 | } |
530 | // wrong revision |
532 | // wrong revision |
531 | return 0; |
533 | return 0; |
532 | } |
534 | } |
533 | 535 | ||
534 | /***************************************************/ |
536 | /***************************************************/ |
535 | /* Read MixerTable from EEPROM */ |
537 | /* Read MixerTable from EEPROM */ |
536 | /***************************************************/ |
538 | /***************************************************/ |
537 | uint8_t MixerTable_ReadFromEEProm(void) |
539 | uint8_t MixerTable_ReadFromEEProm(void) |
538 | { |
540 | { |
539 | uint8_t crc; |
541 | uint8_t crc; |
540 | 542 | ||
541 | // calculate checksum in eeprom |
543 | // calculate checksum in eeprom |
542 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
544 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
543 | 545 | ||
544 | // check crc |
546 | // check crc |
545 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
547 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
546 | 548 | ||
547 | // check revision |
549 | // check revision |
548 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
550 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
549 | 551 | ||
550 | // read mixer table |
552 | // read mixer table |
551 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
553 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
552 | return 1; |
554 | return 1; |
553 | } |
555 | } |
554 | 556 | ||
555 | /***************************************************/ |
557 | /***************************************************/ |
556 | /* Write Mixer Table to EEPROM */ |
558 | /* Write Mixer Table to EEPROM */ |
557 | /***************************************************/ |
559 | /***************************************************/ |
558 | uint8_t MixerTable_WriteToEEProm(void) |
560 | uint8_t MixerTable_WriteToEEProm(void) |
559 | { |
561 | { |
560 | if(Mixer.Revision == EEMIXER_REVISION) |
562 | if(Mixer.Revision == EEMIXER_REVISION) |
561 | { |
563 | { |
562 | // update crc |
564 | // update crc |
563 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
565 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
564 | 566 | ||
565 | // write to eeprom |
567 | // write to eeprom |
566 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
568 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
567 | return 1; |
569 | return 1; |
568 | } |
570 | } |
569 | else return 0; |
571 | else return 0; |
570 | } |
572 | } |
571 | 573 | ||
572 | /***************************************************/ |
574 | /***************************************************/ |
573 | /* Default Values for Mixer Table */ |
575 | /* Default Values for Mixer Table */ |
574 | /***************************************************/ |
576 | /***************************************************/ |
575 | void MixerTable_Default(void) // Quadro |
577 | void MixerTable_Default(void) // Quadro |
576 | { |
578 | { |
577 | uint8_t i; |
579 | uint8_t i; |
578 | 580 | ||
579 | Mixer.Revision = EEMIXER_REVISION; |
581 | Mixer.Revision = EEMIXER_REVISION; |
580 | // clear mixer table |
582 | // clear mixer table |
581 | for(i = 0; i < 16; i++) |
583 | for(i = 0; i < 16; i++) |
582 | { |
584 | { |
583 | Mixer.Motor[i][MIX_GAS] = 0; |
585 | Mixer.Motor[i][MIX_GAS] = 0; |
584 | Mixer.Motor[i][MIX_NICK] = 0; |
586 | Mixer.Motor[i][MIX_NICK] = 0; |
585 | Mixer.Motor[i][MIX_ROLL] = 0; |
587 | Mixer.Motor[i][MIX_ROLL] = 0; |
586 | Mixer.Motor[i][MIX_YAW] = 0; |
588 | Mixer.Motor[i][MIX_YAW] = 0; |
587 | } |
589 | } |
588 | // default = Quadro |
590 | // default = Quadro |
589 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
591 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
590 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
592 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
591 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
593 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
592 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
594 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
593 | memcpy(Mixer.Name, "Quadro\0", 7); |
595 | memcpy(Mixer.Name, "Quadro\0", 7); |
594 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
596 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
595 | } |
597 | } |
596 | 598 | ||
597 | 599 | ||
598 | /***************************************************/ |
600 | /***************************************************/ |
- | 601 | /* Read BL-Config from EEPROM */ |
|
- | 602 | /***************************************************/ |
|
- | 603 | uint8_t BLConfig_ReadFromEEProm(uint8_t index) |
|
- | 604 | { |
|
- | 605 | uint8_t crc; |
|
- | 606 | uint16_t eeadr = EEPROM_ADR_BLCONFIG + (uint16_t)index * sizeof(BLConfig_t); |
|
- | 607 | // calculate checksum in eeprom |
|
- | 608 | crc = EEProm_Checksum(eeadr, sizeof(BLConfig_t) - 1); |
|
- | 609 | ||
- | 610 | // check crc |
|
- | 611 | if( crc != eeprom_read_byte((uint8_t*)(eeadr + sizeof(BLConfig_t) - 1)) ) return 0; |
|
- | 612 | ||
- | 613 | // check revision |
|
- | 614 | if(eeprom_read_byte((uint8_t*)(eeadr)) != EEBLCONFIG_REVISON) return 0; |
|
- | 615 | ||
- | 616 | // read mixer BLConfig |
|
- | 617 | eeprom_read_block((void *)&(BLConfig[index]), (void*)(eeadr), sizeof(BLConfig_t)); |
|
- | 618 | return 1; |
|
- | 619 | } |
|
- | 620 | ||
- | 621 | /***************************************************/ |
|
- | 622 | /* Write BL-Config to EEPROM */ |
|
- | 623 | /***************************************************/ |
|
- | 624 | uint8_t BLConfig_WriteToEEProm(uint8_t index) |
|
- | 625 | { |
|
- | 626 | uint16_t eeadr = EEPROM_ADR_BLCONFIG + (uint16_t)index * sizeof(BLConfig_t); |
|
- | 627 | if(index >= MAX_MOTORS) return 0; |
|
- | 628 | if(BLConfig[index].Revision == EEBLCONFIG_REVISON) |
|
- | 629 | { |
|
- | 630 | // update crc |
|
- | 631 | BLConfig[index].crc = RAM_Checksum((uint8_t*)(&(BLConfig[index])), sizeof(BLConfig_t) - 1); |
|
- | 632 | ||
- | 633 | // write to eeprom |
|
- | 634 | eeprom_write_block((void *) &(BLConfig[index]), (void*)(eeadr), sizeof(BLConfig_t)); |
|
- | 635 | return 1; |
|
- | 636 | } |
|
- | 637 | else return 0; |
|
- | 638 | } |
|
- | 639 | ||
- | 640 | /***************************************************/ |
|
- | 641 | /* Default BLConfig */ |
|
- | 642 | /***************************************************/ |
|
- | 643 | void BLConfig_SetDefault(uint8_t index) |
|
- | 644 | { |
|
- | 645 | if(index < MAX_MOTORS) |
|
- | 646 | { |
|
- | 647 | BLConfig[index].Revision = EEBLCONFIG_REVISON; // set revision |
|
- | 648 | BLConfig[index].SetMask = MASK_SET_PWM_SCALING|MASK_SET_CURRENT_LIMIT|MASK_SET_TEMP_LIMIT|MASK_SET_CURRENT_SCALING|MASK_SET_BITCONFIG; |
|
- | 649 | BLConfig[index].PwmScaling = 255; // MaxPWM |
|
- | 650 | BLConfig[index].CurrentLimit = 30; // Current Limit in A |
|
- | 651 | BLConfig[index].TempLimit = 99; // Temperature Limit in °C |
|
- | 652 | BLConfig[index].CurrentScaling = 64; // Current Scaling |
|
- | 653 | BLConfig[index].BitConfig = 0; // BitConfig |
|
- | 654 | BLConfig[index].crc = RAM_Checksum((uint8_t*)&(BLConfig[index]), sizeof(BLConfig_t) - 1); // update checksum |
|
- | 655 | } |
|
- | 656 | } |
|
- | 657 | ||
- | 658 | ||
- | 659 | /***************************************************/ |
|
599 | /* Get active parameter set */ |
660 | /* Get active parameter set */ |
600 | /***************************************************/ |
661 | /***************************************************/ |
601 | uint8_t GetActiveParamSet(void) |
662 | uint8_t GetActiveParamSet(void) |
602 | { |
663 | { |
603 | uint8_t setnumber; |
664 | uint8_t setnumber; |
604 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
665 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
605 | if(setnumber > 5) |
666 | if(setnumber > 5) |
606 | { |
667 | { |
607 | setnumber = 3; |
668 | setnumber = 3; |
608 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
669 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
609 | } |
670 | } |
610 | return(setnumber); |
671 | return(setnumber); |
611 | } |
672 | } |
612 | 673 | ||
613 | /***************************************************/ |
674 | /***************************************************/ |
614 | /* Set active parameter set */ |
675 | /* Set active parameter set */ |
615 | /***************************************************/ |
676 | /***************************************************/ |
616 | void SetActiveParamSet(uint8_t setnumber) |
677 | void SetActiveParamSet(uint8_t setnumber) |
617 | { |
678 | { |
618 | if(setnumber > 5) setnumber = 5; |
679 | if(setnumber > 5) setnumber = 5; |
619 | if(setnumber < 1) setnumber = 1; |
680 | if(setnumber < 1) setnumber = 1; |
620 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
681 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
621 | } |
682 | } |
622 | 683 | ||
623 | /***************************************************/ |
684 | /***************************************************/ |
624 | /* Initialize EEPROM Parameter Sets */ |
685 | /* Initialize EEPROM Parameter Sets */ |
625 | /***************************************************/ |
686 | /***************************************************/ |
626 | void ParamSet_Init(void) |
687 | void ParamSet_Init(void) |
627 | { |
688 | { |
628 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
689 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
629 | 690 | ||
630 | 691 | ||
631 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
692 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
632 | { |
693 | { |
633 | ee_default = 1; // software update or forced by mktool |
694 | ee_default = 1; // software update or forced by mktool |
634 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
695 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
635 | } |
696 | } |
636 | 697 | ||
637 | 698 | ||
638 | // 1st check for a valid channel backup in eeprom |
699 | // 1st check for a valid channel backup in eeprom |
639 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
700 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
640 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
701 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
641 | 702 | ||
642 | 703 | ||
643 | // parameter check |
704 | // parameter check |
644 | 705 | ||
645 | // check all 5 parameter settings |
706 | // check all 5 parameter settings |
646 | for (i = 1;i < 6; i++) |
707 | for (i = 1;i < 6; i++) |
647 | { |
708 | { |
648 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
709 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
649 | { |
710 | { |
650 | bad_params = 1; |
711 | bad_params = 1; |
651 | printf("\n\rGenerating default Parameter Set %d",i); |
712 | printf("\n\rGenerating default Parameter Set %d",i); |
652 | switch(i) |
713 | switch(i) |
653 | { |
714 | { |
654 | case 1: |
715 | case 1: |
655 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
716 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
656 | break; |
717 | break; |
657 | case 2: |
718 | case 2: |
658 | ParamSet_DefaultSet2(); // Kamera |
719 | ParamSet_DefaultSet2(); // Kamera |
659 | break; |
720 | break; |
660 | case 3: |
721 | case 3: |
661 | ParamSet_DefaultSet3(); // Beginner |
722 | ParamSet_DefaultSet3(); // Beginner |
662 | break; |
723 | break; |
663 | default: |
724 | default: |
664 | ParamSet_DefaultSet2(); // Kamera |
725 | ParamSet_DefaultSet2(); // Kamera |
665 | break; |
726 | break; |
666 | } |
727 | } |
667 | if(channel_backup) // if we have an channel mapping backup in eeprom |
728 | if(channel_backup) // if we have an channel mapping backup in eeprom |
668 | { // restore it from eeprom |
729 | { // restore it from eeprom |
669 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
730 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
670 | } |
731 | } |
671 | else |
732 | else |
672 | { // use default mapping |
733 | { // use default mapping |
673 | ParamSet_DefaultStickMapping(); |
734 | ParamSet_DefaultStickMapping(); |
674 | } |
735 | } |
675 | ParamSet_WriteToEEProm(i); |
736 | ParamSet_WriteToEEProm(i); |
676 | } |
737 | } |
677 | } |
738 | } |
678 | if(bad_params) // at least one of the parameter settings were invalid |
739 | if(bad_params) // at least one of the parameter settings were invalid |
679 | { |
740 | { |
680 | // default-Setting is parameter set 3 |
741 | // default-Setting is parameter set 3 |
681 | SetActiveParamSet(3); |
742 | SetActiveParamSet(3); |
682 | } |
743 | } |
683 | 744 | ||
684 | 745 | ||
685 | // read active parameter set to ParamSet stucture |
746 | // read active parameter set to ParamSet stucture |
686 | i = GetActiveParamSet(); |
747 | i = GetActiveParamSet(); |
687 | ParamSet_ReadFromEEProm(i); |
748 | ParamSet_ReadFromEEProm(i); |
688 | printf("\n\rUsing Parameter Set %d", i); |
749 | printf("\n\rUsing Parameter Set %d", i); |
- | 750 | ||
- | 751 | // load all BLConfig's |
|
- | 752 | for(i=0; i<MAX_MOTORS; i++) |
|
- | 753 | { |
|
- | 754 | if(ee_default || !BLConfig_ReadFromEEProm(i)) // could not read BLConfig from eeprom |
|
- | 755 | { |
|
- | 756 | printf("\n\rGenerating default BL-Config for motor %d", i+1); |
|
- | 757 | BLConfig_SetDefault(i); |
|
- | 758 | BLConfig_WriteToEEProm(i); |
|
- | 759 | } |
|
- | 760 | } |
|
689 | 761 | ||
690 | // load mixer table |
762 | // load mixer table |
691 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
763 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
692 | { |
764 | { |
693 | printf("\n\rGenerating default Mixer Table"); |
765 | printf("\n\rGenerating default Mixer Table"); |
694 | MixerTable_Default(); // Quadro |
766 | MixerTable_Default(); // Quadro |
695 | MixerTable_WriteToEEProm(); |
767 | MixerTable_WriteToEEProm(); |
696 | } |
768 | } |
697 | // determine motornumber |
769 | // determine motornumber |
698 | RequiredMotors = 0; |
770 | RequiredMotors = 0; |
699 | for(i = 0; i < 16; i++) |
771 | for(i = 0; i < 16; i++) |
700 | { |
772 | { |
701 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
773 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
702 | } |
774 | } |
703 | 775 | ||
704 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
776 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
705 | printf("\n\r=============================="); |
777 | printf("\n\r=============================="); |
706 | } |
778 | } |
707 | 779 |