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

library

?curdirlinks? -

Blame information for rev 6

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: a2d.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&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>
8 <h1>a2d.h</h1><a href="a2d_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file a2d.h \brief Analog-to-Digital converter function library. */</span>
9 00002 <span class="comment">//*****************************************************************************</span>
10 00003 <span class="comment">//</span>
11 00004 <span class="comment">// File Name : 'a2d.h'</span>
12 00005 <span class="comment">// Title : Analog-to-digital converter functions</span>
13 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2002</span>
14 00007 <span class="comment">// Created : 4/08/2002</span>
15 00008 <span class="comment">// Revised : 4/30/2002</span>
16 00009 <span class="comment">// Version : 1.1</span>
17 00010 <span class="comment">// Target MCU : Atmel AVR series</span>
18 00011 <span class="comment">// Editor Tabs : 4</span>
19 00012 <span class="comment">//</span>
20 00013 <span class="comment">// This code is distributed under the GNU Public License</span>
21 00014 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>
22 00015 <span class="comment">//</span><span class="comment"></span>
23 00016 <span class="comment">/// \ingroup driver_avr</span>
24 00017 <span class="comment">/// \defgroup a2d A/D Converter Function Library (a2d.c)</span>
25 00018 <span class="comment">/// \code #include "a2d.h" \endcode</span>
26 00019 <span class="comment">/// \par Overview</span>
27 00020 <span class="comment">/// This library provides an easy interface to the analog-to-digital</span>
28 00021 <span class="comment">/// converter available on many AVR processors. Updated to support</span>
29 00022 <span class="comment">/// the ATmega128.</span>
30 00023 <span class="comment"></span><span class="comment">//</span>
31 00024 <span class="comment">//****************************************************************************</span><span class="comment"></span>
32 00025 <span class="comment">//@{</span>
33 00026 <span class="comment"></span>
34 00027 <span class="preprocessor">#ifndef A2D_H</span>
35 00028 <span class="preprocessor"></span><span class="preprocessor">#define A2D_H</span>
36 00029 <span class="preprocessor"></span>
37 00030 <span class="comment">// defines</span>
38 00031
39 00032 <span class="comment">// A2D clock prescaler select</span>
40 00033 <span class="comment">// *selects how much the CPU clock frequency is divided</span>
41 00034 <span class="comment">// to create the A2D clock frequency</span>
42 00035 <span class="comment">// *lower division ratios make conversion go faster</span>
43 00036 <span class="comment">// *higher division ratios make conversions more accurate</span>
44 <a name="l00037"></a><a class="code" href="group__a2d.html#ga9">00037</a> <span class="preprocessor">#define ADC_PRESCALE_DIV2 0x00 </span><span class="comment">///&lt; 0x01,0x00 -&gt; CPU clk/2</span>
45 <a name="l00038"></a><a class="code" href="group__a2d.html#ga10">00038</a> <span class="comment"></span>#define ADC_PRESCALE_DIV4 0x02 <span class="comment">///&lt; 0x02 -&gt; CPU clk/4</span>
46 <a name="l00039"></a><a class="code" href="group__a2d.html#ga11">00039</a> <span class="comment"></span>#define ADC_PRESCALE_DIV8 0x03 <span class="comment">///&lt; 0x03 -&gt; CPU clk/8</span>
47 <a name="l00040"></a><a class="code" href="group__a2d.html#ga12">00040</a> <span class="comment"></span>#define ADC_PRESCALE_DIV16 0x04 <span class="comment">///&lt; 0x04 -&gt; CPU clk/16</span>
48 <a name="l00041"></a><a class="code" href="group__a2d.html#ga13">00041</a> <span class="comment"></span>#define ADC_PRESCALE_DIV32 0x05 <span class="comment">///&lt; 0x05 -&gt; CPU clk/32</span>
49 <a name="l00042"></a><a class="code" href="group__a2d.html#ga14">00042</a> <span class="comment"></span>#define ADC_PRESCALE_DIV64 0x06 <span class="comment">///&lt; 0x06 -&gt; CPU clk/64</span>
50 <a name="l00043"></a><a class="code" href="group__a2d.html#ga15">00043</a> <span class="comment"></span>#define ADC_PRESCALE_DIV128 0x07 <span class="comment">///&lt; 0x07 -&gt; CPU clk/128</span>
51 00044 <span class="comment"></span>// default value
52 00045 <span class="preprocessor">#define ADC_PRESCALE ADC_PRESCALE_DIV64</span>
53 00046 <span class="preprocessor"></span><span class="comment">// do not change the mask value</span>
54 00047 <span class="preprocessor">#define ADC_PRESCALE_MASK 0x07</span>
55 00048 <span class="preprocessor"></span>
56 00049 <span class="comment">// A2D voltage reference select</span>
57 00050 <span class="comment">// *this determines what is used as the</span>
58 00051 <span class="comment">// full-scale voltage point for A2D conversions</span>
59 <a name="l00052"></a><a class="code" href="group__a2d.html#ga18">00052</a> <span class="preprocessor">#define ADC_REFERENCE_AREF 0x00 </span><span class="comment">///&lt; 0x00 -&gt; AREF pin, internal VREF turned off</span>
60 <a name="l00053"></a><a class="code" href="group__a2d.html#ga19">00053</a> <span class="comment"></span>#define ADC_REFERENCE_AVCC 0x01 <span class="comment">///&lt; 0x01 -&gt; AVCC pin, internal VREF turned off</span>
61 <a name="l00054"></a><a class="code" href="group__a2d.html#ga20">00054</a> <span class="comment"></span>#define ADC_REFERENCE_RSVD 0x02 <span class="comment">///&lt; 0x02 -&gt; Reserved</span>
62 <a name="l00055"></a><a class="code" href="group__a2d.html#ga21">00055</a> <span class="comment"></span>#define ADC_REFERENCE_256V 0x03 <span class="comment">///&lt; 0x03 -&gt; Internal 2.56V VREF</span>
63 00056 <span class="comment"></span>// default value
64 00057 <span class="preprocessor">#define ADC_REFERENCE ADC_REFERENCE_AVCC</span>
65 00058 <span class="preprocessor"></span><span class="comment">// do not change the mask value</span>
66 00059 <span class="preprocessor">#define ADC_REFERENCE_MASK 0xC0</span>
67 00060 <span class="preprocessor"></span>
68 00061 <span class="comment">// bit mask for A2D channel multiplexer</span>
69 00062 <span class="preprocessor">#define ADC_MUX_MASK 0x1F</span>
70 00063 <span class="preprocessor"></span>
71 00064 <span class="comment">// channel defines (for reference and use in code)</span>
72 00065 <span class="comment">// these channels supported by all AVRs with A2D</span>
73 00066 <span class="preprocessor">#define ADC_CH_ADC0 0x00</span>
74 00067 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC1 0x01</span>
75 00068 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC2 0x02</span>
76 00069 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC3 0x03</span>
77 00070 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC4 0x04</span>
78 00071 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC5 0x05</span>
79 00072 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC6 0x06</span>
80 00073 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC7 0x07</span>
81 <a name="l00074"></a><a class="code" href="group__a2d.html#ga33">00074</a> <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_122V 0x1E </span><span class="comment">///&lt; 1.22V voltage reference</span>
82 <a name="l00075"></a><a class="code" href="group__a2d.html#ga34">00075</a> <span class="comment"></span>#define ADC_CH_AGND 0x1F <span class="comment">///&lt; AGND</span>
83 00076 <span class="comment"></span>// these channels supported only in ATmega128
84 00077 <span class="comment">// differential with gain</span>
85 00078 <span class="preprocessor">#define ADC_CH_0_0_DIFF10X 0x08</span>
86 00079 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_0_DIFF10X 0x09</span>
87 00080 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_0_0_DIFF200X 0x0A</span>
88 00081 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_0_DIFF200X 0x0B</span>
89 00082 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF10X 0x0C</span>
90 00083 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF10X 0x0D</span>
91 00084 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF200X 0x0E</span>
92 00085 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF200X 0x0F</span>
93 00086 <span class="preprocessor"></span><span class="comment">// differential</span>
94 00087 <span class="preprocessor">#define ADC_CH_0_1_DIFF1X 0x10</span>
95 00088 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_1_DIFF1X 0x11</span>
96 00089 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_1_DIFF1X 0x12</span>
97 00090 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_1_DIFF1X 0x13</span>
98 00091 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_4_1_DIFF1X 0x14</span>
99 00092 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_5_1_DIFF1X 0x15</span>
100 00093 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_6_1_DIFF1X 0x16</span>
101 00094 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_7_1_DIFF1X 0x17</span>
102 00095 <span class="preprocessor"></span>
103 00096 <span class="preprocessor">#define ADC_CH_0_2_DIFF1X 0x18</span>
104 00097 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_2_DIFF1X 0x19</span>
105 00098 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF1X 0x1A</span>
106 00099 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF1X 0x1B</span>
107 00100 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_4_2_DIFF1X 0x1C</span>
108 00101 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_5_2_DIFF1X 0x1D</span>
109 00102 <span class="preprocessor"></span>
110 00103 <span class="comment">// compatibility for new Mega processors</span>
111 00104 <span class="comment">// ADCSR hack apparently no longer necessary in new AVR-GCC</span>
112 00105 <span class="preprocessor">#ifdef ADCSRA</span>
113 00106 <span class="preprocessor"></span><span class="preprocessor">#ifndef ADCSR</span>
114 00107 <span class="preprocessor"></span><span class="preprocessor"> #define ADCSR ADCSRA</span>
115 00108 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
116 00109 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
117 00110 <span class="preprocessor"></span><span class="preprocessor">#ifdef ADATE</span>
118 00111 <span class="preprocessor"></span><span class="preprocessor"> #define ADFR ADATE</span>
119 00112 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
120 00113 <span class="preprocessor"></span>
121 00114 <span class="comment">// function prototypes</span>
122 00115 <span class="comment"></span>
123 00116 <span class="comment">//! Initializes the A/D converter.</span>
124 00117 <span class="comment">/// Turns ADC on and prepares it for use.</span>
125 00118 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga0">a2dInit</a>(<span class="keywordtype">void</span>);
126 00119 <span class="comment"></span>
127 00120 <span class="comment">//! Turn off A/D converter</span>
128 00121 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga1">a2dOff</a>(<span class="keywordtype">void</span>);
129 00122 <span class="comment"></span>
130 00123 <span class="comment">//! Sets the division ratio of the A/D converter clock.</span>
131 00124 <span class="comment">/// This function is automatically called from a2dInit()</span>
132 00125 <span class="comment">/// with a default value.</span>
133 00126 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga2">a2dSetPrescaler</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> prescale);
134 00127 <span class="comment"></span>
135 00128 <span class="comment">//! Configures which voltage reference the A/D converter uses.</span>
136 00129 <span class="comment">/// This function is automatically called from a2dInit()</span>
137 00130 <span class="comment">/// with a default value.</span>
138 00131 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga3">a2dSetReference</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ref);
139 00132 <span class="comment"></span>
140 00133 <span class="comment">//! sets the a2d input channel</span>
141 00134 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga4">a2dSetChannel</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ch);
142 00135 <span class="comment"></span>
143 00136 <span class="comment">//! start a conversion on the current a2d input channel</span>
144 00137 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__a2d.html#ga5">a2dStartConvert</a>(<span class="keywordtype">void</span>);
145 00138 <span class="comment"></span>
146 00139 <span class="comment">//! return TRUE if conversion is complete</span>
147 00140 <span class="comment"></span>u08 <a class="code" href="group__a2d.html#ga6">a2dIsComplete</a>(<span class="keywordtype">void</span>);
148 00141 <span class="comment"></span>
149 00142 <span class="comment">//! Starts a conversion on A/D channel# ch,</span>
150 00143 <span class="comment">/// returns the 10-bit value of the conversion when it is finished.</span>
151 00144 <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="group__a2d.html#ga7">a2dConvert10bit</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ch);
152 00145 <span class="comment"></span>
153 00146 <span class="comment">//! Starts a conversion on A/D channel# ch,</span>
154 00147 <span class="comment">/// returns the 8-bit value of the conversion when it is finished.</span>
155 00148 <span class="comment"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="group__a2d.html#ga8">a2dConvert8bit</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ch);
156 00149
157 00150 <span class="preprocessor">#endif</span>
158 00151 <span class="preprocessor"></span><span class="comment">//@}</span>
159 </span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by&nbsp;
160 <a href="http://www.doxygen.org/index.html">
161 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
162 </body>
163 </html>
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3