Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
USART Debug strings

This driver adds functionality to print debug strings and data through a dedicated USART.

It supports writing both single characters, strings, and integer values in both decimal and hexadecimal form.

Functions

void init_dbg_rs232 (long pba_hz)
 Sets up DBG_USART with 8N1 at DBG_USART_BAUDRATE. More...
 
void init_dbg_rs232_ex (unsigned long baudrate, long pba_hz)
 Sets up DBG_USART with 8N1 at a given baud rate. More...
 
void print (volatile avr32_usart_t *usart, const char *str)
 Prints a string of characters to a given USART. More...
 
void print_char (volatile avr32_usart_t *usart, int c)
 Prints a character to a given USART. More...
 
void print_char_hex (volatile avr32_usart_t *usart, unsigned char n)
 Prints a char to a given USART in an hexadecimal representation. More...
 
void print_dbg (const char *str)
 Prints a string of characters to DBG_USART. More...
 
void print_dbg_char (int c)
 Prints a character to DBG_USART. More...
 
void print_dbg_char_hex (unsigned char n)
 Prints a char to DBG_USART in an hexadecimal representation. More...
 
void print_dbg_hex (unsigned long n)
 Prints an integer to DBG_USART in an hexadecimal representation. More...
 
void print_dbg_short_hex (unsigned short n)
 Prints a short integer to DBG_USART in an hexadecimal representation. More...
 
void print_dbg_ulong (unsigned long n)
 Prints an integer to DBG_USART in a decimal representation. More...
 
void print_hex (volatile avr32_usart_t *usart, unsigned long n)
 Prints an integer to a given USART in an hexadecimal representation. More...
 
void print_short_hex (volatile avr32_usart_t *usart, unsigned short n)
 Prints a short integer to a given USART in an hexadecimal representation. More...
 
void print_ulong (volatile avr32_usart_t *usart, unsigned long n)
 Prints an integer to a given USART in a decimal representation. More...
 

USART Settings for the Debug Module

#define DBG_USART   (&AVR32_USART1)
 
#define DBG_USART_RX_PIN   AVR32_USART1_RXD_0_0_PIN
 
#define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
 
#define DBG_USART_TX_PIN   AVR32_USART1_TXD_0_0_PIN
 
#define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
 
#define DBG_USART_IRQ   AVR32_USART1_IRQ
 
#define DBG_USART_BAUDRATE   57600
 

VT100 Common Commands

#define CLEARSCR   "\x1B[2J\x1B[;H"
 Clear screen. More...
 
#define CLEAREOL   "\x1B[K"
 Clear end of line. More...
 
#define CLEAREOS   "\x1B[J"
 Clear end of screen. More...
 
#define CLEARLCR   "\x1B[0K"
 Clear line cursor right. More...
 
#define CLEARLCL   "\x1B[1K"
 Clear line cursor left. More...
 
#define CLEARELN   "\x1B[2K"
 Clear entire line. More...
 
#define CLEARCDW   "\x1B[0J"
 Clear cursor down. More...
 
#define CLEARCUP   "\x1B[1J"
 Clear cursor up. More...
 
#define GOTOYX   "\x1B[%.2d;%.2dH"
 Set cursor to (y, x). More...
 
#define INSERTMOD   "\x1B[4h"
 Insert mode. More...
 
#define OVERWRITEMOD   "\x1B[4l"
 Overwrite mode. More...
 
#define DELAFCURSOR   "\x1B[K"
 Erase from cursor to end of line. More...
 
#define CRLF   "\r\n"
 Carriage Return + Line Feed. More...
 

VT100 Cursor Commands

#define CURSON   "\x1B[?25h"
 Show cursor. More...
 
#define CURSOFF   "\x1B[?25l"
 Hide cursor. More...
 

VT100 Character Commands

#define NORMAL   "\x1B[0m"
 Normal. More...
 
#define BOLD   "\x1B[1m"
 Bold. More...
 
#define UNDERLINE   "\x1B[4m"
 Underline. More...
 
#define BLINKING   "\x1B[5m"
 Blink. More...
 
#define INVVIDEO   "\x1B[7m"
 Inverse video. More...
 

VT100 Color Commands

#define CL_BLACK   "\033[22;30m"
 Black. More...
 
#define CL_RED   "\033[22;31m"
 Red. More...
 
