⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ad6620_8c-source.html

📁 方便飞利浦arm7tdmi 处理器lpc2100开发的C函数库 Procyon ARMlib-LPC2100 C-Language Function Library for Philips LPC21
💻 HTML
字号:
<!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 ARMlib-LPC2100: ad6620.c Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>ad6620.c</h1><a href="ad6620_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*! \file ad6620.c \brief Analog Devices AD6620 Digital Receiver Driver. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name    : 'ad6620.c'</span>00005 <span class="comment">// Title        : Analog Devices AD6620 Digital Receiver Driver</span>00006 <span class="comment">// Author       : Pascal Stang - Copyright (C) 2004</span>00007 <span class="comment">// Created      : 2004.07.08</span>00008 <span class="comment">// Revised      : 2004.07.12</span>00009 <span class="comment">// Version      : 0.1</span>00010 <span class="comment">// Target MCU   : ARM processors</span>00011 <span class="comment">// Editor Tabs  : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>00015 <span class="comment">// tested.  Nonetheless, you can expect most functions to work.</span>00016 <span class="comment">//</span>00017 <span class="comment">// This code is distributed under the GNU Public License</span>00018 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>00019 <span class="comment">//</span>00020 <span class="comment">//*****************************************************************************</span>00021 00022 <span class="preprocessor">#include "lpc210x.h"</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="timer_8h.html">timer.h</a>"</span>00026 <span class="preprocessor">#include "<a class="code" href="membus_8h.html">membus.h</a>"</span>00027 <span class="preprocessor">#include "<a class="code" href="rprintf_8h.html">rprintf.h</a>"</span>00028 <span class="preprocessor">#include "<a class="code" href="ad6620_8h.html">ad6620.h</a>"</span>00029 00030 <span class="comment">// global variables</span>00031 00032 <span class="keywordtype">void</span> ad6620Init(<span class="keywordtype">void</span>)00033 {00034     membusInit();00035 00036     <span class="comment">// reset device</span>00037     <span class="comment">//IOSET = AD9854_RESET;</span>00038     <span class="comment">//IODIR |= AD9854_RESET;</span>00039     <span class="comment">//delay(10000);</span>00040     <span class="comment">//IOCLR = AD9854_RESET;</span>00041 00042     <span class="comment">// initialize registers</span>00043 00044     <span class="comment">// initialize receiver - set soft reset</span>00045     ad6620WriteReg(AD6620_REG_MODE_CTRL, 0x01);00046     <span class="comment">// set NCO</span>00047     ad6620WriteReg(AD6620_REG_NCO_SYNC, 0);00048     ad6620WriteReg(AD6620_REG_NCO_PHASE, 0);00049     ad6620WriteReg(AD6620_REG_NCO_FREQ, 0);00050     <span class="comment">// set CIC2 filter</span>00051     ad6620WriteReg(AD6620_REG_CIC2_SCALE, 1);00052     ad6620WriteReg(AD6620_REG_CIC2_DECIM, 4-1);00053     <span class="comment">// set CIC5 filter</span>00054     ad6620WriteReg(AD6620_REG_CIC5_SCALE, 1);00055     ad6620WriteReg(AD6620_REG_CIC5_DECIM, 10-1);00056     <span class="comment">// set RCF filter</span>00057     ad6620WriteReg(AD6620_REG_RCF_CTRL, 1);00058     ad6620WriteReg(AD6620_REG_RCF_DECIM, 52-1);00059     ad6620WriteReg(AD6620_REG_RCFADDR_OFS, 0);00060     ad6620WriteReg(AD6620_REG_RCF_TAPS, 52-1);00061     <span class="comment">// set reserved register to zero</span>00062     ad6620WriteReg(AD6620_REG_RESERVED, 0x00);00063     <span class="comment">// initialize receiver - set operation mode</span>00064     ad6620WriteReg(AD6620_REG_MODE_CTRL, 0x08);00065 00066 }00067 00068 <span class="keywordtype">void</span> ad6620WriteReg(u16 reg, u32 data)00069 {00070     <span class="comment">// write address</span>00071     membusWrite(AD6620_REG_BASE+AD6620_REG_AMR, reg&gt;&gt;8);00072     membusRead(0);00073     membusWrite(AD6620_REG_BASE+AD6620_REG_LAR, reg);00074     membusRead(0);00075     <span class="comment">// write value</span>00076     membusWrite(AD6620_REG_BASE+AD6620_REG_DR3, data&gt;&gt;24);00077     membusRead(0);00078     membusWrite(AD6620_REG_BASE+AD6620_REG_DR2, data&gt;&gt;16);00079     membusRead(0);00080     membusWrite(AD6620_REG_BASE+AD6620_REG_DR1, data&gt;&gt;8);00081     membusRead(0);00082     membusWrite(AD6620_REG_BASE+AD6620_REG_DR0, data);00083     membusRead(0);00084 }00085 00086 00087 u32 ad6620ReadReg(u16 reg)00088 {00089     u32 data;00090     <span class="comment">// write address</span>00091     membusWrite(AD6620_REG_BASE+AD6620_REG_AMR, reg&gt;&gt;8);00092     membusRead(0);00093     membusWrite(AD6620_REG_BASE+AD6620_REG_LAR, reg);00094     membusRead(0);00095     <span class="comment">// read value</span>00096     data  = (membusRead(AD6620_REG_BASE+AD6620_REG_DR0) &amp; 0x000000FF);00097     membusRead(0);00098     data |= (membusRead(AD6620_REG_BASE+AD6620_REG_DR1) &amp; 0x000000FF)&lt;&lt;8;00099     membusRead(0);00100     data |= (membusRead(AD6620_REG_BASE+AD6620_REG_DR2) &amp; 0x000000FF)&lt;&lt;16;00101     membusRead(0);00102     data |= (membusRead(AD6620_REG_BASE+AD6620_REG_DR3) &amp; 0x000000FF)&lt;&lt;24;00103     membusRead(0);00104     <span class="keywordflow">return</span> data;00105 }00106 00107 <span class="keywordtype">void</span> ad6620ShowRegisters(<span class="keywordtype">void</span>)00108 {00109     <span class="comment">// read and print all registers</span>00110 00111     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Mode Control      :       "</span>);00112     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_MODE_CTRL));00113     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00114 00115     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"NCO Control       :       "</span>);00116     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_NCO_CTRL));00117     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00118 00119     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"NCO SYNC Control  : "</span>);00120     <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(ad6620ReadReg(AD6620_REG_NCO_SYNC));00121     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00122 00123     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"NCO Frequency     : "</span>);00124     <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(ad6620ReadReg(AD6620_REG_NCO_FREQ));00125     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00126 00127     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"NCO Phase Offset  :     "</span>);00128     <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(ad6620ReadReg(AD6620_REG_NCO_PHASE));00129     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00130 00131     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"INPUT/CIC2 Scale  :       "</span>);00132     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_CIC2_SCALE));00133     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00134 00135     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"CIC2 Decimation   :       "</span>);00136     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_CIC2_DECIM));00137     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00138 00139     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"CIC5 Scale        :       "</span>);00140     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_CIC5_SCALE));00141     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00142 00143     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"CIC5 Decimation   :       "</span>);00144     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_CIC5_DECIM));00145     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00146 00147     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"OUTPUT/RCF Control:       "</span>);00148     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_RCF_CTRL));00149     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00150 00151     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"RCF Decimation    :       "</span>);00152     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_RCF_DECIM));00153     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00154 00155     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"RCF Address Offset:       "</span>);00156     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_RCFADDR_OFS));00157     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00158 00159     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"RCF Taps          :       "</span>);00160     <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(ad6620ReadReg(AD6620_REG_RCF_TAPS));00161     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00162 }00163     </pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 13 03:38:11 2004 for Procyon ARMlib-LPC2100 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -