Subversion Repositories NaviCtrl

Rev

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

Rev 369 Rev 378
Line 91... Line 91...
91
s16 GeoMagDec = 0; // local magnetic declination in 0.1 deg
91
s16 GeoMagDec = 0; // local magnetic declination in 0.1 deg
92
u8 ErrorGpsFixLost = 0;
92
u8 ErrorGpsFixLost = 0;
Line 93... Line 93...
93
 
93
 
94
u8 ClearFCStatusFlags = 0;
94
u8 ClearFCStatusFlags = 0;
-
 
95
u8 StopNavigation = 0;
95
u8 StopNavigation = 0;
96
volatile u32 PollingTimeout = 10000;
96
Param_t Parameter;
97
Param_t Parameter;
97
volatile FC_t FC;
98
volatile FC_t FC;
98
volatile u32 MainWatchDog = 15000; // stop Navigation if this goes to zero
99
volatile u32 SPIWatchDog = 15000; // stop Navigation if this goes to zero
Line 99... Line 100...
99
volatile u32 SD_WatchDog  = 15000; // stop Logging if this goes to zero
100
volatile u32 SD_WatchDog  = 15000; // stop Logging if this goes to zero
Line 100... Line 101...
100
 
101
 
Line 374... Line 375...
374
}
375
}
Line 375... Line 376...
375
 
376
 
376
// the handler will be cyclic called by the timer 1 ISR
377
// the handler will be cyclic called by the timer 1 ISR
377
// used is for critical timing parts that normaly would handled
378
// used is for critical timing parts that normaly would handled
-
 
379
// within the main loop that could block longer at logging activities
-
 
380
 
-
 
381
 
-
 
382
void Polling(void)
-
 
383
{
-
 
384
 static u8 running = 0;
-
 
385
 if(running) return;
-
 
386
 running = 1;
-
 
387
LED_GRN_OFF;
-
 
388
// PollingTimeout = 20;
-
 
389
                SPI0_UpdateBuffer();    // also calls the GPS-functions
-
 
390
                UART0_ProcessRxData();  // GPS process request
-
 
391
                UART0_TransmitTxData(); // GPS send answer
-
 
392
                UART1_TransmitTxData(); // PC send answer
-
 
393
                UART2_TransmitTxData(); // FC send answer
-
 
394
                CalcHeadFree();
-
 
395
LED_GRN_ON;
-
 
396
 running = 0;
-
 
397
}
-
 
398
 
378
// within the main loop that could block longer at logging activities
399
 
379
void EXTIT3_IRQHandler(void)
400
void EXTIT3_IRQHandler(void)
380
{
401
{
381
        IENABLE;
402
        IENABLE;
382
        VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq
-
 
383
        VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit
403
        VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq
384
        Compass_Update();               // update compass communication
404
        Compass_Update();               // update compass communication
-
 
405
        Analog_Update();                // get new ADC values
-
 
406
 
-
 
407
 if(!PollingTimeout)
-
 
408
  {
-
 
409
   PollingTimeout = 3;
-
 
410
   Polling();
-
 
411
  }
-
 
412
 
385
        Analog_Update();                // get new ADC values
413
        VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit
386
        VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq
414
        VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq
-
 
415
        IDISABLE;
387
        IDISABLE;
416
        VIC1->VAR = 0xFF; // write any value to VIC0 Vector address register
Line 388... Line 417...
388
}
417
}
389
 
418
 
390
//----------------------------------------------------------------------------------------------------
419
//----------------------------------------------------------------------------------------------------
Line 467... Line 496...
467
    VIC_ITCmd(EXTIT3_ITLine, ENABLE);
496
    VIC_ITCmd(EXTIT3_ITLine, ENABLE);
Line 468... Line 497...
468
 
497
 
469
        Debug_OK("START");
498
        Debug_OK("START");
Line -... Line 499...
-
 
499
        UART1_PutString("\r\n");
470
        UART1_PutString("\r\n");
500
 
471
 
501
Polling();
472
        for (;;) // the endless main loop
-
 
473
        {
-
 
474
            MainWatchDog = 4500;    // stop communication to FC after this timeout
-
 
475
                UART0_ProcessRxData();  // process request
502
        for (;;) // the endless main loop
476
                UART1_ProcessRxData();  // process request
503
        {
477
                UART0_TransmitTxData(); // send answer
504
            Polling();
478
                UART1_TransmitTxData(); // send answer
-
 
479
                UART2_TransmitTxData(); // send answer
505
                PollingTimeout = 15;
480
                SPI0_UpdateBuffer();    // handle new SPI Data
506
DebugOut.Analog[17] = CountMilliseconds;
Line 481... Line 507...
481
//              USB_ProcessRxData();    // process request
507
                UART1_ProcessRxData();  // PC process request
482
//              USB_TransmitTxData();   // send answer
508
//              UART1_TransmitTxData(); // PC send answer
483
 
509
 
484
                // ---------------- Error Check Timing ----------------------------
510
                // ---------------- Error Check Timing ----------------------------
Line 495... Line 521...
495
                        if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication
521
                        if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication
496
                        else NCFlags &= ~NC_FLAG_NOSERIALLINK;
522
                        else NCFlags &= ~NC_FLAG_NOSERIALLINK;
497
                        if(StopNavigation && (Parameter.NaviGpsModeControl >=  50) && (Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) BeepTime = 1000;
523
                        if(StopNavigation && (Parameter.NaviGpsModeControl >=  50) && (Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) BeepTime = 1000;
498
                }
524
                }
499
                // ---------------- Logging  ---------------------------------------
525
                // ---------------- Logging  ---------------------------------------
-
 
526
 
-
 
527
 
500
                if(SD_WatchDog)
528
                if(SD_WatchDog)
501
                 {
529
                 {
502
                  SD_WatchDog = 4000;
530
                  SD_WatchDog = 10000;
503
                  if(SDCardInfo.Valid == 1) Logging_Update();  // could be block some time for at max. 2 seconds, therefore move time critical part of the mainloop into the ISR of timer 1
531
                  if(SDCardInfo.Valid == 1) Logging_Update();  // could be block some time for at max. 2 seconds, therefore move time critical part of the mainloop into the ISR of timer 1
504
                  else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100;
532
                  else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100;
505
                  if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r");
533
                  if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r");
506
                 }
534
                 }
-
 
535
 
507
                /*
536
                /*
508
                // test
537
                // test
509
                if(CheckDelay(ftimer))
538
                if(CheckDelay(ftimer))
510
                {
539
                {