?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: a2d.h 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>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>
00002 <span class="comment">//*****************************************************************************</span>
00003 <span class="comment">//</span>
00004 <span class="comment">// File Name    : 'a2d.h'</span>
00005 <span class="comment">// Title        : Analog-to-digital converter functions</span>
00006 <span class="comment">// Author       : Pascal Stang - Copyright (C) 2002</span>
00007 <span class="comment">// Created      : 4/08/2002</span>
00008 <span class="comment">// Revised      : 4/30/2002</span>
00009 <span class="comment">// Version      : 1.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">// This code is distributed under the GNU Public License</span>
00014 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>
00015 <span class="comment">//</span><span class="comment"></span>
00016 <span class="comment">/// \ingroup driver_avr</span>
00017 <span class="comment">/// \defgroup a2d A/D Converter Function Library (a2d.c)</span>
00018 <span class="comment">/// \code #include "a2d.h" \endcode</span>
00019 <span class="comment">/// \par Overview</span>
00020 <span class="comment">///     This library provides an easy interface to the analog-to-digital</span>
00021 <span class="comment">///     converter available on many AVR processors.  Updated to support</span>
00022 <span class="comment">///     the ATmega128.</span>
00023 <span class="comment"></span><span class="comment">//</span>
00024 <span class="comment">//****************************************************************************</span><span class="comment"></span>
00025 <span class="comment">//@{</span>
00026 <span class="comment"></span>
00027 <span class="preprocessor">#ifndef A2D_H</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#define A2D_H</span>
00029 <span class="preprocessor"></span>
00030 <span class="comment">// defines</span>
00031 
00032 <span class="comment">// A2D clock prescaler select</span>
00033 <span class="comment">//      *selects how much the CPU clock frequency is divided</span>
00034 <span class="comment">//      to create the A2D clock frequency</span>
00035 <span class="comment">//      *lower division ratios make conversion go faster</span>
00036 <span class="comment">//      *higher division ratios make conversions more accurate</span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
00044 <span class="comment"></span>// default value
00045 <span class="preprocessor">#define ADC_PRESCALE            ADC_PRESCALE_DIV64</span>
00046 <span class="preprocessor"></span><span class="comment">// do not change the mask value</span>
00047 <span class="preprocessor">#define ADC_PRESCALE_MASK       0x07</span>
00048 <span class="preprocessor"></span>
00049 <span class="comment">// A2D voltage reference select</span>
00050 <span class="comment">//      *this determines what is used as the</span>
00051 <span class="comment">//      full-scale voltage point for A2D conversions</span>
<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>
<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>
<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>
<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>
00056 <span class="comment"></span>// default value
00057 <span class="preprocessor">#define ADC_REFERENCE           ADC_REFERENCE_AVCC</span>
00058 <span class="preprocessor"></span><span class="comment">// do not change the mask value</span>
00059 <span class="preprocessor">#define ADC_REFERENCE_MASK      0xC0</span>
00060 <span class="preprocessor"></span>
00061 <span class="comment">// bit mask for A2D channel multiplexer</span>
00062 <span class="preprocessor">#define ADC_MUX_MASK            0x1F</span>
00063 <span class="preprocessor"></span>
00064 <span class="comment">// channel defines (for reference and use in code)</span>
00065 <span class="comment">// these channels supported by all AVRs with A2D</span>
00066 <span class="preprocessor">#define ADC_CH_ADC0             0x00</span>
00067 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC1             0x01</span>
00068 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC2             0x02</span>
00069 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC3             0x03</span>
00070 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC4             0x04</span>
00071 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC5             0x05</span>
00072 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC6             0x06</span>
00073 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_ADC7             0x07</span>
<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>
<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>
00076 <span class="comment"></span>// these channels supported only in ATmega128
00077 <span class="comment">// differential with gain</span>
00078 <span class="preprocessor">#define ADC_CH_0_0_DIFF10X      0x08</span>
00079 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_0_DIFF10X      0x09</span>
00080 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_0_0_DIFF200X     0x0A</span>
00081 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_0_DIFF200X     0x0B</span>
00082 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF10X      0x0C</span>
00083 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF10X      0x0D</span>
00084 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF200X     0x0E</span>
00085 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF200X     0x0F</span>
00086 <span class="preprocessor"></span><span class="comment">// differential</span>
00087 <span class="preprocessor">#define ADC_CH_0_1_DIFF1X       0x10</span>
00088 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_1_DIFF1X       0x11</span>
00089 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_1_DIFF1X       0x12</span>
00090 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_1_DIFF1X       0x13</span>
00091 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_4_1_DIFF1X       0x14</span>
00092 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_5_1_DIFF1X       0x15</span>
00093 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_6_1_DIFF1X       0x16</span>
00094 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_7_1_DIFF1X       0x17</span>
00095 <span class="preprocessor"></span>
00096 <span class="preprocessor">#define ADC_CH_0_2_DIFF1X       0x18</span>
00097 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_1_2_DIFF1X       0x19</span>
00098 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_2_2_DIFF1X       0x1A</span>
00099 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_3_2_DIFF1X       0x1B</span>
00100 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_4_2_DIFF1X       0x1C</span>
00101 <span class="preprocessor"></span><span class="preprocessor">#define ADC_CH_5_2_DIFF1X       0x1D</span>
00102 <span class="preprocessor"></span>
00103 <span class="comment">// compatibility for new Mega processors</span>
00104 <span class="comment">// ADCSR hack apparently no longer necessary in new AVR-GCC</span>
00105 <span class="preprocessor">#ifdef ADCSRA</span>
00106 <span class="preprocessor"></span><span class="preprocessor">#ifndef ADCSR</span>
00107 <span class="preprocessor"></span><span class="preprocessor">    #define ADCSR   ADCSRA</span>
00108 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00109 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00110 <span class="preprocessor"></span><span class="preprocessor">#ifdef ADATE</span>
00111 <span class="preprocessor"></span><span class="preprocessor">    #define ADFR    ADATE</span>
00112 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00113 <span class="preprocessor"></span>
00114 <span class="comment">// function prototypes</span>
00115 <span class="comment"></span>
00116 <span class="comment">//! Initializes the A/D converter.</span>
00117 <span class="comment">/// Turns ADC on and prepares it for use.</span>
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>);
00119 <span class="comment"></span>
00120 <span class="comment">//! Turn off A/D converter</span>
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>);
00122 <span class="comment"></span>
00123 <span class="comment">//! Sets the division ratio of the A/D converter clock.</span>
00124 <span class="comment">/// This function is automatically called from a2dInit()</span>
00125 <span class="comment">/// with a default value.</span>
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);
00127 <span class="comment"></span>
00128 <span class="comment">//! Configures which voltage reference the A/D converter uses.</span>
00129 <span class="comment">/// This function is automatically called from a2dInit()</span>
00130 <span class="comment">/// with a default value.</span>
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);
00132 <span class="comment"></span>
00133 <span class="comment">//! sets the a2d input channel</span>
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);
00135 <span class="comment"></span>
00136 <span class="comment">//! start a conversion on the current a2d input channel</span>
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>);
00138 <span class="comment"></span>
00139 <span class="comment">//! return TRUE if conversion is complete</span>
00140 <span class="comment"></span>u08 <a class="code" href="group__a2d.html#ga6">a2dIsComplete</a>(<span class="keywordtype">void</span>);
00141 <span class="comment"></span>
00142 <span class="comment">//! Starts a conversion on A/D channel# ch,</span>
00143 <span class="comment">/// returns the 10-bit value of the conversion when it is finished.</span>
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);
00145 <span class="comment"></span>
00146 <span class="comment">//! Starts a conversion on A/D channel# ch,</span>
00147 <span class="comment">/// returns the 8-bit value of the conversion when it is finished.</span>
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);
00149 
00150 <span class="preprocessor">#endif</span>
00151 <span class="preprocessor"></span><span class="comment">//@}</span>
</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;
<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