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