Rev 482 | Rev 484 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 482 | Rev 483 | ||
---|---|---|---|
Line 60... | Line 60... | ||
60 | #include "led.h" |
60 | #include "led.h" |
61 | #include "uart0.h" |
61 | #include "uart0.h" |
62 | #include "uart1.h" |
62 | #include "uart1.h" |
63 | #include "uart2.h" |
63 | #include "uart2.h" |
64 | #include "gps.h" |
64 | #include "gps.h" |
- | 65 | #include "i2c0.h" |
|
65 | #include "i2c.h" |
66 | #include "i2c1.h" |
66 | #include "compass.h" |
67 | #include "compass.h" |
67 | #include "ncmag.h" |
68 | #include "ncmag.h" |
68 | #include "timer1.h" |
69 | #include "timer1.h" |
69 | #include "timer2.h" |
70 | #include "timer2.h" |
70 | #include "analog.h" |
71 | #include "analog.h" |
Line 79... | Line 80... | ||
79 | #include "debug.h" |
80 | #include "debug.h" |
80 | #include "eeprom.h" |
81 | #include "eeprom.h" |
81 | #include "ssc.h" |
82 | #include "ssc.h" |
82 | #include "sdc.h" |
83 | #include "sdc.h" |
83 | #include "uart1.h" |
84 | #include "uart1.h" |
84 | - | ||
- | 85 | #include "ncmag.h" |
|
Line 85... | Line 86... | ||
85 | 86 | ||
86 | 87 | ||
87 | #ifdef FOLLOW_ME |
88 | #ifdef FOLLOW_ME |
Line 143... | Line 144... | ||
143 | { |
144 | { |
144 | static s32 no_error_delay = 0; |
145 | static s32 no_error_delay = 0; |
145 | s32 newErrorCode = 0; |
146 | s32 newErrorCode = 0; |
146 | UART_VersionInfo.HardwareError[0] = 0; |
147 | UART_VersionInfo.HardwareError[0] = 0; |
Line 147... | Line 148... | ||
147 | 148 | ||
- | 149 | if((I2C_CompassPort == I2C_INTERN_1 && CheckDelay(I2C1_Timeout)) || (I2C_CompassPort == I2C_EXTERN_0 && CheckDelay(I2C0_Timeout)) || (Compass_Heading < 0)) |
|
- | 150 | ||
148 | if(CheckDelay(I2CBus(Compass_I2CPort)->Timeout) || (Compass_Heading < 0)) DebugOut.StatusRed |= AMPEL_COMPASS; |
151 | DebugOut.StatusRed |= AMPEL_COMPASS; |
Line 149... | Line 152... | ||
149 | else DebugOut.StatusRed &= ~AMPEL_COMPASS; // MK3Mag green status |
152 | else DebugOut.StatusRed &= ~AMPEL_COMPASS; // MK3Mag green status |
150 | 153 | ||
Line 151... | Line 154... | ||
151 | if((FC.Error[1] & FC_ERROR1_I2C) || (FC.Error[1] & FC_ERROR1_BL_MISSING)) DebugOut.StatusRed |= AMPEL_BL; |
154 | if((FC.Error[1] & FC_ERROR1_I2C) || (FC.Error[1] & FC_ERROR1_BL_MISSING)) DebugOut.StatusRed |= AMPEL_BL; |
152 | else DebugOut.StatusRed &= ~AMPEL_BL; // BL-Ctrl green status |
155 | else DebugOut.StatusRed &= ~AMPEL_BL; // BL-Ctrl green status |
Line -... | Line 156... | ||
- | 156 | ||
- | 157 | if(UART_VersionInfo.HardwareError[0] || UART_VersionInfo.HardwareError[1]) DebugOut.StatusRed |= AMPEL_NC; |
|
153 | 158 | else DebugOut.StatusRed &= ~AMPEL_NC; |
|
154 | if(UART_VersionInfo.HardwareError[0] || UART_VersionInfo.HardwareError[1]) DebugOut.StatusRed |= AMPEL_NC; |
159 | |
155 | else DebugOut.StatusRed &= ~AMPEL_NC; |
160 | //if(I2C_CompassPort == I2C_EXTERN_0) LED_RED_OFF_T; |
156 | 161 | ||
157 | if((FCCalibActive || CompassCalState) && FC_Version.Hardware) |
162 | if((FCCalibActive || CompassCalState) && FC_Version.Hardware) |
158 | { |
163 | { |
159 | sprintf(ErrorMSG,"Calibrate... "); |
164 | sprintf(ErrorMSG,"Calibrate... "); |
160 | newErrorCode = 0; |
165 | newErrorCode = 0; |
161 | ErrorCode = 0; |
166 | ErrorCode = 0; |
162 | no_error_delay = 1; |
167 | no_error_delay = 1; |
163 | } |
168 | } |
164 | else if(CheckDelay(I2CBus(Compass_I2CPort)->Timeout)) |
169 | else if(CheckDelay(I2C1_Timeout) && (I2C_CompassPort == I2C_INTERN_1)) |
- | 170 | { |
|
165 | { |
171 | LED_RED_ON; |
166 | LED_RED_ON; |
172 | sprintf(ErrorMSG,"no compass communica"); |
167 | sprintf(ErrorMSG,"no compass communica"); |
173 | //Reset I2CBus |
168 | //Reset Compass communication |
174 | I2C1_Deinit(); |
169 | Compass_Init(); |
175 | I2C1_Init(); |
170 | newErrorCode = 4; |
176 | newErrorCode = 4; |
- | 177 | StopNavigation = 1; |
|
- | 178 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
|
- | 179 | DebugOut.StatusRed |= AMPEL_COMPASS; |
|
- | 180 | } |
|
- | 181 | else if(CheckDelay(I2C0_Timeout) && (I2C_CompassPort == I2C_EXTERN_0)) |
|
- | 182 | { |
|
- | 183 | LED_RED_ON; |
|
- | 184 | //LED_RED_ON_T; |
|
- | 185 | sprintf(ErrorMSG,"no ext. compass "); |
|
- | 186 | //Reset I2CBus |
|
- | 187 | I2C0_Deinit(); |
|
- | 188 | I2C0_Init(); |
|
- | 189 | NCMAG_Update(1); |
|
- | 190 | newErrorCode = 33; |
|
- | 191 | StopNavigation = 1; |
|
171 | StopNavigation = 1; |
192 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
172 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
193 | DebugOut.StatusRed |= AMPEL_COMPASS; |
173 | DebugOut.StatusRed |= AMPEL_COMPASS; |
194 | } |
174 | } |
195 | else |
175 | else if(CheckDelay(SPI0_Timeout)) |
196 | if(CheckDelay(SPI0_Timeout)) |
176 | { |
197 | { |
Line 193... | Line 214... | ||
193 | newErrorCode = 1; |
214 | newErrorCode = 1; |
194 | StopNavigation = 1; |
215 | StopNavigation = 1; |
195 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_FC_INCOMPATIBLE; |
216 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_FC_INCOMPATIBLE; |
196 | DebugOut.StatusRed |= AMPEL_NC; |
217 | DebugOut.StatusRed |= AMPEL_NC; |
197 | } |
218 | } |
- | 219 | ||
198 | else if(FC.Error[0] & FC_ERROR0_GYRO_NICK) |
220 | else if(FC.Error[0] & FC_ERROR0_GYRO_NICK) |
199 | { |
221 | { |
200 | LED_RED_ON; |
222 | LED_RED_ON; |
201 | sprintf(ErrorMSG,"ERR: FC Nick Gyro"); |
223 | sprintf(ErrorMSG,"ERR: FC Nick Gyro"); |
202 | newErrorCode = 10; |
224 | newErrorCode = 10; |
Line 264... | Line 286... | ||
264 | else if(CheckDelay(UBX_Timeout) && Parameter.GlobalConfig & FC_CFG_GPS_AKTIV) |
286 | else if(CheckDelay(UBX_Timeout) && Parameter.GlobalConfig & FC_CFG_GPS_AKTIV) |
265 | { |
287 | { |
266 | LED_RED_ON; |
288 | LED_RED_ON; |
267 | // if(!(Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) sprintf(ErrorMSG,"GPS disconnected "); |
289 | // if(!(Parameter.GlobalConfig & FC_CFG_GPS_AKTIV)) sprintf(ErrorMSG,"GPS disconnected "); |
268 | // else |
290 | // else |
269 | { |
291 | { |
270 | sprintf(ErrorMSG,"no GPS communication"); |
292 | sprintf(ErrorMSG,"no GPS communication"); |
271 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_GPS_RX; |
293 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_GPS_RX; |
272 | UART_VersionInfo.Flags &= ~NC_VERSION_FLAG_GPS_PRESENT; |
294 | UART_VersionInfo.Flags &= ~NC_VERSION_FLAG_GPS_PRESENT; |
273 | newErrorCode = 5; |
295 | newErrorCode = 5; |
274 | } |
296 | } |
275 | StopNavigation = 1; |
297 | StopNavigation = 1; |
276 | // UBX_Timeout = SetDelay(500); |
298 | // UBX_Timeout = SetDelay(500); |
277 | } |
299 | } |
278 | else if(Compass_Heading < 0 && NCMAG_Present && !NCMAG_IsCalibrated) |
300 | else if(Compass_Heading < 0 && NCMAG_Present && !NCMAG_IsCalibrated) |
279 | { |
301 | { |
Line 310... | Line 332... | ||
310 | sprintf(ErrorMSG,"RC Signal lost "); |
332 | sprintf(ErrorMSG,"RC Signal lost "); |
311 | newErrorCode = 7; |
333 | newErrorCode = 7; |
312 | } |
334 | } |
313 | else if(ErrorGpsFixLost) |
335 | else if(ErrorGpsFixLost) |
314 | { |
336 | { |
315 | LED_RED_ON; |
337 | LED_RED_ON; |
316 | sprintf(ErrorMSG,"GPS Fix lost "); |
338 | sprintf(ErrorMSG,"GPS Fix lost "); |
317 | newErrorCode = 21; |
339 | newErrorCode = 21; |
318 | } |
340 | } |
319 | else if(ErrorDisturbedEarthMagnetField) |
341 | else if(ErrorDisturbedEarthMagnetField) |
320 | { |
342 | { |
321 | LED_RED_ON; |
343 | LED_RED_ON; |
322 | sprintf(ErrorMSG,"Magnet error "); |
344 | sprintf(ErrorMSG,"Magnet error "); |
323 | newErrorCode = 22; |
345 | newErrorCode = 22; |
324 | DebugOut.StatusRed |= AMPEL_COMPASS | AMPEL_NC; |
346 | DebugOut.StatusRed |= AMPEL_COMPASS | AMPEL_NC; |
325 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_VALUE; |
347 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_VALUE; |
326 | } |
348 | } |
327 | else if(((BL_MinOfMaxPWM == 40 && (FC.StatusFlags & FC_STATUS_FLY)) || BL_MinOfMaxPWM == 39) && !ErrorCode) |
349 | else if(((BL_MinOfMaxPWM == 40 && (FC.StatusFlags & FC_STATUS_FLY)) || BL_MinOfMaxPWM == 39) && !ErrorCode) |
328 | { |
350 | { |
329 | LED_RED_ON; |
351 | LED_RED_ON; |
330 | sprintf(ErrorMSG,"ERR:Motor restart "); |
352 | sprintf(ErrorMSG,"ERR:Motor restart "); |
331 | newErrorCode = 23; |
353 | newErrorCode = 23; |
332 | DebugOut.StatusRed |= AMPEL_BL; |
354 | DebugOut.StatusRed |= AMPEL_BL; |
333 | } |
355 | } |
334 | else if(BL_MinOfMaxPWM < 30 && !ErrorCode) |
356 | else if(BL_MinOfMaxPWM < 30 && !ErrorCode) |
335 | { |
357 | { |
336 | u16 i; |
358 | unsigned int i; |
337 | for(i = 0; i < 12; i++) if(Motor[i].MaxPWM == BL_MinOfMaxPWM) break; |
359 | for(i = 0; i < 12; i++) if(Motor[i].MaxPWM == BL_MinOfMaxPWM) break; |
- | 360 | ||
338 | LED_RED_ON; |
361 | LED_RED_ON; |
339 | sprintf(ErrorMSG,"ERR:BL%2d Test:%2d ",i+1,BL_MinOfMaxPWM); |
362 | sprintf(ErrorMSG,"ERR:BL%2d Test:%2d ",i+1,BL_MinOfMaxPWM); |
340 | newErrorCode = 32; |
363 | newErrorCode = 32; |
341 | DebugOut.StatusRed |= AMPEL_BL; |
364 | DebugOut.StatusRed |= AMPEL_BL; |
342 | } |
365 | } |
343 | else if(BL_MinOfMaxPWM < 248 && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
366 | else if(BL_MinOfMaxPWM < 248 && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
344 | { |
367 | { |
345 | LED_RED_ON; |
368 | LED_RED_ON; |
346 | sprintf(ErrorMSG,"ERR:BL Limitation "); |
369 | sprintf(ErrorMSG,"ERR:BL Limitation "); |
347 | newErrorCode = 24; |
370 | newErrorCode = 24; |
348 | DebugOut.StatusRed |= AMPEL_BL; |
371 | DebugOut.StatusRed |= AMPEL_BL; |
349 | } |
372 | } |
350 | else if(NCFlags & NC_FLAG_RANGE_LIMIT && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
373 | else if(NCFlags & NC_FLAG_RANGE_LIMIT && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
351 | { |
374 | { |
352 | LED_RED_ON; |
375 | LED_RED_ON; |
353 | sprintf(ErrorMSG,"ERR:GPS range "); |
376 | sprintf(ErrorMSG,"ERR:GPS range "); |
354 | newErrorCode = 25; |
377 | newErrorCode = 25; |
355 | DebugOut.StatusRed |= AMPEL_NC; |
378 | DebugOut.StatusRed |= AMPEL_NC; |
356 | } |
379 | } |
357 | else if((!SD_SWITCH || (SDCardInfo.Valid == 0)) && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START && !(FC.StatusFlags & FC_STATUS_FLY)) |
380 | else if((!SD_SWITCH || (SDCardInfo.Valid == 0)) && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START && !(FC.StatusFlags & FC_STATUS_FLY)) |
358 | { |
381 | { |
359 | LED_RED_ON; |
382 | LED_RED_ON; |
360 | sprintf(ErrorMSG,"ERR:No SD-Card "); |
383 | sprintf(ErrorMSG,"ERR:No SD-Card "); |
361 | newErrorCode = 26; |
384 | newErrorCode = 26; |
362 | DebugOut.StatusRed |= AMPEL_NC; |
385 | DebugOut.StatusRed |= AMPEL_NC; |
363 | } |
386 | } |
364 | else if((SD_LoggingError || (SD_WatchDog < 2000 && SD_WatchDog != 0)) && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START) |
387 | else if((SD_LoggingError || (SD_WatchDog < 2000 && SD_WatchDog != 0)) && Parameter.GlobalConfig3 & CFG3_NO_SDCARD_NO_START) |
365 | { |
388 | { |
366 | LED_RED_ON; |
389 | LED_RED_ON; |
367 | sprintf(ErrorMSG,"ERR:SD Logging abort"); |
390 | sprintf(ErrorMSG,"ERR:SD Logging abort"); |
368 | newErrorCode = 27; |
391 | newErrorCode = 27; |
369 | DebugOut.StatusRed |= AMPEL_NC; |
392 | DebugOut.StatusRed |= AMPEL_NC; |
370 | SD_LoggingError = 0; |
393 | SD_LoggingError = 0; |
371 | } |
394 | } |
372 | else if(((AbsoluteFlyingAltitude) && (NaviData.Altimeter / 20 >= AbsoluteFlyingAltitude)) && (FC.StatusFlags & FC_STATUS_FLY)) |
395 | else if(((AbsoluteFlyingAltitude) && (NaviData.Altimeter / 20 >= AbsoluteFlyingAltitude)) && (FC.StatusFlags & FC_STATUS_FLY)) |
373 | { |
396 | { |
374 | LED_RED_ON; |
397 | LED_RED_ON; |
375 | sprintf(ErrorMSG,"ERR:Max Altitude "); |
398 | sprintf(ErrorMSG,"ERR:Max Altitude "); |
376 | newErrorCode = 29; |
399 | newErrorCode = 29; |
377 | DebugOut.StatusRed |= AMPEL_NC; |
400 | DebugOut.StatusRed |= AMPEL_NC; |
378 | } |
401 | } |
379 | else if(Parameter.GlobalConfig3 & CFG3_NO_GPSFIX_NO_START && !(NCFlags & NC_FLAG_GPS_OK) && ((FC.StatusFlags & (FC_STATUS_START | FC_STATUS_MOTOR_RUN)) || (FC.StickGas < -50 && FC.StickYaw < -50))) |
402 | else if(Parameter.GlobalConfig3 & CFG3_NO_GPSFIX_NO_START && !(NCFlags & NC_FLAG_GPS_OK) && ((FC.StatusFlags & (FC_STATUS_START | FC_STATUS_MOTOR_RUN)) || (FC.StickGas < -50 && FC.StickYaw < -50))) |
380 | { |
403 | { |
381 | LED_RED_ON; |
404 | LED_RED_ON; |
382 | sprintf(ErrorMSG,"No GPS Fix "); |
405 | sprintf(ErrorMSG,"No GPS Fix "); |
383 | newErrorCode = 30; |
406 | newErrorCode = 30; |
384 | } |
407 | } |
385 | else // no error occured |
408 | else // no error occured |
386 | { |
409 | { |
387 | StopNavigation = 0; |
410 | StopNavigation = 0; |
388 | LED_RED_OFF; |
411 | LED_RED_OFF; |
389 | if(no_error_delay) { no_error_delay--; } |
412 | if(no_error_delay) { no_error_delay--; } |
390 | else |
413 | else |
391 | { |
414 | { |
392 | sprintf(ErrorMSG,"No Error "); |
415 | sprintf(ErrorMSG,"No Error "); |
393 | ErrorCode = 0; |
416 | ErrorCode = 0; |
394 | } |
417 | } |
395 | } |
418 | } |
Line 396... | Line 419... | ||
396 | 419 | ||
397 | if(newErrorCode) |
420 | if(newErrorCode) |
398 | { |
421 | { |
Line 410... | Line 433... | ||
410 | 433 | ||
411 | 434 | ||
412 | void Polling(void) |
435 | void Polling(void) |
- | 436 | { |
|
413 | { |
437 | static u8 running = 0, oldFcFlags = 0, count5sec; |
414 | static u8 running = 0, oldFcFlags = 0, count5sec; |
438 | static u32 old_ms = 0; |
- | 439 | if(running) return; |
|
- | 440 | running = 1; |
|
- | 441 | if(CountMilliseconds != old_ms) // 1 ms |
|
- | 442 | { |
|
- | 443 | old_ms = CountMilliseconds; |
|
- | 444 | Compass_Update(); // update compass communication |
|
- | 445 | Analog_Update(); // get new ADC values |
|
415 | if(running) return; |
446 | CalcHeadFree(); |
416 | running = 1; |
447 | } |
417 | SPI0_UpdateBuffer(); // also calls the GPS-functions |
448 | SPI0_UpdateBuffer(); // also calls the GPS-functions |
418 | UART0_ProcessRxData(); // GPS process request |
449 | UART0_ProcessRxData(); // GPS process request |
419 | UART0_TransmitTxData(); // GPS send answer |
450 | UART0_TransmitTxData(); // GPS send answer |
420 | UART1_ProcessRxData(); // PC process request |
451 | UART1_ProcessRxData(); // PC process request |
421 | UART1_TransmitTxData(); // PC send answer |
- | |
422 | UART2_TransmitTxData(); // FC send answer |
452 | UART1_TransmitTxData(); // PC send answer |
423 | CalcHeadFree(); |
453 | UART2_TransmitTxData(); // FC send answer |
424 | // ---------------- Error Check Timing ---------------------------- |
454 | // ---------------- Error Check Timing ---------------------------- |
425 | if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start |
455 | if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start |
426 | { |
456 | { |
Line 451... | Line 481... | ||
451 | } |
481 | } |
Line 452... | Line 482... | ||
452 | 482 | ||
453 | // the handler will be cyclic called by the timer 1 ISR |
483 | // the handler will be cyclic called by the timer 1 ISR |
454 | // used is for critical timing parts that normaly would handled |
484 | // used is for critical timing parts that normaly would handled |
455 | // within the main loop that could block longer at logging activities |
485 | // within the main loop that could block longer at logging activities |
456 | void EXTIT3_IRQHandler(void) |
486 | void EXTIT3_IRQHandler(void) // 1ms - Takt |
457 | { |
487 | { |
458 | IENABLE; |
488 | IENABLE; |
459 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
489 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
460 | Compass_Update(); // update compass communication |
490 | // Compass_Update(); // update compass communication |
461 | Analog_Update(); // get new ADC values |
- | |
462 | 491 | // Analog_Update(); // get new ADC values |
|
463 | if(!PollingTimeout) |
492 | if(!PollingTimeout) |
464 | { |
493 | { |
465 | PollingTimeout = 5; |
494 | PollingTimeout = 5; |
- | 495 | Polling(); |
|
466 | Polling(); |
496 | DebugOut.Analog[16]++; |
Line 467... | Line 497... | ||
467 | } |
497 | } |
468 | 498 | ||
469 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
499 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
Line 474... | Line 504... | ||
474 | 504 | ||
475 | //---------------------------------------------------------------------------------------------------- |
505 | //---------------------------------------------------------------------------------------------------- |
476 | int main(void) |
506 | int main(void) |
Line 477... | Line 507... | ||
477 | { |
507 | { |
478 | 508 | ||
479 | // static u32 ftimer =0; |
509 | static u32 ftimer =0; |
Line 480... | Line 510... | ||
480 | // static u8 fstate = 0; |
510 | static u8 fstate = 0; |
481 | // static File_t* f = NULL; |
511 | // static File_t* f = NULL; |
Line 505... | Line 535... | ||
505 | // initialize adc |
535 | // initialize adc |
506 | Analog_Init(); |
536 | Analog_Init(); |
507 | // initialize SPI0 to FC |
537 | // initialize SPI0 to FC |
508 | SPI0_Init(); |
538 | SPI0_Init(); |
509 | // initialize i2c busses (needs Timer 1) |
539 | // initialize i2c busses (needs Timer 1) |
510 | I2CBus_Init(I2C0); |
540 | I2C0_Init(); |
511 | I2CBus_Init(I2C1); |
541 | I2C1_Init(); |
Line 512... | Line 542... | ||
512 | 542 | ||
513 | // initialize fat16 partition on sd card (needs Timer 1) |
543 | // initialize fat16 partition on sd card (needs Timer 1) |
514 | Fat16_Init(); |
544 | Fat16_Init(); |
515 | // initialize NC params |
545 | // initialize NC params |
Line 561... | Line 591... | ||
561 | Settings_GetParamValue(PID_SEND_NMEA, &NMEA_Interval); |
591 | Settings_GetParamValue(PID_SEND_NMEA, &NMEA_Interval); |
562 | UART1_PutString("\r\n"); |
592 | UART1_PutString("\r\n"); |
563 | for (;;) // the endless main loop |
593 | for (;;) // the endless main loop |
564 | { |
594 | { |
565 | Polling(); |
595 | Polling(); |
566 | PollingTimeout = 15; |
596 | PollingTimeout = 10; |
567 | // ---------------- Logging --------------------------------------- |
597 | // ---------------- Logging --------------------------------------- |
568 | if(SD_WatchDog) |
598 | if(SD_WatchDog) |
569 | { |
599 | { |
570 | SD_WatchDog = 30000; |
600 | SD_WatchDog = 30000; |
571 | if(SDCardInfo.Valid == 1) Logging_Update(); // could be block some time for at max. 2 seconds, therefore move time critical part of the mainloop into the ISR of timer 1 |
601 | if(SDCardInfo.Valid == 1) Logging_Update(); // could be block some time for at max. 2 seconds, therefore move time critical part of the mainloop into the ISR of timer 1 |
572 | else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100; |
602 | else if(FC.StatusFlags & FC_STATUS_START) SD_LoggingError = 100; |
573 | if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r"); |
603 | if(!SD_WatchDog) UART1_PutString("\n\rSD-Watchdog - Logging aborted\n\r"); |
574 | } |
604 | } |
575 | 605 | ||
576 | /* |
606 | /* |
577 | if(CheckDelay(ftimer)) |
607 | if(CheckDelay(ftimer)) |
578 | { |
608 | { |
Line 579... | Line 609... | ||
579 | 609 |