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