Rev 2055 | Rev 2092 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2055 | Rev 2059 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
2 | // + Copyright (c) 04.2007 Holger Buss |
- | |
3 | // + Nur für den privaten Gebrauch |
- | |
4 | // + www.MikroKopter.com |
- | |
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
6 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
- | |
7 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten und nicht-kommerziellen Gebrauch zulässig ist. |
- | |
8 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
- | |
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
- | |
10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
- | |
11 | // + Verkauf von Luftbildaufnahmen, usw. |
- | |
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
13 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
- | |
14 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
- | |
15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
16 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
- | |
17 | // + auf anderen Webseiten oder Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
- | |
18 | // + eindeutig als Ursprung verlinkt und genannt werden |
- | |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
20 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
- | |
21 | // + Benutzung auf eigene Gefahr |
- | |
22 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
- | |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
24 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
- | |
25 | // + mit unserer Zustimmung zulässig |
- | |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
- | |
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
- | |
30 | // + this list of conditions and the following disclaimer. |
- | |
31 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
- | |
32 | // + from this software without specific prior written permission. |
- | |
33 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
- | |
34 | // + for non-commercial use (directly or indirectly) |
- | |
35 | // + Commercial use (for example: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
- | |
36 | // + with our written permission |
- | |
37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
- | |
38 | // + clearly linked as origin |
- | |
39 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
- | |
40 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
41 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
42 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
- | |
43 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
- | |
44 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
- | |
45 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
- | |
46 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
- | |
47 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
- | |
48 | // + 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 |
- | |
50 | // + POSSIBILITY OF SUCH DAMAGE. |
- | |
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
52 | - | ||
53 | #ifndef EEMEM |
1 | #ifndef EEMEM |
54 | #define EEMEM __attribute__ ((section (".eeprom"))) |
2 | #define EEMEM __attribute__ ((section (".eeprom"))) |
55 | #endif |
3 | #endif |
Line 56... | Line 4... | ||
56 | 4 | ||
Line 139... | Line 87... | ||
139 | /* Read Parameter Set from EEPROM */ |
87 | /* Read Parameter Set from EEPROM */ |
140 | /***************************************************/ |
88 | /***************************************************/ |
141 | // setnumber [1..5] |
89 | // setnumber [1..5] |
142 | uint8_t paramSet_readFromEEProm(uint8_t setnumber) { |
90 | uint8_t paramSet_readFromEEProm(uint8_t setnumber) { |
143 | uint16_t offset = EEPROM_ADR_PARAMSET_BEGIN + (setnumber-1)*(sizeof(ParamSet_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD); |
91 | uint16_t offset = EEPROM_ADR_PARAMSET_BEGIN + (setnumber-1)*(sizeof(ParamSet_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD); |
144 | // output_init(); // what's that doing here?? |
- | |
145 | return readChecksummedBlock(EEPARAM_REVISION, (uint8_t*)&staticParams, offset, sizeof(ParamSet_t)); |
92 | uint8_t result = readChecksummedBlock(EEPARAM_REVISION, (uint8_t*)&staticParams, offset, sizeof(ParamSet_t)); |
- | 93 | configuration_paramSetDidChange(); |
|
- | 94 | return result; |
|
146 | } |
95 | } |
Line 147... | Line 96... | ||
147 | 96 | ||
148 | /***************************************************/ |
97 | /***************************************************/ |
149 | /* Write Parameter Set to EEPROM */ |
98 | /* Write Parameter Set to EEPROM */ |
150 | /***************************************************/ |
99 | /***************************************************/ |
151 | void paramSet_writeToEEProm(uint8_t setnumber) { |
100 | void paramSet_writeToEEProm(uint8_t setnumber) { |
152 | uint16_t offset = EEPROM_ADR_PARAMSET_BEGIN + (setnumber-1)*(sizeof(ParamSet_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD); |
101 | uint16_t offset = EEPROM_ADR_PARAMSET_BEGIN + (setnumber-1)*(sizeof(ParamSet_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD); |
153 | writeChecksummedBlock(EEPARAM_REVISION, (uint8_t*)&staticParams, offset, sizeof(ParamSet_t)); |
102 | writeChecksummedBlock(EEPARAM_REVISION, (uint8_t*)&staticParams, offset, sizeof(ParamSet_t)); |
154 | // set this parameter set to active set |
- | |
155 | setActiveParamSet(setnumber); |
- | |
156 | // output_init(); // what's that doing here?? |
103 | // set this parameter set to active set |
Line 157... | Line 104... | ||
157 | } |
104 | } |
158 | 105 | ||
159 | void paramSet_readOrDefault() { |
106 | void paramSet_readOrDefault() { |
Line 164... | Line 111... | ||
164 | printf("\n\rwriting default parameter sets"); |
111 | printf("\n\rwriting default parameter sets"); |
165 | for (uint8_t i=5; i>0; i--) { |
112 | for (uint8_t i=5; i>0; i--) { |
166 | paramSet_default(i); |
113 | paramSet_default(i); |
167 | paramSet_writeToEEProm(i); |
114 | paramSet_writeToEEProm(i); |
168 | } |
115 | } |
169 | // default-Setting is parameter set 3 |
116 | // default-Setting is parameter set 1 |
170 | setActiveParamSet(1); |
117 | setActiveParamSet(1); |
- | 118 | paramSet_readFromEEProm(getActiveParamSet()); |
|
171 | // For some strange reason, the read will have no effect. |
119 | // For some strange reason, the read will have no effect. |
172 | // Lets reset... |
120 | // Lets reset... |
173 | wdt_enable(WDTO_250MS); |
121 | // wdt_enable(WDTO_500MS); |
174 | } |
122 | } |
175 | - | ||
176 | printf("\n\r\rUsing Parameter Set %d", getActiveParamSet()); |
123 | printf("\n\r\rUsing Parameter Set %d", getActiveParamSet()); |
177 | } |
124 | } |
Line 178... | Line 125... | ||
178 | 125 | ||
179 | /***************************************************/ |
126 | /***************************************************/ |
Line 211... | Line 158... | ||
211 | void channelMap_readOrDefault(void) { |
158 | void channelMap_readOrDefault(void) { |
212 | if (readChecksummedBlock(CHANNELMAP_REVISION, (uint8_t*)&channelMap, EEPROM_ADR_CHANNELMAP, sizeof(channelMap_t))) { |
159 | if (readChecksummedBlock(CHANNELMAP_REVISION, (uint8_t*)&channelMap, EEPROM_ADR_CHANNELMAP, sizeof(channelMap_t))) { |
213 | printf("writing default channel map"); |
160 | printf("writing default channel map"); |
214 | channelMap_default(); |
161 | channelMap_default(); |
215 | channelMap_writeToEEProm(); |
162 | channelMap_writeToEEProm(); |
- | 163 | wdt_enable(WDTO_500MS); |
|
216 | } |
164 | } |
217 | } |
165 | } |
Line 218... | Line 166... | ||
218 | 166 | ||
219 | /***************************************************/ |
167 | /***************************************************/ |
Line 247... | Line 195... | ||
247 | /* Get active parameter set */ |
195 | /* Get active parameter set */ |
248 | /***************************************************/ |
196 | /***************************************************/ |
249 | uint8_t getActiveParamSet(void) { |
197 | uint8_t getActiveParamSet(void) { |
250 | uint8_t setnumber; |
198 | uint8_t setnumber; |
251 | setnumber = eeprom_read_byte(&EEPromArray[PID_ACTIVE_SET]); |
199 | setnumber = eeprom_read_byte(&EEPromArray[PID_ACTIVE_SET]); |
252 | if (setnumber > 4) { |
200 | if (setnumber > 5) { |
253 | setActiveParamSet(setnumber = 0); |
201 | setActiveParamSet(setnumber = 1); |
254 | } |
202 | } |
255 | return setnumber; |
203 | return setnumber; |
256 | } |
204 | } |
Line 257... | Line 205... | ||
257 | 205 |