?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{FILE START}

library

?curdirlinks? - Rev 6

?prevdifflink? - Blame - ?getfile?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Procyon AVRlib: debug.c Source File</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>debug.c</h1><a href="debug_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file debug.c \brief Debugging function library. */</span>
00002 <span class="comment">//*****************************************************************************</span>
00003 <span class="comment">//</span>
00004 <span class="comment">// File Name    : 'debug.c'</span>
00005 <span class="comment">// Title        : Helpful debugging functions</span>
00006 <span class="comment">// Author       : Pascal Stang - Copyright (C) 2003</span>
00007 <span class="comment">// Created      : 2003-03-13</span>
00008 <span class="comment">// Revised      : 2003-03-13</span>
00009 <span class="comment">// Version      : 0.1</span>
00010 <span class="comment">// Target MCU   : Atmel AVR series</span>
00011 <span class="comment">// Editor Tabs  : 4</span>
00012 <span class="comment">//</span>
00013 <span class="comment">// Description  : This file contains a set of functions which may be useful</span>
00014 <span class="comment">//      for general debugging.</span>
00015 <span class="comment">//</span>
00016 <span class="comment">// This code is distributed under the GNU Public License</span>
00017 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>
00018 <span class="comment">//</span>
00019 <span class="comment">//*****************************************************************************</span>
00020 
00021 <span class="preprocessor">#include &lt;avr/io.h&gt;</span>
00022 <span class="preprocessor">#include &lt;avr/interrupt.h&gt;</span>
00023 
00024 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
00025 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">debug.h</a>"</span>
00026 
00027 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span>        <span class="comment">// include printf support</span>
00028 
00029 <span class="comment">// global variables</span>
00030 
00031 <span class="comment">// functions</span>
00032 
00033 <span class="comment">// Print a part of memory as a formatted hex table with ascii translation</span>
<a name="l00034"></a><a class="code" href="debug_8h.html#a0">00034</a> <span class="keywordtype">void</span> <a class="code" href="debug_8c.html#a0">debugPrintHexTable</a>(u16 length, u08 *buffer)
00035 {
00036     u08 i;
00037     u16 j;
00038     u08 *buf;
00039     u08 s;
00040 
00041     buf = buffer;
00042     
00043     <span class="comment">// print the low order address indicies and ASCII header</span>
00044     <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF\r\n"</span>);
00045     <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"     -----------------------------------------------  ---- ASCII -----\r\n"</span>);
00046     
00047     <span class="comment">// print the data</span>
00048     <span class="keywordflow">for</span>(j=0; j&lt;((length+15)&gt;&gt;4); j++)
00049     {
00050         <span class="comment">// print the high order address index for this line</span>
00051         <a class="code" href="group__rprintf.html#ga8">rprintfu16</a>(j&lt;&lt;4);
00052         <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(<span class="charliteral">' '</span>);
00053 
00054         <span class="comment">// print the hex data</span>
00055         <span class="keywordflow">for</span>(i=0; i&lt;0x10; i++)
00056         {
00057             <span class="comment">// be nice and print only up to the exact end of the data</span>
00058             <span class="keywordflow">if</span>( ((j&lt;&lt;4)+i) &lt; length)
00059             {
00060                 <span class="comment">// print hex byte</span>
00061                 <a class="code" href="group__rprintf.html#ga7">rprintfu08</a>(buf[(j&lt;&lt;4)+i]);
00062                 <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(<span class="charliteral">' '</span>);
00063             }
00064             <span class="keywordflow">else</span>
00065             {
00066                 <span class="comment">// we're past the end of the data's length</span>
00067                 <span class="comment">// print spaces</span>
00068                 <a class="code" href="group__rprintf.html#ga15">rprintfProgStrM</a>(<span class="stringliteral">"   "</span>);
00069             }
00070         }
00071         
00072         <span class="comment">// leave some space</span>
00073         <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(<span class="charliteral">' '</span>);
00074 
00075         <span class="comment">// print the ascii data</span>
00076         <span class="keywordflow">for</span>(i=0; i&lt;0x10; i++)
00077         {
00078             <span class="comment">// be nice and print only up to the exact end of the data</span>
00079             <span class="keywordflow">if</span>( ((j&lt;&lt;4)+i) &lt; length)
00080             {
00081                 <span class="comment">// get the character</span>
00082                 s = buf[(j&lt;&lt;4)+i]; 
00083                 <span class="comment">// make sure character is printable</span>
00084                 <span class="keywordflow">if</span>(s &gt;= 0x20)
00085                     <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(s);
00086                 <span class="keywordflow">else</span>
00087                     <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(<span class="charliteral">'.'</span>);
00088             }
00089             <span class="keywordflow">else</span>
00090             {
00091                 <span class="comment">// we're past the end of the data's length</span>
00092                 <span class="comment">// print a space</span>
00093                 <a class="code" href="group__rprintf.html#ga1">rprintfChar</a>(<span class="charliteral">' '</span>);
00094             }
00095         }
00096         <a class="code" href="group__rprintf.html#ga5">rprintfCRLF</a>();
00097     }
00098 }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
{FILE END}
{FOOTER START}

Powered by WebSVN v2.8.3