diff --git a/configs/lpcxpresso-lpc1768/README.txt b/configs/lpcxpresso-lpc1768/README.txt index 51622ac417..a37fd379b3 100755 --- a/configs/lpcxpresso-lpc1768/README.txt +++ b/configs/lpcxpresso-lpc1768/README.txt @@ -1,14 +1,14 @@ README ^^^^^^ -README for NuttX port to the Embedded Artists' LPCXpresso base board with +README for NuttX port to the Embedded Artists' base board with the NXP the LPCXpresso daughter board. Contents ^^^^^^^^ LCPXpresso LPC1768 Board - Jumpers + Embedded Artist's Base Board Development Environment GNU Toolchain Options NuttX buildroot Toolchain @@ -98,13 +98,34 @@ LCPXpresso LPC1768 Board P4[28]/RX-MCLK/MAT2.0/TXD3 PAD15 N/A P4[29]/TX-MCLK/MAT2.1/RXD3 PAD16 N/A +Embedded Artist's Base Board +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Jumpers -^^^^^^^ +------- There are many jumpers on the base board. A usable combination is the default jumper settings WITH the two J54 jumpers both removed. Those jumpers are for ISP support and will cause the board to reset. + To use the SD, J55 must be set to provide chip select PIO1_11 signal as + the SD slot chip select. + +SD Slot +------- + + Base-board J4/J6 LPC1768 + SD Signal Pin Pin + --- ----------- ----- -------- + CS PIO1_11* 55 P2.2 + DIN PIO0_9-MOSI 5 P0.9 MOSI1 + DOUT PIO0_8-MISO 6 P0.8 MISO1 + CLK PIO2_11-SCK 7 P0.9 SCK1 + CD PIO2_10 52 P2.11 + + *J55 must be set to provide chip select PIO1_11 signal as the SD slot + chip select. + Development Environment ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/configs/lpcxpresso-lpc1768/nsh/defconfig b/configs/lpcxpresso-lpc1768/nsh/defconfig index ff8124aeea..10aa9e5f24 100755 --- a/configs/lpcxpresso-lpc1768/nsh/defconfig +++ b/configs/lpcxpresso-lpc1768/nsh/defconfig @@ -117,7 +117,7 @@ CONFIG_LPC17_CAN1=n CONFIG_LPC17_CAN2=n CONFIG_LPC17_SPI=n CONFIG_LPC17_SSP0=n -CONFIG_LPC17_SSP1=n +CONFIG_LPC17_SSP1=y CONFIG_LPC17_I2C0=n CONFIG_LPC17_I2C1=n CONFIG_LPC17_I2S=n @@ -332,7 +332,6 @@ CONFIG_HAVE_LIBM=n CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n -CONFIG_DEBUG_USB=n CONFIG_MM_REGIONS=2 CONFIG_ARCH_LOWPUTC=y CONFIG_RR_INTERVAL=200 @@ -836,7 +835,7 @@ CONFIG_NSH_FATMOUNTPT=/tmp # # Architecture-specific NSH options # -CONFIG_NSH_MMCSDSPIPORTNO=0 +CONFIG_NSH_MMCSDSPIPORTNO=1 CONFIG_NSH_MMCSDSLOTNO=0 CONFIG_NSH_MMCSDMINOR=0 diff --git a/configs/lpcxpresso-lpc1768/ostest/defconfig b/configs/lpcxpresso-lpc1768/ostest/defconfig index 57064af5d7..08fbda866f 100755 --- a/configs/lpcxpresso-lpc1768/ostest/defconfig +++ b/configs/lpcxpresso-lpc1768/ostest/defconfig @@ -780,7 +780,7 @@ CONFIG_NSH_FATMOUNTPT=/tmp # # Architecture-specific NSH options # -CONFIG_NSH_MMCSDSPIPORTNO=0 +CONFIG_NSH_MMCSDSPIPORTNO=1 CONFIG_NSH_MMCSDSLOTNO=0 CONFIG_NSH_MMCSDMINOR=0 diff --git a/configs/lpcxpresso-lpc1768/src/Makefile b/configs/lpcxpresso-lpc1768/src/Makefile index 1897ac1911..dddb65b7c1 100755 --- a/configs/lpcxpresso-lpc1768/src/Makefile +++ b/configs/lpcxpresso-lpc1768/src/Makefile @@ -39,9 +39,11 @@ CFLAGS += -I$(TOPDIR)/sched ASRCS = CSRCS = up_boot.c up_leds.c up_ssp.c + ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += up_nsh.c endif + ifeq ($(CONFIG_USBSTRG),y) CSRCS += up_usbstrg.c endif diff --git a/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h b/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h index 2a3b8b61b0..71da859763 100755 --- a/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h +++ b/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h @@ -134,6 +134,25 @@ * P4[28]/RX-MCLK/MAT2.0/TXD3 PAD15 N/A * P4[29]/TX-MCLK/MAT2.1/RXD3 PAD16 N/A */ + +/* SD Slot + * + * Base-board J4/J6 LPC1768 + * SD Signal Pin Pin + * --- ----------- ----- -------- + * CS PIO1_11* 55 P2.2 (See GPIO_SD_CS) + * DIN PIO0_9-MOSI 5 P0.9 MOSI1 (See GPIO_SSP1_MOSI in lpc17_internal.h) + * DOUT PIO0_8-MISO 6 P0.8 MISO1 (See GPIO_SSP1_MISO in lpc17_internal.h) + * CLK PIO2_11-SCK 7 P0.9 SCK1 (See GPIO_SSP1_SCK in board.h) + * CD PIO2_10 52 P2.11 (See GPIO_SD_CD) + */ + +#define GPIO_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN2) +#ifdef CONFIG_GPIO_IRQ +# define GPIO_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) +#else +# define GPIO_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11) +#endif /************************************************************************************ * Public Types diff --git a/configs/lpcxpresso-lpc1768/src/up_nsh.c b/configs/lpcxpresso-lpc1768/src/up_nsh.c index 01b1df6db7..a47181bacd 100755 --- a/configs/lpcxpresso-lpc1768/src/up_nsh.c +++ b/configs/lpcxpresso-lpc1768/src/up_nsh.c @@ -57,8 +57,8 @@ #ifdef CONFIG_ARCH_BOARD_LPCXPRESSO # define CONFIG_NSH_HAVEUSBDEV 1 -# ifdef CONFIG_LPC17_SSP0 -# define CONFIG_NSH_HAVEMMCSD 1 +# ifdef CONFIG_LPC17_SSP1 +# define CONFIG_NSH_HAVEMMCSD 1 # else # undef CONFIG_NSH_HAVEMMCSD # endif @@ -71,13 +71,13 @@ /* Do we have SPI support for MMC/SD? */ #ifdef CONFIG_NSH_HAVEMMCSD -# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 0 -# error "The LPCXpresso MMC/SD is on SSP0" +# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 1 +# error "The LPCXpresso MMC/SD is on SSP1" # undef CONFIG_NSH_MMCSDSPIPORTNO -# define CONFIG_NSH_MMCSDSPIPORTNO 0 +# define CONFIG_NSH_MMCSDSPIPORTNO 1 # endif # if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0 -# error "The LPCXpresso MMC/SD is only one slot (0)" +# error "The LPCXpresso MMC/SD has only one slot (0)" # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 # endif diff --git a/configs/lpcxpresso-lpc1768/src/up_ssp.c b/configs/lpcxpresso-lpc1768/src/up_ssp.c index 01e6020d81..d3977b8526 100755 --- a/configs/lpcxpresso-lpc1768/src/up_ssp.c +++ b/configs/lpcxpresso-lpc1768/src/up_ssp.c @@ -2,7 +2,7 @@ * configs/lpcxpresso-lpc1768/src/up_ssp.c * arch/arm/src/board/up_ssp.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -107,7 +107,16 @@ void weak_function lpc17_sspinitialize(void) /* Configure the SPI-based microSD CS GPIO */ ssp_dumpgpio("lpc17_sspinitialize() Entry)"); -#warning "Configure chip selects here" + + /* Configure card detect and chip select for the SD slot. NOTE: Jumper J55 must + * be set correctly for the SD slot chip select. + */ + +#ifdef CONFIG_LPC17_SSP1 + (void)lpc17_configgpio(GPIO_SD_CS); + (void)lpc17_configgpio(GPIO_SD_CD); +#endif + ssp_dumpgpio("lpc17_sspinitialize() Exit"); } @@ -140,11 +149,11 @@ void weak_function lpc17_sspinitialize(void) void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - ssp_dumpgpio("lpc17_spiselect() Entry"); + ssp_dumpgpio("lpc17_spi0select() Entry"); #warning "Assert CS here (false)" - ssp_dumpgpio("lpc17_spiselect() Exit"); + ssp_dumpgpio("lpc17_spi0select() Exit"); } uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) @@ -155,7 +164,37 @@ uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) #endif #ifdef CONFIG_LPC17_SSP1 -# warning "SSP1 chip selects not known" +void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) +{ + sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); + ssp_dumpgpio("lpc17_spi1select() Entry"); + + if (devid == SPIDEV_MMCSD) + { + /* Assert/de-assert the CS pin to the card */ + + (void)lpc17_gpiowrite(GPIO_SD_CS, !selected); + } + + ssp_dumpgpio("lpc17_spi1select() Exit"); +} + +uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +{ + if (devid == SPIDEV_MMCSD) + { + /* Read the state of the card-detect bit */ + + if (lpc17_gpioread(GPIO_SD_CD) == 0) + { + sspdbg("Returning SPI_STATUS_PRESENT\n"); + return SPI_STATUS_PRESENT; + } + } + + sspdbg("Returning zero\n"); + return 0; +} #endif #endif /* CONFIG_LPC17_SSP0 || CONFIG_LPC17_SSP1 */