Rev 2073 | Rev 2089 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2073 | Rev 2088 | ||
---|---|---|---|
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 | #include <util/delay.h> |
1 | #include <util/delay.h> |
53 | #include <stddef.h> |
2 | #include <stddef.h> |
54 | #include <string.h> |
3 | #include <string.h> |
55 | #include "configuration.h" |
4 | #include "configuration.h" |
56 | #include "sensors.h" |
5 | #include "sensors.h" |
Line 62... | Line 11... | ||
62 | ParamSet_t staticParams; |
11 | ParamSet_t staticParams; |
63 | channelMap_t channelMap; |
12 | channelMap_t channelMap; |
64 | mixerMatrix_t mixerMatrix; |
13 | mixerMatrix_t mixerMatrix; |
65 | volatile DynamicParams_t dynamicParams; |
14 | volatile DynamicParams_t dynamicParams; |
Line 66... | Line 15... | ||
66 | 15 | ||
67 | uint8_t CPUType = ATMEGA644; |
16 | uint8_t CPUType; |
68 | uint8_t boardRelease = 13; |
17 | uint8_t boardRelease; |
Line 69... | Line 18... | ||
69 | uint8_t requiredMotors; |
18 | uint8_t requiredMotors; |
Line 70... | Line 19... | ||
70 | 19 | ||
Line 118... | Line 67... | ||
118 | pointerToTgt = (uint8_t*)(&dynamicParams) + offsetof(DynamicParams_t, userParams) + i; |
67 | pointerToTgt = (uint8_t*)(&dynamicParams) + offsetof(DynamicParams_t, userParams) + i; |
119 | *pointerToTgt = configuration_applyVariableToParam(src, 0, 255); |
68 | *pointerToTgt = configuration_applyVariableToParam(src, 0, 255); |
120 | } |
69 | } |
121 | } |
70 | } |
Line 122... | Line 71... | ||
122 | 71 | ||
123 | uint8_t getCPUType(void) { // works only after reset or power on when the registers have default values |
- | |
124 | uint8_t CPUType = ATMEGA644; |
72 | void setCPUType(void) { // works only after reset or power on when the registers have default values |
125 | if((UCSR1A == 0x20) && (UCSR1C == 0x06)) CPUType = ATMEGA644P; // initial Values for 644P after reset |
73 | if((UCSR1A == 0x20) && (UCSR1C == 0x06)) CPUType = ATMEGA644P; // initial Values for 644P after reset |
126 | return CPUType; |
74 | else CPUType = ATMEGA644; |
Line 127... | Line 75... | ||
127 | } |
75 | } |
128 | 76 | ||
129 | /* |
77 | /* |
Line 134... | Line 82... | ||
134 | * from the makefile. |
82 | * from the makefile. |
135 | * However - we still do detect the board release. Reason: Otherwise it would be too |
83 | * However - we still do detect the board release. Reason: Otherwise it would be too |
136 | * tedious to have to modify the code for how to turn on and off LEDs when deploying |
84 | * tedious to have to modify the code for how to turn on and off LEDs when deploying |
137 | * on different HW version.... |
85 | * on different HW version.... |
138 | */ |
86 | */ |
139 | uint8_t getBoardRelease(void) { |
87 | void setBoardRelease(void) { |
140 | uint8_t boardRelease = 13; |
- | |
141 | // the board release is coded via the pull up or down the 2 status LED |
88 | // the board release is coded via the pull up or down the 2 status LED |
Line 142... | Line 89... | ||
142 | 89 | ||
143 | PORTB &= ~((1 << PORTB1)|(1 << PORTB0)); // set tristate |
90 | PORTB &= ~((1 << PORTB1)|(1 << PORTB0)); // set tristate |
Line 163... | Line 110... | ||
163 | } |
110 | } |
164 | // set LED ports as output |
111 | // set LED ports as output |
165 | DDRB |= (1<<DDB1)|(1<<DDB0); |
112 | DDRB |= (1<<DDB1)|(1<<DDB0); |
166 | RED_OFF; |
113 | RED_OFF; |
167 | GRN_OFF; |
114 | GRN_OFF; |
168 | return boardRelease; |
- | |
169 | } |
115 | } |
Line 170... | Line 116... | ||
170 | 116 | ||
171 | void configuration_setNormalFlightParameters(void) { |
117 | void configuration_setNormalFlightParameters(void) { |
172 | flight_setParameters(staticParams.IFactor, dynamicParams.gyroP, |
118 | flight_setParameters(staticParams.IFactor, dynamicParams.gyroP, |