Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
print.h
Go to the documentation of this file.
1 /*
2  * Paparazzi $I$
3  *
4  * Copyright (C) 2005 Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
25 #ifndef PRINT_H
26 #define PRINT_H
27 
28 #include "mcu_periph/uart.h"
29 #include "mcu_periph/usb_serial.h"
30 
31 #define _PrintString(out_fun, s) { \
32  uint8_t i = 0; \
33  while (s[i]) { \
34  out_fun(s[i]); \
35  i++; \
36  } \
37 }
38 
39 #define _PrintHex(out_fun, c) { \
40  const uint8_t hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', \
41  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; \
42  uint8_t high = (c & 0xF0)>>4; \
43  uint8_t low = c & 0x0F; \
44  out_fun(hex[high]); \
45  out_fun(hex[low]); \
46 } \
47 
48 #define _PrintHex16(out_fun, c ) { \
49  uint8_t high16 = (uint8_t)(c>>8); \
50  uint8_t low16 = (uint8_t)(c); \
51  _PrintHex(out_fun, high16); \
52  _PrintHex(out_fun, low16); \
53 }
54 
55 #define _PrintHex32(out_fun, c ) { \
56  uint16_t high32 = (uint16_t)(c>>16); \
57  uint16_t low32 = (uint16_t)(c); \
58  _PrintHex16(out_fun, high32); \
59  _PrintHex16(out_fun, low32); \
60 }
61 
62 #ifdef USE_UART0
63 
64 #define Uart0PrintHex(c) _PrintHex(Uart0Transmit, c)
65 #define Uart0PrintHex16(c) _PrintHex16(Uart0Transmit, c)
66 #define Uart0PrintHex32(c) _PrintHex32(Uart0Transmit, c)
67 #define Uart0PrintString(s) _PrintString(Uart0Transmit, s)
68 
69 #define UART0PrintHex Uart0PrintHex
70 #define UART0PrintHex16 Uart0PrintHex16
71 #define UART0PrintHex32 Uart0PrintHex32
72 #define UART0PrintString Uart0PrintString
73 
74 #endif /* USE_UART0 */
75 
76 #ifdef USE_UART1
77 
78 #define Uart1PrintHex(c) _PrintHex(Uart1Transmit, c)
79 #define Uart1PrintHex16(c) _PrintHex16(Uart1Transmit, c)
80 #define Uart1PrintHex32(c) _PrintHex32(Uart1Transmit, c)
81 #define Uart1PrintString(s) _PrintString(Uart1Transmit, s)
82 
83 #define UART1PrintHex Uart1PrintHex
84 #define UART1PrintHex16 Uart1PrintHex16
85 #define UART1PrintHex32 Uart1PrintHex32
86 #define UART1PrintString Uart1PrintString
87 
88 #endif /* USE_UART1 */
89 
90 #ifdef USE_UART2
91 
92 #define Uart2PrintHex(c) _PrintHex(Uart2Transmit, c)
93 #define Uart2PrintHex16(c) _PrintHex16(Uart2Transmit, c)
94 #define Uart2PrintHex32(c) _PrintHex32(Uart2Transmit, c)
95 #define Uart2PrintString(s) _PrintString(Uart2Transmit, s)
96 
97 #define UART2PrintHex Uart2PrintHex
98 #define UART2PrintHex16 Uart2PrintHex16
99 #define UART2PrintHex32 Uart2PrintHex32
100 #define UART2PrintString Uart2PrintString
101 
102 #endif /* USE_UART2 */
103 
104 #ifdef USE_UART3
105 
106 #define Uart3PrintHex(c) _PrintHex(Uart3Transmit, c)
107 #define Uart3PrintHex16(c) _PrintHex16(Uart3Transmit, c)
108 #define Uart3PrintHex32(c) _PrintHex32(Uart3Transmit, c)
109 #define Uart3PrintString(s) _PrintString(Uart3Transmit, s)
110 
111 #define UART3PrintHex Uart3PrintHex
112 #define UART3PrintHex16 Uart3PrintHex16
113 #define UART3PrintHex32 Uart3PrintHex32
114 #define UART3PrintString Uart3PrintString
115 
116 #endif /* USE_UART3 */
117 
118 #ifdef USE_UART5
119 
120 #define Uart5PrintHex(c) _PrintHex(Uart5Transmit, c)
121 #define Uart5PrintHex16(c) _PrintHex16(Uart5Transmit, c)
122 #define Uart5PrintHex32(c) _PrintHex32(Uart5Transmit, c)
123 #define Uart5PrintString(s) _PrintString(Uart5Transmit, s)
124 
125 #define UART5PrintHex Uart5PrintHex
126 #define UART5PrintHex16 Uart5PrintHex16
127 #define UART5PrintHex32 Uart5PrintHex32
128 #define UART5PrintString Uart5PrintString
129 
130 #endif /* USE_UART5 */
131 
132 #define UsbSPrintHex(c) _PrintHex(VCOM_putchar, c)
133 #define UsbSPrintHex16(c) _PrintHex16(VCOM_putchar, c)
134 #define UsbSPrintString(s) _PrintString(VCOM_putchar, s)
135 
136 
137 #endif /* PRINT_H */
138 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
arch independent USB API