Subversion Repositories FlightCtrl

Rev

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

Rev 717 Rev 720
Line 12... Line 12...
12
 
12
 
13
volatile unsigned char     SPI_Buffer[sizeof(FromNaviCtrl_Value)];
13
volatile unsigned char     SPI_Buffer[sizeof(FromNaviCtrl_Value)];
Line 14... Line 14...
14
unsigned char *SPI_TX_Buffer, *ToNaviCtrl_Chksum;
14
unsigned char *SPI_TX_Buffer, *ToNaviCtrl_Chksum;
-
 
15
 
-
 
16
unsigned char SPITransferCompleted, SPI_ChkSum;
15
 
17
unsigned char SPI_RxDataValid;
Line 16... Line 18...
16
unsigned char SPITransferCompleted, SPI_ChkSum;
18
 
17
#ifdef USE_SPI_COMMUNICATION
19
#ifdef USE_SPI_COMMUNICATION
18
 
20
 
Line 28... Line 30...
28
  SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);
30
  SLAVE_SELECT_PORT |=  (1 << SPI_SLAVE_SELECT);
29
  SPITransferCompleted = 1;
31
  SPITransferCompleted = 1;
Line 30... Line 32...
30
 
32
 
Line 31... Line 33...
31
  //SPDR = 0x00;  // dummy write
33
  //SPDR = 0x00;  // dummy write
32
 
34
 
Line 33... Line 35...
33
  ToNaviCtrl_Value.Sync1 = 0x81;
35
  ToNaviCtrl_Value.Sync1 = 0xAA;
34
  ToNaviCtrl_Value.Sync2 = 0x55;
36
  ToNaviCtrl_Value.Sync2 = 0x83;
35
 
37
 
36
  ToNaviCtrl_Value.Command = SPI_CMD_VALUE;
38
  ToNaviCtrl_Value.Command = SPI_CMD_VALUE;
37
  ToNaviCtrl_Value.IntegralNick = 12345;
39
  ToNaviCtrl_Value.IntegralNick = 12345;
38
  ToNaviCtrl_Value.IntegralRoll = 56789;
40
  ToNaviCtrl_Value.IntegralRoll = 56789;
39
  ToNaviCtrl_Value.StickNick = 100;
41
  ToNaviCtrl_Value.StickNick = 100;
-
 
42
  ToNaviCtrl_Value.StickRoll = 150;//(char) StickRoll;
40
  ToNaviCtrl_Value.StickRoll = 150;//(char) StickRoll;
43
  ToNaviCtrl_Value.StickGier = 200;//(char) StickGier;
Line 41... Line 44...
41
  ToNaviCtrl_Value.StickGier = 200;//(char) StickGier;
44
   
42
 
45
  SPI_RxDataValid = 0;
43
}
46
}
Line 123... Line 126...
123
                        {
126
                        {
124
                  unsigned char *ptr = (unsigned char *)&FromNaviCtrl_Value;
127
                  unsigned char *ptr = (unsigned char *)&FromNaviCtrl_Value;
Line 125... Line 128...
125
     
128
     
Line 126... Line 129...
126
                          memcpy(ptr, (unsigned char *) SPI_Buffer,  sizeof(SPI_Buffer));
129
                          memcpy(ptr, (unsigned char *) SPI_Buffer,  sizeof(SPI_Buffer));
127
                         
130
                         
128
                          DebugOut.Analog[20]++;
131
                          SPI_RxDataValid = 1;
Line 129... Line 132...
129
                        }
132
                        }
130
                        else DebugOut.Analog[21]++;
133
                        else SPI_RxDataValid = 0;
131
                       
134
                       
132
                        SPI_RXState  = 0;  
135
                        SPI_RXState  = 0;  
Line 164... Line 167...
164
  ToNaviCtrl_Value.IntegralRoll = (int) (IntegralRoll / 1024);
167
  ToNaviCtrl_Value.IntegralRoll = (int) (IntegralRoll / 1024);
165
  ToNaviCtrl_Value.StickNick = 4;
168
  ToNaviCtrl_Value.StickNick = 4;
166
  ToNaviCtrl_Value.StickRoll = 5;//(char) StickRoll;
169
  ToNaviCtrl_Value.StickRoll = 5;//(char) StickRoll;
167
  ToNaviCtrl_Value.StickGier = 6;//(char) StickGier;
170
  ToNaviCtrl_Value.StickGier = 6;//(char) StickGier;
168
  ToNaviCtrl_Value.GyroCompass = ErsatzKompass / GIER_GRAD_FAKTOR;
171
  ToNaviCtrl_Value.GyroCompass = ErsatzKompass / GIER_GRAD_FAKTOR;
169
  ToNaviCtrl_Value.User1 = EE_Parameter.UserParam1;
172
  ToNaviCtrl_Value.User1 = Parameter_UserParam1;
170
  ToNaviCtrl_Value.User2 = EE_Parameter.UserParam2;
173
  ToNaviCtrl_Value.User2 = Parameter_UserParam2;
171
  ToNaviCtrl_Value.User3 = EE_Parameter.UserParam3;
174
  ToNaviCtrl_Value.User3 = Parameter_UserParam3;
172
  ToNaviCtrl_Value.User4 = EE_Parameter.UserParam4;
175
  ToNaviCtrl_Value.User4 = Parameter_UserParam4;
173
  ToNaviCtrl_Value.User5 = EE_Parameter.UserParam5;
176
  ToNaviCtrl_Value.User5 = Parameter_UserParam5;
174
  ToNaviCtrl_Value.User6 = EE_Parameter.UserParam6;
177
  ToNaviCtrl_Value.User6 = Parameter_UserParam6;
175
  ToNaviCtrl_Value.User7 = EE_Parameter.UserParam7;
178
  ToNaviCtrl_Value.User7 = Parameter_UserParam7;
176
  ToNaviCtrl_Value.User8 = EE_Parameter.UserParam8;
179
  ToNaviCtrl_Value.User8 = Parameter_UserParam8;
177
  sei();
180
  sei();
Line -... Line 181...
-
 
181
 
-
 
182
  if (SPI_RxDataValid)
178
 
183
  {
179
  DebugOut.Analog[30] = FromNaviCtrl_Value.GPS_Nick;
184
    GPS_Nick = FromNaviCtrl_Value.GPS_Nick;
180
  DebugOut.Analog[31] = FromNaviCtrl_Value.GPS_Roll;
185
    GPS_Roll = FromNaviCtrl_Value.GPS_Roll;
181
  KompassValue = FromNaviCtrl_Value.CompassValue;
186
    KompassValue = FromNaviCtrl_Value.CompassValue;
-
 
187
    KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
-
 
188
 
-
 
189
    if (FromNaviCtrl_Value.BeepTime != 0) beeptime = FromNaviCtrl_Value.BeepTime;
-
 
190
  }
-
 
191
  else
-
 
192
  {
-
 
193
    KompassValue = 0;
-
 
194
    KompassRichtung = 0;
-
 
195
       
-
 
196
        GPS_Nick = 0;
-
 
197
    GPS_Roll = 0;
182
  KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
198
  }
Line 183... Line 199...
183
}
199
}