#define CL_GREEN   "\033[22;32m"
 Green. More...
 
#define CL_BROWN   "\033[22;33m"
 Brown. More...
 
#define CL_BLUE   "\033[22;34m"
 Blue. More...
 
#define CL_MAGENTA   "\033[22;35m"
 Magenta. More...
 
#define CL_CYAN   "\033[22;36m"
 Cyan. More...
 
#define CL_GRAY   "\033[22;37m"
 Gray. More...
 
#define CL_DARKGRAY   "\033[01;30m"
 Dark gray. More...
 
#define CL_LIGHTRED   "\033[01;31m"
 Light red. More...
 
#define CL_LIGHTGREEN   "\033[01;32m"
 Light green. More...
 
#define CL_YELLOW   "\033[01;33m"
 Yellow. More...
 
#define CL_LIGHTBLUE   "\033[01;34m"
 Light blue. More...
 
#define CL_LIGHTMAGENTA   "\033[01;35m"
 Light magenta. More...
 
#define CL_LIGHTCYAN   "\033[01;36m"
 Light cyan. More...
 
#define CL_WHITE   "\033[01;37m"
 White. More...
 

#define BLINKING   "\x1B[5m"

Blink.

#define BOLD   "\x1B[1m"

Bold.

#define CL_BLACK   "\033[22;30m"

Black.

#define CL_BLUE   "\033[22;34m"

Blue.

#define CL_BROWN   "\033[22;33m"

Brown.

#define CL_CYAN   "\033[22;36m"

Cyan.

#define CL_DARKGRAY   "\033[01;30m"

Dark gray.

#define CL_GRAY   "\033[22;37m"

Gray.

#define CL_GREEN   "\033[22;32m"

Green.

#define CL_LIGHTBLUE   "\033[01;34m"

Light blue.

#define CL_LIGHTCYAN   "\033[01;36m"

Light cyan.

#define CL_LIGHTGREEN   "\033[01;32m"

Light green.

#define CL_LIGHTMAGENTA   "\033[01;35m"

Light magenta.

#define CL_LIGHTRED   "\033[01;31m"

Light red.

#define CL_MAGENTA   "\033[22;35m"

Magenta.

#define CL_RED   "\033[22;31m"

Red.

#define CL_WHITE   "\033[01;37m"

White.

#define CL_YELLOW   "\033[01;33m"

Yellow.

#define CLEARCDW   "\x1B[0J"

Clear cursor down.

#define CLEARCUP   "\x1B[1J"

Clear cursor up.

#define CLEARELN   "\x1B[2K"

Clear entire line.

#define CLEAREOL   "\x1B[K"

Clear end of line.

#define CLEAREOS   "\x1B[J"

Clear end of screen.

#define CLEARLCL   "\x1B[1K"

Clear line cursor left.

#define CLEARLCR   "\x1B[0K"

Clear line cursor right.

#define CLEARSCR   "\x1B[2J\x1B[;H"

Clear screen.

#define CURSOFF   "\x1B[?25l"

Hide cursor.

#define CURSON   "\x1B[?25h"

Show cursor.

#define DBG_USART_BAUDRATE   57600

Referenced by init_dbg_rs232().

#define DBG_USART_IRQ   AVR32_USART1_IRQ
#define DBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION

Referenced by init_dbg_rs232_ex().

#define DBG_USART_RX_PIN   AVR32_USART1_RXD_0_0_PIN

Referenced by init_dbg_rs232_ex().

#define DBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION

Referenced by init_dbg_rs232_ex().

#define DBG_USART_TX_PIN   AVR32_USART1_TXD_0_0_PIN

Referenced by init_dbg_rs232_ex().

#define DELAFCURSOR   "\x1B[K"

Erase from cursor to end of line.

#define GOTOYX   "\x1B[%.2d;%.2dH"

Set cursor to (y, x).

#define INSERTMOD   "\x1B[4h"

Insert mode.

#define INVVIDEO   "\x1B[7m"

Inverse video.

#define NORMAL   "\x1B[0m"

Normal.

#define OVERWRITEMOD   "\x1B[4l"

Overwrite mode.

#define UNDERLINE   "\x1B[4m"

Underline.

void init_dbg_rs232 ( long  pba_hz)

Sets up DBG_USART with 8N1 at DBG_USART_BAUDRATE.

