📄 periph_io_requests.htm
字号:
<html><!-- InstanceBegin template="/Templates/helpnav.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Function Driver IO requests</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<!-- InstanceParam name="HeaderColor" type="color" value="#0000FF" -->
<!-- InstanceParam name="FooterColor" type="color" value="#0000FF" -->
<!-- InstanceParam name="NavBackgroundColor" type="color" value="#FFFFFF" -->
<!-- InstanceParam name="BodyBackgroundColor" type="color" value="#FFFFFF" -->
<link href="CodeTHelp.css" rel="stylesheet" type="text/css">
</head><a name="TopTopic"></a>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="40%" rowspan="2" bgcolor="#0000FF"><a href="http://www.codetelligence.com"><img src="Images/codetelligence_lrg.gif" name="image" width="252" height="40" border="0"></a></td>
<td width="60%" height="62" bgcolor="#0000FF">
<font color="#FFFFFF" size="5" face="Arial, Helvetica, sans-serif"><strong>Embedded SDIO Driver Kit Help </strong></font></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="93%"><font face="Arial, Helvetica, sans-serif">
<p class="Topic"><!-- InstanceBeginEditable name="SubTemplate" --> Function
Driver IO requests<!-- InstanceEndEditable --> </p>
</font></td>
<td><!-- InstanceBeginEditable name="NavBack" --><a href="periph_callbacks.htm"><img src="Images/leftarrow.gif" width="27" height="32" border="0"></a><!-- InstanceEndEditable --></td><td><!-- InstanceBeginEditable name="Nav" --><a href="periph_using_irqs.htm"><img src="Images/rightarrow.gif" width="27" height="32" border="0"></a><!-- InstanceEndEditable --></td>
</tr>
</table>
<hr>
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr><td><!-- InstanceBeginEditable name="Help Content" -->
<OBJECT type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="Function Driver IO requests">
</OBJECT>
<p class="BODYTEXT">Function drivers issue bus requests through the SDIO
core whose job is to serialize the request and route the request to the proper
host controller slot. The SDIO core provides an interface for function drivers
to build card-specific bus requests as well as a set of functions to build
and send standard requests. The interface allows for both blocking and non-blocking
I/O. The
basic operation for issuing a bus request can be described in the following
steps:</p>
<p class="BODYTEXT">1. Allocate a bus request structure.<br>
2. Set the SD command and Argument fields (specific to the command)
<br>
3. Set the bus flags for the transaction (flags include synch or asynch, read
or write
data present)<br>
4. If the transaction involves data (read or write) set the buffer pointer,
block
size
and
length.
<br>5. If the transaction is non-blocking (asynchronous) set a completion routine.<br>
6. Once the request completes a new request can be issued using the same request
structure
or it can be returned back to the core.<br>
<p class="BODYTEXT"><a name="KeyBusRequestFields"></a>Key fields of the <font face="Courier New, Courier, mono">SDREQUEST</font> structure are described below:
<table style="WIDTH: 635px; HEIGHT: 386px" cellspacing="1"
cellpadding="1" width="635" border="1">
<tr>
<td width="161">
<p><font face="Courier New" size="2"><strong>Field</strong></font></p>
</td>
<td width="461"><strong>Description</strong></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">Flags</font></p>
</td>
<td><font face="Arial">Bus request flags that define the response type (if
any), the I/O mode (synchronous, asychronous) and other
processing flags.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">Argument</font></p>
</td>
<td><font face="Arial">The 32 bit argument that is sent in the SD/MMC/SDIO
command packet.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">Command</font></p>
</td>
<td><font face="Arial">The 8-bit command sent in the command packet.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">Response</font></p>
</td>
<td><font face="Arial">A buffer containing the response returned from the
card (if any). This buffer has enough space for all standard
responses (SD/SDIO/MMC).</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">BlockCount</font></p>
</td>
<td><font face="Arial">If the request requires a data transfer phase, this
is the number of blocks to transfer. </font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">BlockLen</font></p>
</td>
<td><font face="Arial">If the request requires a data transfer phase, this
is the number of bytes per block.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">pDataBuffer</font></p>
</td>
<td><font face="Arial">Input/output buffer for a data transfer phase. The
length of this buffer must be at least (<font face="Courier New, Courier, mono">BlockCount</font> x <font face="Courier New, Courier, mono">BlockLen</font>)
bytes. When DMA is used, this points to a DMA descriptor
list instead of a buffer (see <a href="#DMAOperation">Direct
Memory Access</a>).</font></td>
</tr>
<tr>
<td>
<p><font size="2" face="Courier New">DescriptorCount</font></p>
</td>
<td><font face="Arial">If DMA is used, this is the number
of entries in the DMA descriptor list pointed to by <font face="Courier New, Courier, mono">pDataBuffer</font>.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">pCompletion</font></p>
</td>
<td><font face="Arial">A completion routine provided by the function driver
when this request is submitted asynchronously.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">pCompleteContext</font></p>
</td>
<td><font face="Arial">A context for the completion routine, if this is an
asynchronous , non-blocking request.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">Status</font></p>
</td>
<td><font face="Arial">This value represents the final completion status
of the request.</font></td>
</tr>
<tr>
<td>
<p><font face="Courier New" size="2">RetryCount</font></p>
</td>
<td><font face="Arial">A function driver can set a non-zero retry count to
direct the bus driver to retry the bus request on CRC
or response timeout errors. Function drivers should not set
this value for requests containing a data transfer phase.
Most cards require special handling when data transfers fail
(with CRC or timeout) such as issuing CMD12 (stop) or issuing
an I/O abort operation (SDIO).</font></td>
</tr>
</table>
</p>
<p class="BODYTEXT">Specific examples of this process can be found in the generic
driver sample(s) provided in this SDK.</p>
<p class="HEADING3">Synchronous I/O:</p>
<p class="BODYTEXT">
The SD Core by default processes all SDIO request synchronously. The call
to <font face="Courier New, Courier, mono"><a href="PD_Reference.htm#FUNC_SDDEVICE_CALL_REQUEST_FUNC">SDDEVICE_CALL_REQUEST_FUNC()</a></font> blocks
and returns only when the entire transaction completes with success
or failure. The driver should process the response and/or data and
either
reuse the allocated request for the next transaction or recycle it
back to the SDIO core. The completion status of the request is returned
by the function.</p>
<p class="HEADING3">Asynchronous I/O:</p>
<p class="BODYTEXT">Asynchronous
mode is typically used when a function driver must issue a bus request
in a non-blocking context. Some OS's require that certain operations
are performed in non-blocking contexts. For example, a network driver may be
restricted in the way it issues transmit packets and may be required to return
from it's TX handler while the packet is transmitting. With regards to SDIO
request, the driver can set a completion routine, issue the request and return
immediately. An asynchronous request is assembled much like a synchronous request
with the exception that the <font face="Courier New, Courier, mono">SDREQ_FLAGS_TRANS_ASYNC,</font>completion
routine and completion routine context are set. The call to <font face="Courier New, Courier, mono"><a href="PD_Reference.htm#FUNC_SDDEVICE_CALL_REQUEST_FUNC">SDDEVICE_CALL_REQUEST_FUNC()</a></font>will
always return <font face="Courier New, Courier, mono">SDIO_STATUS_PENDING</font> when
the request is flagged for asynchronous operation. The completion routine will
be called whether the request succeeded or failed. Under some circumstances
the completion routine may be called in the same context where the request
was
issued.
This can occur if the request fails during some portion of the transaction
setup and before the request was actually submitted to the host controller.
Additionally, a host controller could complete a request immediately (success
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -