4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2003, 2004, 2005, 2006, 2007 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2000, 2001, 2002 Bernie Innocenti <bernie@codewiz.org>
34 * \brief General pourpose debug support for embedded systems (implementation).
37 * \author Bernie Innocenti <bernie@codewiz.org>
38 * \author Stefano Fedrigo <aleph@develer.com>
43 #include <cfg/debug.h>
44 #include <cfg/macros.h> /* for BV() */
45 #include <appconfig.h>
46 #include <hw/hw_cpufreq.h> /* for CPU_FREQ */
47 #include <hw_ser.h> /* Required for bus macros overrides */
51 #define KDBG_WAIT_READY() do {} while (!(SP_STAT & (SPSF_TX_EMPTY | SPSF_TX_INT)))
52 #define KDBG_WRITE_CHAR(c) do { SBUF = (c); } while(0)
53 #define KDBG_MASK_IRQ(old) \
55 (old) = INT_MASK1 & INT1F_TI; \
56 INT_MASK1 &= ~INT1F_TI; \
58 #define KDBG_RESTORE_IRQ(old) do { INT_MASK1 |= (old); }
59 typedef uint16_t kdbg_irqsave_t; /* FIXME: unconfirmed */
61 #if CONFIG_KDEBUG_PORT == 666
62 #error BITBANG debug console missing for this platform
66 INLINE void kdbg_hw_init(void)
68 /* Set serial port for 19200bps 8N1 */
69 INT_MASK1 &= ~(INT1F_TI | INT1F_RI);
70 SP_CON = SPCF_RECEIVE_ENABLE | SPCF_MODE1;
71 ioc1_img |= IOC1F_TXD_SEL | IOC1F_EXTINT_SRC;