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 | ||
Line 66... | Line 66... | ||
66 | #define FALSE 0 |
66 | #define FALSE 0 |
67 | #define TRUE 1 |
67 | #define TRUE 1 |
Line 68... | Line 68... | ||
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]; |
Line -... | Line 73... | ||
- | 73 | volatile uint8_t rxd_buffer_locked = FALSE; |
|
- | 74 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
|
- | 75 | volatile uint8_t txd_complete = TRUE; |
|
- | 76 | volatile uint8_t ReceivedBytes = 0; |
|
Line -... | Line 77... | ||
- | 77 | ||
- | 78 | #define VERSION_INFO 0x01 |
|
Line 73... | Line -... | ||
73 | volatile uint8_t rxd_buffer_locked = FALSE; |
- | |
74 | volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
- | |
75 | volatile uint8_t txd_complete = TRUE; |
- | |
76 | volatile uint8_t ReceivedBytes = 0; |
- | |
Line 77... | Line 79... | ||
77 | 79 | #define DEBUG_DATA 0x02 |
|
Line 78... | Line -... | ||
78 | - | ||
Line 79... | Line 80... | ||
79 | 80 | #define DEBUG_LABEL 0x04 |
|
80 | uint8_t RequestVerInfo = FALSE; |
81 | #define COMPASS_HEADING 0x08 |
81 | uint8_t RequestDebugData = FALSE; |
82 | |
82 | uint8_t RequestDebugLabel = FALSE; |
83 | uint8_t RequestFlags = 0x00; |
Line 83... | Line 84... | ||
83 | uint8_t RequestCompassHeading = FALSE; |
84 | uint8_t RequestDebugLabel = 0; |
Line 84... | Line 85... | ||
84 | 85 | ||
85 | uint8_t MySlaveAddr = 0; |
86 | |
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; |
Line 421... | Line 422... | ||
421 | break; |
422 | break; |
422 | 423 | ||
423 | case 'b': // extern control |
424 | case 'b': // extern control |
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; |
Line 445... | Line 446... | ||
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; |
Line 449... | Line 450... | ||
449 | break; |
450 | break; |
450 | 451 | ||
451 | case 'a':// Labels of the Analog Debug outputs |
452 | case 'a':// Labels of the Analog Debug outputs |
- | 453 | Decode64((uint8_t *) &tmp_char_arr2[0], sizeof(tmp_char_arr2), 3, ReceivedBytes); |
|
452 | Decode64((uint8_t *) &tmp_char_arr2[0], sizeof(tmp_char_arr2), 3, ReceivedBytes); |
454 | RequestDebugLabel = tmp_char_arr2[0]; |
453 | RequestDebugLabel = tmp_char_arr2[0]; |
455 | RequestFlags |= DEBUG_LABEL; |
Line 454... | Line 456... | ||
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; |
Line 470... | Line 472... | ||
470 | { |
472 | { |
471 | if(!(UCSR0B & (1 << TXEN0))) return; |
473 | if(!(UCSR0B & (1 << TXEN0))) return; |
Line 472... | Line 474... | ||
472 | 474 | ||
Line 473... | Line 475... | ||
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)); |
Line 479... | Line 481... | ||
479 | Debug_Timer = SetDelay(250); |
481 | Debug_Timer = SetDelay(250); |
480 | } |
482 | } |
481 | 483 | ||
482 | if(RequestDebugLabel != 255) |
484 | if(RequestFlags & DEBUG_LABEL) |
- | 485 | { |
|
483 | { |
486 | SendOutData('A',RequestDebugLabel + '0',(uint8_t *) ANALOG_LABEL[RequestDebugLabel],16); |
Line 484... | Line 487... | ||
484 | SendOutData('A',RequestDebugLabel + '0',(uint8_t *) ANALOG_LABEL[RequestDebugLabel],16); |
487 | RequestDebugLabel = 255; |
485 | RequestDebugLabel = 255; |
488 | RequestFlags &= ~DEBUG_LABEL; |
486 | } |
489 | } |
487 | 490 | ||
488 | if(RequestVerInfo && txd_complete) |
491 | if(RequestFlags & VERSION_INFO) |
Line 489... | Line 492... | ||
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) |
Line 495... | Line 498... | ||
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 |