Rev 759 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 759 | Rev 765 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | #define FM_ADDRESS 10 // FOLLOW ME |
27 | #define FM_ADDRESS 10 // FOLLOW ME |
Line 28... | Line 28... | ||
28 | 28 | ||
29 | #define FALSE 0 |
29 | #define FALSE 0 |
Line -... | Line 30... | ||
- | 30 | #define TRUE 1 |
|
Line 30... | Line 31... | ||
30 | #define TRUE 1 |
31 | |
31 | 32 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
|
32 | 33 | ||
33 | //int8_t test __attribute__ ((section (".noinit"))); |
34 | //int8_t test __attribute__ ((section (".noinit"))); |
34 | uint8_t Request_VerInfo = FALSE; |
35 | uint8_t Request_VerInfo = FALSE; |
35 | uint8_t Request_Display = FALSE; |
36 | uint8_t Request_Display = FALSE; |
36 | uint8_t Request_Display1 = FALSE; |
37 | uint8_t Request_Display1 = FALSE; |
37 | uint8_t Request_ExternalControl = FALSE; |
38 | uint8_t Request_ExternalControl = FALSE; |
38 | uint8_t Request_DebugData = FALSE; |
39 | uint8_t Request_DebugData = FALSE; |
- | 40 | uint8_t Request_DebugLabel = 255; |
|
Line 39... | Line 41... | ||
39 | uint8_t Request_DebugLabel = 255; |
41 | uint8_t Request_SendFollowMe = FALSE; |
40 | uint8_t Request_SendFollowMe = FALSE; |
42 | uint8_t DisplayLine = 0; |
41 | uint8_t DisplayLine = 0; |
43 | uint8_t DisplayKeys = 0; |
42 | 44 | ||
43 | volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
45 | volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
44 | volatile uint8_t rxd_buffer_locked = FALSE; |
46 | volatile uint8_t rxd_buffer_locked = FALSE; |
45 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
47 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
Line 46... | Line 48... | ||
46 | volatile uint8_t txd_complete = TRUE; |
48 | volatile uint8_t txd_complete = TRUE; |
- | 49 | volatile uint8_t ReceivedBytes = 0; |
|
Line 47... | Line 50... | ||
47 | volatile uint8_t ReceivedBytes = 0; |
50 | volatile uint8_t *pRxData = 0; |
48 | volatile uint8_t *pRxData = 0; |
51 | volatile uint8_t RxDataLen = 0; |
49 | volatile uint8_t RxDataLen = 0; |
52 | |
Line 50... | Line 53... | ||
50 | 53 | uint8_t PcAccess = 100; |
|
51 | uint8_t PcAccess = 100; |
54 | uint16_t AboTimeOut = 0; |
52 | 55 | ||
53 | ExternControl_t ExternControl; |
56 | ExternControl_t ExternControl; |
Line 54... | Line 57... | ||
54 | DebugOut_t DebugOut; |
57 | DebugOut_t DebugOut; |
Line 55... | Line 58... | ||
55 | UART_VersionInfo_t UART_VersionInfo; |
58 | UART_VersionInfo_t UART_VersionInfo; |
56 | 59 | ||
Line 426... | Line 429... | ||
426 | PcAccess = 255; |
429 | PcAccess = 255; |
427 | break; |
430 | break; |
Line 428... | Line 431... | ||
428 | 431 | ||
429 | case 'h':// request for display columns |
432 | case 'h':// request for display columns |
430 | PcAccess = 255; |
433 | PcAccess = 255; |
431 | if((pRxData[0] & 0x80) == 0x00) // old format |
434 | if((pRxData[0] & 0x80) == 0x00) // old format |
432 | { |
435 | { |
433 | DisplayLine = 2; |
436 | DisplayLine = 2; |
434 | Display_Interval = 0; |
437 | Display_Interval = 0; |
435 | } |
438 | } |
436 | else // new format |
439 | else // new format |
437 | { |
440 | { |
438 | RemoteKeys |= ~pRxData[0]; |
441 | DisplayKeys |= ~pRxData[0]; |
439 | Display_Interval = (unsigned int)pRxData[1] * 10; |
442 | Display_Interval = (uint16_t) pRxData[1] * 10; |
440 | DisplayLine = 4; |
443 | DisplayLine = 4; |
441 | Request_Display = TRUE; |
444 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
- | 445 | } |
|
442 | } |
446 | Request_Display = TRUE; |
Line 443... | Line 447... | ||
443 | break; |
447 | break; |
444 | 448 | ||
445 | case 'l':// request for display columns |
449 | case 'l':// request for display columns |
446 | PcAccess = 255; |
450 | PcAccess = 255; |
447 | MenuItem = pRxData[0]; |
451 | MenuItem = pRxData[0]; |
Line 448... | Line 452... | ||
448 | Request_Display1 = TRUE; |
452 | Request_Display1 = TRUE; |
449 | break; |
453 | break; |
450 | 454 | ||
Line 451... | Line 455... | ||
451 | case 'v': // request for version and board release |
455 | case 'v': // request for version and board release |
452 | Request_VerInfo = TRUE; |
456 | Request_VerInfo = TRUE; |
453 | break; |
457 | break; |
- | 458 | ||
454 | 459 | case 'd': // request for the debug data |
|
Line 455... | Line 460... | ||
455 | case 'd': // request for the debug data |
460 | DebugData_Interval = (uint16_t) pRxData[0] * 10; |
456 | DebugData_Interval = (uint16_t) pRxData[0] * 10; |
461 | if(DebugData_Interval > 0) Request_DebugData = TRUE; |
457 | if(DebugData_Interval > 0) Request_DebugData = TRUE; |
462 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
Line 491... | Line 496... | ||
491 | //--------------------------------------------------------------------------------------------- |
496 | //--------------------------------------------------------------------------------------------- |
492 | void USART0_TransmitTxData(void) |
497 | void USART0_TransmitTxData(void) |
493 | { |
498 | { |
494 | if(!txd_complete) return; |
499 | if(!txd_complete) return; |
Line -... | Line 500... | ||
- | 500 | ||
- | 501 | if(CheckDelay(AboTimeOut)) |
|
- | 502 | { |
|
- | 503 | Display_Interval = 0; |
|
- | 504 | DebugData_Interval = 0; |
|
- | 505 | } |
|
495 | 506 | ||
496 | if(Request_VerInfo && txd_complete) |
507 | if(Request_VerInfo && txd_complete) |
497 | { |
508 | { |
498 | SendOutData('V', FM_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo)); |
509 | SendOutData('V', FM_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo)); |
499 | Request_VerInfo = FALSE; |
510 | Request_VerInfo = FALSE; |
500 | } |
511 | } |
501 | if( ((Display_Interval && CheckDelay(Display_Timer)) || Request_Display) && txd_complete) |
512 | else if( (((Display_Interval > 0) && CheckDelay(Display_Timer)) || Request_Display) && txd_complete) |
502 | { |
513 | { |
503 | if(DisplayLine > 3)// new format |
514 | if(DisplayLine > 3)// new format |
- | 515 | { |
|
504 | { |
516 | Menu_Update(DisplayKeys); |
505 | LCD_PrintMenu(); |
517 | DisplayKeys = 0; |
506 | SendOutData('H', FM_ADDRESS, 1, (uint8_t *)DisplayBuff, 80); |
518 | SendOutData('H', FC_ADDRESS, 1, (uint8_t *)DisplayBuff, sizeof(DisplayBuff)); |
507 | } |
519 | } |
508 | else // old format |
520 | else // old format |
509 | { |
521 | { |
510 | LCD_printfxy(0,0,"!!! INCOMPATIBLE !!!"); |
522 | LCD_printfxy(0,0,"!!! INCOMPATIBLE !!!"); |
511 | SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), (uint8_t *)DisplayBuff, 20); |
523 | SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), (uint8_t *)DisplayBuff, 20); |
512 | if(DisplayLine++ > 3) DisplayLine = 0; |
524 | if(DisplayLine++ > 3) DisplayLine = 0; |
513 | } |
525 | } |
514 | Display_Timer = SetDelay(Display_Interval); |
526 | Display_Timer = SetDelay(Display_Interval); |
515 | Request_Display = FALSE; |
527 | Request_Display = FALSE; |
516 | } |
528 | } |
517 | if(Request_Display1 && txd_complete) |
529 | else if(Request_Display1 && txd_complete) |
518 | { |
530 | { |
519 | LCD_PrintMenu(); |
531 | Menu_Update(0); |
520 | SendOutData('L', FM_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff)); |
532 | SendOutData('L', FC_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff)); |
521 | Request_Display1 = FALSE; |
533 | Request_Display1 = FALSE; |
522 | } |
534 | } |
523 | if(Request_DebugLabel != 0xFF) // Texte für die Analogdaten |
535 | else if(Request_DebugLabel != 0xFF) // Texte für die Analogdaten |
524 | { |
536 | { |
525 | uint8_t label[16]; // local sram buffer |
537 | uint8_t label[16]; // local sram buffer |
526 | memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer |
538 | memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer |
527 | SendOutData('A', FM_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16); |
539 | SendOutData('A', FM_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16); |
528 | Request_DebugLabel = 0xFF; |
540 | Request_DebugLabel = 0xFF; |
529 | } |
541 | } |
530 | if(Request_ExternalControl && txd_complete) |
542 | else if(Request_ExternalControl && txd_complete) |
531 | { |
543 | { |
532 | SendOutData('G', FM_ADDRESS, 1,(uint8_t *) &ExternControl, sizeof(ExternControl)); |
544 | SendOutData('G', FM_ADDRESS, 1,(uint8_t *) &ExternControl, sizeof(ExternControl)); |
533 | Request_ExternalControl = FALSE; |
545 | Request_ExternalControl = FALSE; |
534 | } |
546 | } |
535 | if( ((DebugData_Interval && CheckDelay(DebugData_Timer)) || Request_DebugData) && txd_complete) |
547 | else if( (((DebugData_Interval > 0) && CheckDelay(DebugData_Timer)) || Request_DebugData) && txd_complete) |
536 | { |
548 | { |
537 | SendOutData('D', FM_ADDRESS, 1,(uint8_t *) &DebugOut, sizeof(DebugOut)); |
549 | SendOutData('D', FM_ADDRESS, 1,(uint8_t *) &DebugOut, sizeof(DebugOut)); |
538 | DebugData_Timer = SetDelay(DebugData_Interval); |
550 | DebugData_Timer = SetDelay(DebugData_Interval); |
539 | Request_DebugData = FALSE; |
551 | Request_DebugData = FALSE; |
540 | } |
552 | } |
541 | if(Request_SendFollowMe && txd_complete) |
553 | else if(Request_SendFollowMe && txd_complete) |
542 | { |
554 | { |
543 | SendOutData('s', NC_ADDRESS, 1, (uint8_t *)&FollowMe, sizeof(FollowMe)); |
555 | SendOutData('s', NC_ADDRESS, 1, (uint8_t *)&FollowMe, sizeof(FollowMe)); |
544 | FollowMe.Position.Status = PROCESSED; |
556 | FollowMe.Position.Status = PROCESSED; |
545 | Request_SendFollowMe = FALSE; |
557 | Request_SendFollowMe = FALSE; |