Callbacks need to use worker thread; clean up/document configuration settings

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2268 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-11-17 23:20:08 +00:00
parent 108a8ede6a
commit fd34e51e1c
12 changed files with 1574 additions and 1335 deletions

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
<p>Last Updated: November 5, 2009</p>
<p>Last Updated: November 17, 2009</p>
</td>
</tr>
</table>
@ -2288,6 +2288,25 @@ extern void up_ledoff(int led);
</li>
</ul>
<h2>SDIO-based MMC/SD driver</h2>
<ul>
<li>
<code>CONFIG_FS_READAHEAD</code>: Enable read-ahead buffering
</li>
<li>
<code>CONFIG_FS_WRITEBUFFER</code>: Enable write buffering
</li>
<li>
<code>CONFIG_SDIO_DMA</code>: SDIO driver supports DMA
</li>
<li>
<code>CONFIG_MMCSD_MMCSUPPORT</code>: Enable support for MMC cards
</li>
<li>
<code>CONFIG_MMCSD_HAVECARDDETECT</code>: SDIO driver card detection is 100% accurate
</li>
</ul>
<h2>Network Support</h2>
<h3>TCP/IP and UDP support via uIP</h2>
<ul>

File diff suppressed because it is too large Load Diff

View File

@ -333,6 +333,14 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
Default is 20MHz.
SDIO-based MMC/SD driver
CONFIG_FS_READAHEAD - Enable read-ahead buffering
CONFIG_FS_WRITEBUFFER - Enable write buffering
CONFIG_SDIO_DMA - SDIO driver supports DMA
CONFIG_MMCSD_MMCSUPPORT - Enable support for MMC cards
CONFIG_MMCSD_HAVECARDDETECT - SDIO driver card detection is
100% accurate
TCP/IP and UDP support via uIP
CONFIG_NET - Enable or disable all network features
CONFIG_NET_IPv6 - Build in support for IPv6

View File

@ -382,6 +382,12 @@ STM3210E-EVAL-specific Configuration Options
CONFIG_STM32_SPI_DMA - Use DMA to improve SPI transfer performance.
Cannot be used with CONFIG_STM32_SPI_INTERRUPT.
CONFIG_SDIO_DMA - Support DMA data transfers. Requires CONFIG_STM32_SDIO
and CONFIG_STM32_DMA2.
CONFIG_SDIO_PRI - Select SDIO interrupt prority. Default: Medium
CONFIG_SDIO_DMAPRIO - Select SDIO DMA interrupt priority.
Default: Medium
Configurations
^^^^^^^^^^^^^^

View File

@ -294,6 +294,24 @@ CONFIG_HAVE_LIBM=n
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
# handle delayed processing from interrupt handlers. This feature
# is required for some drivers but, if there are not complaints,
# can be safely disabled. The worker thread also performs
# garbage collection -- completing any delayed memory deallocations
# from interrupt handlers. If the worker thread is disabled,
# then that clean will be performed by the IDLE thread instead
# (which runs at the lowest of priority and may not be appropriate
# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE
# is enabled, then the following options can also be used:
# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker
# thread. Default: 50
# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for
# work. Default: 50 MS.
# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
#
CONFIG_EXAMPLE=null
CONFIG_DEBUG=n
@ -320,6 +338,11 @@ CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
CONFIG_NXFLAT=n
CONFIG_SCHED_WORKQUEUE=n
CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=50
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
#
# The following can be used to disable categories of
@ -444,6 +467,31 @@ CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# Block driver buffering
#
# CONFIG_FS_READAHEAD
# Enable read-ahead buffering
# CONFIG_FS_WRITEBUFFER
# Enable write buffering
#
CONFIG_FS_READAHEAD=n
CONFIG_FS_WRITEBUFFER=n
#
# SDIO-based MMC/SD driver
#
# CONFIG_SDIO_DMA
# SDIO driver supports DMA
# CONFIG_MMCSD_MMCSUPPORT
# Enable support for MMC cards
# CONFIG_MMCSD_HAVECARDDETECT
# SDIO driver card detection is 100% accurate
#
CONFIG_SDIO_DMA=n
CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
@ -563,7 +611,6 @@ CONFIG_USBSER_VENDORSTR="Nuttx"
CONFIG_USBSER_PRODUCTSTR="USBdev Serial"
CONFIG_USBSER_RXBUFSIZE=512
CONFIG_USBSER_TXBUFSIZE=512
CONFIG_NXFLAT=n
#
# USB Storage Device Configuration

