Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
||
3 | <title>Procyon AVRlib: buffer.h Source File</title> |
||
4 | <link href="dox.css" rel="stylesheet" type="text/css"> |
||
5 | </head><body> |
||
6 | <!-- Generated by Doxygen 1.4.2 --> |
||
7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
||
8 | <h1>buffer.h</h1><a href="buffer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file buffer.h \brief Multipurpose byte buffer structure and methods. */</span> |
||
9 | 00002 <span class="comment">//*****************************************************************************</span> |
||
10 | 00003 <span class="comment">//</span> |
||
11 | 00004 <span class="comment">// File Name : 'buffer.h'</span> |
||
12 | 00005 <span class="comment">// Title : Multipurpose byte buffer structure and methods</span> |
||
13 | 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2001-2002</span> |
||
14 | 00007 <span class="comment">// Created : 9/23/2001</span> |
||
15 | 00008 <span class="comment">// Revised : 11/16/2002</span> |
||
16 | 00009 <span class="comment">// Version : 1.1</span> |
||
17 | 00010 <span class="comment">// Target MCU : any</span> |
||
18 | 00011 <span class="comment">// Editor Tabs : 4</span> |
||
19 | 00012 <span class="comment">//</span><span class="comment"></span> |
||
20 | 00013 <span class="comment">/// \ingroup general</span> |
||
21 | 00014 <span class="comment">/// \defgroup buffer Circular Byte-Buffer Structure and Function Library (buffer.c)</span> |
||
22 | 00015 <span class="comment">/// \code #include "buffer.h" \endcode</span> |
||
23 | 00016 <span class="comment">/// \par Overview</span> |
||
24 | 00017 <span class="comment">/// This byte-buffer structure provides an easy and efficient way to store</span> |
||
25 | 00018 <span class="comment">/// and process a stream of bytes. You can create as many buffers as you</span> |
||
26 | 00019 <span class="comment">/// like (within memory limits), and then use this common set of functions to</span> |
||
27 | 00020 <span class="comment">/// access each buffer. The buffers are designed for FIFO operation (first</span> |
||
28 | 00021 <span class="comment">/// in, first out). This means that the first byte you put in the buffer</span> |
||
29 | 00022 <span class="comment">/// will be the first one you get when you read out the buffer. Supported</span> |
||
30 | 00023 <span class="comment">/// functions include buffer initialize, get byte from front of buffer, add</span> |
||
31 | 00024 <span class="comment">/// byte to end of buffer, check if buffer is full, and flush buffer. The</span> |
||
32 | 00025 <span class="comment">/// buffer uses a circular design so no copying of data is ever necessary.</span> |
||
33 | 00026 <span class="comment">/// This buffer is not dynamically allocated, it has a user-defined fixed</span> |
||
34 | 00027 <span class="comment">/// maximum size. This buffer is used in many places in the avrlib code.</span> |
||
35 | 00028 <span class="comment"></span><span class="comment">//</span> |
||
36 | 00029 <span class="comment">// This code is distributed under the GNU Public License</span> |
||
37 | 00030 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span> |
||
38 | 00031 <span class="comment">//</span> |
||
39 | 00032 <span class="comment">//*****************************************************************************</span><span class="comment"></span> |
||
40 | 00033 <span class="comment">//@{</span> |
||
41 | 00034 <span class="comment"></span> |
||
42 | 00035 <span class="preprocessor">#ifndef BUFFER_H</span> |
||
43 | 00036 <span class="preprocessor"></span><span class="preprocessor">#define BUFFER_H</span> |
||
44 | 00037 <span class="preprocessor"></span> |
||
45 | 00038 <span class="comment">// structure/typdefs</span> |
||
46 | 00039 <span class="comment"></span> |
||
47 | 00040 <span class="comment">//! cBuffer structure</span> |
||
48 | <a name="l00041"></a><a class="code" href="structstruct__cBuffer.html">00041</a> <span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structstruct__cBuffer.html">struct_cBuffer</a> |
||
49 | 00042 { |
||
50 | <a name="l00043"></a><a class="code" href="structstruct__cBuffer.html#o0">00043</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *<a class="code" href="structstruct__cBuffer.html#o0">dataptr</a>; <span class="comment">///< the physical memory address where the buffer is stored</span> |
||
51 | <a name="l00044"></a><a class="code" href="structstruct__cBuffer.html#o1">00044</a> <span class="comment"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="structstruct__cBuffer.html#o1">size</a>; <span class="comment">///< the allocated size of the buffer</span> |
||
52 | <a name="l00045"></a><a class="code" href="structstruct__cBuffer.html#o2">00045</a> <span class="comment"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="structstruct__cBuffer.html#o2">datalength</a>; <span class="comment">///< the length of the data currently in the buffer</span> |
||
53 | <a name="l00046"></a><a class="code" href="structstruct__cBuffer.html#o3">00046</a> <span class="comment"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="structstruct__cBuffer.html#o3">dataindex</a>; <span class="comment">///< the index into the buffer where the data starts</span> |
||
54 | 00047 <span class="comment"></span>} <a class="code" href="structstruct__cBuffer.html">cBuffer</a>; |
||
55 | 00048 |
||
56 | 00049 <span class="comment">// function prototypes</span> |
||
57 | 00050 <span class="comment"></span> |
||
58 | 00051 <span class="comment">//! initialize a buffer to start at a given address and have given size</span> |
||
59 | 00052 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__buffer.html#ga1">bufferInit</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *start, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> size); |
||
60 | 00053 <span class="comment"></span> |
||
61 | 00054 <span class="comment">//! get the first byte from the front of the buffer</span> |
||
62 | 00055 <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="group__buffer.html#ga2">bufferGetFromFront</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer); |
||
63 | 00056 <span class="comment"></span> |
||
64 | 00057 <span class="comment">//! dump (discard) the first numbytes from the front of the buffer</span> |
||
65 | 00058 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__buffer.html#ga3">bufferDumpFromFront</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> numbytes); |
||
66 | 00059 <span class="comment"></span> |
||
67 | 00060 <span class="comment">//! get a byte at the specified index in the buffer (kind of like array access)</span> |
||
68 | 00061 <span class="comment"></span><span class="comment">// ** note: this does not remove the byte that was read from the buffer</span> |
||
69 | 00062 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="group__buffer.html#ga4">bufferGetAtIndex</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> index); |
||
70 | 00063 <span class="comment"></span> |
||
71 | 00064 <span class="comment">//! add a byte to the end of the buffer</span> |
||
72 | 00065 <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="group__buffer.html#ga5">bufferAddToEnd</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data); |
||
73 | 00066 <span class="comment"></span> |
||
74 | 00067 <span class="comment">//! check if the buffer is full/not full (returns zero value if full)</span> |
||
75 | 00068 <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="group__buffer.html#ga6">bufferIsNotFull</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer); |
||
76 | 00069 <span class="comment"></span> |
||
77 | 00070 <span class="comment">//! flush (clear) the contents of the buffer</span> |
||
78 | 00071 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__buffer.html#ga7">bufferFlush</a>(<a class="code" href="structstruct__cBuffer.html">cBuffer</a>* buffer); |
||
79 | 00072 |
||
80 | 00073 <span class="preprocessor">#endif</span> |
||
81 | 00074 <span class="preprocessor"></span><span class="comment">//@}</span> |
||
82 | </span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by |
||
83 | <a href="http://www.doxygen.org/index.html"> |
||
84 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
85 | </body> |
||
86 | </html> |
Powered by WebSVN v2.8.3