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

📄 sample_dma_spi_driver.html

📁 ADI 公司blackfin系列的用户使用文挡。
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>  <title></title>  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#sample_spi_dma_driver" class="toc">Sample SPI DMA Driver</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#init_code" class="toc">Init Code</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#fops_table" class="toc">FOPS Table</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#open_function" class="toc">Open Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#read_function" class="toc">Read Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#irq_handler" class="toc">IRQ Handler</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#ioctl" class="toc">IOCTL</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#conclusions" class="toc">Conclusions</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="sample_spi_dma_driver" id="sample_spi_dma_driver">Sample SPI DMA Driver</a></h2><div class="level2"><p> This driver creates a char device to access a  AD7476A ADC ( Analog to Digital Converter ) ( see <a href="hardware_platform.html" class="wikilink1" title="hardware_platform.html">hardware_platform</a> )  attached to the SPI controller.</p><p>The device is an Analog to Digital Converter and the device driver reads a number of samples from the ADC finds a data trigger and then returned the samples to a user function.</p><p><img src="images/smileys/fixme.gif" align="middle" alt="FIXME" />: This document need to be updated with the latest common spi framework in the kernel. The kernel provide an interface for SPI drivers in <strong>linix-2.6.x/drivers/spi/</strong>. There are two driver can be used for reference: <strong>linix-2.6.x/drivers/char/bfin_spi_adc.c</strong> which working in DMA mode, and <strong>linux-2.6.x/drivers/mtd/devices/m25p80.c</strong>, which works in PIO mode.</p></div><!-- SECTION [1-738] --><h3><a name="init_code" id="init_code">Init Code</a></h3><div class="level3"><p> The first code sample to inspect is the init code for the driver.</p></div><!-- SECTION [739-923] --><h3><a name="fops_table" id="fops_table">FOPS Table</a></h3><div class="level3"><p> The next thing to look at is the file operations table Note the following </p><ul><li class="level1"><div class="li"> open, read, write, release functions as expected</div></li><li class="level1"><div class="li"> IOCTL function </div></li><li class="level1"><div class="li"> fasync notification function</div></li></ul><pre class="code c"><span class="kw4">static</span> <span class="kw4">struct</span> file_operations spi_fops = <span class="br0">&#123;</span>    owner:      THIS_MODULE,    read:       adc_spi_read,    write:      adc_spi_write,    ioctl:      adc_spi_ioctl,    open:       adc_spi_open,    release:    adc_spi_release,<span class="br0">&#125;</span>;</pre><p>This provides the basic <acronym title="Application Programming Interface">API</acronym> for the driver.</p></div><!-- SECTION [924-1421] --><h3><a name="open_function" id="open_function">Open Function</a></h3><div class="level3"><p> The <strong>spi_open</strong> function should be inspected next. Note the following in the driver: </p><ul><li class="level1"><div class="li"> There is a MINOR number check</div></li><li class="level1"><div class="li"> only one user at a time</div></li><li class="level1"><div class="li"> NON_BLOCKING operation is possible </div></li><li class="level1"><div class="li"> DMA 5 is used with an interrupt handler</div></li></ul></div><!-- SECTION [1422-1776] --><h3><a name="read_function" id="read_function">Read Function</a></h3><div class="level3"><p> In looking at this driver you can then proceed to the read but remember that there was an interrupt function attached to the DMA 5 completion.</p><p>Here is a section of the <strong>read</strong> function. Note the following: </p><ul><li class="level1"><div class="li"> use kmalloc to allocate a buffer</div></li><li class="level1"><div class="li"> invalidate the data cache for the new memory</div></li><li class="level1"><div class="li"> a device structure is used to control the device</div></li><li class="level1"><div class="li"> the spi device is set up</div></li><li class="level1"><div class="li"> the dma complete is assumed to trigger the interrupt</div></li><li class="level1"><div class="li"> the interrupt will trigger a wakeup to complete the read.</div></li></ul></div><!-- SECTION [1777-2390] --><h3><a name="irq_handler" id="irq_handler">IRQ Handler</a></h3><div class="level3"></div><!-- SECTION [2391-2415] --><h3><a name="ioctl" id="ioctl">IOCTL</a></h3><div class="level3"><p> The IOCTL function provides a means for the user space program to  modify the device function. Only part is produced here.</p><p>Each <strong>cmd</strong> is processed by a case statement</p></div><!-- SECTION [2416-2696] --><h3><a name="conclusions" id="conclusions">Conclusions</a></h3><div class="level3"><p> The basic data flow can be traced in this example.</p><p>The user code will open the device. Then the characteristics of the SPI device and the data trigger detection will be set up using IOCTL functions. Then the user will issue a read and the system will either read until it timeouts or it detects the trigger pattern in the data.</p><p>Refer to the actual code for more details. </p></div><!-- SECTION [2697-] --></body></html>

⌨️ 快捷键说明

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