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: ads7870.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>ads7870.h</h1><a href="ads7870_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file ads7870.h \brief TI ADS7870 12-bit 8ch A/D Converter Driver Library. */</span> |
||
9 | 00002 <span class="comment">//*****************************************************************************</span> |
||
10 | 00003 <span class="comment">//</span> |
||
11 | 00004 <span class="comment">// File Name : 'ads7870.h'</span> |
||
12 | 00005 <span class="comment">// Title : TI ADS7870 12-bit 8ch A/D Converter Driver Library</span> |
||
13 | 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2005</span> |
||
14 | 00007 <span class="comment">// Created : 2005.07.19</span> |
||
15 | 00008 <span class="comment">// Revised : 2005.07.21</span> |
||
16 | 00009 <span class="comment">// Version : 0.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">// NOTE: This code is currently below version 1.0, and therefore is considered</span> |
||
21 | 00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span> |
||
22 | 00015 <span class="comment">// tested. Nonetheless, you can expect most functions to work.</span> |
||
23 | 00016 <span class="comment">//</span> |
||
24 | 00017 <span class="comment">// This code is distributed under the GNU Public License</span> |
||
25 | 00018 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span> |
||
26 | 00019 <span class="comment">//</span><span class="comment"></span> |
||
27 | 00020 <span class="comment">/// \ingroup driver_hw</span> |
||
28 | 00021 <span class="comment">/// \defgroup ads7870 TI ADS7870 SPI A/D Converter Driver (ads7870.c)</span> |
||
29 | 00022 <span class="comment">/// \code #include "ads7870.h" \endcode</span> |
||
30 | 00023 <span class="comment">/// \par Overview</span> |
||
31 | 00024 <span class="comment">/// This library provides high-level functions for accessing the Texas</span> |
||
32 | 00025 <span class="comment">/// Instruments ADS7870 I2C A/D Converter.</span> |
||
33 | 00026 <span class="comment">///</span> |
||
34 | 00027 <span class="comment">/// The basic specs of the ADS7870 are:</span> |
||
35 | 00028 <span class="comment">/// - Fast SPI interface (up to 20MHz)</span> |
||
36 | 00029 <span class="comment">/// - 12-bit results</span> |
||
37 | 00030 <span class="comment">/// - 8 single-ended or 4 differential input channels</span> |
||
38 | 00031 <span class="comment">/// - Programmable gain stage (1,2,4,5,8,10,16,20x gains)</span> |
||
39 | 00032 <span class="comment">/// - Software or hardware triggered conversion</span> |
||
40 | 00033 <span class="comment">/// - 4-bit auxiliary digital I/O lines (controlled via serial interface)</span> |
||
41 | 00034 <span class="comment">/// - Up to 50KHz conversion rate</span> |
||
42 | 00035 <span class="comment">/// - External reference or internal 2.5V, 2.048V, 1.15V reference</span> |
||
43 | 00036 <span class="comment">/// - NOTE: use pin-compatible ADS7871 for 14-bit results</span> |
||
44 | 00037 <span class="comment"></span><span class="comment">//</span> |
||
45 | 00038 <span class="comment">//*****************************************************************************</span><span class="comment"></span> |
||
46 | 00039 <span class="comment">//@{</span> |
||
47 | 00040 <span class="comment"></span> |
||
48 | 00041 <span class="preprocessor">#ifndef ADS7870_H</span> |
||
49 | 00042 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_H</span> |
||
50 | 00043 <span class="preprocessor"></span> |
||
51 | 00044 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
52 | 00045 |
||
53 | 00046 <span class="comment">// constants/macros/typdefs</span> |
||
54 | 00047 <span class="preprocessor">#define ADS7870_CS_PORT PORTB</span> |
||
55 | 00048 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CS_DDR DDRB</span> |
||
56 | 00049 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CS_PIN PB0</span> |
||
57 | 00050 <span class="preprocessor"></span> |
||
58 | 00051 <span class="comment">// instruction bit defines</span> |
||
59 | 00052 <span class="preprocessor">#define ADS7870_CONVERT 0x80</span> |
||
60 | 00053 <span class="preprocessor"></span> |
||
61 | 00054 <span class="preprocessor">#define ADS7870_REG_READ 0x40</span> |
||
62 | 00055 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REG_WRITE 0x00</span> |
||
63 | 00056 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REG_16BIT 0x20</span> |
||
64 | 00057 <span class="preprocessor"></span> |
||
65 | 00058 <span class="comment">// register addresses</span> |
||
66 | 00059 <span class="preprocessor">#define ADS7870_RESULTLO 0x00</span> |
||
67 | 00060 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_RESULTHI 0x01</span> |
||
68 | 00061 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_PGAVALID 0x02</span> |
||
69 | 00062 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ADCTRL 0x03</span> |
||
70 | 00063 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAINMUX 0x04</span> |
||
71 | 00064 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_DIGIOSTATE 0x05</span> |
||
72 | 00065 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_DIGIOCTRL 0x06</span> |
||
73 | 00066 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC 0x07</span> |
||
74 | 00067 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_SERIFCTRL 0x18</span> |
||
75 | 00068 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ID 0x1F</span> |
||
76 | 00069 <span class="preprocessor"></span> |
||
77 | 00070 <span class="comment">// register bit defines</span> |
||
78 | 00071 <span class="preprocessor">#define ADS7870_RESULTLO_OVR 0x01</span> |
||
79 | 00072 <span class="preprocessor"></span> |
||
80 | 00073 <span class="preprocessor">#define ADS7870_ADCTRL_BIN 0x20</span> |
||
81 | 00074 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ADCTRL_RMB1 0x08</span> |
||
82 | 00075 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ADCTRL_RMB0 0x04</span> |
||
83 | 00076 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ADCTRL_CFD1 0x02</span> |
||
84 | 00077 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_ADCTRL_CFD0 0x01</span> |
||
85 | 00078 <span class="preprocessor"></span> |
||
86 | 00079 <span class="preprocessor">#define ADS7870_GAINMUX_CNVBSY 0x80</span> |
||
87 | 00080 <span class="preprocessor"></span> |
||
88 | 00081 <span class="preprocessor">#define ADS7870_REFOSC_OSCR 0x20</span> |
||
89 | 00082 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC_OSCE 0x10</span> |
||
90 | 00083 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC_REFE 0x08</span> |
||
91 | 00084 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC_BUFE 0x04</span> |
||
92 | 00085 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC_R2V 0x02</span> |
||
93 | 00086 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_REFOSC_RBG 0x01</span> |
||
94 | 00087 <span class="preprocessor"></span> |
||
95 | 00088 <span class="preprocessor">#define ADS7870_SERIFCTRL_LSB 0x01</span> |
||
96 | 00089 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_SERIFCTRL_2W3W 0x02</span> |
||
97 | 00090 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_SERIFCTRL_8051 0x04</span> |
||
98 | 00091 <span class="preprocessor"></span> |
||
99 | 00092 <span class="preprocessor">#define ADS7870_ID_VALUE 0x01</span> |
||
100 | 00093 <span class="preprocessor"></span> |
||
101 | 00094 <span class="comment">// gain defines</span> |
||
102 | 00095 <span class="preprocessor">#define ADS7870_GAIN_1X 0x00</span> |
||
103 | 00096 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_2X 0x10</span> |
||
104 | 00097 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_4X 0x20</span> |
||
105 | 00098 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_5X 0x30</span> |
||
106 | 00099 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_8X 0x40</span> |
||
107 | 00100 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_10X 0x50</span> |
||
108 | 00101 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_16X 0x60</span> |
||
109 | 00102 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_GAIN_20X 0x70</span> |
||
110 | 00103 <span class="preprocessor"></span><span class="comment">// channel defines</span> |
||
111 | 00104 <span class="preprocessor">#define ADS7870_CH_0_1_DIFF 0x00</span> |
||
112 | 00105 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_2_3_DIFF 0x01</span> |
||
113 | 00106 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_4_5_DIFF 0x02</span> |
||
114 | 00107 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_6_7_DIFF 0x03</span> |
||
115 | 00108 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_1_0_DIFF 0x04</span> |
||
116 | 00109 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_3_2_DIFF 0x05</span> |
||
117 | 00110 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_5_4_DIFF 0x06</span> |
||
118 | 00111 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_7_6_DIFF 0x07</span> |
||
119 | 00112 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_SINGLE_ENDED 0x08</span> |
||
120 | 00113 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_0 0x08</span> |
||
121 | 00114 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_1 0x09</span> |
||
122 | 00115 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_2 0x0A</span> |
||
123 | 00116 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_3 0x0B</span> |
||
124 | 00117 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_4 0x0C</span> |
||
125 | 00118 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_5 0x0D</span> |
||
126 | 00119 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_6 0x0E</span> |
||
127 | 00120 <span class="preprocessor"></span><span class="preprocessor">#define ADS7870_CH_7 0x0F</span> |
||
128 | 00121 <span class="preprocessor"></span> |
||
129 | 00122 <span class="comment">// functions</span> |
||
130 | 00123 <span class="comment"></span> |
||
131 | 00124 <span class="comment">//! Initialize the ADS7870 chip.</span> |
||
132 | 00125 <span class="comment">/// Returns:</span> |
||
133 | 00126 <span class="comment">/// TRUE if successful, </span> |
||
134 | 00127 <span class="comment">/// FALSE if unsuccessful (chip not responding).</span> |
||
135 | 00128 <span class="comment"></span>u08 <a class="code" href="group__ads7870.html#ga0">ads7870Init</a>(<span class="keywordtype">void</span>); |
||
136 | 00129 <span class="comment"></span> |
||
137 | 00130 <span class="comment">//! Begin single-ended conversion on given logical channel#0-7, and return result.</span> |
||
138 | 00131 <span class="comment">/// \note Result is returned left-justified.</span> |
||
139 | 00132 <span class="comment"></span>s16 <a class="code" href="group__ads7870.html#ga1">ads7870Convert</a>(u08 channel); |
||
140 | 00133 <span class="comment"></span> |
||
141 | 00134 <span class="comment">//! Begin differential conversion on given channel pair, and return result.</span> |
||
142 | 00135 <span class="comment">/// \note Result is returned left-justified.</span> |
||
143 | 00136 <span class="comment"></span>s16 <a class="code" href="group__ads7870.html#ga2">ads7870ConvertDiff</a>(u08 channel); |
||
144 | 00137 <span class="comment"></span> |
||
145 | 00138 <span class="comment">//! Begin conversion on given raw channel#, and return result.</span> |
||
146 | 00139 <span class="comment">/// \note Result is returned left-justified.</span> |
||
147 | 00140 <span class="comment"></span>s16 <a class="code" href="group__ads7870.html#ga3">ads7870ConvertRaw</a>(u08 channel); |
||
148 | 00141 <span class="comment"></span> |
||
149 | 00142 <span class="comment">//! Read value from ADS7870 register.</span> |
||
150 | 00143 <span class="comment">///</span> |
||
151 | 00144 <span class="comment"></span>u08 <a class="code" href="group__ads7870.html#ga4">ads7870ReadReg</a>(u08 reg); |
||
152 | 00145 <span class="comment"></span> |
||
153 | 00146 <span class="comment">//! Write value into ADS7870 register.</span> |
||
154 | 00147 <span class="comment">///</span> |
||
155 | 00148 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__ads7870.html#ga5">ads7870WriteReg</a>(u08 reg, u08 value); |
||
156 | 00149 |
||
157 | 00150 |
||
158 | 00151 |
||
159 | 00152 <span class="preprocessor">#endif</span> |
||
160 | 00153 <span class="preprocessor"></span><span class="comment">//@}</span> |
||
161 | </span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by |
||
162 | <a href="http://www.doxygen.org/index.html"> |
||
163 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
164 | </body> |
||
165 | </html> |
Powered by WebSVN v2.8.3