Rev 252 | Rev 255 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 252 | Rev 254 | ||
---|---|---|---|
Line 78... | Line 78... | ||
78 | #include "settings.h" |
78 | #include "settings.h" |
79 | #include "config.h" |
79 | #include "config.h" |
80 | #include "main.h" |
80 | #include "main.h" |
81 | #include "debug.h" |
81 | #include "debug.h" |
Line -... | Line 82... | ||
- | 82 | ||
- | 83 | #include "eeprom.h" |
|
82 | 84 | ||
83 | u8 BoardRelease = 0; |
85 | u8 BoardRelease = 0; |
84 | u32 TimerCheckError; |
86 | u32 TimerCheckError; |
85 | u8 ErrorCode = 0; |
87 | u8 ErrorCode = 0; |
86 | u16 BeepTime; |
88 | u16 BeepTime; |
Line 152... | Line 154... | ||
152 | 154 | ||
153 | void CheckErrors(void) |
155 | void CheckErrors(void) |
154 | { |
156 | { |
Line 155... | Line 157... | ||
155 | UART_VersionInfo.HardwareError[0] = 0; |
157 | UART_VersionInfo.HardwareError[0] = 0; |
156 | 158 | ||
Line 157... | Line 159... | ||
157 | if(/*(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) ||*/ CheckDelay(I2C1_Timeout) || (CompassHeading < 0)) DebugOut.Status[1] |= 0x08; |
159 | if(/*(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) ||*/ CheckDelay(I2C1_Timeout) || (Compass_Heading < 0)) DebugOut.Status[1] |= 0x08; |
158 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
160 | else DebugOut.Status[1] &= ~0x08; // MK3Mag green status |
Line 265... | Line 267... | ||
265 | sprintf(ErrorMSG,"no GPS communication "); |
267 | sprintf(ErrorMSG,"no GPS communication "); |
266 | ErrorCode = 5; |
268 | ErrorCode = 5; |
267 | StopNavigation = 1; |
269 | StopNavigation = 1; |
268 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
270 | UART_VersionInfo.HardwareError[0] |= ERROR_GPS_COMMUNICATION; |
269 | } |
271 | } |
270 | else if(CompassHeading < 0) |
272 | else if(Compass_Heading < 0) |
271 | { |
273 | { |
272 | LED_RED_ON; |
274 | LED_RED_ON; |
273 | sprintf(ErrorMSG,"bad compass value "); |
275 | sprintf(ErrorMSG,"bad compass value "); |
274 | ErrorCode = 6; |
276 | ErrorCode = 6; |
275 | StopNavigation = 1; |
277 | StopNavigation = 1; |
Line 346... | Line 348... | ||
346 | // initialize UART0 (to MKGPS or MK3MAG) |
348 | // initialize UART0 (to MKGPS or MK3MAG) |
347 | UART0_Init(); |
349 | UART0_Init(); |
348 | // initialize adc |
350 | // initialize adc |
349 | Analog_Init(); |
351 | Analog_Init(); |
350 | // initialize usb |
352 | // initialize usb |
351 | //USB_ConfigInit(); |
353 | USB_ConfigInit(); |
352 | // initialize SPI0 to FC |
354 | // initialize SPI0 to FC |
353 | SPI0_Init(); |
355 | SPI0_Init(); |
354 | // initialize i2c bus (needs Timer 1) |
356 | // initialize i2c bus (needs Timer 1) |
355 | I2C1_Init(); |
357 | I2C1_Init(); |
356 | // initialize fat16 partition on sd card (needs Timer 1) |
358 | // initialize fat16 partition on sd card (needs Timer 1) |
Line 379... | Line 381... | ||
379 | LED_RED_ON; |
381 | LED_RED_ON; |
380 | } |
382 | } |
Line 381... | Line 383... | ||
381 | 383 | ||
Line -... | Line 384... | ||
- | 384 | GPS_Init(); |
|
- | 385 | ||
- | 386 | /*{ |
|
- | 387 | u8 i; |
|
- | 388 | u8 text[20]; |
|
- | 389 | u8 mesg[10]; |
|
- | 390 | UART1_PutString("\r\nFill\r\n"); |
|
- | 391 | for(i=0;i<20;i++) |
|
- | 392 | { |
|
- | 393 | text[i] = 0xAA; |
|
- | 394 | sprintf(mesg,"%02X ", text[i]); |
|
- | 395 | UART1_PutString(mesg); |
|
- | 396 | } |
|
- | 397 | ||
- | 398 | sprintf(mesg, "\r\nEERead = %d\r\n", EEPROM_ReadBlock(50, text, 18)); |
|
- | 399 | UART1_PutString(mesg); |
|
- | 400 | for(i=0;i<20;i++) |
|
- | 401 | { |
|
- | 402 | sprintf(mesg,"%02X ", text[i]); |
|
- | 403 | UART1_PutString(mesg); |
|
- | 404 | text[i] = i; |
|
- | 405 | } |
|
- | 406 | UART1_PutString("\r\nFill\r\n"); |
|
- | 407 | for(i=0;i<20;i++) |
|
- | 408 | { |
|
- | 409 | sprintf(mesg,"%02X ", text[i]); |
|
- | 410 | UART1_PutString(mesg); |
|
- | 411 | } |
|
- | 412 | sprintf(mesg, "\r\nEEWrite = %d\r\n", EEPROM_WriteBlock(0, text, 18)); |
|
- | 413 | UART1_PutString(mesg); |
|
- | 414 | for(i=0;i<20;i++) |
|
- | 415 | { |
|
- | 416 | sprintf(mesg,"%02X ", text[i]); |
|
- | 417 | UART1_PutString(mesg); |
|
- | 418 | text[i]=0xAA; |
|
- | 419 | } |
|
- | 420 | UART1_PutString("\r\nFill\r\n"); |
|
- | 421 | for(i=0;i<20;i++) |
|
- | 422 | { |
|
- | 423 | sprintf(mesg,"%02X ", text[i]); |
|
- | 424 | UART1_PutString(mesg); |
|
- | 425 | } |
|
- | 426 | sprintf(mesg, "\r\nEERead = %d\r\n", EEPROM_ReadBlock(0, text, 18)); |
|
- | 427 | UART1_PutString(mesg); |
|
- | 428 | for(i=0;i<20;i++) |
|
- | 429 | { |
|
- | 430 | sprintf(mesg,"%02X ", text[i]); |
|
- | 431 | UART1_PutString(mesg); |
|
- | 432 | } |
|
382 | GPS_Init(); |
433 | }*/ |
383 | 434 | ||
384 | // ---------- Prepare the isr driven |
435 | // ---------- Prepare the isr driven |
385 | // set to absolute lowest priority |
436 | // set to absolute lowest priority |
386 | VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW); |
437 | VIC_Config(EXTIT3_ITLine, VIC_IRQ, PRIORITY_SW); |
Line 387... | Line 438... | ||
387 | // enable interrupts |
438 | // enable interrupts |
Line -... | Line 439... | ||
- | 439 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); |
|
388 | VIC_ITCmd(EXTIT3_ITLine, ENABLE); |
440 | |
389 | 441 | Debug_OK("START"); |
|
390 | Debug_OK("START"); |
442 | |
391 | 443 | ||
392 | for (;;) // the endless main loop |
444 | for (;;) // the endless main loop |
393 | { |
445 | { |
394 | UART0_ProcessRxData(); // process request |
446 | UART0_ProcessRxData(); // process request |
395 | UART1_ProcessRxData(); // process request |
447 | UART1_ProcessRxData(); // process request |
396 | //USB_ProcessRxData(); // process request |
448 | USB_ProcessRxData(); // process request |
397 | UART0_TransmitTxData(); // send answer |
449 | UART0_TransmitTxData(); // send answer |
398 | UART1_TransmitTxData(); // send answer |
450 | UART1_TransmitTxData(); // send answer |
399 | UART2_TransmitTxData(); // send answer |
451 | UART2_TransmitTxData(); // send answer |
400 | //USB_TransmitTxData(); // send answer |
452 | USB_TransmitTxData(); // send answer |
401 | SPI0_UpdateBuffer(); // handle new SPI Data |
453 | SPI0_UpdateBuffer(); // handle new SPI Data |