diff --git a/nuttx/configs/sure-pic32mx/nsh/defconfig b/nuttx/configs/sure-pic32mx/nsh/defconfig index 8d371508ff..a49a1a4f52 100644 --- a/nuttx/configs/sure-pic32mx/nsh/defconfig +++ b/nuttx/configs/sure-pic32mx/nsh/defconfig @@ -357,6 +357,7 @@ CONFIG_DEBUG_SCHED=n CONFIG_DEBUG_USB=n CONFIG_DEBUG_FS=n CONFIG_DEBUG_SPI=n +CONFIG_SPI_REGDEBUG=n CONFIG_HAVE_CXX=n CONFIG_HAVE_CXXINITIALIZE=n @@ -380,7 +381,7 @@ CONFIG_FDCLONE_DISABLE=n CONFIG_FDCLONE_STDIO=n CONFIG_SDCLONE_DISABLE=y CONFIG_SCHED_WORKQUEUE=n -CONFIG_SCHED_WORKPRIORITY=50 +CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=(50*1000) CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SIG_SIGWORK=4 diff --git a/nuttx/configs/sure-pic32mx/src/up_nsh.c b/nuttx/configs/sure-pic32mx/src/up_nsh.c index 1db5e07818..70d482dbe7 100644 --- a/nuttx/configs/sure-pic32mx/src/up_nsh.c +++ b/nuttx/configs/sure-pic32mx/src/up_nsh.c @@ -69,7 +69,7 @@ # define CONFIG_NSH_MMCSDSPIPORTNO 2 # endif # if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0 -# error "The Sure PIC32MX MMC/SD is only one slot (0)" +# error "The Sure PIC32MX MMC/SD has only one slot (0)" # undef CONFIG_NSH_MMCSDSLOTNO # define CONFIG_NSH_MMCSDSLOTNO 0 # endif @@ -200,13 +200,13 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef CONFIG_NSH_HAVEMMCSD static int nsh_sdinitialize(void) { - FAR struct spi_dev_s *ssp; + FAR struct spi_dev_s *spi; int ret; /* Get the SPI port */ - ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); - if (!ssp) + spi = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); + if (!spi) { message("nsh_archinitialize: Failed to initialize SPI port %d\n", CONFIG_NSH_MMCSDSPIPORTNO); @@ -217,10 +217,19 @@ static int nsh_sdinitialize(void) message("Successfully initialized SPI port %d\n", CONFIG_NSH_MMCSDSPIPORTNO); + /* The SPI should be in 8-bit (default) and mode2: CKP=1, CKE=0. + * The MMC/SD driver will control the SPI frequency. WARNING: + * this is not the right way to do this... this should be done + * the MMC/SD driver: Other device on SPI1 may need other mode + * settings. + */ + + SPI_SETMODE(spi, SPIDEV_MODE2); + /* Bind the SPI port to the slot */ ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, - CONFIG_NSH_MMCSDSLOTNO, ssp); + CONFIG_NSH_MMCSDSLOTNO, spi); if (ret < 0) { message("nsh_sdinitialize: "