Rev 357 | Rev 360 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 357 | Rev 358 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | #include "waypoints.h" |
74 | #include "waypoints.h" |
75 | #include "mkprotocol.h" |
75 | #include "mkprotocol.h" |
76 | #include "params.h" |
76 | #include "params.h" |
77 | #include "fifo.h" |
77 | #include "fifo.h" |
78 | #include "debug.h" |
78 | #include "debug.h" |
- | 79 | #include "spi_slave.h" |
|
79 | #include "ftphelper.h" |
80 | #include "ftphelper.h" |
Line 80... | Line 81... | ||
80 | 81 | ||
81 | #define FALSE 0 |
82 | #define FALSE 0 |
Line 93... | Line 94... | ||
93 | u8 UART1_Request_NaviData = FALSE; |
94 | u8 UART1_Request_NaviData = FALSE; |
94 | u8 UART1_Request_ErrorMessage = FALSE; |
95 | u8 UART1_Request_ErrorMessage = FALSE; |
95 | u8 UART1_Request_WritePoint = 0xFF; |
96 | u8 UART1_Request_WritePoint = 0xFF; |
96 | u8 UART1_Request_ReadPoint = 0; |
97 | u8 UART1_Request_ReadPoint = 0; |
97 | u8 UART1_Request_Data3D = FALSE; |
98 | u8 UART1_Request_Data3D = FALSE; |
- | 99 | u8 UART1_Request_MotorData = FALSE; |
|
98 | u8 UART1_Request_Echo = FALSE; |
100 | u8 UART1_Request_Echo = FALSE; |
99 | u8 UART1_Request_ParameterId = 0; |
101 | u8 UART1_Request_ParameterId = 0; |
100 | u8 UART1_Request_Parameter = FALSE; |
102 | u8 UART1_Request_Parameter = FALSE; |
101 | u8 UART1_DisplayKeys = 0; |
103 | u8 UART1_DisplayKeys = 0; |
102 | u8 UART1_DisplayLine = 0; |
104 | u8 UART1_DisplayLine = 0; |
Line 179... | Line 181... | ||
179 | u32 UART1_DebugData_Interval = 0; // in ms |
181 | u32 UART1_DebugData_Interval = 0; // in ms |
180 | u32 UART1_NaviData_Timer = 0; |
182 | u32 UART1_NaviData_Timer = 0; |
181 | u32 UART1_NaviData_Interval = 0; // in ms |
183 | u32 UART1_NaviData_Interval = 0; // in ms |
182 | u32 UART1_Data3D_Timer = 0; |
184 | u32 UART1_Data3D_Timer = 0; |
183 | u32 UART1_Data3D_Interval = 0; // in ms |
185 | u32 UART1_Data3D_Interval = 0; // in ms |
- | 186 | u32 UART1_MotorData_Timer = 0; |
|
- | 187 | u32 UART1_MotorData_Interval = 0; // in ms |
|
184 | u32 UART1_Display_Timer = 0; |
188 | u32 UART1_Display_Timer = 0; |
185 | u32 UART1_Display_Interval = 0; // in ms |
189 | u32 UART1_Display_Interval = 0; // in ms |
Line 186... | Line 190... | ||
186 | 190 | ||
187 | /********************************************************/ |
191 | /********************************************************/ |
Line 548... | Line 552... | ||
548 | UART1_Data3D_Interval = (u32) SerialMsg.pData[0] * 10; |
552 | UART1_Data3D_Interval = (u32) SerialMsg.pData[0] * 10; |
549 | if(UART1_Data3D_Interval > 0) UART1_Request_Data3D = TRUE; |
553 | if(UART1_Data3D_Interval > 0) UART1_Request_Data3D = TRUE; |
550 | UART1_AboTimeOut = SetDelay(ABO_TIMEOUT); |
554 | UART1_AboTimeOut = SetDelay(ABO_TIMEOUT); |
551 | break; |
555 | break; |
Line -... | Line 556... | ||
- | 556 | ||
- | 557 | case 'k': // request for Motor data; |
|
- | 558 | UART1_MotorData_Interval = (u32) SerialMsg.pData[0] * 10; |
|
- | 559 | if(UART1_MotorData_Interval > 0) UART1_Request_MotorData = TRUE; |
|
- | 560 | UART1_AboTimeOut = SetDelay(ABO_TIMEOUT); |
|
- | 561 | break; |
|
552 | 562 | ||
553 | case 'h':// reqest for display line |
563 | case 'h':// reqest for display line |
554 | if((SerialMsg.pData[0]& 0x80) == 0x00)// old format |
564 | if((SerialMsg.pData[0]& 0x80) == 0x00)// old format |
555 | { |
565 | { |
556 | UART1_DisplayLine = 2; |
566 | UART1_DisplayLine = 2; |
Line 657... | Line 667... | ||
657 | /**************************************************************/ |
667 | /**************************************************************/ |
658 | /* Send the answers to incomming commands at the debug uart */ |
668 | /* Send the answers to incomming commands at the debug uart */ |
659 | /**************************************************************/ |
669 | /**************************************************************/ |
660 | void UART1_TransmitTxData(void) |
670 | void UART1_TransmitTxData(void) |
661 | { |
671 | { |
- | 672 | static u8 motorindex1 = 255, motorindex2 = 0; |
|
662 | if(DebugUART != UART1) return; |
673 | if(DebugUART != UART1) return; |
Line 663... | Line 674... | ||
663 | 674 | ||
664 | if(CheckDelay(UART1_AboTimeOut)) |
675 | if(CheckDelay(UART1_AboTimeOut)) |
665 | { |
676 | { |
Line 726... | Line 737... | ||
726 | UART1_DebugData_Timer = SetDelay(UART1_DebugData_Interval); |
737 | UART1_DebugData_Timer = SetDelay(UART1_DebugData_Interval); |
727 | UART1_Request_DebugData = FALSE; |
738 | UART1_Request_DebugData = FALSE; |
728 | } |
739 | } |
729 | else if((( (UART1_Data3D_Interval > 0) && CheckDelay(UART1_Data3D_Timer) ) || UART1_Request_Data3D) && (UART1_tx_buffer.Locked == FALSE)) |
740 | else if((( (UART1_Data3D_Interval > 0) && CheckDelay(UART1_Data3D_Timer) ) || UART1_Request_Data3D) && (UART1_tx_buffer.Locked == FALSE)) |
730 | { |
741 | { |
- | 742 | Data3D.StickNick = FC.StickNick; |
|
- | 743 | Data3D.StickRoll = FC.StickRoll; |
|
- | 744 | Data3D.StickYaw = FC.StickYaw; |
|
- | 745 | Data3D.StickGas = FC.StickGas; |
|
731 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D)); |
746 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D)); |
732 | UART1_Data3D_Timer = SetDelay(UART1_Data3D_Interval); |
747 | UART1_Data3D_Timer = SetDelay(UART1_Data3D_Interval); |
733 | UART1_Request_Data3D = FALSE; |
748 | UART1_Request_Data3D = FALSE; |
734 | } |
749 | } |
- | 750 | else if((((UART1_MotorData_Interval > 0) && CheckDelay(UART1_MotorData_Timer) ) || UART1_Request_MotorData) && (UART1_tx_buffer.Locked == FALSE)) |
|
- | 751 | { |
|
- | 752 | do |
|
- | 753 | { |
|
- | 754 | motorindex1++; |
|
- | 755 | motorindex1%=12; |
|
- | 756 | if(!motorindex1) {motorindex2++; motorindex2 %= 12;}; |
|
- | 757 | if(motorindex1 == motorindex2) break; |
|
- | 758 | } |
|
- | 759 | while((Motor[motorindex1].State & 0x80) != 0x80); // skip unused Motors |
|
- | 760 | ||
- | 761 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'K', NC_ADDRESS, 2, &motorindex1, sizeof(motorindex1),(u8 *)&Motor[motorindex1], sizeof(Motor_t)); |
|
- | 762 | UART1_MotorData_Timer = SetDelay(UART1_MotorData_Interval); |
|
- | 763 | UART1_Request_MotorData = FALSE; |
|
- | 764 | } |
|
735 | /* |
765 | /* |
736 | else if(UART1_ConfirmFrame && (UART1_tx_buffer.Locked == FALSE)) |
766 | else if(UART1_ConfirmFrame && (UART1_tx_buffer.Locked == FALSE)) |
737 | { |
767 | { |
738 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'B', NC_ADDRESS, 1, &UART1_ConfirmFrame, sizeof(UART1_ConfirmFrame)); |
768 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'B', NC_ADDRESS, 1, &UART1_ConfirmFrame, sizeof(UART1_ConfirmFrame)); |
739 | UART1_ConfirmFrame = 0; |
769 | UART1_ConfirmFrame = 0; |