Subversion Repositories NaviCtrl

Rev

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

Rev 360 Rev 362
Line 77... Line 77...
77
#include "config.h"
77
#include "config.h"
78
#include "main.h"
78
#include "main.h"
79
#include "debug.h"
79
#include "debug.h"
80
#include "eeprom.h"
80
#include "eeprom.h"
81
#include "ssc.h"
81
#include "ssc.h"
-
 
82
#include "sdc.h"
Line 82... Line 83...
82
 
83
 
83
#ifdef FOLLOW_ME
84
#ifdef FOLLOW_ME
84
u8 TransmitAlsoToFC = 0;
85
u8 TransmitAlsoToFC = 0;
85
#endif
86
#endif
Line 92... Line 93...
92
 
93
 
93
u8 ClearFCStatusFlags = 0;
94
u8 ClearFCStatusFlags = 0;
94
u8 StopNavigation = 0;
95
u8 StopNavigation = 0;
95
Param_t Parameter;
96
Param_t Parameter;
-
 
97
volatile FC_t FC;
-
 
98
volatile u32 MainWatchDog = 15000; // stop Navigation if this goes to zero
Line 96... Line 99...
96
volatile FC_t FC;
99
volatile u32 SD_WatchDog  = 15000; // stop Logging if this goes to zero
Line 97... Line 100...
97
 
100
 
98
s8 ErrorMSG[25];
101
s8 ErrorMSG[25];
Line 328... Line 331...
328
         LED_RED_ON;
331
         LED_RED_ON;
329
         sprintf(ErrorMSG,"ERR:No SD-Card  ");
332
         sprintf(ErrorMSG,"ERR:No SD-Card  ");
330
         newErrorCode = 26;
333
         newErrorCode = 26;
331
         DebugOut.StatusRed |= AMPEL_NC;
334
         DebugOut.StatusRed |= AMPEL_NC;
332
        }
335
        }
333
        else if(SD_LoggingError && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START)
336
        else if((SD_LoggingError || (SD_WatchDog == 0)) && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START )
334
        {
337
        {
335
         LED_RED_ON;
338
         LED_RED_ON;
336
         sprintf(ErrorMSG,"ERR:SD Logging aborted");
339
         sprintf(ErrorMSG,"ERR:SD Logging aborted");
337
         newErrorCode = 27;
340
         newErrorCode = 27;
338
         DebugOut.StatusRed |= AMPEL_NC;
341
         DebugOut.StatusRed |= AMPEL_NC;
Line 431... Line 434...
431
        // initialize the settings
434
        // initialize the settings
432
        Settings_Init();
435
        Settings_Init();
433
        // initialize logging (needs settings)
436
        // initialize logging (needs settings)
434
        Logging_Init();
437
        Logging_Init();
Line -... Line 438...
-
 
438
 
435
 
439
        LED_GRN_ON;
436
        TimerCheckError = SetDelay(3000);
440
        TimerCheckError = SetDelay(3000);
437
        UART1_PutString("\r\n++++++++++++++++++++++++++++++++++++++++++");
441
        UART1_PutString("\r\n++++++++++++++++++++++++++++++++++++++++++");
Line 438... Line 442...
438
        UART1_PutString("\n\r Version information:");
442
        UART1_PutString("\n\r Version information:");
Line 455... Line 459...
455
        {
459
        {
456
                UART1_PutString("\n\r Flight-Ctrl not compatible");
460
                UART1_PutString("\n\r Flight-Ctrl not compatible");
457
                LED_RED_ON;
461
                LED_RED_ON;
458
        }
462
        }
459
#endif
463
#endif
460
 
-
 
461
        GPS_Init();
464
        GPS_Init();
462
 
-
 
463
        // ---------- Prepare the isr driven
465
        // ---------- Prepare the isr driven
464
        // set to absolute lowest priority
466
        // set to absolute lowest priority
465
    VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW);
467
    VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW);
466
        // enable interrupts
468
        // enable interrupts
467
    VIC_ITCmd(EXTIT3_ITLine, ENABLE);
469
    VIC_ITCmd(EXTIT3_ITLine, ENABLE);
Line 468... Line 470...
468
 
470
 
-
 
471
        Debug_OK("START");
Line 469... Line 472...
469
        Debug_OK("START");
472
        UART1_PutString("\r\n");
470
 
473
 
-
 
474
        for (;;) // the endless main loop
471
        for (;;) // the endless main loop
475
        {
472
        {
476
            MainWatchDog = 3500;    // stop communication to FC after this timeout
473
                UART0_ProcessRxData();  // process request
477
                UART0_ProcessRxData();  // process request
474
                UART1_ProcessRxData();  // process request
478
                UART1_ProcessRxData();  // process request
475
                USB_ProcessRxData();    // process request
479
                USB_ProcessRxData();    // process request
Line 492... Line 496...
492
                        if(SerialLinkOkay) SerialLinkOkay--;
496
                        if(SerialLinkOkay) SerialLinkOkay--;
493
                        if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication
497
                        if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication
494
                        else NCFlags &= ~NC_FLAG_NOSERIALLINK;
498
                        else NCFlags &= ~NC_FLAG_NOSERIALLINK;
495
                        if(StopNavigation && (Parameter.NaviGpsModeControl >=  50) && (Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) BeepTime = 1000;
499
                        if(StopNavigation && (Parameter.NaviGpsModeControl >=  50) && (Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) BeepTime = 1000;
496
                }
500
                }
497
 
-
 
498
                // ---------------- Logging  ---------------------------------------
501
                // ---------------- Logging  ---------------------------------------
-
 
502
                if(SD_WatchDog)
-
 
503
                 {
-
 
504
                  SD_WatchDog = 3000;
499
                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
505
                  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
-
 
506
                  else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100;
-
 
507
                  if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r");
500
 
508
                 }
501
                /*
509
                /*
502
                // test
510
                // test
503
                if(CheckDelay(ftimer))
511
                if(CheckDelay(ftimer))
504
                {
512
                {