Subversion Repositories FlightCtrl

Rev

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

Rev 624 Rev 683
Line 1... Line 1...
1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Copyright (c) 04.2007 Holger Buss
2
// + Copyright (c) 04.2007 Holger Buss
3
// + Nur für den privaten Gebrauch
3
// + Nur für den privaten Gebrauch
4
// + www.MikroKopter.com
4
// + www.MikroKopter.com
5
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), 
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. 
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 
8
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
9
// + bzgl. der Nutzungsbedingungen aufzunehmen. 
9
// + bzgl. der Nutzungsbedingungen aufzunehmen.
10
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
10
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
11
// + Verkauf von Luftbildaufnahmen, usw.
11
// + Verkauf von Luftbildaufnahmen, usw.
12
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, 
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
14
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
15
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
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"
17
// + auf anderen Webseiten oder Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
18
// + eindeutig als Ursprung verlinkt und genannt werden
18
// + eindeutig als Ursprung verlinkt und genannt werden
19
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
20
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
21
// + Benutzung auf eigene Gefahr
21
// + Benutzung auf eigene Gefahr
22
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
22
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
23
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur 
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
25
// + mit unserer Zustimmung zulässig
26
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
27
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
28
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
// + Redistributions of source code (with or without modifications) must retain the above copyright notice, 
29
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
30
// + this list of conditions and the following disclaimer.
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
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.
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 
33
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
34
// +     for non-commercial use (directly or indirectly)
34
// +     for non-commercial use (directly or indirectly)
35
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted 
35
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
36
// +     with our written permission
36
// +     with our written permission
37
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be 
37
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
38
// +     clearly linked as origin 
38
// +     clearly linked as origin
39
// +   * porting to systems other than hardware from www.mikrokopter.de is not allowed
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"
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
41
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
43
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Line 45... Line 45...
45
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
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
47
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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
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
#include "main.h"
52
#include "main.h"
Line 53... Line 53...
53
 
53
 
54
unsigned char EEPromArray[E2END+1] EEMEM;
54
unsigned char EEPromArray[E2END+1] EEMEM;
Line 55... Line 55...
55
unsigned char PlatinenVersion = 10;
55
unsigned char PlatinenVersion = 10;
56
 
56
 
57
// -- Parametersatz aus EEPROM lesen ---
57
// -- Parametersatz aus EEPROM lesen ---
58
// number [0..5]   
58
// number [0..5]
59
void ReadParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
59
void ReadParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
60
{
60
{
61
   if (number > 5) number = 5;
61
   if (number > 5) number = 5;
Line 62... Line 62...
62
   eeprom_read_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
62
   eeprom_read_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
63
}
63
}
64
 
64
 
65
 
65
 
66
// -- Parametersatz ins EEPROM schreiben ---
66
// -- Parametersatz ins EEPROM schreiben ---
67
// number [0..5]   
67
// number [0..5]
68
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
68
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
69
{
69
{
Line 70... Line 70...
70
   if(number > 5) number = 5;  
70
   if(number > 5) number = 5;
71
   eeprom_write_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
71
   eeprom_write_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
72
   eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], number);                              // diesen Parametersatz als aktuell merken
72
   eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], number);                              // diesen Parametersatz als aktuell merken
73
}
73
}
74
 
74
 
75
unsigned char GetActiveParamSetNumber(void)
75
unsigned char GetActiveParamSetNumber(void)
76
{
76
{
77
 unsigned char set;
77
 unsigned char set;
78
 set = eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET]);
78
 set = eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET]);
79
 if(set > 5)
79
 if(set > 5)
80
  {
80
  {
Line 81... Line 81...
81
   set = 2;  
81
   set = 2;
82
   eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], set);                                 // diesen Parametersatz als aktuell merken
82
   eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], set);                                 // diesen Parametersatz als aktuell merken
83
  }
83
  }
84
 return(set);
84
 return(set);
85
}
85
}
86
 
86
 
Line 87... Line 87...
87
//############################################################################
87
//############################################################################
-
 
88
//Hauptprogramm
-
 
89
int main (void)
88
//Hauptprogramm
90
//############################################################################
89
int main (void)
91
{
90
//############################################################################
92
        unsigned int timer;
91
{
93
 
92
        unsigned int timer;
94
        // disable interrupts global
93
 
95
        cli();
94
        //unsigned int timer2 = 0;
96
 
95
    DDRB  = 0x00;
97
    DDRB  = 0x00;
96
    PORTB = 0x00;
98
    PORTB = 0x00;
97
    for(timer = 0; timer < 1000; timer++); // verzögern
99
    for(timer = 0; timer < 1000; timer++); // make delay
98
    if(PINB & 0x01) PlatinenVersion = 11; else PlatinenVersion = 10;
100
    if(PINB & 0x01) PlatinenVersion = 11; else PlatinenVersion = 10;
99
    DDRC  = 0x81; // SCL
101
    DDRC  = 0x81; // SCL & Speaker
100
    PORTC = 0xff; // Pullup SDA
102
    PORTC = 0xff; // Pullup SDA
101
    DDRB  = 0x1B; // LEDs und Druckoffset
103
    DDRB  = 0x1B; // LEDs und Druckoffset
102
    PORTB = 0x01; // LED_Rot
104
    PORTB = 0x01; // LED_Rot
103
    DDRD  = 0x3E; // Speaker & TXD & J3 J4 J5
105
    DDRD  = 0x3E; // Speaker & TXD & J3 J4 J5
104
    DDRD  |=0x80; // J7
106
    DDRD  |=0x80; // J7
Line 105... Line 107...
105
   
107
 
Line 106... Line 108...
106
        PORTD = 0xF7; // LED
108
        PORTD = 0xF7; // LED
-
 
109
 
-
 
110
 
-
 
111
    MCUSR &=~(1<<WDRF);
Line 107... Line 112...
107
 
112
    WDTCSR |= (1<<WDCE)|(1<<WDE);
108
   
113
    WDTCSR = 0;
-
 
114
 
109
    MCUSR &=~(1<<WDRF);
115
    BeepTime = 2000;
-
 
116
 
110
    WDTCSR |= (1<<WDCE)|(1<<WDE);
117
        PPM_in[K_GAS] = 0;
111
    WDTCSR = 0;
118
        StickGier = 0;
112
 
119
        StickRoll = 0;
113
    beeptime = 2000;
120
        StickNick = 0;
114
 
121
 
115
        StickGier = 0; PPM_in[K_GAS] = 0;StickRoll = 0; StickNick = 0;
122
    ROT_OFF;
-
 
123
 
116
 
124
    TIMER0_Init();
Line 117... Line 125...
117
    ROT_OFF;
125
    TIMER2_Init();
118
   
126
        USART0_Init();
119
    Timer_Init();
127
        USART1_Init();
120
        UART_Init();
128
    rc_sum_init();
121
    rc_sum_init();
129
        ADC_Init();
122
        ADC_Init();
130
        i2c_init();
123
        i2c_init();
131
        //SPI_MasterInit();
Line 124... Line 132...
124
        SPI_MasterInit();
132
 
125
   
133
        // enable interrupts global
126
        sei();
134
        sei();
127
 
135
 
128
    VersionInfo.Hauptversion = VERSION_HAUPTVERSION;
136
    VersionInfo.Hauptversion = VERSION_HAUPTVERSION;
129
    VersionInfo.Nebenversion = VERSION_NEBENVERSION;
137
    VersionInfo.Nebenversion = VERSION_NEBENVERSION;
130
    VersionInfo.PCKompatibel = VERSION_KOMPATIBEL;
138
    VersionInfo.PCKompatibel = VERSION_KOMPATIBEL;
131
   
139
 
132
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX + 'a');
140
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX + 'a');
133
        printf("\n\r==============================");
141
        printf("\n\r==============================");
134
        GRN_ON;
142
        GRN_ON;
135
 
143
 
136
#define EE_DATENREVISION 69 // wird angepasst, wenn sich die EEPROM-Daten geändert haben
144
#define EE_DATENREVISION 69 // wird angepasst, wenn sich die EEPROM-Daten geändert haben
137
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION)
145
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION)
138
        {
146
        {
Line 139... Line 147...
139
          printf("\n\rInit. EEPROM: Generiere Default-Parameter...");
147
          printf("\n\rInit. EEPROM: Generiere Default-Parameter...");
140
          DefaultKonstanten1();
148
          DefaultKonstanten1();
141
          for (unsigned char i=0;i<6;i++)  
149
          for (unsigned char i=0;i<6;i++)
142
      {
150
      {
143
       if(i==2) DefaultKonstanten2(); // Kamera
151
       if(i==2) DefaultKonstanten2(); // Kamera
144
       if(i==3) DefaultKonstanten3(); // Beginner
152
       if(i==3) DefaultKonstanten3(); // Beginner
145
       if(i>3)  DefaultKonstanten2(); // Kamera
153
       if(i>3)  DefaultKonstanten2(); // Kamera
Line 146... Line 154...
146
       WriteParameterSet(i, (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
154
       WriteParameterSet(i, (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
147
      }
155
      }
148
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], 3); // default-Setting
156
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], 3); // default-Setting
149
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION);
157
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION);
150
        }
158
        }
151
 
159
 
152
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
160
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
153
     {
161
     {
154
       printf("\n\rACC nicht abgeglichen!");
162
       printf("\n\rACC nicht abgeglichen!");
155
     }
163
     }
156
       
164
 
Line 157... Line 165...
157
        ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
165
        ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
158
    printf("\n\rBenutze Parametersatz %d", GetActiveParamSetNumber());
-
 
159
 
-
 
160
   
-
 
Line -... Line 166...
-
 
166
    printf("\n\rBenutze Parametersatz %d", GetActiveParamSetNumber());
-
 
167
 
-
 
168
 
161
        if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
169
        if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
162
         {
170
         {
163
           printf("\n\rAbgleich Luftdrucksensor..");
171
           printf("\n\rAbgleich Luftdrucksensor..");
164
           timer = SetDelay(1000);  
172
           timer = SetDelay(1000);
165
       SucheLuftruckOffset();
173
       SucheLuftruckOffset();
166
           while (!CheckDelay(timer));
174
           while (!CheckDelay(timer));
167
       printf("OK\n\r");
175
       printf("OK\n\r");
168
        }
176
        }
169
       
177
 
170
        SetNeutral();
178
        SetNeutral();
171
 
179
 
172
        ROT_OFF;
180
        ROT_OFF;
173
   
181
 
174
    beeptime = 2000;
182
    BeepTime = 2000;
175
    ExternControl.Digital[0] = 0x55;   
183
    ExternControl.Digital[0] = 0x55;
176
 
184
 
177
   
185
 
Line 178... Line 186...
178
        printf("\n\rSteuerung: ");
186
        printf("\n\rSteuerung: ");
179
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
187
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
180
        else printf("Neutral");
188
        else printf("Neutral");
181
       
189
 
182
        printf("\n\n\r");
190
        printf("\n\n\r");
183
               
191
 
184
    LcdClear();
192
    LcdClear();
185
    I2CTimeout = 5000;
193
    I2CTimeout = 5000;
186
        while (1)
194
        while (1)
187
        {
195
        {
188
        if(UpdateMotor)      // ReglerIntervall
196
        if(UpdateMotor)      // ReglerIntervall
189
            {
197
            {
Line 208... Line 216...
208
            if(SenderOkay)  SenderOkay--;
216
            if(SenderOkay)  SenderOkay--;
209
            if(!I2CTimeout)
217
            if(!I2CTimeout)
210
                {
218
                {
211
                 I2CTimeout = 5;
219
                 I2CTimeout = 5;
212
                 i2c_reset();
220
                 i2c_reset();
213
                  if((BeepMuster == 0xffff) && MotorenEin)
221
                  if((BeepModulation == 0xFFFF) && MotorenEin)
214
                   {
222
                   {
215
                    beeptime = 10000;
223
                    BeepTime = 10000; // 1 second
216
                    BeepMuster = 0x0080;
224
                    BeepModulation = 0x0080;
217
                   }
225
                   }
218
                }
226
                }
219
            else        
227
            else
220
                {
228
                {
221
                 I2CTimeout--;
229
                 I2CTimeout--;
222
                 ROT_OFF;
230
                 ROT_OFF;
223
                }
231
                }
224
            if(SIO_DEBUG && !UpdateMotor)
232
            if(SIO_DEBUG && !UpdateMotor)
225
              {
233
              {
226
               DatenUebertragung();
234
               DatenUebertragung();
227
               BearbeiteRxDaten();
235
               BearbeiteRxDaten();
228
              }
236
              }
229
              else BearbeiteRxDaten();
237
              else BearbeiteRxDaten();
230
         if(CheckDelay(timer))
238
         if(CheckDelay(timer))
231
            {
239
            {
232
            if(UBat < EE_Parameter.UnterspannungsWarnung)
240
            if(UBat < EE_Parameter.UnterspannungsWarnung)
233
                {    
241
                {
234
                  if(BeepMuster == 0xffff)
242
                  if(BeepModulation == 0xFFFF)
235
                   {
243
                   {
236
                    beeptime = 6000;
244
                    BeepTime = 6000; // 0.6 seconds
237
                    BeepMuster = 0x0300;
245
                    BeepModulation = 0x0300;
238
                   }
246
                   }
239
                }
247
                }
240
             SPI_StartTransmitPacket();//#
248
             SPI_StartTransmitPacket();//#
241
                         timer = SetDelay(100);  
249
                         timer = SetDelay(100);
242
            }
250
            }
243
           //if(UpdateMotor) DebugOut.Analog[26]++;
251
           //if(UpdateMotor) DebugOut.Analog[26]++;
244
          }
252
          }
245
    }
253
    }
246
 return (1);
254
 return (1);
247
}
255
}