Add SD card support to the PIC32MX7 MMB board; Add regiser level debug instrumentatin for the PIC32 SPI driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4797 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
05f76a96ed
commit
bab1c895de
@ -32,8 +32,8 @@ PIN CONFIGURATIONS SIGNAL NAME ON-BOARD CONNE
|
||||
7 RC2/AC2TX/T3CK EE_CS# M25P80 CS
|
||||
8 RC3/AC2RX/T4CK ACL_CS# ADXL345 CS and VCC
|
||||
9 RC4/SDI1/T5CK SDI1 SPI1 data IN
|
||||
10 PMA5/CN8/ECOL/RG6/SCK2/U3RTS/U6TX RG6 ?
|
||||
11 PMA4/CN9/ECRS/RG7/SDA4/SDI2/U3RX SD_CD# SD Connector
|
||||
10 PMA5/CN8/ECOL/RG6/SCK2/U3RTS/U6TX SD_WP SD card, write protect
|
||||
11 PMA4/CN9/ECRS/RG7/SDA4/SDI2/U3RX SD_CD# SD card, card detect (not)
|
||||
12 PMA3/AECRSDV/AERXDV/CN10/ECRSDV/ AECRSDV LAN8720A SRS_DIV
|
||||
ERXDV/RG8/SCL4/SDO2/U3TX
|
||||
13 MCLR MCLR Debug connector
|
||||
@ -636,14 +636,19 @@ Where <subdir> is one of the following:
|
||||
before the networking finally gives up and decides that no network is
|
||||
available.
|
||||
|
||||
2. This example can support an FTP client. In order to build in FTP client
|
||||
2. To add SPI-based support for the SD card slot:
|
||||
|
||||
CONFIG_PIC32MX_SPI1=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
|
||||
3. This example can support an FTP client. In order to build in FTP client
|
||||
support simply uncomment the following lines in the appconfig file (before
|
||||
configuring) or in the apps/.config file (after configuring):
|
||||
|
||||
#CONFIGURED_APPS += netutils/ftpc
|
||||
#CONFIGURED_APPS += examples/ftpc
|
||||
|
||||
3. This example can support an FTP server. In order to build in FTP server
|
||||
4. This example can support an FTP server. In order to build in FTP server
|
||||
support simply uncomment the following lines in the appconfig file (before
|
||||
configuring) or in the apps/.config file (after configuring):
|
||||
|
||||
@ -654,11 +659,10 @@ Where <subdir> is one of the following:
|
||||
|
||||
CONFIG_DISABLE_POLL=n
|
||||
|
||||
Using a RAM disk and the USB MSC device with nsh and nsh2
|
||||
---------------------------------------------------------
|
||||
Here is an experimental change to either examples/nsh or examples/nsh2
|
||||
that will create a RAM disk and attempt to export that RAM disk as a
|
||||
USB mass storage device.
|
||||
Using a RAM disk and the USB MSC device to the nsh configuration
|
||||
----------------------------------------------------------------
|
||||
Here is an experimental change to examples/nsh that will create a RAM
|
||||
disk and attempt to export that RAM disk as a USB mass storage device.
|
||||
|
||||
1. Changes to nuttx/.config
|
||||
|
||||
@ -737,8 +741,8 @@ Where <subdir> is one of the following:
|
||||
Status: Open
|
||||
Priority: High
|
||||
|
||||
Adding LCD and graphics support:
|
||||
-------------------------------
|
||||
Adding LCD and graphics support to the nsh configuration:
|
||||
--------------------------------------------------------
|
||||
|
||||
appconfig (apps/.config): Enable the application configurations that you
|
||||
want to use. Asexamples:
|
||||
|
@ -445,6 +445,9 @@ CONFIG_DEBUG_NET=n
|
||||
CONFIG_DEBUG_LCD=n
|
||||
CONFIG_DEBUG_GRAPHICS=n
|
||||
CONFIG_DEBUG_INPUT=n
|
||||
CONFIG_DEBUG_FS=n
|
||||
CONFIG_DEBUG_SPI=n
|
||||
CONFIG_SPI_REGDEBUG=n
|
||||
|
||||
CONFIG_HAVE_CXX=n
|
||||
CONFIG_HAVE_CXXINITIALIZE=n
|
||||
|
@ -83,6 +83,20 @@
|
||||
* RD2 LCD-BLED Backlight Light Low value turns off
|
||||
*/
|
||||
|
||||
/* SPI1 and SD Card
|
||||
*
|
||||
* ------ -------- ------------------------- --------------------------------
|
||||
* GPIO SIGNAL BOARD CONNECTION NOTES
|
||||
* ------ -------- ------------------------- --------------------------------
|
||||
* RC4 SPI1 SD card slot SPI1 data IN
|
||||
* RD0 SPO1 SD card slot SPI1 data OUT
|
||||
* RD10 SCK1 SD card slot SD card, SPI clock
|
||||
*
|
||||
* RA9 SD_CS# SD card slot SD card, SPI chip select (active low)
|
||||
* RG6 SD_WP SD card slot SD card, write protect
|
||||
* RG7 SD_CD# SD card slot SD card, card detect (not)
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -108,11 +122,13 @@ extern "C" {
|
||||
* Name: pic32mx_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the PCB Logic board.
|
||||
* Called to configure SPI chip select GPIO pins for the Mikroelektronika PIC32MX7
|
||||
* MMB board.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(CONFIG_PIC32MX_SPI2)
|
||||
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \
|
||||
defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4)
|
||||
EXTERN void weak_function pic32mx_spiinitialize(void);
|
||||
#endif
|
||||
|
||||
|
@ -61,13 +61,10 @@
|
||||
#define CONFIG_NSH_HAVEMMCSD 1
|
||||
#define CONFIG_NSH_HAVEUSBHOST 1
|
||||
|
||||
/* TheMikroelektronika PIC32MX7 MMB does not have an SD slot on board. If one
|
||||
* is added, then it must be specified by defining which SPI bus that it
|
||||
* is connected on.
|
||||
*/
|
||||
/* The Mikroelektronika PIC32MX7 MMB has one SD slot on board, connected to SPI 1. */
|
||||
|
||||
#ifndef CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||
# undef CONFIG_NSH_HAVEMMCSD
|
||||
# define CONFIG_PIC32MX_MMCSDSPIPORTNO 1
|
||||
#endif
|
||||
|
||||
/* Make sure that the configuration will support the SD card */
|
||||
@ -84,7 +81,9 @@
|
||||
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||
# endif
|
||||
|
||||
/* Make sure that the NSH configuration uses the slot */
|
||||
/* Make sure that the NSH configuration uses slot 0 (there is only one
|
||||
* SD slot on the Mikroelektronica PIC32MX7 MMB).
|
||||
*/
|
||||
|
||||
# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# warning "The Mikroelektronika PIC32MX7 MMB has only one slot (0)"
|
||||
|
@ -58,24 +58,35 @@
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
/* SPI1 and SD Card
|
||||
*
|
||||
* ------ -------- ------------------------- --------------------------------
|
||||
* GPIO SIGNAL BOARD CONNECTION NOTES
|
||||
* ------ -------- ------------------------- --------------------------------
|
||||
* RC4 SPI1 SD card slot SPI1 data IN
|
||||
* RD0 SPO1 SD card slot SPI1 data OUT
|
||||
* RD10 SCK1 SD card slot SD card, SPI clock
|
||||
*
|
||||
* RA9 SD_CS# SD card slot SD card, SPI chip select (active low)
|
||||
* RG6 SD_WP SD card slot SD card, write protect
|
||||
* RG7 SD_CD# SD card slot SD card, card detect (not)
|
||||
*/
|
||||
|
||||
#define GPIO_SD_CS (GPIO_OUTPUT|GPIO_VALUE_ONE|GPIO_PORTA|GPIO_PIN9)
|
||||
#define GPIO_SD_WP (GPIO_INPUT|GPIO_PORTG|GPIO_PIN6)
|
||||
#define GPIO_SD_CD (GPIO_INPUT|GPIO_INT|GPIO_PORTG|GPIO_PIN7)
|
||||
|
||||
/* The following enable debug output from this file (needs CONFIG_DEBUG too).
|
||||
*
|
||||
* CONFIG_SPI_DEBUG - Define to enable basic SPI debug
|
||||
* CONFIG_SPI_VERBOSE - Define to enable verbose SPI debug
|
||||
* CONFIG_DEBUG_SPI - Define to enable basic SPI debug
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SPI_DEBUG
|
||||
# define sspdbg lldbg
|
||||
# ifdef CONFIG_SPI_VERBOSE
|
||||
# define sspvdbg lldbg
|
||||
# else
|
||||
# define sspvdbg(x...)
|
||||
# endif
|
||||
#ifdef CONFIG_DEBUG_SPI
|
||||
# define spidbg lldbg
|
||||
# define spivdbg llvdbg
|
||||
#else
|
||||
# undef CONFIG_SPI_VERBOSE
|
||||
# define sspdbg(x...)
|
||||
# define sspvdbg(x...)
|
||||
# define spidbg(x...)
|
||||
# define spivdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
@ -90,15 +101,20 @@
|
||||
* Name: pic32mx_sspinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the Sure PIC32MX board.
|
||||
* Called to configure SPI chip select GPIO pins for the Mikroelektronka PIC32MX7
|
||||
* MMB board.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function pic32mx_sspinitialize(void)
|
||||
{
|
||||
/* Configure the SPI chip select GPIOs */
|
||||
/* Configure the SPI chip select, write protect, and card detect GPIOs */
|
||||
|
||||
#warning "Missing logic"
|
||||
#ifdef CONFIG_PIC32MX_SPI1
|
||||
pic32mx_configgpio(GPIO_SD_CS);
|
||||
pic32mx_configgpio(GPIO_SD_WP);
|
||||
pic32mx_configgpio(GPIO_SD_CD);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
@ -135,15 +151,37 @@ enum spi_dev_e;
|
||||
#ifdef CONFIG_PIC32MX_SPI1
|
||||
void pic32mx_spi1select(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");
|
||||
#warning "Missing logic"
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
if (devid == SPIDEV_MMCSD)
|
||||
{
|
||||
pic32mx_gpiowrite(GPIO_SD_CS, !selected);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
sspdbg("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
uint8_t ret = 0;
|
||||
|
||||
/* Card detect active low. */
|
||||
|
||||
if (devid == SPIDEV_MMCSD)
|
||||
{
|
||||
if (!pic32mx_gpioread(GPIO_SD_CD))
|
||||
{
|
||||
ret = SPI_STATUS_PRESENT;
|
||||
|
||||
/* A high value indicates the the card is write protected. */
|
||||
|
||||
if (pic32mx_gpioread(GPIO_SD_WP))
|
||||
{
|
||||
ret |= SPI_STATUS_WRPROTECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spidbg("Returning %02x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
@ -154,21 +192,22 @@ int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cm
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC31MX_SPI1
|
||||
void pic31mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
#ifdef CONFIG_PIC31MX_SPI2
|
||||
void pic31mx_spi2select(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");
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic31mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
uint8_t pic31mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
sspdbg("Returning nothing\n");
|
||||
spidbg("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic31mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
int pic31mx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
@ -179,16 +218,17 @@ int pic31mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cm
|
||||
#ifdef CONFIG_PIC31MX_SPI3
|
||||
void pic32mx_spi3select(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");
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
sspdbg("Returning nothing\n");
|
||||
spidbg("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
@ -201,16 +241,17 @@ int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cm
|
||||
#ifdef CONFIG_PIC32MX_SPI4
|
||||
void pic32mx_spi4select(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");
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
sspdbg("Returning nothing\n");
|
||||
spidbg("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mx_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user