Rev 199 | Rev 261 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 199 | Rev 201 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | #include "uart0.h" |
67 | #include "uart0.h" |
68 | #include "uart1.h" |
68 | #include "uart1.h" |
69 | #include "uart2.h" |
69 | #include "uart2.h" |
70 | #include "menu.h" |
70 | #include "menu.h" |
Line -... | Line 71... | ||
- | 71 | ||
- | 72 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
|
Line 71... | Line 73... | ||
71 | 73 | u32 USB_AboTimeOut = 0; |
|
72 | 74 | ||
73 | // the tx buffer |
75 | // the tx buffer |
74 | #define USB_TX_BUFFER_LEN 150 |
76 | #define USB_TX_BUFFER_LEN 150 |
Line 92... | Line 94... | ||
92 | u8 USB_Request_NewWaypoint = FALSE; |
94 | u8 USB_Request_NewWaypoint = FALSE; |
93 | u8 USB_Request_ReadWaypoint = 255; |
95 | u8 USB_Request_ReadWaypoint = 255; |
94 | u8 USB_Request_Data3D = FALSE; |
96 | u8 USB_Request_Data3D = FALSE; |
95 | u8 USB_Request_Echo = FALSE; |
97 | u8 USB_Request_Echo = FALSE; |
Line 96... | Line 98... | ||
96 | 98 | ||
97 | u8 USB_DisplayLine = 0; |
99 | u8 USB_DisplayKeys = 0; |
Line 98... | Line 100... | ||
98 | u8 USB_ConfirmFrame = 0; |
100 | u8 USB_ConfirmFrame = 0; |
99 | 101 | ||
100 | u32 USB_DebugData_Timer = 0; |
102 | u32 USB_DebugData_Timer = 0; |
101 | u32 USB_DebugData_Interval = 0; // in ms |
103 | u32 USB_DebugData_Interval = 0; // in ms |
102 | u32 USB_NaviData_Timer = 0; |
104 | u32 USB_NaviData_Timer = 0; |
103 | u32 USB_NaviData_Interval = 0; // in ms |
105 | u32 USB_NaviData_Interval = 0; // in ms |
- | 106 | u32 USB_Data3D_Timer = 0; |
|
- | 107 | u32 USB_Data3D_Interval = 0; // in ms |
|
Line 104... | Line 108... | ||
104 | u32 USB_Data3D_Timer = 0; // in ms |
108 | u32 USB_Display_Timer = 0; |
105 | u32 USB_Data3D_Interval = 0; |
109 | u32 USB_Display_Interval = 0; // in ms |
106 | 110 | ||
107 | //----------------------------------------------------------------- |
111 | //----------------------------------------------------------------- |
Line 242... | Line 246... | ||
242 | { |
246 | { |
243 | case 'a':// request for the labels of the analog debug outputs |
247 | case 'a':// request for the labels of the analog debug outputs |
244 | USB_Request_DebugLabel = SerialMsg.pData[0]; |
248 | USB_Request_DebugLabel = SerialMsg.pData[0]; |
245 | if(USB_Request_DebugLabel > 31) USB_Request_DebugLabel = 31; |
249 | if(USB_Request_DebugLabel > 31) USB_Request_DebugLabel = 31; |
246 | break; |
250 | break; |
247 | 251 | /* |
|
248 | case 'b': // submit extern control |
252 | case 'b': // submit extern control |
249 | memcpy(&ExternControl, SerialMsg.pData, sizeof(ExternControl)); |
253 | memcpy(&ExternControl, SerialMsg.pData, sizeof(ExternControl)); |
250 | USB_ConfirmFrame = ExternControl.Frame; |
254 | USB_ConfirmFrame = ExternControl.Frame; |
251 | break; |
255 | break; |
252 | 256 | */ |
|
253 | case 'd': // request for debug data; |
257 | case 'd': // request for debug data; |
254 | USB_DebugData_Interval = (u32) SerialMsg.pData[0] * 10; |
258 | USB_DebugData_Interval = (u32) SerialMsg.pData[0] * 10; |
- | 259 | USB_AboTimeOut = SetDelay(ABO_TIMEOUT); |
|
255 | if(USB_DebugData_Interval > 0) USB_Request_DebugData = TRUE; |
260 | if(USB_DebugData_Interval > 0) USB_Request_DebugData = TRUE; |
256 | break; |
261 | break; |
Line 257... | Line 262... | ||
257 | 262 | ||
258 | case 'c': // request for 3D data; |
263 | case 'c': // request for 3D data; |
- | 264 | USB_Data3D_Interval = (u32) SerialMsg.pData[0] * 10; |
|
259 | USB_Data3D_Interval = (u32) SerialMsg.pData[0] * 10; |
265 | USB_AboTimeOut = SetDelay(ABO_TIMEOUT); |
260 | if(USB_Data3D_Interval > 0) USB_Request_Data3D = TRUE; |
266 | if(USB_Data3D_Interval > 0) USB_Request_Data3D = TRUE; |
261 | break; |
267 | break; |
262 | 268 | /* |
|
263 | case 'g':// request for external control data |
269 | case 'g':// request for external control data |
264 | USB_Request_ExternalControl = TRUE; |
270 | USB_Request_ExternalControl = TRUE; |
265 | break; |
271 | break; |
266 | 272 | */ |
|
267 | case 'h':// reqest for display line |
273 | case 'h':// reqest for display line |
268 | RemoteKeys |= SerialMsg.pData[0]; |
274 | USB_DisplayKeys |= ~SerialMsg.pData[0]; |
- | 275 | USB_Display_Interval = (u32) SerialMsg.pData[1] * 10; |
|
269 | if(RemoteKeys != 0) USB_DisplayLine = 0; |
276 | USB_AboTimeOut = SetDelay(ABO_TIMEOUT); |
270 | USB_Request_Display = TRUE; |
277 | USB_Request_Display = TRUE; |
Line 271... | Line 278... | ||
271 | break; |
278 | break; |
272 | 279 | ||
273 | case 'l':// reqest for display columns |
280 | case 'l':// reqest for display columns |
274 | MenuItem = SerialMsg.pData[0]; |
281 | MenuItem = SerialMsg.pData[0]; |
Line 275... | Line 282... | ||
275 | USB_Request_Display1 = TRUE; |
282 | USB_Request_Display1 = TRUE; |
276 | break; |
283 | break; |
- | 284 | ||
277 | 285 | case 'o': // request for navigation information |
|
278 | case 'o': // request for navigation information |
286 | USB_NaviData_Interval = (u32) SerialMsg.pData[0] * 10; |
Line 279... | Line 287... | ||
279 | USB_NaviData_Interval = (u32) SerialMsg.pData[0] * 10; |
287 | USB_AboTimeOut = SetDelay(ABO_TIMEOUT); |
280 | if(USB_NaviData_Interval > 0) USB_Request_NaviData = TRUE; |
288 | if(USB_NaviData_Interval > 0) USB_Request_NaviData = TRUE; |
Line 384... | Line 392... | ||
384 | void USB_TransmitTxData(void) |
392 | void USB_TransmitTxData(void) |
385 | { |
393 | { |
386 | USB_Transmit(); // output pending bytes in tx buffer |
394 | USB_Transmit(); // output pending bytes in tx buffer |
387 | if((USB_tx_buffer.Locked == TRUE)) return; |
395 | if((USB_tx_buffer.Locked == TRUE)) return; |
Line -... | Line 396... | ||
- | 396 | ||
- | 397 | if(CheckDelay(USB_AboTimeOut)) |
|
- | 398 | { |
|
- | 399 | USB_DebugData_Interval = 0; |
|
- | 400 | USB_NaviData_Interval = 0; |
|
- | 401 | USB_Data3D_Interval = 0; |
|
- | 402 | USB_Display_Interval = 0; |
|
- | 403 | } |
|
388 | 404 | ||
389 | if((USB_Request_DebugLabel != 0xFF) && (USB_tx_buffer.Locked == FALSE)) |
405 | if((USB_Request_DebugLabel != 0xFF) && (USB_tx_buffer.Locked == FALSE)) |
390 | { |
406 | { |
391 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'A', NC_ADDRESS, 2, &USB_Request_DebugLabel, sizeof(USB_Request_DebugLabel), (u8 *) ANALOG_LABEL[USB_Request_DebugLabel], 16); |
407 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'A', NC_ADDRESS, 2, &USB_Request_DebugLabel, sizeof(USB_Request_DebugLabel), (u8 *) ANALOG_LABEL[USB_Request_DebugLabel], 16); |
392 | USB_Request_DebugLabel = 0xFF; |
408 | USB_Request_DebugLabel = 0xFF; |
393 | } |
409 | } |
394 | if(USB_ConfirmFrame && (USB_tx_buffer.Locked == FALSE)) |
410 | else if(USB_ConfirmFrame && (USB_tx_buffer.Locked == FALSE)) |
395 | { |
411 | { |
396 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'B', NC_ADDRESS, 1, &USB_ConfirmFrame, sizeof(USB_ConfirmFrame)); |
412 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'B', NC_ADDRESS, 1, &USB_ConfirmFrame, sizeof(USB_ConfirmFrame)); |
397 | USB_ConfirmFrame = 0; |
413 | USB_ConfirmFrame = 0; |
398 | } |
414 | } |
399 | if( (( (USB_DebugData_Interval > 0) && CheckDelay(USB_DebugData_Timer)) || USB_Request_DebugData) && (USB_tx_buffer.Locked == FALSE)) |
415 | else if( (( (USB_DebugData_Interval > 0) && CheckDelay(USB_DebugData_Timer)) || USB_Request_DebugData) && (USB_tx_buffer.Locked == FALSE)) |
400 | { |
416 | { |
401 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'D', NC_ADDRESS, 1,(u8 *)&DebugOut, sizeof(DebugOut)); |
417 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'D', NC_ADDRESS, 1,(u8 *)&DebugOut, sizeof(DebugOut)); |
402 | USB_DebugData_Timer = SetDelay(USB_DebugData_Interval); |
418 | USB_DebugData_Timer = SetDelay(USB_DebugData_Interval); |
403 | USB_Request_DebugData = FALSE; |
419 | USB_Request_DebugData = FALSE; |
404 | } |
- | |
405 | 420 | } |
|
406 | if((( (USB_Data3D_Interval > 0) && CheckDelay(USB_Data3D_Timer) ) || USB_Request_Data3D) && (USB_tx_buffer.Locked == FALSE)) |
421 | else if((( (USB_Data3D_Interval > 0) && CheckDelay(USB_Data3D_Timer) ) || USB_Request_Data3D) && (USB_tx_buffer.Locked == FALSE)) |
407 | { |
422 | { |
408 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D)); |
423 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D)); |
409 | USB_Data3D_Timer = SetDelay(USB_Data3D_Interval); |
424 | USB_Data3D_Timer = SetDelay(USB_Data3D_Interval); |
410 | USB_Request_Data3D = FALSE; |
425 | USB_Request_Data3D = FALSE; |
411 | } |
- | |
412 | 426 | } |
|
413 | if(USB_Request_ExternalControl && (USB_tx_buffer.Locked == FALSE)) |
427 | else if(USB_Request_ExternalControl && (USB_tx_buffer.Locked == FALSE)) |
414 | { |
428 | { |
415 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'G', NC_ADDRESS, 1, (u8 *)&ExternControl, sizeof(ExternControl)); |
429 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'G', NC_ADDRESS, 1, (u8 *)&ExternControl, sizeof(ExternControl)); |
416 | USB_Request_ExternalControl = FALSE; |
430 | USB_Request_ExternalControl = FALSE; |
417 | } |
431 | } |
418 | if(USB_Request_Display && (USB_tx_buffer.Locked == FALSE)) |
432 | else if( (( (USB_Display_Interval > 0) && CheckDelay(USB_Display_Timer)) || USB_Request_Display) && (USB_tx_buffer.Locked == FALSE)) |
419 | { |
433 | { |
420 | LCD_PrintMenu(); |
- | |
421 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'H', NC_ADDRESS, 2, &USB_DisplayLine, sizeof(USB_DisplayLine), (u8*)&DisplayBuff[USB_DisplayLine * 20], 20); |
434 | Menu_Update(USB_DisplayKeys); |
422 | USB_DisplayLine++; |
435 | USB_DisplayKeys = 0; |
423 | if(USB_DisplayLine >= 4) USB_DisplayLine = 0; |
436 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'H', NC_ADDRESS, 1, (u8*)DisplayBuff, sizeof(DisplayBuff)); |
424 | USB_Request_Display = FALSE; |
437 | USB_Request_Display = FALSE; |
425 | } |
438 | } |
426 | if(USB_Request_Display1 && (USB_tx_buffer.Locked == FALSE)) |
439 | else if(USB_Request_Display1 && (USB_tx_buffer.Locked == FALSE)) |
427 | { |
440 | { |
428 | LCD_PrintMenu(); |
441 | Menu_Update(0); |
429 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'L', NC_ADDRESS, 3, (u8*)&MenuItem, sizeof(MenuItem), (u8*)&MaxMenuItem, sizeof(MaxMenuItem),(u8*)DisplayBuff, sizeof(DisplayBuff)); |
442 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'L', NC_ADDRESS, 3, (u8*)&MenuItem, sizeof(MenuItem), (u8*)&MaxMenuItem, sizeof(MaxMenuItem),(u8*)DisplayBuff, sizeof(DisplayBuff)); |
430 | USB_Request_Display1 = FALSE; |
443 | USB_Request_Display1 = FALSE; |
431 | } |
444 | } |
432 | if(USB_Request_VersionInfo && (USB_tx_buffer.Locked == FALSE)) |
445 | else if(USB_Request_VersionInfo && (USB_tx_buffer.Locked == FALSE)) |
433 | { |
446 | { |
434 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'V', NC_ADDRESS,1, (u8 *)&UART_VersionInfo, sizeof(UART_VersionInfo)); |
447 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'V', NC_ADDRESS,1, (u8 *)&UART_VersionInfo, sizeof(UART_VersionInfo)); |
435 | USB_Request_VersionInfo = FALSE; |
448 | USB_Request_VersionInfo = FALSE; |
436 | } |
449 | } |
437 | if(( (USB_NaviData_Interval && CheckDelay(USB_NaviData_Timer) ) || USB_Request_NaviData) && (USB_tx_buffer.Locked == FALSE)) |
450 | else if(( (USB_NaviData_Interval && CheckDelay(USB_NaviData_Timer) ) || USB_Request_NaviData) && (USB_tx_buffer.Locked == FALSE)) |
438 | { |
451 | { |
439 | NaviData.Errorcode = ErrorCode; |
452 | NaviData.Errorcode = ErrorCode; |
440 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'O', NC_ADDRESS,1, (u8 *)&NaviData, sizeof(NaviData)); |
453 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'O', NC_ADDRESS,1, (u8 *)&NaviData, sizeof(NaviData)); |
441 | USB_NaviData_Timer = SetDelay(USB_NaviData_Interval); |
454 | USB_NaviData_Timer = SetDelay(USB_NaviData_Interval); |
442 | USB_Request_NaviData = FALSE; |
455 | USB_Request_NaviData = FALSE; |
443 | } |
456 | } |
444 | if(USB_Request_ErrorMessage && (USB_tx_buffer.Locked == FALSE)) |
457 | else if(USB_Request_ErrorMessage && (USB_tx_buffer.Locked == FALSE)) |
445 | { |
458 | { |
446 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
459 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
447 | USB_Request_ErrorMessage = FALSE; |
460 | USB_Request_ErrorMessage = FALSE; |
448 | } |
461 | } |
449 | if(USB_Request_NewWaypoint && (USB_tx_buffer.Locked == FALSE)) |
462 | else if(USB_Request_NewWaypoint && (USB_tx_buffer.Locked == FALSE)) |
450 | { |
463 | { |
451 | u8 WPNumber = WPList_GetCount(); |
464 | u8 WPNumber = WPList_GetCount(); |
452 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'W', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber)); |
465 | MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'W', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber)); |
453 | USB_Request_NewWaypoint = FALSE; |
466 | USB_Request_NewWaypoint = FALSE; |
454 | } |
467 | } |
455 | if((USB_Request_ReadWaypoint != 0xFF) && (USB_tx_buffer.Locked == FALSE)) |
468 | else if((USB_Request_ReadWaypoint != 0xFF) && (USB_tx_buffer.Locked == FALSE)) |
456 | { |
469 | { |
457 | u8 WPNumber = WPList_GetCount(); |
470 | u8 WPNumber = WPList_GetCount(); |
458 | if (USB_Request_ReadWaypoint < WPNumber) |
471 | if (USB_Request_ReadWaypoint < WPNumber) |
459 | { |
472 | { |