Subversion Repositories FlightCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
304 ingob 1
// ######################## SPI - FlightCtrl ###################
2
#include "main.h"
1622 killagreg 3
#include "eeprom.h"
304 ingob 4
 
5
 
823 ingob 6
//struct str_ToNaviCtrl_Version   ToNaviCtrl_Version;
7
//struct str_FromNaviCtrl_Version   FromNaviCtrl_Version;
8
struct str_ToNaviCtrl   ToNaviCtrl;
9
struct str_FromNaviCtrl   FromNaviCtrl;
978 hbuss 10
struct str_FromNaviCtrl_Value FromNaviCtrl_Value;
1448 killagreg 11
struct str_SPI_VersionInfo NC_Version;
1451 killagreg 12
struct str_GPSInfo GPSInfo;
708 ingob 13
 
304 ingob 14
unsigned char              SPI_BufferIndex;
708 ingob 15
unsigned char              SPI_RxBufferIndex;
1668 holgerb 16
signed char FromNC_Rotate_C = 32, FromNC_Rotate_S = 0;
606 ingob 17
 
882 hbuss 18
volatile unsigned char     SPI_Buffer[sizeof(FromNaviCtrl)];
823 ingob 19
unsigned char *SPI_TX_Buffer;
708 ingob 20
 
617 ingob 21
unsigned char SPITransferCompleted, SPI_ChkSum;
1690 holgerb 22
unsigned char SPI_RxDataValid,NaviDataOkay = 250;
720 ingob 23
 
1509 killagreg 24
unsigned char SPI_CommandSequence[] = {SPI_FCCMD_STICK, SPI_FCCMD_USER, SPI_FCCMD_PARAMETER1, SPI_FCCMD_STICK, SPI_FCCMD_MISC, SPI_FCCMD_VERSION, SPI_FCCMD_STICK, SPI_FCCMD_SERVOS, SPI_FCCMD_ACCU};
823 ingob 25
unsigned char SPI_CommandCounter = 0;
1703 holgerb 26
unsigned char NC_ErrorCode = 0;
1920 holgerb 27
unsigned char NC_GPS_ModeCharacter = ' ';
1840 holgerb 28
signed int POI_KameraNick = 0; // in 0,1°
1852 killagreg 29
vector16_t MagVec = {0,0,0};
823 ingob 30
 
597 ingob 31
#ifdef USE_SPI_COMMUNICATION
691 ingob 32
 
304 ingob 33
//------------------------------------------------------
34
void SPI_MasterInit(void)
35
{
1051 killagreg 36
  DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK);    // Set MOSI and SCK output, all others input
304 ingob 37
  SLAVE_SELECT_DDR_PORT |= (1 << SPI_SLAVE_SELECT);
1051 killagreg 38
 
39
  SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(0<<SPR0)|(0<<SPIE);   // Enable SPI, Master, set clock rate fck/64
723 hbuss 40
  SPSR = 0;//(1<<SPI2X);
1051 killagreg 41
 
42
  SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);
606 ingob 43
  SPITransferCompleted = 1;
1051 killagreg 44
 
708 ingob 45
  //SPDR = 0x00;  // dummy write
1051 killagreg 46
 
823 ingob 47
  ToNaviCtrl.Sync1 = 0xAA;
48
  ToNaviCtrl.Sync2 = 0x83;
1051 killagreg 49
 
1448 killagreg 50
  ToNaviCtrl.Command = SPI_FCCMD_USER;
823 ingob 51
  ToNaviCtrl.IntegralNick = 0;
52
  ToNaviCtrl.IntegralRoll = 0;
1215 hbuss 53
  FromNaviCtrl_Value.SerialDataOkay = 0;
1051 killagreg 54
  SPI_RxDataValid = 0;
55
 
304 ingob 56
}
57
 
58
//------------------------------------------------------
823 ingob 59
void SPI_StartTransmitPacket(void)
304 ingob 60
{
606 ingob 61
   //if ((SLAVE_SELECT_PORT & (1 << SPI_SLAVE_SELECT)) == 0) return;    // transfer of prev. packet not completed
62
   if (!SPITransferCompleted) return;
1051 killagreg 63
//   _delay_us(30);
64
 
304 ingob 65
   SLAVE_SELECT_PORT &=  ~(1 << SPI_SLAVE_SELECT);  // SelectSlave
823 ingob 66
   SPI_TX_Buffer = (unsigned char *) &ToNaviCtrl;
1051 killagreg 67
 
823 ingob 68
   ToNaviCtrl.Command = SPI_CommandSequence[SPI_CommandCounter++];
69
   if (SPI_CommandCounter >= sizeof(SPI_CommandSequence)) SPI_CommandCounter = 0;
1051 killagreg 70
 
606 ingob 71
   SPITransferCompleted = 0;
304 ingob 72
   UpdateSPI_Buffer();                              // update buffer
823 ingob 73
 
304 ingob 74
   SPI_BufferIndex = 1;
1051 killagreg 75
  //ebugOut.Analog[16]++;
304 ingob 76
   // -- Debug-Output ---
77
   //----
691 ingob 78
   asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
79
   asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
80
   asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
823 ingob 81
   ToNaviCtrl.Chksum = ToNaviCtrl.Sync1;
1051 killagreg 82
   SPDR = ToNaviCtrl.Sync1;                  // Start transmission
691 ingob 83
//     SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);   // DeselectSlave
84
 
304 ingob 85
}
86
 
87
//------------------------------------------------------
88
//SIGNAL(SIG_SPI)
89
void SPI_TransmitByte(void)
90
{
708 ingob 91
   static unsigned char SPI_RXState = 0;
1051 killagreg 92
   unsigned char rxdata;
708 ingob 93
   static unsigned char rxchksum;
1051 killagreg 94
 
691 ingob 95
   if (SPITransferCompleted) return;
304 ingob 96
   if (!(SPSR & (1 << SPIF))) return;
1051 killagreg 97
  SendSPI = 4;
98
 
99
//   _delay_us(30);
606 ingob 100
  SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);   // DeselectSlave
1051 killagreg 101
 
708 ingob 102
  rxdata = SPDR;
103
  switch ( SPI_RXState)
104
  {
1051 killagreg 105
  case 0:
106
 
107
                        SPI_RxBufferIndex = 0;
108
                        rxchksum = rxdata;
109
                        if (rxdata == 0x81 )  { SPI_RXState  = 1;  }   // 1. Syncbyte ok
110
 
708 ingob 111
           break;
112
 
1051 killagreg 113
   case 1:
114
                    if (rxdata == 0x55) { rxchksum += rxdata; SPI_RXState  = 2;  }   // 2. Syncbyte ok
115
                 else SPI_RXState  = 0;
116
           break;
117
 
708 ingob 118
   case 2:
119
                   SPI_Buffer[SPI_RxBufferIndex++]= rxdata;             // get data
120
           //DebugOut.Analog[19]++;
1051 killagreg 121
           if (SPI_RxBufferIndex >= sizeof(FromNaviCtrl))
122
                   {
123
 
708 ingob 124
                if (rxdata == rxchksum)
125
                        {
823 ingob 126
                  unsigned char *ptr = (unsigned char *)&FromNaviCtrl;
708 ingob 127
                          memcpy(ptr, (unsigned char *) SPI_Buffer,  sizeof(SPI_Buffer));
1051 killagreg 128
                          SPI_RxDataValid = 1;
129
                        }
1856 killagreg 130
                        else
1855 holgerb 131
                         {
132
                          SPI_RxDataValid = 0;
1856 killagreg 133
                         }
1051 killagreg 134
 
1856 killagreg 135
 
1051 killagreg 136
                        SPI_RXState  = 0;
708 ingob 137
                   }
1051 killagreg 138
                  else rxchksum += rxdata;
139
        break;
140
 
141
  }
142
 
143
   if (SPI_BufferIndex < sizeof(ToNaviCtrl))
144
     {
606 ingob 145
           SLAVE_SELECT_PORT &=  ~(1 << SPI_SLAVE_SELECT);  // SelectSlave
691 ingob 146
           asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
147
           asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
148
           asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");         asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop");
1051 killagreg 149
 
708 ingob 150
           SPDR = SPI_TX_Buffer[SPI_BufferIndex];
823 ingob 151
           ToNaviCtrl.Chksum += SPI_TX_Buffer[SPI_BufferIndex];
