Contiki 3.x
debug-uart.c
1 /*
2  * Contiki PIC32 Port project
3  *
4  * Copyright (c) 2012,
5  * Scuola Superiore Sant'Anna (http://www.sssup.it) and
6  * Consorzio Nazionale Interuniversitario per le Telecomunicazioni
7  * (http://www.cnit.it).
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the Institute nor the names of its contributors
20  * may be used to endorse or promote products derived from this software
21  * without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  */
36 
37 /**
38  * \addtogroup pic32 PIC32 Contiki Port
39  *
40  * @{
41  */
42 
43 /**
44  * \file cpu/pic32/debug-uart.h
45  * \brief Debug output redirection to uart.
46  * \author Giovanni Pellerano <giovanni.pellerano@evilaliv3.org>
47  * \date 2012-03-21
48  */
49 
50 #ifdef __USE_UART__
51 
52 #include <debug-uart.h>
53 #include <pic32_uart.h>
54 
55 #include <dev/serial-line.h>
56 
57 #define DEBUG 0
58 #if DEBUG
59 #include <stdio.h>
60 #define PRINTF(...) printf(__VA_ARGS__)
61 #else
62 #define PRINTF(...)
63 #endif
64 
65 #define DEBUG_UART(XX, YY) \
66  void \
67  _mon_putc(char c) \
68  { \
69  pic32_uart##XX##_write(c); \
70  } \
71  \
72  void \
73  dbg_setup_uart(unsigned long ubr) \
74  { \
75  pic32_uart##XX##_init(ubr, 0); \
76  \
77  PRINTF("Initializing debug uart: %lubps\n", ubr); \
78  } \
79  \
80  UART_INTERRUPT(XX, YY, pic32_uart##XX##_write);
81 
82 #ifdef __USE_UART_PORT1A_FOR_DEBUG__
83 DEBUG_UART(1A, 0);
84 #elif defined __USE_UART_PORT1B_FOR_DEBUG__
85 DEBUG_UART(1B, 2);
86 #elif defined __USE_UART_PORT2A_FOR_DEBUG__
87 DEBUG_UART(2A, 1);
88 #elif defined __USE_UART_PORT2B_FOR_DEBUG__
89 DEBUG_UART(2B, 2);
90 #elif defined __USE_UART_PORT3A_FOR_DEBUG__
91 DEBUG_UART(3A, 1);
92 #elif defined __USE_UART_PORT3B_FOR_DEBUG__
93 DEBUG_UART(3B, 2);
94 #else
95 DEBUG_UART(1A);
96 #endif
97 
98 #endif /* __USE_UART__*/
99 
100 /** @} */
UART Interface for PIC32MX (pic32mx795f512l)
Generic serial I/O process header filer.