Subversion Repositories NaviCtrl

Rev

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

Rev 427 Rev 431
Line 456... Line 456...
456
}
456
}
Line 457... Line 457...
457
 
457
 
458
//----------------------------------------------------------------------------------------------------
458
//----------------------------------------------------------------------------------------------------
459
int main(void)
459
int main(void)
460
{
460
{
461
        /*
461
       
462
        static u32 ftimer =0;
462
        static u32 ftimer =0;
463
        static u8 fstate = 0;
463
        static u8 fstate = 0;
464
        static File_t* f = NULL;
464
        static File_t* f = NULL;
Line 465... Line 465...
465
        */
465
       
466
       
466
       
467
        /* Configure the system clocks */
467
        /* Configure the system clocks */
468
        SCU_Config();
468
        SCU_Config();
Line 541... Line 541...
541
        fifo_purge(&UART1_rx_fifo); // flush the whole fifo init buffer
541
        fifo_purge(&UART1_rx_fifo); // flush the whole fifo init buffer
542
        LED_GRN_ON;
542
        LED_GRN_ON;
543
        LED_RED_OFF;
543
        LED_RED_OFF;
544
        for (;;) // the endless main loop
544
        for (;;) // the endless main loop
545
        {
545
        {
546
            Polling();
546
                Polling();
547
                PollingTimeout = 15;
547
                PollingTimeout = 15;
548
                // ---------------- Logging  ---------------------------------------
548
                // ---------------- Logging  ---------------------------------------
549
                if(SD_WatchDog)
549
                if(SD_WatchDog)
550
                 {
550
                {
551
                  SD_WatchDog = 30000;
551
                        SD_WatchDog = 30000;
552
                  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
552
                        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
553
                  else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100;
553
                        else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100;
554
                  if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r");
554
                        if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r");
555
                 }
555
                }
556
                /*
556
               
Line 557... Line 557...
557
               
557
               
558
                if(CheckDelay(ftimer))
558
                if(CheckDelay(ftimer))
Line 559... Line 559...
559
                {
559
                {
-
 
560
 
-
 
561
                        static s8 filename[35];
-
 
562
                        static u8 i = 0;
-
 
563
                        s8 dbgmsg[40];
Line 560... Line 564...
560
 
564
                       
561
                        s8* filename = "test.txt";
565
                       
562
 
566
 
563
                        ftimer = SetDelay(100);
567
                        ftimer = SetDelay(100);
-
 
568
                        if(FC.Poti[3]>100 && fstate == 0)
564
                        if(FC.Poti[3]>100 && fstate == 0)
569
                        {
565
                        {
570
                                fstate = 1;
566
                                fstate = 1;
571
                                sprintf(filename, "/toast/toasta/toast%02i.txt",i++);
567
                        }
572
                        }
568
                        else if(FC.Poti[3]<100 && fstate == 2)
573
                        else if(FC.Poti[3]<100 && fstate == 2)
Line 569... Line 574...
569
                        {
574
                        {
570
                                fstate = 3;
575
                                fstate = 3;
571
                        }
576
                        }
572
 
577
 
573
                        switch(fstate)
578
                        switch(fstate)
574
                        {
579
                        {
575
                                case 1:
580
                                case 1:
576
                                        sprintf(text,"\r\nStart writing file: %s", filename);
581
                                        sprintf(dbgmsg,"\r\nStart writing file: %s", filename);
577
                                        UART1_PutString(text);
582
                                        Debug(dbgmsg);
Line 578... Line 583...
578
                                        f = fopen_(filename, 'a');
583
                                        f = fopen_(filename, 'a');
579
                                        if(f== NULL) Fat16_Init();
584
                                        if(f== NULL) Fat16_Init();
580
                                        fstate = 2;
585
                                        fstate = 2;
Line 581... Line 586...
581
                                        break;
586
                                        break;
582
 
587
 
583
                                case 2:
588
                                case 2:
584
                                        fputs_("\r\ntest edins sdv dsivbds iv dsivb disbv idsv bisd bv d suiv dsibsivbdis fbvisdöb visdbvisdb vidbfibds ibv", f);
589
                                        fputs_("\r\ntest edins sdv dsivbds iv dsivb disbv idsv bisd bv d suiv dsibsivbdis fbvisdöb visdbvisdb vidbfibds ibv", f);
585
                                        break;
590
                                        break;
586
                                       
591
                                       
Line 587... Line 592...
587
                                case 3:
592
                                case 3:
588
                                        sprintf(text,"\r\nClosing file: %s", filename);
593
                                        sprintf(dbgmsg,"\r\nClosing file: %s", filename);
589
                                        UART1_PutString(text);
594
                                        Debug(dbgmsg);
590
                                        fclose_(f);
595
                                        fclose_(f);
591
                                        fstate = 0;
596
                                        fstate = 0;
592
                                        break;
597
                                        break;
593
 
598
 
Line 594... Line -...
594
                                default:
-