00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __oddebug_h_included__
00012 #define __oddebug_h_included__
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef F_CPU
00028 # define F_CPU 12000000
00029 #endif
00030
00031
00032 #include "iarcompat.h"
00033 #ifndef __IAR_SYSTEMS_ICC__
00034 # include <avr/io.h>
00035 #endif
00036
00037 #ifndef uchar
00038 # define uchar unsigned char
00039 #endif
00040
00041 #if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0)
00042 # warning "Debugging disabled because device has no UART"
00043 # undef DEBUG_LEVEL
00044 #endif
00045
00046 #ifndef DEBUG_LEVEL
00047 # define DEBUG_LEVEL 0
00048 #endif
00049
00050
00051
00052 #if DEBUG_LEVEL > 0
00053 # define DBG1(prefix, data, len) odDebug(prefix, data, len)
00054 #else
00055 # define DBG1(prefix, data, len)
00056 #endif
00057
00058 #if DEBUG_LEVEL > 1
00059 # define DBG2(prefix, data, len) odDebug(prefix, data, len)
00060 #else
00061 # define DBG2(prefix, data, len)
00062 #endif
00063
00064
00065
00066 #if DEBUG_LEVEL > 0
00067 extern void odDebug(uchar prefix, uchar *data, uchar len);
00068
00069
00070
00071 #if defined UBRR
00072 # define ODDBG_UBRR UBRR
00073 #elif defined UBRRL
00074 # define ODDBG_UBRR UBRRL
00075 #elif defined UBRR0
00076 # define ODDBG_UBRR UBRR0
00077 #elif defined UBRR0L
00078 # define ODDBG_UBRR UBRR0L
00079 #endif
00080
00081 #if defined UCR
00082 # define ODDBG_UCR UCR
00083 #elif defined UCSRB
00084 # define ODDBG_UCR UCSRB
00085 #elif defined UCSR0B
00086 # define ODDBG_UCR UCSR0B
00087 #endif
00088
00089 #if defined TXEN
00090 # define ODDBG_TXEN TXEN
00091 #else
00092 # define ODDBG_TXEN TXEN0
00093 #endif
00094
00095 #if defined USR
00096 # define ODDBG_USR USR
00097 #elif defined UCSRA
00098 # define ODDBG_USR UCSRA
00099 #elif defined UCSR0A
00100 # define ODDBG_USR UCSR0A
00101 #endif
00102
00103 #if defined UDRE
00104 # define ODDBG_UDRE UDRE
00105 #else
00106 # define ODDBG_UDRE UDRE0
00107 #endif
00108
00109 #if defined UDR
00110 # define ODDBG_UDR UDR
00111 #elif defined UDR0
00112 # define ODDBG_UDR UDR0
00113 #endif
00114
00115 static inline void odDebugInit(void)
00116 {
00117 ODDBG_UCR |= (1<<ODDBG_TXEN);
00118 ODDBG_UBRR = F_CPU / (19200 * 16L) - 1;
00119 }
00120 #else
00121 # define odDebugInit()
00122 #endif
00123
00124
00125
00126 #endif