Parameters
pba_hzPBA clock frequency (Hz).

References DBG_USART_BAUDRATE, and init_dbg_rs232_ex().

Referenced by main().

void init_dbg_rs232_ex ( unsigned long  baudrate,
long  pba_hz 
)

Sets up DBG_USART with 8N1 at a given baud rate.

Parameters
baudrateBaud rate to set DBG_USART to.
pba_hzPBA clock frequency (Hz).

References usart_options_t::baudrate, DBG_USART, DBG_USART_RX_FUNCTION, DBG_USART_RX_PIN, DBG_USART_TX_FUNCTION, DBG_USART_TX_PIN, gpio_enable_module(), USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, and USART_NORMAL_CHMODE.

Referenced by init_dbg_rs232().

void print ( volatile avr32_usart_t *  usart,
const char *  str 
)

Prints a string of characters to a given USART.

Parameters
usartBase address of the USART instance to print to.
strThe string of characters to print.

References usart_write_line().

Referenced by dsp16_debug_printf(), dsp16_debug_sprintf(), dsp16_sprintf(), dsp32_debug_printf(), dsp32_debug_sprintf(), dsp32_sprintf(), fat_example_append_file(), fat_example_build_cmd(), fat_example_parse_cmd(), main(), print_char_hex(), print_dbg(), print_hex(), print_short_hex(), print_ulong(), and toggle_led().

void print_char ( volatile avr32_usart_t *  usart,
int  c 
)

Prints a character to a given USART.

Parameters
usartBase address of the USART instance to print to.
cThe character to print.

References usart_putchar().

Referenced by fat_example_append_file(), fat_example_build_cmd(), main(), and print_dbg_char().

void print_char_hex ( volatile avr32_usart_t *  usart,
unsigned char  n 
)

Prints a char to a given USART in an hexadecimal representation.

Parameters
usartBase address of the USART instance to print to.
nThe char to print.

References HEX_DIGITS, i, print(), and tmp.

Referenced by print_dbg_char_hex().

void print_dbg_char ( int  c)

Prints a character to DBG_USART.

Parameters
cThe character to print.

References DBG_USART, and print_char().

Referenced by fsaccess_example_get_filename(), fsaccess_example_get_mode(), and main().

void print_dbg_char_hex ( unsigned char  n)

Prints a char to DBG_USART in an hexadecimal representation.

Parameters
nThe char to print.

References DBG_USART, and print_char_hex().

Referenced by main(), and print_nvram_variables().

void print_dbg_hex ( unsigned long  n)

Prints an integer to DBG_USART in an hexadecimal representation.

Parameters
nThe integer to print.

References DBG_USART, and print_hex().

Referenced by configure_memory_area(), main(), and print_nvram_variables().

void print_dbg_short_hex ( unsigned short  n)

Prints a short integer to DBG_USART in an hexadecimal representation.

Parameters
nThe short integer to print.

References DBG_USART, and print_short_hex().

Referenced by print_nvram_variables().

void print_dbg_ulong ( unsigned long  n)

Prints an integer to DBG_USART in a decimal representation.

Parameters
nThe integer to print.

References DBG_USART, and print_ulong().

Referenced by at45dbx_example_check_mem(), at45dbx_example_test_multiple_sector(), fsaccess_example_read(), fsaccess_example_write(), and main().

void print_hex ( volatile avr32_usart_t *  usart,
unsigned long  n 
)

Prints an integer to a given USART in an hexadecimal representation.

Parameters
usartBase address of the USART instance to print to.
nThe integer to print.

References HEX_DIGITS, i, print(), and tmp.

Referenced by print_dbg_hex().

void print_short_hex ( volatile avr32_usart_t *  usart,
unsigned short  n 
)

Prints a short integer to a given USART in an hexadecimal representation.

Parameters
usartBase address of the USART instance to print to.
nThe short integer to print.

References HEX_DIGITS, i, print(), and tmp.

Referenced by print_dbg_short_hex().

void print_ulong ( volatile avr32_usart_t *  usart,
unsigned long  n 
)

Prints an integer to a given USART in a decimal representation.

Parameters
usartBase address of the USART instance to print to.
nThe integer to print.

References i, print(), and tmp.

Referenced by main(), print_dbg_ulong(), and toggle_led().