691 ingob 152
        //   SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);   // DeselectSlave
153
 
606 ingob 154
         }
1051 killagreg 155
         else SPITransferCompleted = 1;
156
 
304 ingob 157
         SPI_BufferIndex++;
158
}
159
 
691 ingob 160
 
304 ingob 161
//------------------------------------------------------
162
void UpdateSPI_Buffer(void)
163
{
846 hbuss 164
  signed int tmp;
1171 hbuss 165
  ToNaviCtrl.IntegralNick = (int) (IntegralNick / (long)(EE_Parameter.GyroAccFaktor * 4));
166
  ToNaviCtrl.IntegralRoll = (int) (IntegralRoll / (long)(EE_Parameter.GyroAccFaktor * 4));
167
  ToNaviCtrl.GyroCompass = (10 * ErsatzKompass) / GIER_GRAD_FAKTOR;
1664 holgerb 168
  ToNaviCtrl.GyroGier = (signed int) AdNeutralGier - AdWertGier;
1171 hbuss 169
  ToNaviCtrl.AccNick = ((int) ACC_AMPLIFY * (NaviAccNick / NaviCntAcc))/4;
170
  ToNaviCtrl.AccRoll = ((int) ACC_AMPLIFY * (NaviAccRoll / NaviCntAcc))/4;
819 hbuss 171
  NaviCntAcc = 0; NaviAccNick = 0; NaviAccRoll = 0;
823 ingob 172
//  ToNaviCtrl.User8 = Parameter_UserParam8;
173
//  ToNaviCtrl.CalState = WinkelOut.CalcState;
1051 killagreg 174
   switch(ToNaviCtrl.Command)  //
823 ingob 175
   {
1448 killagreg 176
         case SPI_FCCMD_USER:
823 ingob 177
                                ToNaviCtrl.Param.Byte[0] = Parameter_UserParam1;
178
                                ToNaviCtrl.Param.Byte[1] = Parameter_UserParam2;
179
                                ToNaviCtrl.Param.Byte[2] = Parameter_UserParam3;
180
                                ToNaviCtrl.Param.Byte[3] = Parameter_UserParam4;
181
                                ToNaviCtrl.Param.Byte[4] = Parameter_UserParam5;
182
                                ToNaviCtrl.Param.Byte[5] = Parameter_UserParam6;
183
                                ToNaviCtrl.Param.Byte[6] = Parameter_UserParam7;
921 hbuss 184
                                ToNaviCtrl.Param.Byte[7] = Parameter_UserParam8;
1765 killagreg 185
                                ToNaviCtrl.Param.Byte[8] = FC_StatusFlags;
186
                FC_StatusFlags &= ~(FC_STATUS_CALIBRATE | FC_STATUS_START);
1622 killagreg 187
                    ToNaviCtrl.Param.Byte[9] = GetActiveParamSet();
1915 holgerb 188
                                ToNaviCtrl.Param.Byte[10] = EE_Parameter.ComingHomeAltitude;
1861 holgerb 189
                                ToNaviCtrl.Param.Byte[11] = FC_StatusFlags2;
921 hbuss 190
        break;
1241 killagreg 191
 
1508 killagreg 192
     case SPI_FCCMD_ACCU:
193
                        ToNaviCtrl.Param.Int[0] = Capacity.ActualCurrent; // 0.1A
194
                        ToNaviCtrl.Param.Int[1] = Capacity.UsedCapacity; // mAh
195
                        ToNaviCtrl.Param.Byte[4] = (unsigned char) UBat; // 0.1V
196
                        ToNaviCtrl.Param.Byte[5] = (unsigned char) BattLowVoltageWarning; //0.1V
1865 holgerb 197
                                ToNaviCtrl.Param.Byte[6] = VarioCharacter;
1916 holgerb 198
                                ToNaviCtrl.Param.Byte[7] = Parameter_GlobalConfig;
199
                                ToNaviCtrl.Param.Byte[8] = Parameter_ExtraConfig;
1508 killagreg 200
        break;
201
 
1448 killagreg 202
         case SPI_FCCMD_PARAMETER1:
993 hbuss 203
                                ToNaviCtrl.Param.Byte[0] = EE_Parameter.NaviGpsModeControl;     // Parameters for the Naviboard
1051 killagreg 204
                                ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviGpsGain;
205
                                ToNaviCtrl.Param.Byte[2] = EE_Parameter.NaviGpsP;
206
                                ToNaviCtrl.Param.Byte[3] = EE_Parameter.NaviGpsI;
207
                                ToNaviCtrl.Param.Byte[4] = EE_Parameter.NaviGpsD;
208
                                ToNaviCtrl.Param.Byte[5] = EE_Parameter.NaviGpsACC;
209
                                ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsMinSat;
210
                ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviStickThreshold;
993 hbuss 211
                ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviOperatingRadius;
212
                ToNaviCtrl.Param.Byte[9] = EE_Parameter.NaviWindCorrection;
1936 holgerb 213
                ToNaviCtrl.Param.Byte[10] = EE_Parameter.NaviAccCompensation;
1064 hbuss 214
                                ToNaviCtrl.Param.Byte[11] = EE_Parameter.NaviAngleLimitation;
823 ingob 215
            break;
1241 killagreg 216
 
1448 killagreg 217
         case SPI_FCCMD_STICK:
1320 hbuss 218
              cli();
871 hbuss 219
                tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]];  if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127;
