embeddedsw/XilinxProcessorIPLib/drivers/spi/doc/html/api/xspi_8c.html
Kedareswara rao Appana 9a24a3184e doxygen: Update doxygen for the drivers to include .h files in documentation.
This patch updates the doxygen for the drivers
spi,spips,srio,sysmon,tmrctr to include .h files
in the listof files provided in the index.html file.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
2014-09-02 11:21:40 +05:30

564 lines
34 KiB
HTML
Executable file

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>
Xilinx Driver spi v4_1: xspi.c File Reference
</title>
<link href="doxygen_kalyanidocs/doc/css/driver_api_doxygen.css" rel="stylesheet" type="text/css">
</head>
<h3 class="PageHeader">Xilinx Processor IP Library</h3>
<hl>Software Drivers</hl>
<hr class="whs1">
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>xspi.c File Reference</h1><code>#include &quot;<a class="el" href="xspi_8h.html">xspi.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="xspi__i_8h.html">xspi_i.h</a>&quot;</code><br/>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a44a2dc795761b35ed0ebdd6989675022">XSpi_Abort</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a48d8cea3864b01b7eed7320e83beacf1">XSpi_CfgInitialize</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr, <a class="el" href="struct_x_spi___config.html">XSpi_Config</a> *Config, u32 EffectiveAddr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a87fdaad742a2669200c9b2617e5c86ea">XSpi_Start</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#ad4bb67cfcfe73844ffb1917b11d5284c">XSpi_Stop</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a343938fcdf672bec329d876a146178cd">XSpi_Reset</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a4c44c082ef2d2b9cf4ba3db8bcebd954">XSpi_Transfer</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, unsigned int ByteCount)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a162523a3e9b29f063701db303ac8cf17">XSpi_SetSlaveSelect</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr, u32 SlaveMask)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u32&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#a8043891b8f68a3291bd035be74aa6b94">XSpi_GetSlaveSelect</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#abc09f4d503de2a772e5079ac46fc62b6">XSpi_SetStatusHandler</a> (<a class="el" href="struct_x_spi.html">XSpi</a> *InstancePtr, void *CallBackRef, <a class="el" href="xspi_8h.html#aa9c3c5101d73a626380c46bcc906069e">XSpi_StatusHandler</a> FuncPtr)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi_8c.html#af3863f11d27469d8797424319601c980">XSpi_InterruptHandler</a> (void *InstancePtr)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>Contains required functions of the <a class="el" href="struct_x_spi.html">XSpi</a> driver component. See <a class="el" href="xspi_8h.html">xspi.h</a> for a detailed description of the device and driver.</p>
<pre>
MODIFICATION HISTORY:</pre><pre> Ver Who Date Changes
----- ---- -------- -----------------------------------------------
1.00a rpm 10/11/01 First release
1.00b jhl 03/14/02 Repartitioned driver for smaller files.
1.00b rpm 04/25/02 Collapsed IPIF and reg base addresses into one
1.00b rmm 05/14/03 Fixed diab compiler warnings relating to asserts
1.01a jvb 12/13/05 Changed Initialize() into CfgInitialize(), and made
CfgInitialize() take a pointer to a config structure
instead of a device id. Moved Initialize() into
<a class="el" href="xspi__sinit_8c.html">xspi_sinit.c</a>, and had Initialize() call CfgInitialize()
after it retrieved the config structure using the device
id. Removed include of xparameters.h along with any
dependencies on xparameters.h and the _g.c config table.
1.11a wgr 03/22/07 Converted to new coding style.
1.11a rpm 01/22/08 Updated comment on Transfer regarding needing interrupts.
1.12a sdm 03/27/08 Updated the code to support 16/32 bit transfer width and
polled mode of operation. Even for the polled mode of
operation the Interrupt Logic in the core should be
included. The driver can be put in polled mode of
operation by disabling the Global Interrupt after the
Spi Initialization is completed.
2.00a sdm 07/30/08 Updated the code to support 16/32 bit transfer width and
polled mode of operation. Even for the polled mode of
operation the Interrupt Logic in the core should be
included. The driver can be put in polled mode of
operation by disabling the Global Interrupt after the
Spi Initialization is completed.
2.01b sdm 04/08/09 Fixed an issue in the XSpi_Transfer function where the
Global Interrupt is being enabled in polled mode when a
slave is not selected.
3.00a ktn 10/28/09 Updated all the register accesses as 32 bit access.
Updated to use the HAL APIs/macros.
Removed the macro XSpi_mReset, XSpi_Reset API should be
used in its place.
The macros have been renamed to remove _m from the name.
Removed an unnecessary read to the core register in the
XSpi_GetSlaveSelect API.
3.01a sdm 04/23/10 Updated the driver to handle new slave mode interrupts
and the DTR Half Empty interrupt.
3.04a bss 03/21/12 Updated XSpi_CfgInitialize to support XIP Mode
3.05a adk 18/04/13 Updated the code to avoid unused variable
warnings when compiling with the -Wextra -Wall flags
In the file <a class="el" href="xspi_8c.html">xspi.c</a>. CR:705005.
3.06a adk 07/08/13 Added a dummy read in the CfgInitialize(), if startup
block is used in the h/w design (CR 721229).
3.07a adk 11/10/13 In the xspi_transfer function moved the assert slave chip
select after the configuration of the Data Transmit
register inorder to work with CPOL and CPHA High Options.
As per spec (Dual/Quad SPI Transaction instrunction 7,8,9)
CR:732962
4.1 bss 08/07/14 Modified XSpi_Transfer to check for Interrupt Status
register Tx Empty bit instead of Status register
CR#810294.
</pre> <hr/><h2>Function Documentation</h2>
<a class="anchor" id="a44a2dc795761b35ed0ebdd6989675022"></a><!-- doxytag: member="xspi.c::XSpi_Abort" ref="a44a2dc795761b35ed0ebdd6989675022" args="(XSpi *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XSpi_Abort </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Aborts a transfer in progress by setting the stop bit in the control register, then resetting the FIFOs if present. The byte counts are cleared and the busy flag is set to false.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>This function does a read/modify/write of the control register. The user of this function needs to take care of critical sections. </p>
</div>
</div>
<a class="anchor" id="a48d8cea3864b01b7eed7320e83beacf1"></a><!-- doxytag: member="xspi.c::XSpi_CfgInitialize" ref="a48d8cea3864b01b7eed7320e83beacf1" args="(XSpi *InstancePtr, XSpi_Config *Config, u32 EffectiveAddr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XSpi_CfgInitialize </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="struct_x_spi___config.html">XSpi_Config</a> *&nbsp;</td>
<td class="paramname"> <em>Config</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u32&nbsp;</td>
<td class="paramname"> <em>EffectiveAddr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Initializes a specific <a class="el" href="struct_x_spi.html">XSpi</a> instance such that the driver is ready to use.</p>
<p>The state of the device after initialization is:</p>
<ul>
<li>Device is disabled</li>
<li>Slave mode</li>
<li>Active high clock polarity</li>
<li>Clock phase 0</li>
</ul>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>Config</em>&nbsp;</td><td>is a reference to a structure containing information about a specific SPI device. This function initializes an InstancePtr object for a specific device specified by the contents of Config. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>EffectiveAddr</em>&nbsp;</td><td>is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use Config-&gt;BaseAddress for this parameters, passing the physical address instead.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><ul>
<li>XST_SUCCESS if successful.</li>
<li>XST_DEVICE_IS_STARTED if the device is started. It must be stopped to re-initialize.</li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>None. </dd></dl>
</div>
</div>
<a class="anchor" id="a8043891b8f68a3291bd035be74aa6b94"></a><!-- doxytag: member="xspi.c::XSpi_GetSlaveSelect" ref="a8043891b8f68a3291bd035be74aa6b94" args="(XSpi *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">u32 XSpi_GetSlaveSelect </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Gets the current slave select bit mask for the SPI device.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The value returned is a 32-bit mask with a 1 in the bit position of the slave currently selected. The value may be zero if no slaves are selected.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>This API is used to get the current slave select bit mask that was set using the XSpi_SetSlaveSelect API. This API deos not read the register from the core and returns the slave select register stored in the instance pointer. </dd></dl>
</div>
</div>
<a class="anchor" id="af3863f11d27469d8797424319601c980"></a><!-- doxytag: member="xspi.c::XSpi_InterruptHandler" ref="af3863f11d27469d8797424319601c980" args="(void *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XSpi_InterruptHandler </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>The interrupt handler for SPI interrupts. This function must be connected by the user to an interrupt source. This function does not save and restore the processor context such that the user must provide this processing.</p>
<p>The interrupts that are handled are:</p>
<ul>
<li>Mode Fault Error. This interrupt is generated if this device is selected as a slave when it is configured as a master. The driver aborts any data transfer that is in progress by resetting FIFOs (if present) and resetting its buffer pointers. The upper layer software is informed of the error.</li>
</ul>
<ul>
<li>Data Transmit Register (FIFO) Empty. This interrupt is generated when the transmit register or FIFO is empty. The driver uses this interrupt during a transmission to continually send/receive data until there is no more data to send/receive.</li>
</ul>
<ul>
<li>Data Transmit Register (FIFO) Underrun. This interrupt is generated when the SPI device, when configured as a slave, attempts to read an empty DTR/FIFO. An empty DTR/FIFO usually means that software is not giving the device data in a timely manner. No action is taken by the driver other than to inform the upper layer software of the error.</li>
</ul>
<ul>
<li>Data Receive Register (FIFO) Overrun. This interrupt is generated when the SPI device attempts to write a received byte to an already full DRR/FIFO. A full DRR/FIFO usually means software is not emptying the data in a timely manner. No action is taken by the driver other than to inform the upper layer software of the error.</li>
</ul>
<ul>
<li>Slave Mode Fault Error. This interrupt is generated if a slave device is selected as a slave while it is disabled. No action is taken by the driver other than to inform the upper layer software of the error.</li>
</ul>
<ul>
<li>Command Error. This interrupt occurs when the first byte in the Tx FIFO, after the CS is asserted, doesn't match any command in the Lookup table. This interrupt is valid only for axi_qspi.</li>
</ul>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>The slave select register is being set to deselect the slave when a transfer is complete. This is being done regardless of whether it is a slave or a master since the hardware does not drive the slave select as a slave. </p>
</div>
</div>
<a class="anchor" id="a343938fcdf672bec329d876a146178cd"></a><!-- doxytag: member="xspi.c::XSpi_Reset" ref="a343938fcdf672bec329d876a146178cd" args="(XSpi *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XSpi_Reset </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Resets the SPI device by writing to the Software Reset register. Reset must only be called after the driver has been initialized. The configuration of the device after reset is the same as its configuration after initialization. Refer to the XSpi_Initialize function for more details. This is a hard reset of the device. Any data transfer that is in progress is aborted.</p>
<p>The upper layer software is responsible for re-configuring (if necessary) and restarting the SPI device after the reset.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>None. </dd></dl>
</div>
</div>
<a class="anchor" id="a162523a3e9b29f063701db303ac8cf17"></a><!-- doxytag: member="xspi.c::XSpi_SetSlaveSelect" ref="a162523a3e9b29f063701db303ac8cf17" args="(XSpi *InstancePtr, u32 SlaveMask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XSpi_SetSlaveSelect </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u32&nbsp;</td>
<td class="paramname"> <em>SlaveMask</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Selects or deselect the slave with which the master communicates. Each slave that can be selected is represented in the slave select register by a bit. The argument passed to this function is the bit mask with a 1 in the bit position of the slave being selected. Only one slave can be selected.</p>
<p>The user is not allowed to deselect the slave while a transfer is in progress. If no transfer is in progress, the user can select a new slave, which implicitly deselects the current slave. In order to explicitly deselect the current slave, a zero can be passed in as the argument to the function.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>SlaveMask</em>&nbsp;</td><td>is a 32-bit mask with a 1 in the bit position of the slave being selected. Only one slave can be selected. The SlaveMask can be zero if the slave is being deselected.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><ul>
<li>XST_SUCCESS if the slave is selected or deselected successfully.</li>
<li>XST_DEVICE_BUSY if a transfer is in progress, slave cannot be changed</li>
<li>XST_SPI_TOO_MANY_SLAVES if more than one slave is being selected.</li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>This function only sets the slave which will be selected when a transfer occurs. The slave is not selected when the SPI is idle. The slave select has no affect when the device is configured as a slave. </p>
</div>
</div>
<a class="anchor" id="abc09f4d503de2a772e5079ac46fc62b6"></a><!-- doxytag: member="xspi.c::XSpi_SetStatusHandler" ref="abc09f4d503de2a772e5079ac46fc62b6" args="(XSpi *InstancePtr, void *CallBackRef, XSpi_StatusHandler FuncPtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void XSpi_SetStatusHandler </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>CallBackRef</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="xspi_8h.html#aa9c3c5101d73a626380c46bcc906069e">XSpi_StatusHandler</a>&nbsp;</td>
<td class="paramname"> <em>FuncPtr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets the status callback function, the status handler, which the driver calls when it encounters conditions that should be reported to the higher layer software. The handler executes in an interrupt context, so it must minimize the amount of processing performed such as transferring data to a thread context. One of the following status events is passed to the status handler. </p>
<pre><ul>
<li>XST_SPI_MODE_FAULT A mode fault error occurred, meaning another
master tried to select this device as a slave
when this device was configured to be a master.
Any transfer in progress is aborted.</li>
</ul>
</pre><pre><ul>
<li>XST_SPI_TRANSFER_DONE The requested data transfer is done</li>
</ul>
</pre><pre><ul>
<li>XST_SPI_TRANSMIT_UNDERRUN As a slave device, the master clocked
data but there were none available in the
transmit register/FIFO. This typically means the
slave application did not issue a transfer
request fast enough, or the processor/driver
could not fill the transmit register/FIFO fast
enough.</li>
</ul>
</pre><pre><ul>
<li>XST_SPI_RECEIVE_OVERRUN The SPI device lost data. Data was received
but the receive data register/FIFO was full.
This indicates that the device is receiving data
faster than the processor/driver can consume it.</li>
</ul>
</pre><pre><ul>
<li>XST_SPI_SLAVE_MODE_FAULT A slave SPI device was selected as a slave while
it was disabled. This indicates the master is
already transferring data (which is being
dropped until the slave application issues a
transfer).
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.
</td></tr>
<tr><td valign="top"></td><td valign="top"><em>CallBackRef</em>&nbsp;</td><td>is the upper layer callback reference passed back
when the callback function is invoked.
</td></tr>
<tr><td valign="top"></td><td valign="top"><em>FuncPtr</em>&nbsp;</td><td>is the pointer to the callback function.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
The handler is called within interrupt context, so it should do its work
quickly and queue potentially time-consuming work to a task-level thread.
</li>
</ul>
</pre>
</div>
</div>
<a class="anchor" id="a87fdaad742a2669200c9b2617e5c86ea"></a><!-- doxytag: member="xspi.c::XSpi_Start" ref="a87fdaad742a2669200c9b2617e5c86ea" args="(XSpi *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XSpi_Start </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>This function enables interrupts for the SPI device. If the Spi driver is used in interrupt mode, it is up to the user to connect the SPI interrupt handler to the interrupt controller before this function is called. If the Spi driver is used in polled mode the user has to disable the Global Interrupts after this function is called. If the device is configured with FIFOs, the FIFOs are reset at this time.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><ul>
<li>XST_SUCCESS if the device is successfully started</li>
<li>XST_DEVICE_IS_STARTED if the device was already started.</li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>None. </dd></dl>
</div>
</div>
<a class="anchor" id="ad4bb67cfcfe73844ffb1917b11d5284c"></a><!-- doxytag: member="xspi.c::XSpi_Stop" ref="ad4bb67cfcfe73844ffb1917b11d5284c" args="(XSpi *InstancePtr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XSpi_Stop </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>This function stops the SPI device by disabling interrupts and disabling the device itself. Interrupts are disabled only within the device itself. If desired, the caller is responsible for disabling interrupts in the interrupt controller and disconnecting the interrupt handler from the interrupt controller.</p>
<p>In interrupt mode, if the device is in progress of transferring data on the SPI bus, this function returns a status indicating the device is busy. The user will be notified via the status handler when the transfer is complete, and at that time can again try to stop the device. As a master, we do not allow the device to be stopped while a transfer is in progress because the slave may be left in a bad state. As a slave, we do not allow the device to be stopped while a transfer is in progress because the master is not done with its transfer yet.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><ul>
<li>XST_SUCCESS if the device is successfully started.</li>
<li>XST_DEVICE_BUSY if a transfer is in progress and cannot be stopped.</li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd></dd></dl>
<p>This function makes use of internal resources that are shared between the <a class="el" href="xspi_8c.html#ad4bb67cfcfe73844ffb1917b11d5284c">XSpi_Stop()</a> and <a class="el" href="xspi_8h.html#a67c2076b133a55b6f80343642a1ace41">XSpi_SetOptions()</a> functions. So if one task might be setting device options while another is trying to stop the device, the user is is required to provide protection of this shared data (typically using a semaphore). </p>
</div>
</div>
<a class="anchor" id="a4c44c082ef2d2b9cf4ba3db8bcebd954"></a><!-- doxytag: member="xspi.c::XSpi_Transfer" ref="a4c44c082ef2d2b9cf4ba3db8bcebd954" args="(XSpi *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, unsigned int ByteCount)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int XSpi_Transfer </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&nbsp;</td>
<td class="paramname"> <em>InstancePtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u8 *&nbsp;</td>
<td class="paramname"> <em>SendBufPtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u8 *&nbsp;</td>
<td class="paramname"> <em>RecvBufPtr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>ByteCount</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Transfers the specified data on the SPI bus. If the SPI device is configured to be a master, this function initiates bus communication and sends/receives the data to/from the selected SPI slave. If the SPI device is configured to be a slave, this function prepares the data to be sent/received when selected by a master. For every byte sent, a byte is received.</p>
<p>This function/driver operates in interrupt mode and polled mode.</p>
<ul>
<li>In interrupt mode this function is non-blocking and the transfer is initiated by this function and completed by the interrupt service routine.</li>
<li>In polled mode this function is blocking and the control exits this function only after all the requested data is transferred.</li>
</ul>
<p>The caller has the option of providing two different buffers for send and receive, or one buffer for both send and receive, or no buffer for receive. The receive buffer must be at least as big as the send buffer to prevent unwanted memory writes. This implies that the byte count passed in as an argument must be the smaller of the two buffers if they differ in size. Here are some sample usages: </p>
<pre>
XSpi_Transfer(InstancePtr, SendBuf, RecvBuf, ByteCount)
The caller wishes to send and receive, and provides two different
buffers for send and receive.</pre><pre> XSpi_Transfer(InstancePtr, SendBuf, NULL, ByteCount)
The caller wishes only to send and does not care about the received
data. The driver ignores the received data in this case.</pre><pre> XSpi_Transfer(InstancePtr, SendBuf, SendBuf, ByteCount)
The caller wishes to send and receive, but provides the same buffer
for doing both. The driver sends the data and overwrites the send
buffer with received data as it transfers the data.</pre><pre> XSpi_Transfer(InstancePtr, RecvBuf, RecvBuf, ByteCount)
The caller wishes to only receive and does not care about sending
data. In this case, the caller must still provide a send buffer, but
it can be the same as the receive buffer if the caller does not care
what it sends. The device must send N bytes of data if it wishes to
receive N bytes of data.
</pre><p> In interrupt mode, though this function takes a buffer as an argument, the driver can only transfer a limited number of bytes at time. It transfers only one byte at a time if there are no FIFOs, or it can transfer the number of bytes up to the size of the FIFO if FIFOs exist.</p>
<ul>
<li>In interrupt mode a call to this function only starts the transfer, the subsequent transfer of the data is performed by the interrupt service routine until the entire buffer has been transferred.The status callback function is called when the entire buffer has been sent/received.</li>
<li>In polled mode this function is blocking and the control exits this function only after all the requested data is transferred.</li>
</ul>
<p>As a master, the SetSlaveSelect function must be called prior to this function.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>InstancePtr</em>&nbsp;</td><td>is a pointer to the <a class="el" href="struct_x_spi.html">XSpi</a> instance to be worked on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>SendBufPtr</em>&nbsp;</td><td>is a pointer to a buffer of data which is to be sent. This buffer must not be NULL. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>RecvBufPtr</em>&nbsp;</td><td>is a pointer to a buffer which will be filled with received data. This argument can be NULL if the caller does not wish to receive data. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>ByteCount</em>&nbsp;</td><td>contains the number of bytes to send/receive. The number of bytes received always equals the number of bytes sent.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>-XST_SUCCESS if the buffers are successfully handed off to the driver for transfer. Otherwise, returns:<ul>
<li>XST_DEVICE_IS_STOPPED if the device must be started before transferring data.</li>
<li>XST_DEVICE_BUSY indicates that a data transfer is already in progress. This is determined by the driver.</li>
<li>XST_SPI_NO_SLAVE indicates the device is configured as a master and a slave has not yet been selected.</li>
</ul>
</dd></dl>
<p>This function is not thread-safe. The higher layer software must ensure that no two threads are transferring data on the SPI bus at the same time. </p>
</div>
</div>
</div>
<p class="Copyright">
Copyright &copy; 1995-2014 Xilinx, Inc. All rights reserved.
</p>
</body>
</html>