Rev 227 | Rev 229 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 227 | Rev 228 | ||
---|---|---|---|
Line 132... | Line 132... | ||
132 | LED_RED_ON; |
132 | LED_RED_ON; |
133 | sprintf(ErrorMSG,"no FC communication "); |
133 | sprintf(ErrorMSG,"no FC communication "); |
134 | ErrorCode = 3; |
134 | ErrorCode = 3; |
135 | StopNavigation = 1; |
135 | StopNavigation = 1; |
136 | } |
136 | } |
137 | else if(CheckDelay(I2C1_Timeout)) |
137 | else if((CheckDelay(I2C1_Timeout)) || (I2C_Heading.Heading == -2)) |
138 | { |
138 | { |
139 | LED_RED_ON; |
139 | LED_RED_ON; |
140 | sprintf(ErrorMSG,"no MK3Mag communication "); |
140 | sprintf(ErrorMSG,"no MK3Mag communication "); |
141 | //Reset I2CBus |
141 | //Reset I2CBus |
142 | I2C1_Deinit(); |
142 | I2C1_Deinit(); |
Line 239... | Line 239... | ||
239 | // initialize usb |
239 | // initialize usb |
240 | //USB_ConfigInit(); |
240 | //USB_ConfigInit(); |
241 | // initialize SPI0 to FC |
241 | // initialize SPI0 to FC |
242 | SPI0_Init(); |
242 | SPI0_Init(); |
243 | // initialize i2c bus to MK3MAG (needs Timer 1) |
243 | // initialize i2c bus to MK3MAG (needs Timer 1) |
- | 244 | I2C_Heading.Heading = -1; |
|
244 | I2C1_Init(); |
245 | I2C1_Init(); |
245 | // initialize the gps position controller (needs Timer 1) |
246 | // initialize the gps position controller (needs Timer 1) |
246 | Fat16_Init(); |
247 | Fat16_Init(); |
247 | // initialize NC params |
248 | // initialize NC params |
248 | NCParams_Init(); |
249 | NCParams_Init(); |
Line 279... | Line 280... | ||
279 | // ---------- Prepare the isr driven |
280 | // ---------- Prepare the isr driven |
280 | // set to absolute lowest priority |
281 | // set to absolute lowest priority |
281 | VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW); |
282 | VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW); |
282 | // enable interrupts |
283 | // enable interrupts |
283 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); |
284 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); |
284 | - | ||
- | 285 | I2C1_Timeout = SetDelay(1000); |
|
285 | for (;;) // the endless main loop |
286 | for (;;) // the endless main loop |
286 | { |
287 | { |
287 | UART0_ProcessRxData(); // process request |
288 | UART0_ProcessRxData(); // process request |
288 | UART1_ProcessRxData(); // process request |
289 | UART1_ProcessRxData(); // process request |
289 | USB_ProcessRxData(); // process request |
290 | USB_ProcessRxData(); // process request |
Line 302... | Line 303... | ||
302 | if(FC.Flags & FCFLAG_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
303 | if(FC.Flags & FCFLAG_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
303 | // else NaviData.FlyingTime = 0; // not the time per flight |
304 | // else NaviData.FlyingTime = 0; // not the time per flight |
304 | if(SerialLinkOkay) SerialLinkOkay--; |
305 | if(SerialLinkOkay) SerialLinkOkay--; |
305 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
306 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
306 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |
307 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |
307 | if(StopNavigation && (Parameter.NaviGpsModeControl >= 50)) BeepTime = 500; |
308 | if(StopNavigation && (Parameter.NaviGpsModeControl >= 50)) BeepTime = 1000; |
308 | } |
309 | } |
309 | // ---------------- Logging --------------------------------------- |
310 | // ---------------- Logging --------------------------------------- |
310 | 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 |
311 | 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 |
311 | } |
312 | } |
312 | } |
313 | } |