Rev 396 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
249 | ingob | 1 | #include <stdio.h> |
2 | #include <stdarg.h> |
||
3 | #include <string.h> |
||
4 | |||
5 | #include "91x_lib.h" |
||
6 | #include "main.h" |
||
7 | #include "debug.h" |
||
396 | ingob | 8 | #include "uart1.h" |
249 | ingob | 9 | |
396 | ingob | 10 | // get the address of calling function |
11 | // |
||
12 | // usage: Backtrace(__builtin_frame_address (0)); |
||
13 | // |
||
14 | void Backtrace(void* fp) |
||
15 | { |
||
16 | UART1_PutString("\n\r### Backtrace: "); |
||
17 | sprintf(text, "%p ", *((int*)fp - 1)); |
||
18 | UART1_PutString(text); |
||
19 | } |
||
20 | |||
21 | |||
22 | |||
254 | killagreg | 23 | #ifdef DEBUG // only include functions if DEBUG is defined in main.h |
249 | ingob | 24 | |
25 | #warning : "### DEBUG-Funktion aktiv ###" |
||
26 | |||
27 | |||
28 | |||
396 | ingob | 29 | |
254 | killagreg | 30 | u8 Debug_BufPtr = 0; |
31 | Debug_t tDebug; |
||
32 | u8 SendDebugOutput = 0; |
||
249 | ingob | 33 | |
34 | // function called from _printf_P to output character |
||
35 | void Debug_Putchar(char c) |
||
36 | { |
||
37 | if (!SendDebugOutput) |
||
38 | { |
||
254 | killagreg | 39 | tDebug.Text[Debug_BufPtr++] = c; // copy character to buffer |
40 | if (Debug_BufPtr > 30) Debug_BufPtr = 30; // avoid buffer overflow |
||
249 | ingob | 41 | } |
42 | } |
||
43 | |||
254 | killagreg | 44 | void DebugSend(u8 cmd) |
249 | ingob | 45 | { |
46 | if (!SendDebugOutput) |
||
47 | { |
||
48 | tDebug.Cmd = cmd; |
||
49 | tDebug.Text[Debug_BufPtr] = '\0'; // end of text marker |
||
50 | Debug_BufPtr = 0; // set bufferindex to 0 |
||
51 | SendDebugOutput = 1; // set flag to trasmit data the next time in serial transmit function |
||
52 | } |
||
53 | } |
||
54 | #endif |
||
55 |