Rev 310 | Rev 315 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 310 | Rev 314 | ||
---|---|---|---|
Line 101... | Line 101... | ||
101 | u8 UART1_DisplayLine = 0; |
101 | u8 UART1_DisplayLine = 0; |
102 | u8 UART1_ConfirmFrame = 0; |
102 | u8 UART1_ConfirmFrame = 0; |
Line 103... | Line 103... | ||
103 | 103 | ||
Line -... | Line 104... | ||
- | 104 | UART_TypeDef *DebugUART = UART1; |
|
- | 105 | ||
- | 106 | #ifdef FOLLOW_ME |
|
- | 107 | #define FOLLOW_ME_INTERVAL 200 // 5 Hz |
|
- | 108 | u8 UART1_FollowMe_Timer = 0; |
|
- | 109 | Point_t FollowMe; |
|
104 | UART_TypeDef *DebugUART = UART1; |
110 | #endif |
105 | 111 | ||
106 | // the primary rx fifo |
112 | // the primary rx fifo |
107 | #define UART1_RX_FIFO_LEN 512 |
113 | #define UART1_RX_FIFO_LEN 512 |
Line 577... | Line 583... | ||
577 | if (c == '\n') UART1_Putchar('\r'); |
583 | if (c == '\n') UART1_Putchar('\r'); |
578 | // wait until txd fifo is not full |
584 | // wait until txd fifo is not full |
579 | while (UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != RESET); |
585 | while (UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != RESET); |
580 | // transmit byte |
586 | // transmit byte |
581 | UART_SendData(UART1, c); |
587 | UART_SendData(UART1, c); |
- | 588 | #ifdef FOLLOW_ME |
|
- | 589 | if(TransmitAlsoToFC) UART_SendData(UART2, c); |
|
- | 590 | #endif |
|
582 | return (0); |
591 | return (0); |
583 | } |
592 | } |
Line 584... | Line 593... | ||
584 | 593 | ||
585 | /*****************************************************/ |
594 | /*****************************************************/ |
Line 609... | Line 618... | ||
609 | // while there is some space in the tx fifo |
618 | // while there is some space in the tx fifo |
610 | while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != SET) |
619 | while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != SET) |
611 | { |
620 | { |
612 | tmp_tx = UART1_tx_buffer.pData[UART1_tx_buffer.Position++]; // read next byte from txd buffer |
621 | tmp_tx = UART1_tx_buffer.pData[UART1_tx_buffer.Position++]; // read next byte from txd buffer |
613 | UART_SendData(UART1, tmp_tx); // put character to txd fifo |
622 | UART_SendData(UART1, tmp_tx); // put character to txd fifo |
- | 623 | #ifdef FOLLOW_ME |
|
- | 624 | if(TransmitAlsoToFC) |
|
- | 625 | { |
|
- | 626 | UART_SendData(UART2, tmp_tx); // put character to txd fifo |
|
- | 627 | } |
|
- | 628 | #endif |
|
614 | // if terminating character or end of txd buffer reached |
629 | // if terminating character or end of txd buffer reached |
615 | if((tmp_tx == '\r') || (UART1_tx_buffer.Position == UART1_tx_buffer.DataBytes)) |
630 | if((tmp_tx == '\r') || (UART1_tx_buffer.Position == UART1_tx_buffer.DataBytes)) |
616 | { |
631 | { |
617 | Buffer_Clear(&UART1_tx_buffer); // clear txd buffer |
632 | Buffer_Clear(&UART1_tx_buffer); // clear txd buffer |
- | 633 | #ifdef FOLLOW_ME |
|
- | 634 | TransmitAlsoToFC = 0; |
|
- | 635 | #endif |
|
618 | break; // end while loop |
636 | break; // end while loop |
619 | } |
637 | } |
620 | } |
638 | } |
621 | } |
639 | } |
622 | } |
640 | } |
Line 740... | Line 758... | ||
740 | else if(UART1_Request_ErrorMessage && (UART1_tx_buffer.Locked == FALSE)) |
758 | else if(UART1_Request_ErrorMessage && (UART1_tx_buffer.Locked == FALSE)) |
741 | { |
759 | { |
742 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
760 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
743 | UART1_Request_ErrorMessage = FALSE; |
761 | UART1_Request_ErrorMessage = FALSE; |
744 | } |
762 | } |
- | 763 | #ifdef FOLLOW_ME |
|
- | 764 | else if(CheckDelay(UART1_FollowMe_Timer) && (UART1_tx_buffer.Locked == FALSE)) |
|
- | 765 | { |
|
- | 766 | if((GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.NumOfSats >= 4)) |
|
- | 767 | { |
|
- | 768 | TransmitAlsoToFC = 1; |
|
- | 769 | // update FollowMe content |
|
- | 770 | FollowMe.Position.Longitude = GPSData.Position.Longitude; |
|
- | 771 | FollowMe.Position.Latitude = GPSData.Position.Latitude; |
|
- | 772 | FollowMe.Position.Status = NEWDATA; |
|
- | 773 | FollowMe.Position.Altitude = 1; |
|
- | 774 | // 0 -> no Orientation |
|
- | 775 | // 1-360 -> CompassCourse Setpoint |
|
- | 776 | // -1 -> points to WP1 -> itself |
|
- | 777 | FollowMe.Heading = -1; |
|
- | 778 | FollowMe.ToleranceRadius = 1; |
|
- | 779 | FollowMe.HoldTime = 60; |
|
- | 780 | FollowMe.Event_Flag = 1; |
|
- | 781 | FollowMe.Index = 1; // 0 = Delete List, 1 place at first entry in the list |
|
- | 782 | FollowMe.Type = POINT_TYPE_WP; |
|
- | 783 | FollowMe.WP_EventChannelValue = 100; // set servo value |
|
- | 784 | FollowMe.AltitudeRate = 0; // do not change height |
|
- | 785 | FollowMe.reserve[0] = 0; // reserve |
|
- | 786 | FollowMe.reserve[1] = 0; // reserve |
|
- | 787 | FollowMe.reserve[2] = 0; // reserve |
|
- | 788 | FollowMe.reserve[3] = 0; // reserve |
|
- | 789 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 's', NC_ADDRESS, 1, (u8 *)&FollowMe, sizeof(FollowMe)); |
|
- | 790 | } |
|
- | 791 | UART1_FollowMe_Timer = SetDelay(FOLLOW_ME_INTERVAL); // set new update time |
|
- | 792 | } |
|
- | 793 | #endif |
|
745 | #ifdef DEBUG // only include functions if DEBUG is defined |
794 | #ifdef DEBUG // only include functions if DEBUG is defined |
746 | if(SendDebugOutput && (UART1_tx_buffer.Locked == FALSE)) |
795 | else if(SendDebugOutput && (UART1_tx_buffer.Locked == FALSE)) |
747 | { |
796 | { |
748 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer,'0', NC_ADDRESS, 1, (u8 *) &tDebug, sizeof(tDebug)); |
797 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer,'0', NC_ADDRESS, 1, (u8 *) &tDebug, sizeof(tDebug)); |
749 | SendDebugOutput = 0; |
798 | SendDebugOutput = 0; |
750 | } |
799 | } |
751 | #endif |
800 | #endif |