Rev 234 | Rev 242 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 234 | Rev 241 | ||
---|---|---|---|
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 "timer1.h" |
69 | #include "timer1.h" |
69 | #include "timer2.h" |
70 | #include "timer2.h" |
70 | #include "analog.h" |
71 | #include "analog.h" |
71 | #include "spi_slave.h" |
72 | #include "spi_slave.h" |
72 | #include "fat16.h" |
73 | #include "fat16.h" |
Line 150... | Line 151... | ||
150 | 151 | ||
151 | void CheckErrors(void) |
152 | void CheckErrors(void) |
152 | { |
153 | { |
Line 153... | Line 154... | ||
153 | UART_VersionInfo.HardwareError[0] = 0; |
154 | UART_VersionInfo.HardwareError[0] = 0; |
154 | 155 | ||
Line 155... | Line 156... | ||
155 | if((MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) || CheckDelay(I2C1_Timeout) || (I2C_Heading.Heading < 0)) DebugOut.Status[1] |= 0x08; |
156 | if((MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) || CheckDelay(I2C1_Timeout) || (MK3MAG_Heading.Heading < 0)) DebugOut.Status[1] |= 0x08; |
156 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
157 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
Line 263... | Line 264... | ||
263 | sprintf(ErrorMSG,"no GPS communication "); |
264 | sprintf(ErrorMSG,"no GPS communication "); |
264 | ErrorCode = 5; |
265 | ErrorCode = 5; |
265 | StopNavigation = 1; |
266 | StopNavigation = 1; |
266 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
267 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
267 | } |
268 | } |
268 | else if(I2C_Heading.Heading < 0) |
269 | else if(MK3MAG_Heading.Heading < 0) |
269 | { |
270 | { |
270 | LED_RED_ON; |
271 | LED_RED_ON; |
271 | sprintf(ErrorMSG,"bad compass value "); |
272 | sprintf(ErrorMSG,"bad compass value "); |
272 | ErrorCode = 6; |
273 | ErrorCode = 6; |
273 | StopNavigation = 1; |
274 | StopNavigation = 1; |
Line 310... | Line 311... | ||
310 | { |
311 | { |
311 | IENABLE; |
312 | IENABLE; |
Line 312... | Line 313... | ||
312 | 313 | ||
313 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
314 | VIC_ITCmd(EXTIT3_ITLine,DISABLE); // disable irq |
314 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
315 | VIC_SWITCmd(EXTIT3_ITLine,DISABLE); // clear pending bit |
315 | I2C1_UpdateCompass(); // update compass communication |
316 | MK3MAG_UpdateCompass(); // update compass communication |
316 | Analog_Update(); // get new ADC values |
317 | Analog_Update(); // get new ADC values |
Line 317... | Line 318... | ||
317 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq |
318 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); // enable irq |
318 | 319 | ||
Line 348... | Line 349... | ||
348 | // initialize usb |
349 | // initialize usb |
349 | //USB_ConfigInit(); |
350 | //USB_ConfigInit(); |
350 | // initialize SPI0 to FC |
351 | // initialize SPI0 to FC |
351 | SPI0_Init(); |
352 | SPI0_Init(); |
352 | // initialize i2c bus to MK3MAG (needs Timer 1) |
353 | // initialize i2c bus to MK3MAG (needs Timer 1) |
353 | I2C_Heading.Heading = -1; |
354 | MK3MAG_Init(); |
354 | I2C1_Init(); |
355 | I2C1_Init(); |
355 | // initialize the gps position controller (needs Timer 1) |
356 | // initialize the gps position controller (needs Timer 1) |
356 | Fat16_Init(); |
357 | Fat16_Init(); |
357 | // initialize NC params |
358 | // initialize NC params |
358 | NCParams_Init(); |
359 | NCParams_Init(); |
Line 367... | Line 368... | ||
367 | 368 | ||
368 | GetNaviCtrlVersion(); |
369 | GetNaviCtrlVersion(); |
369 | DebugOut.Status[0] = 0x04 | 0x08; // NC and MK3Mag |
370 | DebugOut.Status[0] = 0x04 | 0x08; // NC and MK3Mag |
Line 370... | Line 371... | ||
370 | DebugOut.Status[1] = 0x00; |
371 | DebugOut.Status[1] = 0x00; |
371 | 372 | ||
372 | I2C1_GetMK3MagVersion(); |
373 | MK3MAG_GetVersion(); |
373 | if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
374 | if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
374 | { |
375 | { |
375 | UART1_PutString("\n\r MK3Mag not compatible"); |
376 | UART1_PutString("\n\r MK3Mag not compatible"); |