Rev 1701 | Rev 1703 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1701 | Rev 1702 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | unsigned char SendVersionToNavi = 1; |
56 | unsigned char SendVersionToNavi = 1; |
57 | unsigned char BattLowVoltageWarning = 94; |
57 | unsigned char BattLowVoltageWarning = 94; |
58 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
58 | unsigned int FlugMinuten = 0,FlugMinutenGesamt = 0; |
59 | unsigned int FlugSekunden = 0; |
59 | unsigned int FlugSekunden = 0; |
60 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
60 | pVoidFnct_pVoidFnctChar_const_fmt _printf_P; |
61 | - | ||
- | 61 | unsigned char FoundMotors = 0; |
|
Line 62... | Line 62... | ||
62 | 62 | ||
63 | void CalMk3Mag(void) |
63 | void CalMk3Mag(void) |
64 | { |
64 | { |
65 | static unsigned char stick = 1; |
65 | static unsigned char stick = 1; |
Line 185... | Line 185... | ||
185 | } |
185 | } |
186 | } |
186 | } |
187 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
187 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
188 | { |
188 | { |
189 | printf("%d",i+1); |
189 | printf("%d",i+1); |
- | 190 | FoundMotors++; |
|
190 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
191 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
191 | } |
192 | } |
192 | } |
193 | } |
193 | for(i=0; i < MAX_MOTORS; i++) |
194 | for(i=0; i < MAX_MOTORS; i++) |
194 | { |
195 | { |
Line 199... | Line 200... | ||
199 | } |
200 | } |
200 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
201 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
201 | } |
202 | } |
202 | printf("\n\r==================================="); |
203 | printf("\n\r==================================="); |
Line -... | Line 204... | ||
- | 204 | ||
- | 205 | if(RequiredMotors < FoundMotors) VersionInfo.HardwareError[1] |= DEFEKT_MIXER_ERR; |
|
203 | 206 | ||
204 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
207 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
205 | { |
208 | { |
206 | printf("\n\rCalibrating pressure sensor.."); |
209 | printf("\n\rCalibrating pressure sensor.."); |
207 | timer = SetDelay(1000); |
210 | timer = SetDelay(1000); |
Line 219... | Line 222... | ||
219 | 222 | ||
220 | 223 | ||
Line 221... | Line 224... | ||
221 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
224 | FlugMinuten = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES + 1); |
222 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
225 | FlugMinutenGesamt = (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL) * 256 + (unsigned int)GetParamByte(PID_FLIGHT_MINUTES_TOTAL + 1); |
223 | 226 | ||
224 | if( (FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF) ) |
227 | if((FlugMinutenGesamt == 0xFFFF) || (FlugMinuten == 0xFFFF)) |
225 | { |
228 | { |
226 | FlugMinuten = 0; |
229 | FlugMinuten = 0; |
Line 243... | Line 246... | ||
243 | //SpektrumBinding(); |
246 | //SpektrumBinding(); |
244 | timer = SetDelay(2000); |
247 | timer = SetDelay(2000); |
245 | timerPolling = SetDelay(250); |
248 | timerPolling = SetDelay(250); |
Line 246... | Line 249... | ||
246 | 249 | ||
- | 250 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
|
Line 247... | Line 251... | ||
247 | Debug(ANSI_CLEAR "FC-Start!\n\rFlugzeit: %d min", FlugMinutenGesamt); // Note: this won't waste flash memory, if #DEBUG is not active |
251 | DebugOut.Status[0] = 0x01 | 0x02; |
248 | 252 | ||
249 | while (1) |
253 | while (1) |
250 | { |
254 | { |
Line 258... | Line 262... | ||
258 | UpdateMotor=0; |
262 | UpdateMotor=0; |
259 | if(WinkelOut.CalcState) CalMk3Mag(); |
263 | if(WinkelOut.CalcState) CalMk3Mag(); |
260 | else MotorRegler(); |
264 | else MotorRegler(); |
261 | SendMotorData(); |
265 | SendMotorData(); |
262 | ROT_OFF; |
266 | ROT_OFF; |
263 | if(SenderOkay) SenderOkay--; |
267 | if(SenderOkay) { SenderOkay--; VersionInfo.HardwareError[1] &= ~DEFEKT_PPM_ERR; } |
264 | else |
268 | else |
265 | { |
269 | { |
266 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
270 | TIMSK1 |= _BV(ICIE1); // enable PPM-Input |
267 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
271 | PPM_in[0] = 0; // set RSSI to zero on data timeout |
- | 272 | VersionInfo.HardwareError[1] |= DEFEKT_PPM_ERR; |
|
268 | } |
273 | } |
269 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
274 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
270 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
275 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 160 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 220) SenderOkay = 160; |
271 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
276 | //if(HoehenReglerAktiv && NaviDataOkay && SenderOkay < 101 && SenderOkay > 10 && FromNaviCtrl_Value.SerialDataOkay > 1) SenderOkay = 101; |
272 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
277 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
273 | - | ||
274 | if(!--I2CTimeout || MissingMotor) |
278 | if(!--I2CTimeout || MissingMotor) |
275 | { |
279 | { |
276 | if(!I2CTimeout) |
280 | if(!I2CTimeout) |
277 | { |
281 | { |
278 | I2C_Reset(); |
282 | I2C_Reset(); |
279 | I2CTimeout = 5; |
283 | I2CTimeout = 5; |
280 | DebugOut.Analog[28]++; // I2C-Error |
284 | DebugOut.Analog[28]++; // I2C-Error |
281 | FCFlags |= FCFLAG_I2CERR; |
285 | FCFlags |= FCFLAG_I2CERR; |
- | 286 | VersionInfo.HardwareError[1] |= DEFEKT_I2C; |
|
- | 287 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
|
282 | } |
288 | } |
283 | if((BeepMuster == 0xffff) && MotorenEin) |
289 | if((BeepMuster == 0xffff) && MotorenEin) |
284 | { |
290 | { |
285 | beeptime = 10000; |
291 | beeptime = 10000; |
286 | BeepMuster = 0x0080; |
292 | BeepMuster = 0x0080; |
287 | } |
293 | } |
288 | } |
294 | } |
289 | else |
295 | else |
290 | { |
296 | { |
291 | ROT_OFF; |
297 | ROT_OFF; |
- | 298 | if(!beeptime) |
|
- | 299 | { |
|
292 | if(!beeptime) FCFlags &= ~FCFLAG_I2CERR; |
300 | FCFlags &= ~FCFLAG_I2CERR; |
- | 301 | } |
|
293 | } |
302 | } |
294 | if(!UpdateMotor) |
303 | if(!UpdateMotor) |
295 | { |
304 | { |
296 | DatenUebertragung(); |
305 | DatenUebertragung(); |
297 | BearbeiteRxDaten(); |
306 | BearbeiteRxDaten(); |
298 | if(CheckDelay(timer)) |
307 | if(CheckDelay(timer)) |
299 | { |
308 | { |
300 | static unsigned char second; |
309 | static unsigned char second; |
301 | timer += 20; // 20 ms interval |
310 | timer += 20; // 20 ms interval |
- | 311 | if(MissingMotor) |
|
- | 312 | { |
|
- | 313 | VersionInfo.HardwareError[1] |= DEFEKT_BL_MISSING; |
|
- | 314 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
|
- | 315 | } |
|
- | 316 | else |
|
- | 317 | { |
|
- | 318 | VersionInfo.HardwareError[1] &= ~DEFEKT_BL_MISSING; |
|
- | 319 | if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status |
|
- | 320 | } |
|
- | 321 | ||
- | 322 | if(I2CTimeout > 6) VersionInfo.HardwareError[1] &= ~DEFEKT_I2C; |
|
- | 323 | ||
302 | if(PcZugriff) PcZugriff--; |
324 | if(PcZugriff) PcZugriff--; |
303 | else |
325 | else |
304 | { |
326 | { |
305 | ExternControl.Config = 0; |
327 | ExternControl.Config = 0; |
306 | ExternStickNick = 0; |
328 | ExternStickNick = 0; |
Line 314... | Line 336... | ||
314 | } |
336 | } |
315 | if(NaviDataOkay > 200) |
337 | if(NaviDataOkay > 200) |
316 | { |
338 | { |
317 | NaviDataOkay--; |
339 | NaviDataOkay--; |
318 | FCFlags &= ~FCFLAG_SPI_RX_ERR; |
340 | FCFlags &= ~FCFLAG_SPI_RX_ERR; |
- | 341 | VersionInfo.HardwareError[1] &= ~DEFEKT_SPI_RX_ERR; |
|
319 | } |
342 | } |
320 | else |
343 | else |
321 | { |
344 | { |
- | 345 | if(NC_Version.Compatible) |
|
- | 346 | { |
|
- | 347 | FCFlags |= FCFLAG_SPI_RX_ERR; |
|
- | 348 | VersionInfo.HardwareError[1] |= DEFEKT_SPI_RX_ERR; |
|
322 | if(NC_Version.Compatible && BeepMuster == 0xffff && MotorenEin) |
349 | if(BeepMuster == 0xffff && MotorenEin) |
323 | { |
350 | { |
324 | beeptime = 15000; |
351 | beeptime = 15000; |
325 | BeepMuster = 0xA800; |
352 | BeepMuster = 0xA800; |
- | 353 | } |
|
326 | } |
354 | } |
327 | GPS_Nick = 0; |
355 | GPS_Nick = 0; |
328 | GPS_Roll = 0; |
356 | GPS_Roll = 0; |
329 | //if(!beeptime) |
357 | //if(!beeptime) |
330 | FCFlags |= FCFLAG_SPI_RX_ERR; |
- | |
331 | FromNaviCtrl.CompassValue = -1; |
358 | FromNaviCtrl.CompassValue = -1; |
332 | } |
359 | } |
333 | if(UBat < BattLowVoltageWarning) |
360 | if(UBat < BattLowVoltageWarning) |
334 | { |
361 | { |
335 | FCFlags |= FCFLAG_LOWBAT; |
362 | FCFlags |= FCFLAG_LOWBAT; |