📄 adsp-spiadc_documentation.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="#how_to_use_adsp-spiadc_driver" class="toc">How to use ADSP-SPIADC driver</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#introduction" class="toc">Introduction</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#interrupt_driven_spi_driver" class="toc">Interrupt driven SPI driver</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#dma_driven_spi_driver" class="toc">DMA driven SPI driver</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#building_the_adsp-spiadc_driver_into_the_kernel" class="toc">Building the ADSP-SPIADC driver into the Kernel</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#supported_driver_access_methods" class="toc">Supported driver access methods</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#driver_usage_example" class="toc">Driver usage example</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#act_as_master" class="toc">Act as master</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#act_as_slave" class="toc">Act as slave</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#spi_transfer_format" class="toc">SPI transfer format</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#supported_ioctl_function_calls" class="toc">Supported ioctl function calls</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="how_to_use_adsp-spiadc_driver" id="how_to_use_adsp-spiadc_driver">How to use ADSP-SPIADC driver</a></h2><div class="level2"><p>Michael Hennerich <br/> hennerich@blackfin.uclinux.org </p></div><!-- SECTION [1-95] --><h3><a name="introduction" id="introduction">Introduction</a></h3><div class="level3"><p> SPI is a serial transfer protocol with four interface signals: MISO, MOSI, SCLK, and SPISS. MISO and MOSI are data signals, SCLK is clock signal, and SPISS is a slave mode chip select signal. The ADSP-BF533/2/1 Blackfin processors have a single SPI port, and can generate 7 chip select signals when acting as master. Please refer to <a href="http://www.analog.com/blackfin" class="urlextern" title="http://www.analog.com/blackfin" rel="nofollow">Blackfin</a> <a href="http://www.analog.com/UploadedFiles/Data_Sheets/144127970ADSP_BF531_2_3_a.pdf" class="urlextern" title="http://www.analog.com/UploadedFiles/Data_Sheets/144127970ADSP_BF531_2_3_a.pdf" rel="nofollow">datasheet</a> and <a href="http://www.analog.com/processors/epManualsDisplay/0,2795,,00.html?SectionWeblawId=207&ContentID=35223&Language=English" class="urlextern" title="http://www.analog.com/processors/epManualsDisplay/0,2795,,00.html?SectionWeblawId=207&ContentID=35223&Language=English" rel="nofollow">Hardware Reference Manual</a> for more details.</p><p>In Linux, the SPI port can be operated by opening /dev/spi. In the Blackfin uClinux distribution there are two different SPI drivers available: an interrupt driven SPI driver (linux-2.6.x/drivers/char/spi.c), and a DMA driven (linux-2.6.x/drivers/char/adsp-spiadc.c) SPI driver. </p></div><!-- SECTION [96-1041] --><h3><a name="interrupt_driven_spi_driver" id="interrupt_driven_spi_driver">Interrupt driven SPI driver</a></h3><div class="level3"><p> When SPI sends a word, it receives a word at the same time. The number of words sent and received by the SPI port must be the same. If SPI wants to read (receive) data, it must write (send) data first. Be aware - the SPI will interrupt CPU when sending out a word, so large blocks of memory should not be sent out at one time. If large blocks of memory are sent, the CPU will be interrupted over 1k/second (Interrupt times depend on baud rate).</p></div><!-- SECTION [1042-1527] --><h3><a name="dma_driven_spi_driver" id="dma_driven_spi_driver">DMA driven SPI driver</a></h3><div class="level3"><p> The adsp-spiadc driver was mainly written to support different SPI serial Analog-to-Digital or Digital-to-Analog converters, however, this driver can be used for other SPI capable devices. Note that the SPI has a single DMA engine which can be configured to support either an SPI transmit channel, or a receive channel, but not both simultaneously. Therefore when configured as a transmit channel, the received data will be ignored. </p></div><!-- SECTION [1528-1996] --><h3><a name="building_the_adsp-spiadc_driver_into_the_kernel" id="building_the_adsp-spiadc_driver_into_the_kernel">Building the ADSP-SPIADC driver into the Kernel</a></h3><div class="level3"><pre class="code">make menuconfig Select "Kernel/Library/defaults Selection"Select "[*] Customize Kernel Settings"Select "Exit"Select "Exit"Select "Yes"</pre><p>Next dialog box</p><pre class="code">Select "Character Devices"Select "[*] Blackfin BF533/2/1 ADSP SPI ADC support"Select "Exit"Select "Exit"Select "Exit"Select "Yes"</pre><p> <a href="media/spi_makemenu.png" class="media" target="_blank" title="spi_makemenu.png"><img src="media/spi_makemenu.png" class="media" alt="" /></a></p></div><!-- SECTION [1997-2400] --><h3><a name="supported_driver_access_methods" id="supported_driver_access_methods">Supported driver access methods</a></h3><div class="level3"><p> <strong><code>int open(const char *path, int flags [, mode_t mode])</code></strong><br/> Open opens the file path for reading and/or writing, as specified by the flags argument and returns a descriptor for that file.</p><p><strong><code>ssize_t write(int d, const void *buf, size_t nbytes)</code></strong><br/> Write attempts to write nbytes of data to the object referenced by the descriptor d from the buffer pointed to by buf.</p><p><strong><code>ssize_t read(int d, void *buf, size_t nbytes)</code></strong><br/> Read attempts to read nbytes of data from the object referenced by the descriptor d into the buffer pointed to by buf.</p><p><strong><code>int ioctl(int d, int request, void *argp)</code></strong><br/> Ioctl performs a variety of functions on open descriptors. In particular, many operating characteristics of character special files (device driver) can be controlled with ioctl requests.</p><p><strong><code>int close(int d)</code></strong><br/> The close call deletes a descriptor from the per-process object reference table. If this is the last reference to the underlying object, then it will be deactivated. </p></div><!-- SECTION [2401-3432] --><h2><a name="driver_usage_example" id="driver_usage_example">Driver usage example</a></h2><div class="level2"><p> Following User Space example application shows how to open and close the device for read and write access. Several ioctls are used to configure the SPI - for more details see 鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -