📄 hd_reference.htm
字号:
<br>
</p>
</blockquote>
<p class="FUNCHEADINGS">Example: </p>
<blockquote>
<p class="BODYCODE">
<pre>
<font face="Arial, Helvetica, sans-serif" color="#FF00FF"> test for non-CRC SPI mode:</font>
if (IS_HCD_BUS_MODE_SPI_NO_CRC(&pHct->Hcd)) {
.. disable CRC checking in hardware.
</pre>
</p>
</blockquote>
<p class="FUNCHEADINGS">See also:</p>
<blockquote>
<p class="BODYTEXT"></p>
</blockquote>
</td>
</tr>
</table>
<a name="FUNC_Request"></a>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#0000FF" rowspan="2" width="40%"><a href="http://www.codetelligence.com"><img border="0" height="40" width="252" name="image" src="Images/codetelligence_lrg.gif"></a></td><td bgcolor="#0000FF" height="62" width="50%"><font face="Arial, Helvetica, sans-serif" size="5" color="#FFFFFF"><strong>Codetelligence Embedded SDIO Stack<br>Host Controller Driver Documentation</strong></font></td><td bgcolor="#0000FF" height="62" width="10%"><td><a href="#FUNC_IS_HCD_BUS_MODE_SPI_NO_CRC"><img border="0" height="32" width="27" src="Images/leftarrow.gif"></a></td><td><a href="#FUNC_SDHCD_GET_OPER_CLOCK"><img border="0" height="32" width="27" src="Images/rightarrow.gif"></a></td></td>
</tr>
</table>
<table cellpadding="0" cellspacing="10" border="0" width="100%">
<tr>
<td width="93%"><font face="Arial, Helvetica, sans-serif"><span class="Topic">
<blockquote>
<table width="100%" cellspacing="0" cellpadding="0">
<td>
<br>
<pre>
<span class="FUNCPROTOTYPE">
SDIO_STATUS (*pRequest) (struct _SDHCD *pHcd)
</span>
</pre>
</td>
</table>
</blockquote>
</span></font></td>
</tr>
</table>
<hr>
<table cellpadding="15" cellspacing="0" border="0" width="100%">
<tr>
<td>
<p class="FUNCHEADINGS">Description:</p>
<blockquote>
<p class="BODYTEXT">The bus driver calls the request callback to start an SDIO bus transaction.</p>
</blockquote>
<p class="FUNCHEADINGS">Parameters:</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Inputs:</p>
<blockquote>
<p class="BODYTEXT">
pHcd - the host controller structure that was registered
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Outputs:</p>
<blockquote>
<p class="BODYTEXT">
none
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Returns:</p>
<blockquote>
<p class="BODYCODE">
SDIO_STATUS
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="FUNCHEADINGS">Notes:</p>
<blockquote>
<p class="BODYTEXT">
The bus driver maintains an internal queue of SDREQUEST structures submited by function
drivers. The driver should use request macros to obtain a pointer to the current SDREQUEST
at the head of the queue. The driver can access the fields of the current request in order
to program hardware appropriately. Once the request completes, the driver should update
the current request information (final status, response bytes and/or data) and call
SDIO_HandleHcdEvent() with the event type of EVENT_HCD_TRANSFER_DONE.
The bus driver will remove the current request from the head of the queue and start the next
request.
<br>
</p>
</blockquote>
<p class="FUNCHEADINGS">Example: </p>
<blockquote>
<p class="BODYCODE">
<pre>
<font face="Arial, Helvetica, sans-serif" color="#FF00FF"> Example of a typical Request callback:</font>
SDIO_STATUS HcdRequest(PSDHCD pHcd)
{
SDIO_STATUS status = SDIO_STATUS_SUCCESS;
PSDHCD_DRIVER_CONTEXT pHct = (PSDHCD_DRIVER_CONTEXT)pHcd->pContext;
UINT32 temp = 0;
PSDREQUEST pReq;
<font face="Arial, Helvetica, sans-serif" color="#999999">// get the current request
</font> pReq = GET_CURRENT_REQUEST(pHcd);
DBG_ASSERT(pReq != NULL);
<font face="Arial, Helvetica, sans-serif" color="#999999">// get controller settings based on response type
</font> switch (GET_SDREQ_RESP_TYPE(pReq->Flags)) {
case SDREQ_FLAGS_NO_RESP:
break;
case SDREQ_FLAGS_RESP_R1:
case SDREQ_FLAGS_RESP_MMC_R4:
case SDREQ_FLAGS_RESP_MMC_R5:
case SDREQ_FLAGS_RESP_R6:
case SDREQ_FLAGS_RESP_SDIO_R5:
temp |= CMDDAT_RES_R1_R4_R5;
break;
case SDREQ_FLAGS_RESP_R1B:
temp |= (CMDDAT_RES_R1_R4_R5 | CMDAT_RES_BUSY);
break;
case SDREQ_FLAGS_RESP_R2:
temp |= CMDDAT_RES_R2;
break;
case SDREQ_FLAGS_RESP_R3:
case SDREQ_FLAGS_RESP_SDIO_R4:
temp |= CMDDAT_RES_R3;
break;
}
<font face="Arial, Helvetica, sans-serif" color="#999999">// check for data
</font> if (pReq->Flags & SDREQ_FLAGS_DATA_TRANS){
temp |= CMDDAT_DATA_EN;
<font face="Arial, Helvetica, sans-serif" color="#999999">// set data remaining count
</font> pReq->DataRemaining = pReq->BlockLen * pReq->BlockCount;
DBG_PRINT(TRACE_DATA, ("SDIO %s Data Transfer, Blocks:%d, BlockLen:%d, Total:%d \n",
IS_SDREQ_WRITE_DATA(pReq->Flags) ? "TX":"RX",
pReq->BlockCount, pReq->BlockLen, pReq->DataRemaining));
if (IS_SDREQ_WRITE_DATA(pReq->Flags)) {
<font face="Arial, Helvetica, sans-serif" color="#999999">// write operation
</font> }
}
<font face="Arial, Helvetica, sans-serif" color="#999999">// .... program hardware, interrupt handler will complete request
</font> return SDIO_STATUS_PENDING;
</pre>
</p>
</blockquote>
<p class="FUNCHEADINGS">See also:</p>
<blockquote>
<p class="BODYTEXT">
<a href="#FUNC_SDIO_HandleHcdEvent">
SDIO_HandleHcdEvent
</a>
<br>
</p>
</blockquote>
</td>
</tr>
</table>
<a name="FUNC_SDHCD_GET_OPER_CLOCK"></a>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#0000FF" rowspan="2" width="40%"><a href="http://www.codetelligence.com"><img border="0" height="40" width="252" name="image" src="Images/codetelligence_lrg.gif"></a></td><td bgcolor="#0000FF" height="62" width="50%"><font face="Arial, Helvetica, sans-serif" size="5" color="#FFFFFF"><strong>Codetelligence Embedded SDIO Stack<br>Host Controller Driver Documentation</strong></font></td><td bgcolor="#0000FF" height="62" width="10%"><td><a href="#FUNC_Request"><img border="0" height="32" width="27" src="Images/leftarrow.gif"></a></td><td><a href="#FUNC_SDIO_CheckResponse"><img border="0" height="32" width="27" src="Images/rightarrow.gif"></a></td></td>
</tr>
</table>
<table cellpadding="0" cellspacing="10" border="0" width="100%">
<tr>
<td width="93%"><font face="Arial, Helvetica, sans-serif"><span class="Topic">
<blockquote>
<table width="100%" cellspacing="0" cellpadding="0">
<td>
<br>
<pre>
<span class="FUNCPROTOTYPE">
SD_BUSCLOCK_RATE SDHCD_GET_OPER_CLOCK(PSDHCD pHcd)
</span>
</pre>
</td>
</table>
</blockquote>
</span></font></td>
</tr>
</table>
<hr>
<table cellpadding="15" cellspacing="0" border="0" width="100%">
<tr>
<td>
<p class="FUNCHEADINGS">Description:</p>
<blockquote>
<p class="BODYTEXT">Get host controller's current operational bus clock</p>
</blockquote>
<p class="FUNCHEADINGS">Parameters:</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Inputs:</p>
<blockquote>
<p class="BODYTEXT">
pHcd - the registered host structure
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Outputs:</p>
<blockquote>
<p class="BODYTEXT">
none
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Returns:</p>
<blockquote>
<p class="BODYCODE">
clock rate
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="FUNCHEADINGS">Notes:</p>
<blockquote>
<p class="BODYTEXT">
Implemented as a macro. Returns the current bus clock rate.
<br>
</p>
</blockquote>
<p class="FUNCHEADINGS">Example: </p>
<blockquote>
<p class="BODYCODE">
<pre></pre>
</p>
</blockquote>
<p class="FUNCHEADINGS">See also:</p>
<blockquote>
<p class="BODYTEXT"></p>
</blockquote>
</td>
</tr>
</table>
<a name="FUNC_SDIO_CheckResponse"></a>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#0000FF" rowspan="2" width="40%"><a href="http://www.codetelligence.com"><img border="0" height="40" width="252" name="image" src="Images/codetelligence_lrg.gif"></a></td><td bgcolor="#0000FF" height="62" width="50%"><font face="Arial, Helvetica, sans-serif" size="5" color="#FFFFFF"><strong>Codetelligence Embedded SDIO Stack<br>Host Controller Driver Documentation</strong></font></td><td bgcolor="#0000FF" height="62" width="10%"><td><a href="#FUNC_SDHCD_GET_OPER_CLOCK"><img border="0" height="32" width="27" src="Images/leftarrow.gif"></a></td><td><a href="#FUNC_SDIO_HandleHcdEvent"><img border="0" height="32" width="27" src="Images/rightarrow.gif"></a></td></td>
</tr>
</table>
<table cellpadding="0" cellspacing="10" border="0" width="100%">
<tr>
<td width="93%"><font face="Arial, Helvetica, sans-serif"><span class="Topic">
<blockquote>
<table width="100%" cellspacing="0" cellpadding="0">
<td>
<br>
<pre>
<span class="FUNCPROTOTYPE">
SDIO_STATUS SDIO_CheckResponse(PSDHCD pHcd, PSDREQUEST pReq, SDHCD_RESPONSE_CHECK_MODE CheckMode)
</span>
</pre>
</td>
</table>
</blockquote>
</span></font></td>
</tr>
</table>
<hr>
<table cellpadding="15" cellspacing="0" border="0" width="100%">
<tr>
<td>
<p class="FUNCHEADINGS">Description:</p>
<blockquote>
<p class="BODYTEXT">Check an SD/MMC/SDIO response.</p>
</blockquote>
<p class="FUNCHEADINGS">Parameters:</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Inputs:</p>
<blockquote>
<p class="BODYTEXT">
pHcd - the host controller definition structure.
<br>
pReq - request containing the response
<br>
CheckMode - mode
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Outputs:</p>
<blockquote>
<p class="BODYTEXT"></p>
</blockquote>
</blockquote>
</p>
<p class="BODYTEXT">
<blockquote>
<p class="BODYTEXT">Returns:</p>
<blockquote>
<p class="BODYCODE">
SDIO_STATUS
<br>
</p>
</blockquote>
</blockquote>
</p>
<p class="FUNCHEADINGS">Notes:</p>
<blockquote>
<p class="BODYTEXT">
Host controller drivers must call into this function to validate various command
responses before continuing with data transfers or for decoding received SPI tokens.
The CheckMode option determines the type of validation to perform.
if (CheckMode == SDHCD_CHECK_DATA_TRANS_OK) :
The host controller must check the card response to determine whether it
is safe to perform a data transfer. This API only checks commands that
involve data transfers and checks various status fields in the command response.
If the card cannot accept data, this function will return a non-successful status that
should be treated as a request failure. The host driver should complete the request with the
returned status. Host controller should only call this function in preparation for a
data transfer.
if (CheckMode == SDHCD_CHECK_SPI_TOKEN) :
This API checks the SPI token and returns a timeout status if the illegal command bit is
set. This simulates the behavior of SD 1/4 bit operation where illegal commands result in
a command timeout. A driver that supports SPI mode should pass every response to this
function to determine the appropriate error status to complete the request with. If the
API returns success, the response indicates that the card accepted the command.
<br>
</p>
</blockquote>
<p class="FUNCHEADINGS">Example: </p>
<blockquote>
<p class="BODYCODE">
<pre>
<font face="Arial, Helvetica, sans-serif" color="#FF00FF"> Checking the response before starting the data transfer :</font>
if (SDIO_SUCCESS(status) && (pReq->Flags & SDREQ_FLAGS_DATA_TRANS)) {
<font face="Arial, Helvetica, sans-serif" color="#999999">// check the response to see if we should continue with data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -