Subversion Repositories FlightCtrl

Rev

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

Rev 1403 Rev 1419
Line 152... Line 152...
152
//############################################################################
152
//############################################################################
153
//Hauptprogramm
153
//Hauptprogramm
154
int main (void)
154
int main (void)
155
//############################################################################
155
//############################################################################
156
{
156
{
157
        unsigned int timer,i,timer2 = 0;
157
        unsigned int timer,i,timer2 = 0, timerJeti;
158
    DDRB  = 0x00;
158
    DDRB  = 0x00;
159
    PORTB = 0x00;
159
    PORTB = 0x00;
160
    for(timer = 0; timer < 1000; timer++); // verzögern
160
    for(timer = 0; timer < 1000; timer++); // verzögern
161
    if(PINB & 0x01)
161
    if(PINB & 0x01)
162
     {
162
     {
Line 192... Line 192...
192
    rc_sum_init();
192
    rc_sum_init();
193
        ADC_Init();
193
        ADC_Init();
194
        i2c_init();
194
        i2c_init();
195
        SPI_MasterInit();
195
        SPI_MasterInit();
Line -... Line 196...
-
 
196
 
-
 
197
    if(UCSR1A == 0x20 && UCSR1C == 0x06)  // initial Values for 644P
-
 
198
     {
-
 
199
      //Uart1Init();
-
 
200
          JetiBoxUartInit();
-
 
201
     }
196
 
202
 
197
        sei();
203
        sei();
198
        printf("\n\r===================================");
204
        printf("\n\r===================================");
199
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR,VERSION_PATCH + 'a');
205
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR,VERSION_PATCH + 'a');
200
        printf("\n\rthe use of this software is only permitted \n\ron original MikroKopter-Hardware");
206
        printf("\n\rthe use of this software is only permitted \n\ron original MikroKopter-Hardware");
201
        printf("\n\rwww.MikroKopter.de (c) HiSystems GmbH");
207
        printf("\n\rwww.MikroKopter.de (c) HiSystems GmbH");
Line 202... Line -...
202
        printf("\n\r===================================");
-
 
203
 
-
 
204
    if(UCSR1A == 0x20 && UCSR1C == 0x06)  // initial Values for 644P
-
 
205
     {
-
 
206
      Uart1Init();
208
        printf("\n\r===================================");
207
     }
209
 
208
        GRN_ON;
210
        GRN_ON;
209
        ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 13); // read only the first bytes
211
        ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 13); // read only the first bytes
210
    if((eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) && // Check Revision in the first Byte
212
    if((eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) && // Check Revision in the first Byte
Line 234... Line 236...
234
// + Check connected BL-Ctrls
236
// + Check connected BL-Ctrls
235
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
237
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
236
        printf("\n\rFound BL-Ctrl: ");
238
        printf("\n\rFound BL-Ctrl: ");
237
    motorread = 0;   UpdateMotor = 0;   SendMotorData(); while(!UpdateMotor); motorread = 0;  // read the first I2C-Data
239
    motorread = 0;   UpdateMotor = 0;   SendMotorData(); while(!UpdateMotor); motorread = 0;  // read the first I2C-Data
238
    timer = SetDelay(2000);
240
    timer = SetDelay(2000);
-
 
241
       
-
 
242
       
239
        for(i=0; i < MAX_MOTORS; i++)
243
        for(i=0; i < MAX_MOTORS; i++)
240
         {
244
         {
241
          UpdateMotor = 0;
245
          UpdateMotor = 0;
242
      SendMotorData();
246
      SendMotorData();
243
          while(!UpdateMotor);
247
          while(!UpdateMotor);
Line 358... Line 362...
358
    WinkelOut.Orientation = 1;
362
    WinkelOut.Orientation = 1;
359
    LipoDetection(1);
363
    LipoDetection(1);
360
        printf("\n\r===================================\n\r");
364
        printf("\n\r===================================\n\r");
361
//SpektrumBinding();
365
//SpektrumBinding();
362
    timer = SetDelay(2000);
366
    timer = SetDelay(2000);
-
 
367
        timerJeti = SetDelay(250);
363
        while (1)
368
        while (1)
364
        {
369
        {
-
 
370
           
-
 
371
        if(CheckDelay(timerJeti))
-
 
372
        {
-
 
373
          timerJeti = SetDelay(100);
-
 
374
          JetiBoxPolling();
-
 
375
        }
-
 
376
       
365
            if(UpdateMotor && AdReady)      // ReglerIntervall
377
        if(UpdateMotor && AdReady)      // ReglerIntervall
366
            {
378
            {
367
                    UpdateMotor=0;
379
                    UpdateMotor=0;
368
            if(WinkelOut.CalcState) CalMk3Mag();
380
            if(WinkelOut.CalcState) CalMk3Mag();
369
            else MotorRegler();
381
            else MotorRegler();
370
            SendMotorData();
382
            SendMotorData();
Line 381... Line 393...
381
                           {
393
                           {
382
                    GPS_Nick = 0;
394
                    GPS_Nick = 0;
383
                GPS_Roll = 0;
395
                GPS_Roll = 0;
384
               }
396
               }
385
              }
397
              }
-
 
398
                         
386
            if(!--I2CTimeout || MissingMotor)
399
            if(!--I2CTimeout || MissingMotor)
387
                {
400
                {
388
                  if(!I2CTimeout)
401
                  if(!I2CTimeout)
389
                                   {
402
                                   {
390
                                    i2c_reset();
403
                                    i2c_reset();
Line 399... Line 412...
399
                }
412
                }
400
            else
413
            else
401
                {
414
                {
402
                 ROT_OFF;
415
                 ROT_OFF;
403
                }
416
                }
-
 
417
                               
404
            if(SIO_DEBUG && (!UpdateMotor || !MotorenEin))
418
            if(SIO_DEBUG && (!UpdateMotor || !MotorenEin))
405
              {
419
              {
406
               DatenUebertragung();
420
               DatenUebertragung();
407
               BearbeiteRxDaten();
421
               BearbeiteRxDaten();
408
              }
422
              }
409
                        else BearbeiteRxDaten();
423
                        else BearbeiteRxDaten();
-
 
424
                       
-
 
425
                       
410
                        if(CheckDelay(timer))
426
                        if(CheckDelay(timer))
411
                        {
427
                        {
-
 
428
                         
412
                          timer += 20;
429
                  timer += 20;
-
 
430
       
-
 
431
                 
-
 
432
 
413
              if(PcZugriff) PcZugriff--;
433
              if(PcZugriff) PcZugriff--;
414
              else
434
              else
415
               {
435
               {
416
                            ExternControl.Config = 0;
436
                            ExternControl.Config = 0;
417
                ExternStickNick = 0;
437
                ExternStickNick = 0;
Line 431... Line 451...
431
                                                beeptime = 6000;
451
                                                beeptime = 6000;
432
                                                BeepMuster = 0x0300;
452
                                                BeepMuster = 0x0300;
433
                                        }
453
                                        }
434
                                }
454
                                }
435
                                else MikroKopterFlags &= ~FLAG_LOWBAT;
455
                                else MikroKopterFlags &= ~FLAG_LOWBAT;
-
 
456
                               
436
                                SPI_StartTransmitPacket();
457
                                SPI_StartTransmitPacket();
437
                                SendSPI = 4;
458
                                SendSPI = 4;
-
 
459
                               
438
                                if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden
460
                                if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden
-
 
461
                               
439
                                if(++timer2 == 2930)  // eine Minute
462
                                if(++timer2 == 2930)  // eine Minute
440
                                 {
463
                                 {
441
                                   timer2 = 0;
464
                                   timer2 = 0;
442
                   FlugMinuten++;
465
                   FlugMinuten++;
443
                       FlugMinutenGesamt++;
466
                       FlugMinutenGesamt++;