Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

debug.c File Reference

Copyright (c) 2004 This file contains the routines of debug trace and assert. More...

#include "config.h"
#include "debug.h"

Go to the source code of this file.

Functions

void put_OCD (U8 val)
 This macro is used to output a character on OCD/Serial Debug Interface when SOFT_OCD switch enabled, character is output as is => VT100 or Hyperterminal usage when switch disabled, character are ORed with 0x80 to distinguish from debug status byte output from OCD hardware => OCD dongle usage.

void trace_u32 (U32 val)
 Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

void trace_u16 (U16 val)
 Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

void trace_u8 (U16 val)
 Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

void trace_hex (U8 val)
 Fonction used to display a byte value in the hex form on OCD/Serial Debug Interface.

void trace (const U8 *str)
 Fonction used for send a texte on OCD/Serial Debug Interface.


Variables

U8 _MEM_TYPE_SLOW_ g_trace_en = TRUE
 Fonction used to enable OCD perform an OCD software entry, set Baudrate to valueperform an OCD software entry.


Detailed Description

Copyright (c) 2004 This file contains the routines of debug trace and assert.

Please read file license.txt for copyright notice.

Version:
1.1 (c5131-usb-generic-1_2_0)

Todo:
Bug:

Definition in file debug.c.


Function Documentation

void put_OCD U8  val  )  [static]
 

This macro is used to output a character on OCD/Serial Debug Interface when SOFT_OCD switch enabled, character is output as is => VT100 or Hyperterminal usage when switch disabled, character are ORed with 0x80 to distinguish from debug status byte output from OCD hardware => OCD dongle usage.

Parameters:
val character to output on SDI

Definition at line 71 of file debug.c.

Referenced by trace(), trace_hex(), trace_u16(), trace_u32(), and trace_u8().

00072 { 00073 while( OSCON & MSK_OCDTBSY ); 00074 # ifdef SOFT_OCD 00075 OSBUF = val; 00076 # else 00077 OSBUF = (val|0x80); 00078 # endif 00079 }

void trace_u32 U32  val  ) 
 

Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

Parameters:
val: value of byte

Definition at line 87 of file debug.c.

References _MEM_TYPE_SLOW_, Bool, FALSE, g_trace_en, put_OCD(), TRACE_START_CHAR, TRACE_STOP_CHAR, TRUE, and U32.

00088 { 00089 _MEM_TYPE_SLOW_ U32 div; 00090 _MEM_TYPE_SLOW_ U32 tmp; 00091 Bool filter=TRUE; 00092 if( FALSE==g_trace_en ) return; 00093 put_OCD( TRACE_START_CHAR ); 00094 00095 for( div=1000000000 ; div!=1 ; val%=div, div/=10 ) 00096 { 00097 tmp = val/div; 00098 if ( ( filter==TRUE ) && !tmp ) { continue; } 00099 filter=FALSE; 00100 put_OCD('0' + tmp ); 00101 } 00102 put_OCD('0' + val ); 00103 put_OCD( TRACE_STOP_CHAR ); 00104 }

void trace_u16 U16  val  ) 
 

Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

Parameters:
val: value of byte

Definition at line 110 of file debug.c.

References _MEM_TYPE_SLOW_, Bool, FALSE, g_trace_en, put_OCD(), TRACE_START_CHAR, TRACE_STOP_CHAR, TRUE, and U16.

00111 { 00112 _MEM_TYPE_SLOW_ U16 div; 00113 _MEM_TYPE_SLOW_ U16 tmp; 00114 Bool filter=TRUE; 00115 if( FALSE==g_trace_en ) return; 00116 put_OCD( TRACE_START_CHAR ); 00117 00118 for( div=10000 ; div!=1 ; val%=div, div/=10 ) 00119 { 00120 tmp = val/div; 00121 if ( ( filter==TRUE ) && !tmp ) { continue; } 00122 filter=FALSE; 00123 put_OCD('0' + tmp ); 00124 } 00125 put_OCD('0' + val ); 00126 put_OCD( TRACE_STOP_CHAR ); 00127 }

void trace_u8 U16  val  ) 
 

Fonction used to display a byte value in the decimal form (16 bits) on OCD/Serial Debug Interface.

Parameters:
val: value of byte

Definition at line 133 of file debug.c.

References _MEM_TYPE_SLOW_, Bool, FALSE, g_trace_en, put_OCD(), TRACE_START_CHAR, TRACE_STOP_CHAR, TRUE, and U8.

00134 { 00135 _MEM_TYPE_SLOW_ U8 div; 00136 _MEM_TYPE_SLOW_ U8 tmp; 00137 Bool filter=TRUE; 00138 if( FALSE==g_trace_en ) return; 00139 put_OCD( TRACE_START_CHAR ); 00140 00141 for( div=100 ; div!=1 ; val%=div, div/=10 ) 00142 { 00143 tmp = val/div; 00144 if ( ( filter==TRUE ) && !tmp ) { continue; } 00145 filter=FALSE; 00146 put_OCD('0' + tmp ); 00147 } 00148 put_OCD('0' + val ); 00149 put_OCD( TRACE_STOP_CHAR ); 00150 }

void trace_hex U8  val  ) 
 

Fonction used to display a byte value in the hex form on OCD/Serial Debug Interface.

Parameters:
val: value of byte

Definition at line 156 of file debug.c.

References FALSE, g_trace_en, put_OCD(), TRACE_START_CHAR, and TRACE_STOP_CHAR.

00157 { 00158 if( FALSE==g_trace_en ) return; 00159 put_OCD( TRACE_START_CHAR ); 00160 00161 if ((val >> 4) >= 10) { put_OCD('A' + (val >> 4) - 10); } 00162 else { put_OCD('0' + (val >> 4)); } 00163 00164 if ((val & 0x0F) >= 10) { put_OCD('A' + (val & 0x0F) - 10); } 00165 else { put_OCD('0' + (val & 0x0F)); } 00166 00167 put_OCD( TRACE_STOP_CHAR ); 00168 }

void trace const U8 str  ) 
 

Fonction used for send a texte on OCD/Serial Debug Interface.

Parameters:
str: texte to send (max. size = 256)

Definition at line 176 of file debug.c.

References FALSE, g_trace_en, put_OCD(), TRACE_START_CHAR, TRACE_STOP_CHAR, and U8.

00177 { 00178 U8 index=0; 00179 if( FALSE==g_trace_en ) return; 00180 put_OCD( TRACE_START_CHAR ); 00181 00182 while( 0 != str[index] ) 00183 { 00184 put_OCD( str[index++] ); 00185 } 00186 put_OCD( TRACE_STOP_CHAR ); 00187 }


Variable Documentation

U8 _MEM_TYPE_SLOW_ g_trace_en = TRUE
 

Fonction used to enable OCD perform an OCD software entry, set Baudrate to valueperform an OCD software entry.

Definition at line 61 of file debug.c.

Referenced by trace(), trace_hex(), trace_u16(), trace_u32(), and trace_u8().


Generated on Mon Apr 10 17:23:30 2006 for Atmel by doxygen 1.3.7