846 hbuss 220
                                ToNaviCtrl.Param.Byte[0] = (char) tmp;
871 hbuss 221
                tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127;
846 hbuss 222
                                ToNaviCtrl.Param.Byte[1] = (char) tmp;
871 hbuss 223
                tmp = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127;
846 hbuss 224
                                ToNaviCtrl.Param.Byte[2] = (char) tmp;
871 hbuss 225
                tmp = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127;
1320 hbuss 226
              sei();
846 hbuss 227
                                ToNaviCtrl.Param.Byte[3] = (char) tmp;
1377 hbuss 228
                                ToNaviCtrl.Param.Byte[4] = (unsigned char) Poti[0];
229
                                ToNaviCtrl.Param.Byte[5] = (unsigned char) Poti[1];
230
                                ToNaviCtrl.Param.Byte[6] = (unsigned char) Poti[2];
231
                    ToNaviCtrl.Param.Byte[7] = (unsigned char) Poti[3];
232
                                ToNaviCtrl.Param.Byte[8] = (unsigned char) Poti[4];
233
                                ToNaviCtrl.Param.Byte[9] = (unsigned char) Poti[5];
234
                                ToNaviCtrl.Param.Byte[10] = (unsigned char) Poti[6];
235
                                ToNaviCtrl.Param.Byte[11] = (unsigned char) Poti[7];
1241 killagreg 236
                        break;
1448 killagreg 237
                case SPI_FCCMD_MISC:
1241 killagreg 238
                        if(WinkelOut.CalcState > 5)
239
                        {
240
                                WinkelOut.CalcState = 0;
241
                                ToNaviCtrl.Param.Byte[0] = 5;
242
                        }
243
                        else ToNaviCtrl.Param.Byte[0] = WinkelOut.CalcState;
1312 hbuss 244
                        ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviPH_LoginTime;
1662 killagreg 245
                        ToNaviCtrl.Param.Int[1] = (int)(HoehenWert/5);
1312 hbuss 246
                        ToNaviCtrl.Param.Int[2] = (int)(SollHoehe/5);
247
                        ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsPLimit;
248
                        ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviGpsILimit;
249
                        ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviGpsDLimit;
1377 hbuss 250
            ToNaviCtrl.Param.Byte[9] = (unsigned char) SenderOkay;
1600 killagreg 251
            ToNaviCtrl.Param.Byte[10] = (unsigned char) PPM_in[0];
1377 hbuss 252
                        ToNaviCtrl.Param.Byte[11] = DebugOut.Analog[7] / 4; //GasMischanteil
1241 killagreg 253
                        break;
1448 killagreg 254
                case SPI_FCCMD_VERSION:
255
                        ToNaviCtrl.Param.Byte[0] = VERSION_MAJOR;
256
                        ToNaviCtrl.Param.Byte[1] = VERSION_MINOR;
257
                        ToNaviCtrl.Param.Byte[2] = VERSION_PATCH;
258
                        ToNaviCtrl.Param.Byte[3] = NC_SPI_COMPATIBLE;
1241 killagreg 259
                        ToNaviCtrl.Param.Byte[4] = PlatinenVersion;
