3 * Author: Christian Starkjohann
4 * Creation Date: 2005-01-16
6 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
7 * License: Proprietary, free under certain conditions. See Documentation.
8 * This Revision: $Id: oddebug.h 52 2005-04-12 16:57:29Z cs $
11 #ifndef __oddebug_h_included__
12 #define __oddebug_h_included__
18 This module implements a function for debug logs on the serial line of the
19 AVR microcontroller. Debugging can be configured with the define
20 'DEBUG_LEVEL'. If this macro is not defined or defined to 0, all debugging
21 calls are no-ops. If it is 1, DBG1 logs will appear, but not DBG2. If it is
22 2, DBG1 and DBG2 logs will be printed.
24 A debug log consists of a label ('prefix') to indicate which debug log created
25 the output and a memory block to dump in hex ('data' and 'len').
30 # define F_CPU 12000000 /* 12 MHz */
34 # define uchar unsigned char
37 #if DEBUG_LEVEL > 0 && !defined TXEN /* no UART in device */
38 # warning "Debugging disabled because device has no UART"
43 # define DEBUG_LEVEL 0
46 /* ------------------------------------------------------------------------- */
49 # define DBG1(prefix, data, len) odDebug(prefix, data, len)
51 # define DBG1(prefix, data, len)
55 # define DBG2(prefix, data, len) odDebug(prefix, data, len)
57 # define DBG2(prefix, data, len)
60 /* ------------------------------------------------------------------------- */
63 extern void odDebug(uchar prefix
, uchar
*data
, uchar len
);
65 /* Try to find our control registers; ATMEL likes to rename these */
68 # define ODDBG_UBRR UBRR
70 # define ODDBG_UBRR UBRRL
72 # define ODDBG_UBRR UBRR1
74 # define ODDBG_UBRR UBRR1L
78 # define ODDBG_UCR UCR
80 # define ODDBG_UCR UCSRB
82 # define ODDBG_UCR UCSR1B
86 # define ODDBG_USR USR
88 # define ODDBG_USR UCSRA
90 # define ODDBG_USR UCSR1A
94 # define ODDBG_UDR UDR
96 # define ODDBG_UDR UDR1
99 static inline void odDebugInit(void)
101 ODDBG_UCR
|= (1<<TXEN
);
102 ODDBG_UBRR
= F_CPU
/ (19200 * 16L) - 1;
105 # define odDebugInit()
108 /* ------------------------------------------------------------------------- */
110 #endif /* __oddebug_h_included__ */