Subversion Repositories FlightCtrl

Rev

Rev 2033 | Rev 2039 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2033 Rev 2035
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
#include <avr/io.h>
1
#include <avr/io.h>
54
#include <avr/interrupt.h>
2
#include <avr/interrupt.h>
55
#include <avr/wdt.h>
3
#include <avr/wdt.h>
56
#include <avr/pgmspace.h>
4
#include <avr/pgmspace.h>
57
#include <stdarg.h>
5
#include <stdarg.h>
Line 135... Line 83...
135
                "-               ",
83
                "-               ",
136
                "Pitch Term      ",
84
                "Pitch Term      ",
137
                "Roll Term       ",
85
                "Roll Term       ",
138
                "Yaw Term        ",
86
                "Yaw Term        ",
139
                "Throttle Term   ", //15
87
                "Throttle Term   ", //15
140
                "gyroP           ",
88
                "-               ",
141
                "ControlAct/10   ",
89
                "ControlAct/10   ",
142
        "Acc. Vector     ",
90
        "Acc. Vector     ",
143
        "targetheight    ",
-
 
144
                "var0            ", //20
-
 
145
                "dHeightThrottle ",
91
                "heightTrottleIn ",
146
                "M1              ",
-
 
147
                "M2              ",
-
 
148
                "M3              ",
-
 
149
                "M4              ", //25
92
                "HeightdThrottle ", //20
150
                "Height          ",
93
                "Height          ",
151
                "HeightI",
94
                "TargetHeight    ",
152
                "DriftCompPitch  ",
95
                "heightError     ",
-
 
96
                "HeightPdThrottle",
-
 
97
                "HeightIdThrottle", //25
-
 
98
                "HeightDdThrottle",
-
 
99
                "HeightPFactor   ",
153
                "DriftCompRoll   ",
100
                "HeightIFactor   ",
-
 
101
                "HeightDFactor   ",
154
                "Altitude        ", //30
102
                "Altitude        ", //30
155
                "AirpressADC     " };
103
                "AirpressADC     " };
Line 156... Line 104...
156
 
104
 
157
/****************************************************************/
105
/****************************************************************/
Line 557... Line 505...
557
                        break;
505
                        break;
Line 558... Line 506...
558
 
506
 
559
                case 's': // save settings
507
                case 's': // save settings
560
                        if (!(MKFlags & MKFLAG_MOTOR_RUN)) // save settings only if motors are off
508
                        if (!(MKFlags & MKFLAG_MOTOR_RUN)) // save settings only if motors are off
561
                        {
-
 
562
                                if ((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1]
509
                        {
563
                                                == EEPARAM_REVISION)) // check for setting to be in range and version of settings
510
                                if ((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_REVISION)) // check for setting to be in range and version of settings
564
                                {
511
                                {
565
                                        memcpy(&staticParams, (uint8_t*) &pRxData[2], sizeof(staticParams));
512
                                        memcpy(&staticParams, (uint8_t*) &pRxData[2], sizeof(staticParams));
566
                                        paramSet_writeToEEProm(pRxData[0]);
513
                                        paramSet_writeToEEProm(pRxData[0]);
567
                                        tempchar[0] = getActiveParamSet();
514
                                        tempchar[0] = getActiveParamSet();
Line 641... Line 588...
641
        rxDataLen = 0;
588
        rxDataLen = 0;
642
        rxd_buffer_locked = FALSE;
589
        rxd_buffer_locked = FALSE;
643
}
590
}
Line 644... Line 591...
644
 
591
 
645
/************************************************************************/
592
/************************************************************************/
646
/* Routine für die Serielle Ausgabe                                     */
593
/* Routine f�r die Serielle Ausgabe                                     */
647
/************************************************************************/
594
/************************************************************************/
648
int16_t uart_putchar(int8_t c) {
595
int16_t uart_putchar(int8_t c) {
649
        if (c == '\n')
596
        if (c == '\n')
650
                uart_putchar('\r');
597
                uart_putchar('\r');
Line 680... Line 627...
680
                sendOutData('L', FC_ADDRESS, 3, &menuItem, sizeof(menuItem), &maxMenuItem,
627
                sendOutData('L', FC_ADDRESS, 3, &menuItem, sizeof(menuItem), &maxMenuItem,
681
                                sizeof(maxMenuItem), displayBuff, sizeof(displayBuff));
628
                                sizeof(maxMenuItem), displayBuff, sizeof(displayBuff));
682
                request_display1 = FALSE;
629
                request_display1 = FALSE;
683
        }
630
        }
Line 684... Line 631...
684
 
631
 
685
        if (request_debugLabel != 0xFF) { // Texte für die Analogdaten
632
        if (request_debugLabel != 0xFF) { // Texte f�r die Analogdaten
686
                uint8_t label[16]; // local sram buffer
633
                uint8_t label[16]; // local sram buffer
687
                memcpy_P(label, ANALOG_LABEL[request_debugLabel], 16); // read lable from flash to sram buffer
634
                memcpy_P(label, ANALOG_LABEL[request_debugLabel], 16); // read lable from flash to sram buffer
688
                sendOutData('A', FC_ADDRESS, 2, (uint8_t *) &request_debugLabel,
635
                sendOutData('A', FC_ADDRESS, 2, (uint8_t *) &request_debugLabel,
689
                                sizeof(request_debugLabel), label, 16);
636
                                sizeof(request_debugLabel), label, 16);
690
                request_debugLabel = 0xFF;
637
                request_debugLabel = 0xFF;
Line 691... Line 638...
691
        }
638
        }
692
 
639
 
693
        if (confirmFrame && txd_complete) { // Datensatz ohne checksum bestätigen
640
        if (confirmFrame && txd_complete) { // Datensatz ohne checksum best�tigen
694
                sendOutData('B', FC_ADDRESS, 1, (uint8_t*) &confirmFrame, sizeof(confirmFrame));
641
                sendOutData('B', FC_ADDRESS, 1, (uint8_t*) &confirmFrame, sizeof(confirmFrame));
Line 695... Line 642...
695
                confirmFrame = 0;
642
                confirmFrame = 0;