View File

@ -101,10 +101,10 @@ CONFIG_STM32_DFU=y
# Individual subsystems can be enabled:
# AHB:
CONFIG_STM32_DMA1=n
CONFIG_STM32_DMA2=n
CONFIG_STM32_DMA2=y
CONFIG_STM32_CRC=n
CONFIG_STM32_FSMC=y
CONFIG_STM32_SDIO=n
CONFIG_STM32_SDIO=y
# APB1:
CONFIG_STM32_TIM2=n
CONFIG_STM32_TIM3=n
@ -304,6 +304,24 @@ CONFIG_HAVE_LIBM=n
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
# handle delayed processing from interrupt handlers. This feature
# is required for some drivers but, if there are not complaints,
# can be safely disabled. The worker thread also performs
# garbage collection -- completing any delayed memory deallocations
# from interrupt handlers. If the worker thread is disabled,
# then that clean will be performed by the IDLE thread instead
# (which runs at the lowest of priority and may not be appropriate
# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE
# is enabled, then the following options can also be used:
# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker
# thread. Default: 50
# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for
# work. Default: 50 MS.
# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
#
CONFIG_EXAMPLE=nsh
CONFIG_DEBUG=n
@ -329,6 +347,11 @@ CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
CONFIG_NXFLAT=n
CONFIG_SCHED_WORKQUEUE=y
CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=50
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
#
# The following can be used to disable categories of
@ -453,6 +476,31 @@ CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# Block driver buffering
#
# CONFIG_FS_READAHEAD
# Enable read-ahead buffering
# CONFIG_FS_WRITEBUFFER
# Enable write buffering
#
CONFIG_FS_READAHEAD=n
CONFIG_FS_WRITEBUFFER=n
#
# SDIO-based MMC/SD driver
#
# CONFIG_SDIO_DMA
# SDIO driver supports DMA
# CONFIG_MMCSD_MMCSUPPORT
# Enable support for MMC cards
# CONFIG_MMCSD_HAVECARDDETECT
# SDIO driver card detection is 100% accurate
#
CONFIG_SDIO_DMA=n
CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
@ -572,7 +620,6 @@ CONFIG_USBSER_VENDORSTR="Nuttx"
CONFIG_USBSER_PRODUCTSTR="USBdev Serial"
CONFIG_USBSER_RXBUFSIZE=512
CONFIG_USBSER_TXBUFSIZE=512
CONFIG_NXFLAT=n
#
# USB Storage Device Configuration

View File

@ -306,6 +306,24 @@ CONFIG_HAVE_LIBM=n
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
# handle delayed processing from interrupt handlers. This feature
# is required for some drivers but, if there are not complaints,
# can be safely disabled. The worker thread also performs
# garbage collection -- completing any delayed memory deallocations
# from interrupt handlers. If the worker thread is disabled,
# then that clean will be performed by the IDLE thread instead
# (which runs at the lowest of priority and may not be appropriate
# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE
# is enabled, then the following options can also be used:
# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker
# thread. Default: 50
# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for
# work. Default: 50 MS.
# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
#
CONFIG_EXAMPLE=ostest
CONFIG_DEBUG=n
@ -331,6 +349,11 @@ CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
CONFIG_NXFLAT=n
CONFIG_SCHED_WORKQUEUE=n
CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=50
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
#
# The following can be used to disable categories of
@ -455,6 +478,31 @@ CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# Block driver buffering
#
# CONFIG_FS_READAHEAD
# Enable read-ahead buffering
# CONFIG_FS_WRITEBUFFER
# Enable write buffering
#
CONFIG_FS_READAHEAD=n
CONFIG_FS_WRITEBUFFER=n
#
# SDIO-based MMC/SD driver
#
# CONFIG_SDIO_DMA
# SDIO driver supports DMA
# CONFIG_MMCSD_MMCSUPPORT
# Enable support for MMC cards
# CONFIG_MMCSD_HAVECARDDETECT
# SDIO driver card detection is 100% accurate
#
CONFIG_SDIO_DMA=n
CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
@ -574,7 +622,6 @@ CONFIG_USBSER_VENDORSTR="Nuttx"
CONFIG_USBSER_PRODUCTSTR="USBdev Serial"
CONFIG_USBSER_RXBUFSIZE=512
CONFIG_USBSER_TXBUFSIZE=512
CONFIG_NXFLAT=n
#
# USB Storage Device Configuration

View File

@ -306,6 +306,24 @@ CONFIG_HAVE_LIBM=n
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
# handle delayed processing from interrupt handlers. This feature
# is required for some drivers but, if there are not complaints,
# can be safely disabled. The worker thread also performs
# garbage collection -- completing any delayed memory deallocations
# from interrupt handlers. If the worker thread is disabled,
# then that clean will be performed by the IDLE thread instead
# (which runs at the lowest of priority and may not be appropriate
# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE
# is enabled, then the following options can also be used:
# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker
# thread. Default: 50
# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for
# work. Default: 50 MS.
# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker
# thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
# the worker thread. Default: 4
#
CONFIG_EXAMPLE=usbserial
CONFIG_DEBUG=n
@ -332,6 +350,11 @@ CONFIG_FDCLONE_DISABLE=n
CONFIG_FDCLONE_STDIO=n
CONFIG_SDCLONE_DISABLE=y
CONFIG_NXFLAT=n
CONFIG_SCHED_WORKQUEUE=n
CONFIG_SCHED_WORKPRIORITY=50
CONFIG_SCHED_WORKPERIOD=50
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SIG_SIGWORK=4
#
# The following can be used to disable categories of
@ -456,6 +479,31 @@ CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# Block driver buffering
#
# CONFIG_FS_READAHEAD
# Enable read-ahead buffering
# CONFIG_FS_WRITEBUFFER
# Enable write buffering
#
CONFIG_FS_READAHEAD=n
CONFIG_FS_WRITEBUFFER=n
#
# SDIO-based MMC/SD driver
#
# CONFIG_SDIO_DMA
# SDIO driver supports DMA
# CONFIG_MMCSD_MMCSUPPORT
# Enable support for MMC cards
# CONFIG_MMCSD_HAVECARDDETECT
# SDIO driver card detection is 100% accurate
#
CONFIG_SDIO_DMA=n
CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
@ -575,7 +623,6 @@ CONFIG_USBSER_VENDORSTR="Nuttx"
CONFIG_USBSER_PRODUCTSTR="USBdev Serial"
CONFIG_USBSER_RXBUFSIZE=512
CONFIG_USBSER_TXBUFSIZE=512
CONFIG_NXFLAT=n
#
# USB Storage Device Configuration

View File

@ -944,13 +944,13 @@ static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32 state)
* Transfer Helpers
****************************************************************************/
/****************************************************************************
* Name: mmcsd_wrprotected
*
* Description:
/****************************************************************************
* Name: mmcsd_wrprotected
*
* Description:
* Return true if the the card is unlocked an not write protected. The
*
*
*
*
****************************************************************************/
static boolean mmcsd_wrprotected(FAR struct mmcsd_state_s *priv)
@ -964,12 +964,12 @@ static boolean mmcsd_wrprotected(FAR struct mmcsd_state_s *priv)
return (priv->wrprotect || priv->locked || SDIO_WRPROTECTED(priv->dev));
}
/****************************************************************************
* Name: mmcsd_eventwait
*
* Description:
* Wait for the specified events to occur. Check for wakeup on error events.
*
/****************************************************************************
* Name: mmcsd_eventwait
*
* Description:
* Wait for the specified events to occur. Check for wakeup on error events.
*
****************************************************************************/
static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv,
@ -1001,14 +1001,14 @@ static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv,
return OK;
}
/****************************************************************************
* Name: mmcsd_transferready
*
* Description:
/****************************************************************************
* Name: mmcsd_transferready
*
* Description:
* Check if the MMC/SD card is ready for the next read or write transfer.
* Ready means: (1) card still in the slot, and (2) if the last transfer
* was a write transfer, the card is no longer busy from that transfer.
*
* was a write transfer, the card is no longer busy from that transfer.
*
****************************************************************************/
static int mmcsd_transferready(FAR struct mmcsd_state_s *priv)
@ -1095,27 +1095,27 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv)
return -ETIMEDOUT;
}
/****************************************************************************
* Name: mmcsd_stoptransmission
*
* Description:
* Send STOP_TRANSMISSION
*
/****************************************************************************
* Name: mmcsd_stoptransmission
*
* Description:
* Send STOP_TRANSMISSION
*
****************************************************************************/
static int mmcsd_stoptransmission(FAR struct mmcsd_state_s *priv)
{
int ret;
/* Send CMD12, STOP_TRANSMISSION, and verify good R1 return status */
int ret;
mmcsd_sendcmdpoll(priv, MMCSD_CMD12, 0);
/* Send CMD12, STOP_TRANSMISSION, and verify good R1 return status */
mmcsd_sendcmdpoll(priv, MMCSD_CMD12, 0);
ret = mmcsd_recvR1(priv, MMCSD_CMD12);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD12 failed: %d\n", ret);
}
return ret;
}
return ret;
}
/****************************************************************************
@ -1139,16 +1139,16 @@ static int mmcsd_setblocklen(FAR struct mmcsd_state_s *priv, uint32 blocklen)
* block length is specified in the CSD.
*/
mmcsd_sendcmdpoll(priv, MMCSD_CMD16, priv->blocksize);
ret = mmcsd_recvR1(priv, MMCSD_CMD16);
if (ret == OK)
mmcsd_sendcmdpoll(priv, MMCSD_CMD16, priv->blocksize);
ret = mmcsd_recvR1(priv, MMCSD_CMD16);
if (ret == OK)
{
priv->selblocklen = blocklen;
}
else
{
fdbg("ERROR: mmcsd_recvR1 for CMD16 failed: %d\n", ret);
}
fdbg("ERROR: mmcsd_recvR1 for CMD16 failed: %d\n", ret);
}
}
return ret;
@ -1172,12 +1172,12 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv,
DEBUGASSERT(priv != NULL && buffer != NULL);
/* Check if the card is locked */
if (priv->locked)
if (priv->locked)
{
fdbg("ERROR: Card is locked\n");
return -EPERM;
}
fdbg("ERROR: Card is locked\n");
return -EPERM;
}
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
@ -1207,28 +1207,28 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv,
}
fvdbg("offset=%d\n", offset);
/* Select the block size for the card */
/* Select the block size for the card */
ret = mmcsd_setblocklen(priv, priv->blocksize);
if (ret != OK)
if (ret != OK)
{
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
/* Configure SDIO controller hardware for the read transfer */
SDIO_WAITENABLE(priv->dev, SDIOWAIT_TRANSFERDONE|SDIOWAIT_TIMEOUT);
#ifdef CONFIG_SDIO_DMA
#ifdef CONFIG_SDIO_DMA
if (priv->dma)
{
{
SDIO_DMARECVSETUP(priv->dev, buffer, priv->blocksize);
}
else
#endif
{
#endif
{
SDIO_RECVSETUP(priv->dev, buffer, priv->blocksize);
}
}
/* Send CMD17, READ_SINGLE_BLOCK: Read a block of the size selected
* by the mmcsd_setblocklen() and verify that good R1 status is
@ -1236,19 +1236,19 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv,
* state.
*/
mmcsd_sendcmdpoll(priv, MMCSD_CMD17, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD17);
if (ret != OK)
{
mmcsd_sendcmdpoll(priv, MMCSD_CMD17, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD17);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD17 failed: %d\n", ret);
return ret;
return ret;
}
/* Then wait for the data transfer to complete */
ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
fdbg("ERROR: CMD17 transfer failed: %d\n", ret);
}
return ret;
@ -1274,12 +1274,12 @@ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv,
DEBUGASSERT(priv != NULL && buffer != NULL && nblocks > 1);
/* Check if the card is locked */
if (priv->locked)
if (priv->locked)
{
fdbg("ERROR: Card is locked\n");
return -EPERM;
}
fdbg("ERROR: Card is locked\n");
return -EPERM;
}
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
@ -1310,48 +1310,48 @@ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv,
}
fvdbg("nbytes=%d byte offset=%d\n", nbytes, offset);
/* Select the block size for the card */
/* Select the block size for the card */
ret = mmcsd_setblocklen(priv, priv->blocksize);
if (ret != OK)
if (ret != OK)
{
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
/* Configure SDIO controller hardware for the read transfer */
SDIO_WAITENABLE(priv->dev, SDIOWAIT_TRANSFERDONE|SDIOWAIT_TIMEOUT);
#ifdef CONFIG_SDIO_DMA
#ifdef CONFIG_SDIO_DMA
if (priv->dma)
{
{
SDIO_DMARECVSETUP(priv->dev, buffer, nbytes);
}
else
#endif
{
#endif
{
SDIO_RECVSETUP(priv->dev, buffer, nbytes);
}
}
/* Send CMD18, READ_MULT_BLOCK: Read a block of the size selected by
* the mmcsd_setblocklen() and verify that good R1 status is returned
*/
mmcsd_sendcmdpoll(priv, MMCSD_CMD18, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD18);
if (ret != OK)
{
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD18 failed: %d\n", ret);
return ret;
return ret;
}
/* Wait for the transfer to complete */
ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, nblocks * MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
if (ret != OK)
{
fdbg("ERROR: CMD18 transfer failed: %d\n", ret);
return ret;
return ret;
}
/* Send STOP_TRANSMISSION */
@ -1414,12 +1414,12 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
/* Check if the card is locked or write protected (either via software or
* via the mechanical write protect on the card)
*/
if (mmcsd_wrprotected(priv))
if (mmcsd_wrprotected(priv))
{
fdbg("ERROR: Card is locked or write protected\n");
return -EPERM;
}
fdbg("ERROR: Card is locked or write protected\n");
return -EPERM;
}
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
@ -1449,13 +1449,13 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
}
fvdbg("offset=%d\n", offset);
/* Select the block size for the card */
/* Select the block size for the card */
ret = mmcsd_setblocklen(priv, priv->blocksize);
if (ret != OK)
if (ret != OK)
{
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
/* Send CMD24, WRITE_BLOCK, and verify that good R1 status is returned */
@ -1464,29 +1464,29 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
ret = mmcsd_recvR1(priv, MMCSD_CMD24);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
}
/* Configure SDIO controller hardware for the write transfer */
SDIO_WAITENABLE(priv->dev, SDIOWAIT_TRANSFERDONE|SDIOWAIT_TIMEOUT);
#ifdef CONFIG_SDIO_DMA
#ifdef CONFIG_SDIO_DMA
if (priv->dma)
{
SDIO_DMASENDSETUP(priv->dev, buffer, priv->blocksize);
{
SDIO_DMASENDSETUP(priv->dev, buffer, priv->blocksize);
}
else
#endif
{
SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
}
#endif
{
SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
}
/* Wait for the transfer to complete */
ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
ret = mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
fdbg("ERROR: CMD24 transfer failed: %d\n", ret);
}
@ -1520,12 +1520,12 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
/* Check if the card is locked or write protected (either via software or
* via the mechanical write protect on the card)
*/
if (mmcsd_wrprotected(priv))
if (mmcsd_wrprotected(priv))
{
fdbg("ERROR: Card is locked or write protected\n");
return -EPERM;
}
fdbg("ERROR: Card is locked or write protected\n");
return -EPERM;
}
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
@ -1556,13 +1556,13 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
}
fvdbg("nbytes=%d byte offset=%d\n", nbytes, offset);
/* Select the block size for the card */
/* Select the block size for the card */
ret = mmcsd_setblocklen(priv, priv->blocksize);
if (ret != OK)
if (ret != OK)
{
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_setblocklen failed: %d\n", ret);
return ret;
}
/* If this is an SD card, then send ACMD23 (SET_WR_BLK_COUNT) just before
@ -1573,14 +1573,14 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
if (IS_SD(priv->type))
{
/* Send CMD55, APP_CMD, a verify that good R1 status is retured */
/* Send CMD55, APP_CMD, a verify that good R1 status is retured */
mmcsd_sendcmdpoll(priv, SD_CMD55, 0);
ret = mmcsd_recvR1(priv, SD_CMD55);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD55 (ACMD23) failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_recvR1 for CMD55 (ACMD23) failed: %d\n", ret);
return ret;
}
/* Send CMD23, SET_WR_BLK_COUNT, and verify that good R1 status is returned */
@ -1589,8 +1589,8 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
ret = mmcsd_recvR1(priv, SD_ACMD23);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for ACMD23 failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_recvR1 for ACMD23 failed: %d\n", ret);
return ret;
}
}
@ -1602,31 +1602,31 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
ret = mmcsd_recvR1(priv, MMCSD_CMD25);
if (ret != OK)
{
fdbg("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
fdbg("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
}
/* Configure SDIO controller hardware for the write transfer */
SDIO_WAITENABLE(priv->dev, SDIOWAIT_TRANSFERDONE|SDIOWAIT_TIMEOUT);
#ifdef CONFIG_SDIO_DMA
#ifdef CONFIG_SDIO_DMA
if (priv->dma)
{
SDIO_DMASENDSETUP(priv->dev, buffer, nbytes);
{
SDIO_DMASENDSETUP(priv->dev, buffer, nbytes);
}
else
#endif
{
SDIO_SENDSETUP(priv->dev, buffer, nbytes);
}
#endif
{
SDIO_SENDSETUP(priv->dev, buffer, nbytes);
}
/* Wait for the transfer to complete */
ret =mmcsd_eventwait(priv, SDIOWAIT_TIMEOUT, nblocks * MMCSD_BLOCK_DATADELAY);
if (ret != OK)
{
if (ret != OK)
{
fdbg("ERROR: CMD18 transfer failed: %d\n", ret);
return ret;
return ret;
}
/* Send STOP_TRANSMISSION */
@ -1951,7 +1951,8 @@ static void mmcsd_mediachange(FAR void *arg)
if (SDIO_PRESENT(priv->dev))
{
/* No... process the card insertion. This could cause chaos if we think
* that a card is already present and there are mounted filesystms!
* that a card is already present and there are mounted filesystems!
* NOTE that mmcsd_probe() will always re-enable callbacks appropriately.
*/
(void)mmcsd_probe(priv);
@ -1959,7 +1960,8 @@ static void mmcsd_mediachange(FAR void *arg)
else
{
/* No... process the card removal. This could have very bad implications
* for any mounted file systems!
* for any mounted file systems! NOTE that mmcsd_removed() does NOT
* re-enable callbacks so we will need to do that here.
*/
(void)mmcsd_removed(priv);

View File

@ -42,6 +42,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/wqueue.h>
/****************************************************************************
* Pre-Processor Definitions
@ -505,8 +506,8 @@
*
* Input Parameters:
* dev - An instance of the SDIO device interface
* eventset - A bitset of events to enable or disable (see SDIOWAIT_*
* definitions). 0=disable; 1=enable.
* eventset - A bitset of events to enable or disable (see SDIOWAIT_*
* definitions). 0=disable; 1=enable.
*
* Returned Value:
* None
@ -532,7 +533,7 @@
*
* Returned Value:
* Event set containing the event(s) that ended the wait. Should always
* be non-zero. All events are disabled after the wait concludes.
* be non-zero. All events are disabled after the wait concludes.
*
****************************************************************************/
@ -552,8 +553,8 @@
*
* Input Parameters:
* dev - An instance of the SDIO device interface
* eventset - A bitset of events to enable or disable (see SDIOMEDIA_*
* definitions). 0=disable; 1=enable.
* eventset - A bitset of events to enable or disable (see SDIOMEDIA_*
* definitions). 0=disable; 1=enable.
*
* Returned Value:
* None
@ -660,10 +661,6 @@
* Public Types
****************************************************************************/
/* The type of the media change callback function */
typedef void (*sdio_mediachange_t)(FAR void *arg);
/* Various clocking used by the SDIO driver */
enum sdio_clock_e
@ -727,7 +724,7 @@ struct sdio_dev_s
void (*callbackenable)(FAR struct sdio_dev_s *dev,
sdio_eventset_t eventset);
int (*registercallback)(FAR struct sdio_dev_s *dev,
sdio_mediachange_t callback, void *arg);
worker_t callback, void *arg);
/* DMA */

View File

@ -45,8 +45,6 @@
#include <signal.h>
#include <queue.h>
#ifdef CONFIG_SCHED_WORKQUEUE
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@ -166,5 +164,4 @@ EXTERN int work_cancel(struct work_s *work);
#endif
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_SCHED_WORKQUEUE */
#endif /* __INCLUDE_NUTTX_WQUEUE_H */

View File

@ -56,7 +56,7 @@
# define CONFIG_SCHED_WORKPRIORITY 50
#endif
#ifndef CONFIG_SCHED_WORKPERIODUS
#ifndef CONFIG_SCHED_WORKPERIOD
# define CONFIG_SCHED_WORKPERIOD (50*1000) /* 50 milliseconds */
#endif