1702 holgerb 260
                        ToNaviCtrl.Param.Byte[5] = VersionInfo.HardwareError[0];
261
                        ToNaviCtrl.Param.Byte[6] = VersionInfo.HardwareError[1];
1938 holgerb 262
                        VersionInfo.HardwareError[0] = 0;
263
                        VersionInfo.HardwareError[1] &= FC_ERROR1_MIXER;
1702 holgerb 264
                        ToNaviCtrl.Param.Byte[7] = VersionInfo.HardwareError[2];
1765 killagreg 265
                        ToNaviCtrl.Param.Byte[8] = VersionInfo.HardwareError[3];
266
                        ToNaviCtrl.Param.Byte[9] = VersionInfo.HardwareError[4];
1913 holgerb 267
                        ToNaviCtrl.Param.Byte[10] = EE_Parameter.OrientationAngle;
1241 killagreg 268
                break;
1448 killagreg 269
            case SPI_FCCMD_SERVOS:
1241 killagreg 270
                ToNaviCtrl.Param.Byte[0] = EE_Parameter.ServoNickRefresh;     // Parameters for the Servo Control
271
                        ToNaviCtrl.Param.Byte[1] = EE_Parameter.ServoCompInvert;
272
                        ToNaviCtrl.Param.Byte[2] = Parameter_ServoNickControl;
273
                        ToNaviCtrl.Param.Byte[3] = EE_Parameter.ServoNickComp;
274
                        ToNaviCtrl.Param.Byte[4] = EE_Parameter.ServoNickMin;
275
                        ToNaviCtrl.Param.Byte[5] = EE_Parameter.ServoNickMax;
276
                        ToNaviCtrl.Param.Byte[6] = Parameter_ServoRollControl;
277
                        ToNaviCtrl.Param.Byte[7] = EE_Parameter.ServoRollComp;
278
                        ToNaviCtrl.Param.Byte[8] = EE_Parameter.ServoRollMin;
279
                        ToNaviCtrl.Param.Byte[9] = EE_Parameter.ServoRollMax;
280
                break;
281
        }
1856 killagreg 282
 
1215 hbuss 283
  if(SPI_RxDataValid)
