Rev 241 | Rev 244 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 241 | Rev 242 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | #include "uart0.h" |
63 | #include "uart0.h" |
64 | #include "uart1.h" |
64 | #include "uart1.h" |
65 | #include "uart2.h" |
65 | #include "uart2.h" |
66 | #include "gps.h" |
66 | #include "gps.h" |
67 | #include "i2c.h" |
67 | #include "i2c.h" |
68 | #include "mk3mag.h" |
68 | #include "compass.h" |
69 | #include "timer1.h" |
69 | #include "timer1.h" |
70 | #include "timer2.h" |
70 | #include "timer2.h" |
71 | #include "analog.h" |
71 | #include "analog.h" |
72 | #include "spi_slave.h" |
72 | #include "spi_slave.h" |
73 | #include "fat16.h" |
73 | #include "fat16.h" |
Line 151... | Line 151... | ||
151 | 151 | ||
152 | void CheckErrors(void) |
152 | void CheckErrors(void) |
153 | { |
153 | { |
Line 154... | Line 154... | ||
154 | UART_VersionInfo.HardwareError[0] = 0; |
154 | UART_VersionInfo.HardwareError[0] = 0; |
155 | 155 | ||
Line 156... | Line 156... | ||
156 | if((MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) || CheckDelay(I2C1_Timeout) || (MK3MAG_Heading.Heading < 0)) DebugOut.Status[1] |= 0x08; |
156 | if(/*(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) ||*/ CheckDelay(I2C1_Timeout) || (CompassHeading < 0)) DebugOut.Status[1] |= 0x08; |
157 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
157 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
Line 248... | Line 248... | ||
248 | { |
248 | { |
249 | LED_RED_ON; |
249 | LED_RED_ON; |
250 | sprintf(ErrorMSG,"Mixer Error"); |
250 | sprintf(ErrorMSG,"Mixer Error"); |
251 | ErrorCode = 19; |
251 | ErrorCode = 19; |
252 | } |
252 | } |
253 | else if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
253 | /* else if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
254 | { |
254 | { |
255 | sprintf(ErrorMSG,"MK3Mag not compatible "); |
255 | sprintf(ErrorMSG,"MK3Mag not compatible "); |
256 | LED_RED_ON; |
256 | LED_RED_ON; |
257 | ErrorCode = 2; |
257 | ErrorCode = 2; |
258 | StopNavigation = 1; |
258 | StopNavigation = 1; |
259 | UART_VersionInfo.HardwareError[0] |= ERROR_MK3_INCOMPATIBLE; |
259 | UART_VersionInfo.HardwareError[0] |= ERROR_MK3_INCOMPATIBLE; |
260 | } |
260 | } */ |
261 | else if(CheckDelay(UBX_Timeout)) |
261 | else if(CheckDelay(UBX_Timeout)) |
262 | { |
262 | { |
263 | LED_RED_ON; |
263 | LED_RED_ON; |
264 | sprintf(ErrorMSG,"no GPS communication "); |
264 | sprintf(ErrorMSG,"no GPS communication "); |
265 | ErrorCode = 5; |
265 | ErrorCode = 5; |
266 | StopNavigation = 1; |
266 | StopNavigation = 1; |
267 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
267 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
268 | } |
268 | } |
269 | else if(MK3MAG_Heading.Heading < 0) |
269 | else if(CompassHeading < 0) |
270 | { |
270 | { |
271 | LED_RED_ON; |
271 | LED_RED_ON; |
272 | sprintf(ErrorMSG,"bad compass value "); |
272 | sprintf(ErrorMSG,"bad compass value "); |
273 | ErrorCode = 6; |
273 | ErrorCode = 6; |
274 | StopNavigation = 1; |
274 | StopNavigation = 1; |
Line 311... | Line 311... | ||
311 | { |
311 | { |
312 | IENABLE; |
312 | IENABLE; |
Line 313... | Line 313... | ||
313 | 313 | ||
314 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
314 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
315 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
315 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
316 | MK3MAG_UpdateCompass(); // update compass communication |
316 | Compass_UpdateHeading(); // update compass communication |
317 | Analog_Update(); // get new ADC values |
317 | Analog_Update(); // get new ADC values |
Line 318... | Line 318... | ||
318 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq |
318 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq |
319 | 319 | ||
Line 348... | Line 348... | ||
348 | Analog_Init(); |
348 | Analog_Init(); |
349 | // initialize usb |
349 | // initialize usb |
350 | //USB_ConfigInit(); |
350 | //USB_ConfigInit(); |
351 | // initialize SPI0 to FC |
351 | // initialize SPI0 to FC |
352 | SPI0_Init(); |
352 | SPI0_Init(); |
353 | // initialize i2c bus to MK3MAG (needs Timer 1) |
353 | // initialize i2c bus (needs Timer 1) |
354 | MK3MAG_Init(); |
- | |
355 | I2C1_Init(); |
354 | I2C1_Init(); |
356 | // initialize the gps position controller (needs Timer 1) |
355 | // initialize the gps position controller (needs Timer 1) |
357 | Fat16_Init(); |
356 | Fat16_Init(); |
358 | // initialize NC params |
357 | // initialize NC params |
359 | NCParams_Init(); |
358 | NCParams_Init(); |
Line 368... | Line 367... | ||
368 | 367 | ||
369 | GetNaviCtrlVersion(); |
368 | GetNaviCtrlVersion(); |
370 | DebugOut.Status[0] = 0x04 | 0x08; // NC and MK3Mag |
369 | DebugOut.Status[0] = 0x04 | 0x08; // NC and MK3Mag |
Line 371... | Line 370... | ||
371 | DebugOut.Status[1] = 0x00; |
370 | DebugOut.Status[1] = 0x00; |
372 | - | ||
373 | MK3MAG_GetVersion(); |
- | |
374 | if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
- | |
375 | { |
- | |
376 | UART1_PutString("\n\r MK3Mag not compatible"); |
- | |
377 | LED_RED_ON; |
371 | |
378 | } |
372 | Compass_Init(); |
379 | 373 | ||
380 | SPI0_GetFlightCtrlVersion(); |
374 | SPI0_GetFlightCtrlVersion(); |
381 | if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
375 | if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
382 | { |
376 | { |