Rev 22 | Rev 26 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 22 | Rev 23 | ||
---|---|---|---|
Line 64... | Line 64... | ||
64 | 64 | ||
65 | 65 | ||
66 | #define FALSE 0 |
66 | #define FALSE 0 |
67 | #define TRUE 1 |
67 | #define TRUE 1 |
68 | 68 | ||
69 | #define TXD_BUFFER_LEN 150 |
69 | #define TXD_BUFFER_LEN 100 |
70 | #define RXD_BUFFER_LEN 150 |
70 | #define RXD_BUFFER_LEN 100 |
71 | 71 | ||
72 | volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
72 | volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
73 | volatile uint8_t rxd_buffer_locked = FALSE; |
73 | volatile uint8_t rxd_buffer_locked = FALSE; |
74 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
74 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
75 | volatile uint8_t txd_complete = TRUE; |
75 | volatile uint8_t txd_complete = TRUE; |
76 | volatile uint8_t ReceivedBytes = 0; |
76 | volatile uint8_t ReceivedBytes = 0; |
77 | 77 | ||
- | 78 | #define VERSION_INFO 0x01 |
|
- | 79 | #define DEBUG_DATA 0x02 |
|
- | 80 | #define DEBUG_LABEL 0x04 |
|
- | 81 | #define COMPASS_HEADING 0x08 |
|
78 | 82 | ||
- | 83 | uint8_t RequestFlags = 0x00; |
|
- | 84 | uint8_t RequestDebugLabel = 0; |
|
79 | 85 | ||
80 | uint8_t RequestVerInfo = FALSE; |
- | |
81 | uint8_t RequestDebugData = FALSE; |
- | |
82 | uint8_t RequestDebugLabel = FALSE; |
- | |
83 | uint8_t RequestCompassHeading = FALSE; |
- | |
84 | 86 | ||
85 | uint8_t MySlaveAddr = 0; |
87 | uint8_t MySlaveAddr = 0; |
86 | 88 | ||
87 | //unsigned char,DebugGetAnforderung = 0, |
- | |
88 | 89 | ||
89 | DebugOut_t DebugOut; |
90 | struct DebugOut_t DebugOut; |
90 | ExternData_t ExternData; |
91 | struct ExternData_t ExternData; |
91 | ExternControl_t ExternControl; |
92 | struct ExternControl_t ExternControl; |
92 | VersionInfo_t VersionInfo; |
93 | struct VersionInfo_t VersionInfo; |
93 | 94 | ||
94 | uint16_t Debug_Timer; |
95 | uint16_t Debug_Timer; |
95 | 96 | ||
96 | const uint8_t ANALOG_LABEL[32][16] = |
97 | const uint8_t ANALOG_LABEL[32][16] = |
97 | { |
98 | { |
Line 415... | Line 416... | ||
415 | 416 | ||
416 | switch(rxd_buffer[2]) |
417 | switch(rxd_buffer[2]) |
417 | { |
418 | { |
418 | case 'w':// Attitude |
419 | case 'w':// Attitude |
419 | Decode64((uint8_t *) &ExternData, sizeof(ExternData), 3, ReceivedBytes); |
420 | Decode64((uint8_t *) &ExternData, sizeof(ExternData), 3, ReceivedBytes); |
420 | RequestCompassHeading = TRUE; |
421 | RequestFlags |= COMPASS_HEADING; |
421 | break; |
422 | break; |
422 | 423 | ||
423 | case 'b': // extern control |
424 | case 'b': // extern control |
424 | case 'c': // extern control with debug request |
425 | case 'c': // extern control with debug request |
425 | Decode64((uint8_t *) &ExternControl,sizeof(ExternControl), 3,ReceivedBytes); |
426 | Decode64((uint8_t *) &ExternControl,sizeof(ExternControl), 3,ReceivedBytes); |
Line 442... | Line 443... | ||
442 | case 'h':// x-1 display columns |
443 | case 'h':// x-1 display columns |
443 | PC_Connected = 255; |
444 | PC_Connected = 255; |
444 | break; |
445 | break; |
445 | 446 | ||
446 | case 'v': // get version and board release |
447 | case 'v': // get version and board release |
447 | RequestVerInfo = TRUE; |
448 | RequestFlags |= VERSION_INFO; |
448 | PC_Connected = 255; |
449 | PC_Connected = 255; |
449 | break; |
450 | break; |
450 | 451 | ||
451 | case 'a':// Labels of the Analog Debug outputs |
452 | case 'a':// Labels of the Analog Debug outputs |
452 | Decode64((uint8_t *) &tmp_char_arr2[0], sizeof(tmp_char_arr2), 3, ReceivedBytes); |
453 | Decode64((uint8_t *) &tmp_char_arr2[0], sizeof(tmp_char_arr2), 3, ReceivedBytes); |
453 | RequestDebugLabel = tmp_char_arr2[0]; |
454 | RequestDebugLabel = tmp_char_arr2[0]; |
- | 455 | RequestFlags |= DEBUG_LABEL; |
|
454 | PC_Connected = 255; |
456 | PC_Connected = 255; |
455 | break; |
457 | break; |
456 | 458 | ||
457 | case 'g':// get debug data |
459 | case 'g':// get debug data |
458 | RequestDebugData = TRUE; |
460 | RequestFlags |= DEBUG_DATA; |
459 | PC_Connected = 255; |
461 | PC_Connected = 255; |
460 | break; |
462 | break; |
461 | } |
463 | } |
462 | // unlock the rxd buffer after processing |
464 | // unlock the rxd buffer after processing |
463 | rxd_buffer_locked = FALSE; |
465 | rxd_buffer_locked = FALSE; |
Line 470... | Line 472... | ||
470 | { |
472 | { |
471 | if(!(UCSR0B & (1 << TXEN0))) return; |
473 | if(!(UCSR0B & (1 << TXEN0))) return; |
472 | 474 | ||
473 | if(!txd_complete) return; |
475 | if(!txd_complete) return; |
474 | 476 | ||
475 | if(CheckDelay(Debug_Timer) && txd_complete) |
477 | if(CheckDelay(Debug_Timer)) |
476 | { |
478 | { |
477 | SetDebugValues(); |
479 | SetDebugValues(); |
478 | SendOutData('D',MySlaveAddr,(uint8_t *) &DebugOut,sizeof(DebugOut)); |
480 | SendOutData('D',MySlaveAddr,(uint8_t *) &DebugOut,sizeof(DebugOut)); |
479 | Debug_Timer = SetDelay(250); |
481 | Debug_Timer = SetDelay(250); |
480 | } |
482 | } |
481 | 483 | ||
482 | if(RequestDebugLabel != 255) |
484 | if(RequestFlags & DEBUG_LABEL) |
483 | { |
485 | { |
484 | SendOutData('A',RequestDebugLabel + '0',(uint8_t *) ANALOG_LABEL[RequestDebugLabel],16); |
486 | SendOutData('A',RequestDebugLabel + '0',(uint8_t *) ANALOG_LABEL[RequestDebugLabel],16); |
485 | RequestDebugLabel = 255; |
487 | RequestDebugLabel = 255; |
- | 488 | RequestFlags &= ~DEBUG_LABEL; |
|
486 | } |
489 | } |
487 | 490 | ||
488 | if(RequestVerInfo && txd_complete) |
491 | if(RequestFlags & VERSION_INFO) |
489 | { |
492 | { |
490 | SendOutData('V',MySlaveAddr,(uint8_t *) &VersionInfo, sizeof(VersionInfo)); |
493 | SendOutData('V',MySlaveAddr,(uint8_t *) &VersionInfo, sizeof(VersionInfo)); |
491 | RequestVerInfo = FALSE; |
494 | RequestFlags &= ~VERSION_INFO; |
492 | } |
495 | } |
493 | 496 | ||
494 | if(RequestDebugData && txd_complete) |
497 | if(RequestFlags & DEBUG_DATA) |
495 | { |
498 | { |
496 | SetDebugValues(); |
499 | SetDebugValues(); |
497 | SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl)); |
500 | SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl)); |
498 | RequestDebugData = FALSE; |
501 | RequestFlags &= ~DEBUG_DATA; |
499 | } |
502 | } |
500 | 503 | ||
501 | if(RequestCompassHeading && txd_complete) |
504 | if(RequestFlags & COMPASS_HEADING) |
502 | { |
505 | { |
503 | SendOutData('K',MySlaveAddr,(uint8_t *) &I2C_Heading, sizeof(I2C_Heading)); |
506 | SendOutData('K',MySlaveAddr,(uint8_t *) &I2C_Heading, sizeof(I2C_Heading)); |
504 | RequestCompassHeading = FALSE; |
507 | RequestFlags &= ~COMPASS_HEADING; |
505 | } |
508 | } |
506 | } |
509 | } |