Fix MicroSD card support

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3148 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2010-11-30 13:08:31 +00:00
parent ea5affe87e
commit cc1e0f4555
5 changed files with 36 additions and 11 deletions

View File

@ -94,7 +94,7 @@ void lpc17_boardinitialize(void)
* function lpc17_sspinitialize() has been brought into the link.
*/
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP0)
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
if (lpc17_sspinitialize)
{
lpc17_sspinitialize();

View File

@ -174,15 +174,15 @@
/* SD/MMC GPIO PIN SIGNAL NAME
* -------------------------------- ---- --------------
* P0[6]/I2SRX_SDA/SSEL1/MAT2[0] 79 SSEL1
* P0[6]/I2SRX_SDA/SSEL1/MAT2[0] 79 SSEL1 (active low)
* P0[7]/I2STX_CLK/SCK1/MAT2[1] 78 SCK1
* P0[8]/I2STX_WS/MISO1/MAT2[2] 77 MISO1
* P0[9]/I2STX_SDA/MOSI1/MAT2[3] 76 MOSI1
* P0[21]/RI1/RD1 57 MMC PWR
* P0[21]/RI1/RD1 57 MMC PWR (active low)
*/
#define LPC1766STK_MMC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN6)
#define LPC1766STK_MMC_PWR (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN21)
#define LPC1766STK_MMC_PWR (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN21)
/* AD GPIO PIN SIGNAL NAME
* -------------------------------- ---- --------------

View File

@ -78,7 +78,7 @@ void lpc17_boardinitialize(void)
* function lpc17_sspinitialize() has been brought into the link.
*/
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP0)
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
if (lpc17_sspinitialize)
{
lpc17_sspinitialize();

View File

@ -47,6 +47,9 @@
#include <nuttx/spi.h>
#include <nuttx/mmcsd.h>
#include "lpc17_internal.h"
#include "lpc1766stk_internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@ -118,6 +121,10 @@ int nsh_archinitialize(void)
FAR struct spi_dev_s *ssp;
int ret;
/* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */
lpc17_gpiowrite(LPC1766STK_MMC_PWR, false);
/* Get the SSP port */
ssp = up_spiinitialize(CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO);
@ -125,7 +132,8 @@ int nsh_archinitialize(void)
{
message("nsh_archinitialize: Failed to initialize SSP port %d\n",
CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO);
return -ENODEV;
ret = -ENODEV;
goto errout;
}
message("Successfully initialized SSP port %d\n",
@ -133,15 +141,25 @@ int nsh_archinitialize(void)
/* Bind the SSP port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_NSH_MMCSDMINOR, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ssp);
ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_NSH_MMCSDMINOR,
CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ssp);
if (ret < 0)
{
message("nsh_archinitialize: Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ret);
return ret;
message("nsh_archinitialize: "
"Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO,
CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ret);
goto errout;
}
message("Successfuly bound SSP port %d to MMC/SD slot %d\n",
CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO);
CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO,
CONFIG_EXAMPLES_NSH_MMCSDSLOTNO);
return OK;
/* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */
errout:
lpc17_gpiowrite(LPC1766STK_MMC_PWR, true);
return ret;
}

View File

@ -118,6 +118,13 @@ void weak_function lpc17_sspinitialize(void)
#ifdef CONFIG_LPC17_SSP1
ssp_dumpssp0gpio("BEFORE SSP1 Initialization");
lpc17_configgpio(LPC1766STK_MMC_CS);
/* Also configure the SD/MMC power GPIO (but leave power off). This really has
* nothing to do with SSP, but does belong with other SD/MMC GPIO configuration
* settings.
*/
lpc17_configgpio(LPC1766STK_MMC_PWR);
ssp_dumpssp0gpio("AFTER SSP1 Initialization");
#endif
}