aboutsummaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_spi.c10
-rw-r--r--nuttx/drivers/mtd/at25.c16
2 files changed, 16 insertions, 10 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.c b/nuttx/drivers/mmcsd/mmcsd_spi.c
index d437b7fea..3d4cf1dd1 100644
--- a/nuttx/drivers/mmcsd/mmcsd_spi.c
+++ b/nuttx/drivers/mmcsd/mmcsd_spi.c
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/mmcsd/mmcsd_spi.c
*
- * Copyright (C) 2008-2010, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2010, 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -409,10 +409,14 @@ static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot,
int ret;
int i;
- /* Wait until the card is not busy */
+ /* Wait until the card is not busy. Some SD cards will not enter the IDLE
+ * state until CMD0 is sent for the first time, switching the card to SPI
+ * mode. Having a pull-up resistor on MISO may avoid this problem, but
+ * this check makes it work also without the pull-up.
+ */
ret = mmcsd_waitready(slot);
- if (ret != OK)
+ if (ret != OK && cmd != &g_cmd0)
{
return ret;
}
diff --git a/nuttx/drivers/mtd/at25.c b/nuttx/drivers/mtd/at25.c
index e35b794a5..c58b16122 100644
--- a/nuttx/drivers/mtd/at25.c
+++ b/nuttx/drivers/mtd/at25.c
@@ -691,14 +691,16 @@ FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev)
kfree(priv);
priv = NULL;
}
-
- /* Unprotect all sectors */
+ else
+ {
+ /* Unprotect all sectors */
- at25_writeenable(priv);
- SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
- (void)SPI_SEND(priv->dev, AT25_WRSR);
- (void)SPI_SEND(priv->dev, AT25_SR_UNPROT);
- SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
+ at25_writeenable(priv);
+ SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
+ (void)SPI_SEND(priv->dev, AT25_WRSR);
+ (void)SPI_SEND(priv->dev, AT25_SR_UNPROT);
+ SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
+ }
}
/* Return the implementation-specific state structure as the MTD device */