Rev 245 | Rev 261 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 245 | Rev 247 | ||
---|---|---|---|
Line 76... | Line 76... | ||
76 | UART0_MuxerState_t UART0_Muxer = UART0_UNDEF; |
76 | UART0_MuxerState_t UART0_Muxer = UART0_UNDEF; |
77 | u16 Uart0Baudrate = UART0_BAUD_RATE; |
77 | u16 Uart0Baudrate = UART0_BAUD_RATE; |
78 | u16 Uart0MK3MagBaudrate = UART0_BAUD_RATE; |
78 | u16 Uart0MK3MagBaudrate = UART0_BAUD_RATE; |
Line 79... | Line 79... | ||
79 | 79 | ||
80 | // the tx buffer |
80 | // the tx buffer |
81 | #define UART0_TX_BUFFER_LEN 200 |
81 | #define UART0_TX_BUFFER_LEN 150 |
82 | u8 UART0_tbuffer[UART0_TX_BUFFER_LEN]; |
82 | u8 UART0_tbuffer[UART0_TX_BUFFER_LEN]; |
Line 83... | Line 83... | ||
83 | Buffer_t UART0_tx_buffer; |
83 | Buffer_t UART0_tx_buffer; |
84 | 84 | ||
85 | // the rx buffer |
85 | // the rx buffer |
86 | #define UART0_RX_BUFFER_LEN 200 |
86 | #define UART0_RX_BUFFER_LEN 150 |
Line 87... | Line 87... | ||
87 | u8 UART0_rbuffer[UART0_RX_BUFFER_LEN]; |
87 | u8 UART0_rbuffer[UART0_RX_BUFFER_LEN]; |
88 | Buffer_t UART0_rx_buffer; |
88 | Buffer_t UART0_rx_buffer; |
Line 417... | Line 417... | ||
417 | 417 | ||
418 | 418 | ||
419 | /**************************************************************/ |
419 | /**************************************************************/ |
420 | /* Get the version of the MKOSD */ |
420 | /* Get the version of the MKOSD */ |
421 | /**************************************************************/ |
421 | /**************************************************************/ |
422 | void UART0_GetMKOSDVersion(void) |
422 | u8 UART0_GetMKOSDVersion(void) |
423 | { |
423 | { |
- | 424 | u32 timeout; |
|
Line 424... | Line 425... | ||
424 | u32 timeout; |
425 | u8 msg[64]; |
425 | u8 msg[64]; |
426 | u8 retval = 0; |
426 | 427 | ||
Line 443... | Line 444... | ||
443 | 444 | ||
444 | if(MKOSD_VersionInfo.SWMajor != 0xFF) |
445 | if(MKOSD_VersionInfo.SWMajor != 0xFF) |
445 | { |
446 | { |
446 | sprintf(msg, "\n\r MK-OSD V%d.%d%c", MKOSD_VersionInfo.SWMajor, MKOSD_VersionInfo.SWMinor, 'a'+MKOSD_VersionInfo.SWPatch); |
447 | sprintf(msg, "\n\r MK-OSD V%d.%d%c", MKOSD_VersionInfo.SWMajor, MKOSD_VersionInfo.SWMinor, 'a'+MKOSD_VersionInfo.SWPatch); |
- | 448 | UART1_PutString(msg); |
|
447 | UART1_PutString(msg); |
449 | retval = 1; |
448 | } |
450 | } |
- | 451 | //else UART1_PutString("\n\r No version information from MK-OSD."); |
|
449 | //else UART1_PutString("\n\r No version information from MK-OSD."); |
452 | return(retval); |
Line 450... | Line -... | ||
450 | } |
- | |
451 | 453 | } |
|
452 | 454 | ||
453 | /**************************************************************/ |
455 | /**************************************************************/ |
454 | /* Send a configuration message to the UBLOX device */ |
456 | /* Send a message to the UBLOX device */ |
455 | /**************************************************************/ |
457 | /**************************************************************/ |
456 | u8 UART0_UBXSendCFGMsg(u8 Id, u8* pData, u16 Len) |
- | |
457 | { |
458 | u8 UART0_UBXSendMsg(u8* pData, u16 Len) |
458 | u32 timeout; |
459 | { |
459 | u8 retval = 0; |
460 | u8 retval = 0; |
460 | // check for connection to GPS |
- | |
461 | if(UART0_Muxer != UART0_MKGPS) return(retval); |
- | |
462 | // free the acknowledge buffer |
461 | // check for connection to GPS |
463 | UbxAck.Status = INVALID; |
462 | if(UART0_Muxer != UART0_MKGPS) return(retval); |
464 | while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; |
463 | while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; |
- | 464 | UBX_CreateMsg(&UART0_tx_buffer, pData, Len); // build ubx message frame |
|
- | 465 | while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; |
|
- | 466 | return(1); |
|
- | 467 | } |
|
- | 468 | ||
- | 469 | /**************************************************************/ |
|
- | 470 | /* Send a configuration message to the UBLOX device */ |
|
- | 471 | /**************************************************************/ |
|
- | 472 | u8 UART0_UBXSendCFGMsg(u8* pData, u16 Len) |
|
- | 473 | { |
|
- | 474 | u32 timeout; |
|
- | 475 | u8 retval = 0; |
|
- | 476 | // if data are not a CFG MSG |
|
- | 477 | if(pData[0]!= UBX_CLASS_CFG) return(retval); |
|
- | 478 | // prepare rx msg filter |
|
- | 479 | UbxMsg.Hdr.Class = UBX_CLASS_ACK; |
|
- | 480 | UbxMsg.Hdr.Id = 0xFF; |
|
- | 481 | UbxMsg.Hdr.Length = 0; |
|
- | 482 | UbxMsg.ClassMask = 0xFF; |
|
- | 483 | UbxMsg.IdMask = 0x00; |
|
465 | UBX_CreateMsg(&UART0_tx_buffer, UBX_CLASS_CFG, Id, pData, Len); // build ubx message frame |
484 | UbxMsg.Status = INVALID; |
- | 485 | UART0_UBXSendMsg(pData, Len); |
|
- | 486 | // check for acknowledge msg |
|
- | 487 | timeout = SetDelay(100); |
|
- | 488 | do |
|
- | 489 | { |
|
- | 490 | if(UbxMsg.Status == NEWDATA) break; |
|
- | 491 | }while(!CheckDelay(timeout)); |
|
- | 492 | if(UbxMsg.Status == NEWDATA) |
|
- | 493 | { // 2 bytes payload |
|
- | 494 | if((UbxMsg.Data[0] == pData[0]) && (UbxMsg.Data[1] == pData[1]) && (UbxMsg.Hdr.Length == 2)) retval = UbxMsg.Hdr.Id; |
|
- | 495 | } |
|
- | 496 | UbxMsg.Status = INVALID; |
|
- | 497 | return(retval); |
|
- | 498 | } |
|
- | 499 | ||
- | 500 | /**************************************************************/ |
|
- | 501 | /* Get Version Info from UBX Module */ |
|
- | 502 | /**************************************************************/ |
|
- | 503 | u8 UART0_GetUBXVersion(void) |
|
- | 504 | { |
|
- | 505 | u32 timeout; |
|
- | 506 | u8 retval = 0xFF; |
|
- | 507 | u8 ubxmsg[]={0x0A, 0x04, 0x00, 0x00}; //MON-VER |
|
- | 508 | // prepare rx msg filter |
|
- | 509 | UbxMsg.Hdr.Class = 0x0A; |
|
- | 510 | UbxMsg.Hdr.Id = 0x04; |
|
- | 511 | UbxMsg.Hdr.Length = 0; |
|
- | 512 | UbxMsg.ClassMask = 0xFF; |
|
- | 513 | UbxMsg.IdMask = 0xFF; |
|
- | 514 | UbxMsg.Status = INVALID; |
|
466 | while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; |
515 | UART0_UBXSendMsg(ubxmsg, sizeof(ubxmsg)); |
467 | // check for acknowledge |
516 | // check for answer |
468 | timeout = SetDelay(500); |
517 | timeout = SetDelay(100); |
469 | do |
518 | do |
470 | { |
519 | { |
471 | if(UbxAck.Status == NEWDATA) break; |
520 | if(UbxMsg.Status == NEWDATA) break; |
472 | }while(!CheckDelay(timeout)); |
521 | }while(!CheckDelay(timeout)); |
473 | if(UbxAck.Status == NEWDATA) |
522 | if((UbxMsg.Hdr.Length >= 40) && (UbxMsg.Status == NEWDATA)) |
- | 523 | { |
|
- | 524 | UbxMsg.Data[4] = 0; //Only the fisrt 4 chsracters |
|
- | 525 | UbxMsg.Data[39] = 0; |
|
- | 526 | UART1_PutString(" V"); |
|
- | 527 | UART1_PutString((u8*)&UbxMsg.Data); |
|
- | 528 | UART1_PutString(" HW:"); |
|
474 | { |
529 | UART1_PutString((u8*)&UbxMsg.Data[30]); |
475 | if((UbxAck.clsID == UBX_CLASS_CFG) && (UbxAck.msgID == Id)) retval = UbxAck.Ack; |
530 | retval = UbxMsg.Data[0]-'0'; // major sw version |
476 | } |
531 | } |
477 | UbxAck.Status = INVALID; |
532 | UbxMsg.Status = INVALID; |