Subversion Repositories NaviCtrl

Rev

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

Rev 774 Rev 780
Line 89... Line 89...
89
 
89
 
90
#ifdef FOLLOW_ME
90
#ifdef FOLLOW_ME
91
u8 TransmitAlsoToFC = 0;
91
u8 TransmitAlsoToFC = 0;
92
#endif
92
#endif
-
 
93
u32 TimerCheckError;
93
u32 TimerCheckError;
94
u32 TimerSecond;
94
u8 ErrorCode = 0;
95
u8 ErrorCode = 0;
95
u16 BeepTime;
96
u16 BeepTime;
96
u8  NCFlags = 0;
97
u8  NCFlags = 0;
97
s16 GeoMagDec = 0; // local magnetic declination in 0.1 deg
98
s16 GeoMagDec = 0; // local magnetic declination in 0.1 deg
Line 114... Line 115...
114
u8 OEM_String[OEM_NAME_LENGHT+1] = {0xff,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',0x00};
115
u8 OEM_String[OEM_NAME_LENGHT+1] = {0xff,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',0x00};
115
u32 TimeSinceMotorStart = 0;
116
u32 TimeSinceMotorStart = 0;
116
u8 IamMaster = NOTHING; // for Master/Slave Redundance
117
u8 IamMaster = NOTHING; // for Master/Slave Redundance
117
u16 ToFC_Parachute_Off;
118
u16 ToFC_Parachute_Off;
118
u8 IO1_Function = 0;
119
u8 IO1_Function = 0;
-
 
120
s16 LuftdruckTemperaturKompensation = 0, LuftdruckTemperaturOffset = 0;
-
 
121
u8 BaroCalState = 0;
Line 119... Line 122...
119
 
122
 
120
//----------------------------------------------------------------------------------------------------
123
//----------------------------------------------------------------------------------------------------
121
void SCU_Config(void)
124
void SCU_Config(void)
122
{
125
{
Line 575... Line 578...
575
             CountNewGpsDataIn5Sec = 25;
578
             CountNewGpsDataIn5Sec = 25;
576
             CountGpsProcessedIn5Sec = 0;
579
             CountGpsProcessedIn5Sec = 0;
577
             TimerCheckError = SetDelay(1000);
580
             TimerCheckError = SetDelay(1000);
578
            }
581
            }
Line -... Line 582...
-
 
582
 
-
 
583
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
584
// + Baro Temperature offset
-
 
585
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
586
        if(!BaroCalState && LuftdruckTemperaturKompensation)
-
 
587
         {
-
 
588
           LuftdruckTemperaturOffset = (31 * (s32)LuftdruckTemperaturOffset + ((FC_Temperatur_raw - FC_StartTemperature*10) * LuftdruckTemperaturKompensation) / 100) / 32;
-
 
589
         }
-
 
590
/*
-
 
591
DebugOut.Analog[] = FC_Temperatur_raw/10;
-
 
592
DebugOut.Analog[] = FC_Temperatur;
-
 
593
DebugOut.Analog[] = NaviData.Altimeter_5cm * 5;
-
 
594
DebugOut.Analog[] = LuftdruckTemperaturOffset;
-
 
595
*/
-
 
596
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
597
// + one second timer
-
 
598
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
599
        if(CheckDelay(TimerSecond)) // one second Timer 
-
 
600
        {
-
 
601
         TimerSecond += 1000;
-
 
602
 
-
 
603
         if(FC.StatusFlags & FC_STATUS_FLY)
-
 
604
                 {
-
 
605
                  NaviData.FlyingTime++; // we want to count the battery-time
-
 
606
                  TimeSinceMotorStart++;
-
 
607
                 }
-
 
608
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
609
// + FC 3.0 Temperature
-
 
610
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
611
     if(UART_VersionInfo.HWMajor >= 30)
-
 
612
      {
-
 
613
        if(FC_Temperatur == -1000 && FC_Temperatur_raw != -10000)  // init
-
 
614
                  {
-
 
615
                   FC_Temperatur = FC_Temperatur_raw/10;
-
 
616
                   FC_StartTemperature = FC_Temperatur;
-
 
617
              }
-
 
618
            else
-
 
619
            if(FC_Temperatur > FC_Temperatur_raw/10) FC_Temperatur--;
-
 
620
            else
-
 
621
            if(FC_Temperatur < FC_Temperatur_raw/10) FC_Temperatur++;
-
 
622
          }
-
 
623
    }
-
 
624
// ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
625
 
579
 
626
 
580
        // ---------------- Error Check Timing ----------------------------
627
        // ---------------- Error Check Timing ----------------------------
581
        if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start
628
        if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start
582
        {
629
        {
583
                if(CheckDelay(TimerCheckError))
630
                if(CheckDelay(TimerCheckError))
Line 603... Line 650...
603
                oldFcFlags = FC.StatusFlags;
650
                oldFcFlags = FC.StatusFlags;
604
//              if(CheckDelay(SPI0_Timeout) && (DebugUART == UART1)) GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); // process the GPS data even if the FC is not connected
651
//              if(CheckDelay(SPI0_Timeout) && (DebugUART == UART1)) GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); // process the GPS data even if the FC is not connected
Line 605... Line 652...
605
 
652
 
Line 606... Line -...
606
                if(!CheckDelay(SPI0_Timeout) || (DebugUART == UART1)) CheckErrors();
-
 
607
 
-
 
608
                if(FC.StatusFlags & FC_STATUS_FLY)
-
 
609
                 {
-
 
610
                  NaviData.FlyingTime++; // we want to count the battery-time
-
 
611
                  TimeSinceMotorStart++;
-
 
612
                 }
653
                if(!CheckDelay(SPI0_Timeout) || (DebugUART == UART1)) CheckErrors();
613
 
654
 
614
            if(EE_Parameter.Revision == 0) RequestConfigFromFC = 1;
655
            if(EE_Parameter.Revision == 0) RequestConfigFromFC = 1;
615
                if(SerialLinkOkay) SerialLinkOkay--;
656
                if(SerialLinkOkay) SerialLinkOkay--;
616
                if(SerialLinkOkay < 250 - 6) NCFlags |= NC_FLAG_NOSERIALLINK; // 6 seconds timeout for serial communication
657
                if(SerialLinkOkay < 250 - 6) NCFlags |= NC_FLAG_NOSERIALLINK; // 6 seconds timeout for serial communication
Line 691... Line 732...
691
        Logging_Init();
732
        Logging_Init();
Line 692... Line 733...
692
 
733
 
693
//UART_VersionInfo.HWMajor = 30;
734
//UART_VersionInfo.HWMajor = 30;
694
        LED_GRN_ON;
735
        LED_GRN_ON;
-
 
736
        TimerCheckError = SetDelay(3000);
695
        TimerCheckError = SetDelay(3000);
737
        TimerSecond = SetDelay(3500);
696
        UART1_PutString("\r\n++++++++++++++++++++++++++++++++++++++++++");
738
        UART1_PutString("\r\n++++++++++++++++++++++++++++++++++++++++++");
Line 697... Line 739...
697
        UART1_PutString("\r\n Version information:");
739
        UART1_PutString("\r\n Version information:");
698
 
740
 
Line 748... Line 790...
748
        // Intilizes the Canbus
790
        // Intilizes the Canbus
749
        if(UART_VersionInfo.HWMajor >= 30)
791
        if(UART_VersionInfo.HWMajor >= 30)
750
         {
792
         {
751
           EXT2_Init(); // External Output EXT2
793
           EXT2_Init(); // External Output EXT2
752
           CanbusInit();
794
           CanbusInit();
-
 
795
       ReadBaroCalibrationfromEEprom();
753
         }
796
         }
754
 if(FromCamCtrl.CamStatus)
797
 if(FromCamCtrl.CamStatus)
755
  {
798
  {
756
   u8 msg[30];
799
   u8 msg[30];
757
   sprintf(msg, " CamCtrl found V%i.%02i \r\n",1 + FromCamCtrl.Version / 100, FromCamCtrl.Version % 100);
800
   sprintf(msg, " CamCtrl found V%i.%02i \r\n",1 + FromCamCtrl.Version / 100, FromCamCtrl.Version % 100);
758
   UART1_PutString(msg);
801
   UART1_PutString(msg);
759
  }
802
  }
760
  else if(Compass_I2CPort == NCMAG_PORT_INTERN) UART1_PutString(" No CamCtrl connected \r\n");
803
  else if(Compass_I2CPort == NCMAG_PORT_INTERN) UART1_PutString(" No CamCtrl connected \r\n");
-
 
804
 
761
// ++++++++++++++++++++++++++++++++++++++++++++++
805
// ++++++++++++++++++++++++++++++++++++++++++++++
762
        for (;;) // the endless main loop
806
        for (;;) // the endless main loop
763
        {
807
        {
764
                PollingTimeout = 5;
808
                PollingTimeout = 5;
765
                Polling();
809
                Polling();