1051 killagreg 284
  {
1852 killagreg 285
        NaviDataOkay = 250;
286
        CalculateCompassTimer = 1;
287
        if(abs(FromNaviCtrl.GPS_Nick) < 512 && abs(FromNaviCtrl.GPS_Roll) < 512 && (EE_Parameter.GlobalConfig & CFG_GPS_AKTIV))
288
        {
289
                GPS_Nick = FromNaviCtrl.GPS_Nick;
290
                GPS_Roll = FromNaviCtrl.GPS_Roll;
291
        }
1690 holgerb 292
 
1852 killagreg 293
        // update compass readings
1936 holgerb 294
//      MagVec.x = FromNaviCtrl.MagVecX;
295
//      MagVec.y = FromNaviCtrl.MagVecY;
296
//      MagVec.z = FromNaviCtrl.MagVecZ;
1852 killagreg 297
 
1690 holgerb 298
        if(FromNaviCtrl.CompassValue <= 360)   KompassValue = FromNaviCtrl.CompassValue;
1837 holgerb 299
    KompassRichtung = ((540 + KompassValue - KompassSollWert) % 360) - 180;
1051 killagreg 300
 
1834 holgerb 301
    if(FromNaviCtrl.BeepTime > beeptime /*&& !WinkelOut.CalcState*/) beeptime = FromNaviCtrl.BeepTime;
1912 holgerb 302
#define FLAG_GPS_AID 0x01
823 ingob 303
          switch (FromNaviCtrl.Command)
304
          {
1448 killagreg 305
            case SPI_NCCMD_KALMAN:
1231 killagreg 306
                        FromNaviCtrl_Value.Kalman_K = FromNaviCtrl.Param.sByte[0];
307
                        FromNaviCtrl_Value.Kalman_MaxFusion = FromNaviCtrl.Param.sByte[1];
308
                        FromNaviCtrl_Value.Kalman_MaxDrift = FromNaviCtrl.Param.sByte[2];
309
                        FromNaviCtrl_Value.SerialDataOkay = FromNaviCtrl.Param.Byte[3];
1283 hbuss 310
                        FromNaviCtrl_Value.GpsZ = FromNaviCtrl.Param.Byte[4];
1664 holgerb 311
                        FromNC_Rotate_C = FromNaviCtrl.Param.Byte[5];
312
                        FromNC_Rotate_S = FromNaviCtrl.Param.Byte[6];
1912 holgerb 313
            if(FromNaviCtrl.Param.Byte[7] & FLAG_GPS_AID) GPS_AidMode = 1; else GPS_AidMode = 0;
314
                        if(CareFree && FromNaviCtrl.Param.sInt[4] >= 0)
1840 holgerb 315
                         {
316
                          KompassSollWert = FromNaviCtrl.Param.sInt[4]; // bei Carefree kann NC den Kompass-Sollwinkel vorgeben
1876 holgerb 317
                          if(EE_Parameter.CamOrientation)  // Kamera angle is not front
318
                           {
319
                            KompassSollWert += 360 - ((unsigned int) EE_Parameter.CamOrientation * 15);
320
                                KompassSollWert %= 360;
321
                           }   
1856 killagreg 322
                         }
1862 holgerb 323
                        POI_KameraNick = (POI_KameraNick + FromNaviCtrl.Param.sInt[5]) / 2; // FromNaviCtrl.Param.sInt[5]; // Nickwinkel
1231 killagreg 324
                        break;
1448 killagreg 325
                case SPI_NCCMD_VERSION:
326
                        NC_Version.Major = FromNaviCtrl.Param.Byte[0];
327
                        NC_Version.Minor = FromNaviCtrl.Param.Byte[1];
328
                        NC_Version.Patch = FromNaviCtrl.Param.Byte[2];
329
                        NC_Version.Compatible = FromNaviCtrl.Param.Byte[3];
330
                        NC_Version.Hardware = FromNaviCtrl.Param.Byte[4];
1702 holgerb 331
                        DebugOut.Status[0] |= FromNaviCtrl.Param.Byte[5];
332
                        DebugOut.Status[1] = (DebugOut.Status[1] & (0x01|0x02)) | (FromNaviCtrl.Param.Byte[6] & (0x04 | 0x08));
1920 holgerb 333
                        NC_ErrorCode = FromNaviCtrl.Param.Byte[7];
334
                        NC_GPS_ModeCharacter = FromNaviCtrl.Param.Byte[8];
1856 killagreg 335
                        break;
1451 killagreg 336
 
337
                case SPI_NCCMD_GPSINFO:
338
                        GPSInfo.Flags = FromNaviCtrl.Param.Byte[0];
339
                        GPSInfo.NumOfSats = FromNaviCtrl.Param.Byte[1];
340
                        GPSInfo.SatFix = FromNaviCtrl.Param.Byte[2];
1690 holgerb 341
                        GPSInfo.Speed = FromNaviCtrl.Param.Byte[3];
1852 killagreg 342
                        GPSInfo.HomeDistance = FromNaviCtrl.Param.Int[2];
1472 killagreg 343
                        GPSInfo.HomeBearing = FromNaviCtrl.Param.sInt[3];
1790 holgerb 344
                        PPM_in[25] = (signed char) FromNaviCtrl.Param.Byte[8]; // WP_EVENT-Channel-Value
1855 holgerb 345
            FromNC_AltitudeSpeed = FromNaviCtrl.Param.Byte[9];
1857 holgerb 346
                FromNC_AltitudeSetpoint = (long) FromNaviCtrl.Param.sInt[5] * 10;  // in cm
1451 killagreg 347
                        break;
1855 holgerb 348
// 0 = 0,1
349
// 1 = 2,3
350
// 2 = 4,5
351
// 3 = 6,7
352
// 4 = 8,9
353
// 5 = 10,11
823 ingob 354
                default:
1451 killagreg 355
                        break;
823 ingob 356
          }
720 ingob 357
  }
358
  else
359
  {
819 hbuss 360
//    KompassValue = 0;
361
//    KompassRichtung = 0;
720 ingob 362
        GPS_Nick = 0;
363
    GPS_Roll = 0;
364
  }
304 ingob 365
}
366
 
597 ingob 367
#endif
304 ingob 368
 
369