Rev 249 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 249 | Rev 254 | ||
---|---|---|---|
1 | #include <stdio.h> |
1 | #include <stdio.h> |
2 | #include <stdarg.h> |
2 | #include <stdarg.h> |
3 | #include <string.h> |
3 | #include <string.h> |
4 | 4 | ||
5 | #include "91x_lib.h" |
5 | #include "91x_lib.h" |
6 | #include "main.h" |
6 | #include "main.h" |
7 | #include "debug.h" |
7 | #include "debug.h" |
8 | 8 | ||
9 | #ifdef DEBUG // only include functions if DEBUG is defined in main.h |
9 | #ifdef DEBUG // only include functions if DEBUG is defined in main.h |
10 | 10 | ||
11 | #warning : "### DEBUG-Funktion aktiv ###" |
11 | #warning : "### DEBUG-Funktion aktiv ###" |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | unsigned char Debug_BufPtr = 0; |
15 | u8 Debug_BufPtr = 0; |
16 | struct str_Debug tDebug; |
16 | Debug_t tDebug; |
17 | unsigned char SendDebugOutput = 0; |
17 | u8 SendDebugOutput = 0; |
18 | 18 | ||
19 | // function called from _printf_P to output character |
19 | // function called from _printf_P to output character |
20 | void Debug_Putchar(char c) |
20 | void Debug_Putchar(char c) |
21 | { |
21 | { |
22 | if (!SendDebugOutput) |
22 | if (!SendDebugOutput) |
23 | { |
23 | { |
24 | tDebug.Text[Debug_BufPtr++] = c; // copy character to buffer |
24 | tDebug.Text[Debug_BufPtr++] = c; // copy character to buffer |
25 | if (Debug_BufPtr > 30) Debug_BufPtr = 30; // avoid buffer overflow |
25 | if (Debug_BufPtr > 30) Debug_BufPtr = 30; // avoid buffer overflow |
26 | } |
26 | } |
27 | } |
27 | } |
28 | 28 | ||
29 | void DebugSend(unsigned char cmd) |
29 | void DebugSend(u8 cmd) |
30 | { |
30 | { |
31 | if (!SendDebugOutput) |
31 | if (!SendDebugOutput) |
32 | { |
32 | { |
33 | tDebug.Cmd = cmd; |
33 | tDebug.Cmd = cmd; |
34 | tDebug.Text[Debug_BufPtr] = '\0'; // end of text marker |
34 | tDebug.Text[Debug_BufPtr] = '\0'; // end of text marker |
35 | Debug_BufPtr = 0; // set bufferindex to 0 |
35 | Debug_BufPtr = 0; // set bufferindex to 0 |
36 | SendDebugOutput = 1; // set flag to trasmit data the next time in serial transmit function |
36 | SendDebugOutput = 1; // set flag to trasmit data the next time in serial transmit function |
37 | } |
37 | } |
38 | } |
38 | } |
39 | #endif |
39 | #endif |
40 | - | ||
41 | /* |
- | |
42 | add the following code block to the serial transmit function |
- | |
43 | - | ||
44 | #ifdef DEBUG // only include functions if DEBUG is defined |
- | |
45 | if(SendDebugOutput && UebertragungAbgeschlossen) |
- | |
46 | { |
- | |
47 | SendOutData('0', FC_ADDRESS, 1, (unsigned char *) &tDebug, sizeof(tDebug)); |
- | |
48 | SendDebugOutput = 0; |
- | |
49 | } |
- | |
50 | #endif |
- | |
51 | - | ||
52 | */ |
- | |
53 | 40 | ||
54 | 41 |