source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifi_dnld/src/SOFTWARE_FRAMEWORK/UTILS/DEBUG/print_funcs.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 11.7 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*This file is prepared for Doxygen automatic documentation generation.*/
4/*! \file *********************************************************************
5 *
6 * \brief Strings and integers print module for debug purposes.
7 *
8 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
9 * - Supported devices:  All AVR32 devices with a USART module can be used.
10 *
11 * \author               Atmel Corporation: http://www.atmel.com \n
12 *                       Support and FAQ: http://support.atmel.no/
13 *
14 ******************************************************************************/
15
16/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are met:
20 *
21 * 1. Redistributions of source code must retain the above copyright notice, this
22 * list of conditions and the following disclaimer.
23 *
24 * 2. Redistributions in binary form must reproduce the above copyright notice,
25 * this list of conditions and the following disclaimer in the documentation
26 * and/or other materials provided with the distribution.
27 *
28 * 3. The name of Atmel may not be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * 4. This software may only be redistributed and used in connection with an Atmel
32 * AVR product.
33 *
34 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
35 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
37 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
38 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
44 *
45 */
46
47#ifndef _PRINT_FUNCS_H_
48#define _PRINT_FUNCS_H_
49
50#include <avr32/io.h>
51#include "board.h"
52
53
54/*! \name USART Settings for the Debug Module
55 */
56//! @{
57#if BOARD == EVK1100
58#  define DBG_USART               (&AVR32_USART1)
59#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_0_PIN
60#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
61#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_0_PIN
62#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
63#  define DBG_USART_BAUDRATE      57600
64#elif BOARD == EVK1101
65#  define DBG_USART               (&AVR32_USART1)
66#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_0_PIN
67#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
68#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_0_PIN
69#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
70#  define DBG_USART_BAUDRATE      57600
71#elif BOARD == UC3C_EK
72#  define DBG_USART               (&AVR32_USART2)
73#  define DBG_USART_RX_PIN        AVR32_USART2_RXD_0_1_PIN
74#  define DBG_USART_RX_FUNCTION   AVR32_USART2_RXD_0_1_FUNCTION
75#  define DBG_USART_TX_PIN        AVR32_USART2_TXD_0_1_PIN
76#  define DBG_USART_TX_FUNCTION   AVR32_USART2_TXD_0_1_FUNCTION
77#  define DBG_USART_BAUDRATE      57600
78#elif BOARD == EVK1104
79#  define DBG_USART               (&AVR32_USART1)
80#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_0_PIN
81#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
82#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_0_PIN
83#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
84#  define DBG_USART_BAUDRATE      57600
85#elif BOARD == EVK1105
86#  define DBG_USART               (&AVR32_USART0)
87#  define DBG_USART_RX_PIN        AVR32_USART0_RXD_0_0_PIN
88#  define DBG_USART_RX_FUNCTION   AVR32_USART0_RXD_0_0_FUNCTION
89#  define DBG_USART_TX_PIN        AVR32_USART0_TXD_0_0_PIN
90#  define DBG_USART_TX_FUNCTION   AVR32_USART0_TXD_0_0_FUNCTION
91#  define DBG_USART_BAUDRATE      57600
92#elif BOARD == STK1000
93#  define DBG_USART               (&AVR32_USART1)
94#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_PIN
95#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_FUNCTION
96#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_PIN
97#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_FUNCTION
98#  define DBG_USART_BAUDRATE      115200
99#elif BOARD == NGW100
100#  define DBG_USART               (&AVR32_USART1)
101#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_PIN
102#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_FUNCTION
103#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_PIN
104#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_FUNCTION
105#  define DBG_USART_BAUDRATE      115200
106#elif BOARD == STK600_RCUC3L0
107#  define DBG_USART               (&AVR32_USART1)
108#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_1_PIN
109#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_1_FUNCTION
110// For the RX pin, connect STK600.PORTE.PE3 to STK600.RS232 SPARE.RXD
111#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_1_PIN
112#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_1_FUNCTION
113// For the TX pin, connect STK600.PORTE.PE2 to STK600.RS232 SPARE.TXD
114#  define DBG_USART_BAUDRATE      57600
115#  define DBG_USART_CLOCK_MASK    AVR32_USART1_CLK_PBA
116#elif BOARD == UC3L_EK
117#  define DBG_USART               (&AVR32_USART3)
118#  define DBG_USART_RX_PIN        AVR32_USART3_RXD_0_0_PIN
119#  define DBG_USART_RX_FUNCTION   AVR32_USART3_RXD_0_0_FUNCTION
120#  define DBG_USART_TX_PIN        AVR32_USART3_TXD_0_0_PIN
121#  define DBG_USART_TX_FUNCTION   AVR32_USART3_TXD_0_0_FUNCTION
122#  define DBG_USART_BAUDRATE      57600
123#  define DBG_USART_CLOCK_MASK    AVR32_USART3_CLK_PBA
124#elif BOARD == ARDUINO
125#  define DBG_USART               (&AVR32_USART1)
126#  define DBG_USART_RX_PIN        AVR32_USART1_RXD_0_0_PIN
127#  define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
128#  define DBG_USART_TX_PIN        AVR32_USART1_TXD_0_0_PIN
129#  define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
130#  define DBG_USART_BAUDRATE      57600
131#  define DBG_USART_CLOCK_MASK    AVR32_USART1_CLK_PBA
132#endif
133
134#if !defined(DBG_USART)             || \
135    !defined(DBG_USART_RX_PIN)      || \
136    !defined(DBG_USART_RX_FUNCTION) || \
137    !defined(DBG_USART_TX_PIN)      || \
138    !defined(DBG_USART_TX_FUNCTION) || \
139    !defined(DBG_USART_BAUDRATE)
140#  error The USART configuration to use for debug on your board is missing
141#endif
142//! @}
143
144/*! \name VT100 Common Commands
145 */
146//! @{
147#define CLEARSCR          "\x1B[2J\x1B[;H"    //!< Clear screen.
148#define CLEAREOL          "\x1B[K"            //!< Clear end of line.
149#define CLEAREOS          "\x1B[J"            //!< Clear end of screen.
150#define CLEARLCR          "\x1B[0K"           //!< Clear line cursor right.
151#define CLEARLCL          "\x1B[1K"           //!< Clear line cursor left.
152#define CLEARELN          "\x1B[2K"           //!< Clear entire line.
153#define CLEARCDW          "\x1B[0J"           //!< Clear cursor down.
154#define CLEARCUP          "\x1B[1J"           //!< Clear cursor up.
155#define GOTOYX            "\x1B[%.2d;%.2dH"   //!< Set cursor to (y, x).
156#define INSERTMOD         "\x1B[4h"           //!< Insert mode.
157#define OVERWRITEMOD      "\x1B[4l"           //!< Overwrite mode.
158#define DELAFCURSOR       "\x1B[K"            //!< Erase from cursor to end of line.
159#define CRLF              "\r\n"              //!< Carriage Return + Line Feed.
160//! @}
161
162/*! \name VT100 Cursor Commands
163 */
164//! @{
165#define CURSON            "\x1B[?25h"         //!< Show cursor.
166#define CURSOFF           "\x1B[?25l"         //!< Hide cursor.
167//! @}
168
169/*! \name VT100 Character Commands
170 */
171//! @{
172#define NORMAL            "\x1B[0m"           //!< Normal.
173#define BOLD              "\x1B[1m"           //!< Bold.
174#define UNDERLINE         "\x1B[4m"           //!< Underline.
175#define BLINKING          "\x1B[5m"           //!< Blink.
176#define INVVIDEO          "\x1B[7m"           //!< Inverse video.
177//! @}
178
179/*! \name VT100 Color Commands
180 */
181//! @{
182#define CL_BLACK          "\033[22;30m"       //!< Black.
183#define CL_RED            "\033[22;31m"       //!< Red.
184#define CL_GREEN          "\033[22;32m"       //!< Green.
185#define CL_BROWN          "\033[22;33m"       //!< Brown.
186#define CL_BLUE           "\033[22;34m"       //!< Blue.
187#define CL_MAGENTA        "\033[22;35m"       //!< Magenta.
188#define CL_CYAN           "\033[22;36m"       //!< Cyan.
189#define CL_GRAY           "\033[22;37m"       //!< Gray.
190#define CL_DARKGRAY       "\033[01;30m"       //!< Dark gray.
191#define CL_LIGHTRED       "\033[01;31m"       //!< Light red.
192#define CL_LIGHTGREEN     "\033[01;32m"       //!< Light green.
193#define CL_YELLOW         "\033[01;33m"       //!< Yellow.
194#define CL_LIGHTBLUE      "\033[01;34m"       //!< Light blue.
195#define CL_LIGHTMAGENTA   "\033[01;35m"       //!< Light magenta.
196#define CL_LIGHTCYAN      "\033[01;36m"       //!< Light cyan.
197#define CL_WHITE          "\033[01;37m"       //!< White.
198//! @}
199
200
201/*! \brief Sets up DBG_USART with 8N1 at DBG_USART_BAUDRATE.
202 *
203 * \param pba_hz PBA clock frequency (Hz).
204 */
205extern void init_dbg_rs232(long pba_hz);
206
207/*! \brief Sets up DBG_USART with 8N1 at a given baud rate.
208 *
209 * \param baudrate Baud rate to set DBG_USART to.
210 * \param pba_hz PBA clock frequency (Hz).
211 */
212extern void init_dbg_rs232_ex(unsigned long baudrate, long pba_hz);
213
214/*! \brief Prints a string of characters to DBG_USART.
215 *
216 * \param str The string of characters to print.
217 */
218extern void print_dbg(const char *str);
219
220/*! \brief Prints a character to DBG_USART.
221 *
222 * \param c The character to print.
223 */
224extern void print_dbg_char(int c);
225
226/*! \brief Prints an integer to DBG_USART in a decimal representation.
227 *
228 * \param n The integer to print.
229 */
230extern void print_dbg_ulong(unsigned long n);
231
232/*! \brief Prints a char to DBG_USART in an hexadecimal representation.
233 *
234 * \param n The char to print.
235 */
236extern void print_dbg_char_hex(unsigned char n);
237
238/*! \brief Prints a short integer to DBG_USART in an hexadecimal representation.
239 *
240 * \param n The short integer to print.
241 */
242extern void print_dbg_short_hex(unsigned short n);
243
244/*! \brief Prints an integer to DBG_USART in an hexadecimal representation.
245 *
246 * \param n The integer to print.
247 */
248extern void print_dbg_hex(unsigned long n);
249
250/*! \brief Prints a string of characters to a given USART.
251 *
252 * \param usart Base address of the USART instance to print to.
253 * \param str The string of characters to print.
254 */
255extern void print(volatile avr32_usart_t *usart, const char *str);
256
257/*! \brief Prints a character to a given USART.
258 *
259 * \param usart Base address of the USART instance to print to.
260 * \param c The character to print.
261 */
262extern void print_char(volatile avr32_usart_t *usart, int c);
263
264/*! \brief Prints an integer to a given USART in a decimal representation.
265 *
266 * \param usart Base address of the USART instance to print to.
267 * \param n The integer to print.
268 */
269extern void print_ulong(volatile avr32_usart_t *usart, unsigned long n);
270
271/*! \brief Prints a char to a given USART in an hexadecimal representation.
272 *
273 * \param usart Base address of the USART instance to print to.
274 * \param n The char to print.
275 */
276extern void print_char_hex(volatile avr32_usart_t *usart, unsigned char n);
277
278/*! \brief Prints a short integer to a given USART in an hexadecimal
279 *         representation.
280 *
281 * \param usart Base address of the USART instance to print to.
282 * \param n The short integer to print.
283 */
284extern void print_short_hex(volatile avr32_usart_t *usart, unsigned short n);
285
286/*! \brief Prints an integer to a given USART in an hexadecimal representation.
287 *
288 * \param usart Base address of the USART instance to print to.
289 * \param n The integer to print.
290 */
291extern void print_hex(volatile avr32_usart_t *usart, unsigned long n);
292
293
294#endif  // _PRINT_FUNCS_H_
Note: See TracBrowser for help on using the repository browser.