Updates to PIC32 SPI driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4461 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
91746fa121
commit
bab5654afc
@ -77,7 +77,7 @@ PIC32MX440F512H Pin Out
|
||||
21 AN8/U2CTS/C1OUT/RB8 N/C Not connected
|
||||
22 AN9/C2OUT/PMA7/RB9 N/C Not connected
|
||||
23 TMS/AN10/CVREFOUT/PMA13/RB10 UTIL_WP FLASH (U1) WP*
|
||||
24 TDO/AN11/PMA12//RB11 SD_CS SD connector CS
|
||||
24 TDO/AN11/PMA12/RB11 SD_CS SD connector CS
|
||||
25 Vss Grounded
|
||||
26 Vdd +3.3V ---
|
||||
27 TCK/AN12/PMA11/RB12 SD_CD SD connector CD
|
||||
@ -452,15 +452,21 @@ selected as follow:
|
||||
Where <subdir> is one of the following:
|
||||
|
||||
ostest:
|
||||
-------
|
||||
=======
|
||||
Description.
|
||||
------------
|
||||
This configuration directory, performs a simple OS test using
|
||||
apps/examples/ostest.
|
||||
|
||||
nsh:
|
||||
----
|
||||
====
|
||||
Description.
|
||||
------------
|
||||
Configures the NuttShell (nsh) located at apps/examples/nsh. The
|
||||
Configuration enables only the serial NSH interface.
|
||||
|
||||
USB Configuations.
|
||||
-----------------
|
||||
Several USB device configurations can be enabled and included
|
||||
as NSH built-in built in functions. All require the following
|
||||
basic setup in your .config to enable USB device support:
|
||||
@ -491,8 +497,27 @@ Where <subdir> is one of the following:
|
||||
to enable the USB mass storage device. However, this device cannot
|
||||
work until support for the SD card is also incorporated.
|
||||
|
||||
SD Card Support.
|
||||
----------------
|
||||
Support for the on-board, SPI-based SD card is available but is
|
||||
not yet functional (at least at the time of this writing). SD
|
||||
card support can be enabled for testing by simply enabling SPI2
|
||||
support in the configuration file:
|
||||
|
||||
-CONFIG_PIC32MX_SPI2=n
|
||||
+CONFIG_PIC32MX_SPI2=y
|
||||
|
||||
Debug output for testing the SD card can be enabled using:
|
||||
|
||||
-CONFIG_DEBUG_FS=n
|
||||
-CONFIG_DEBUG_SPI=n
|
||||
+CONFIG_DEBUG_FS=y
|
||||
+CONFIG_DEBUG_SPI=y
|
||||
|
||||
usbnsh:
|
||||
-------
|
||||
=======
|
||||
Description.
|
||||
------------
|
||||
This is another NSH example. If differs from the 'nsh' configuration
|
||||
above in that this configurations uses a USB serial device for console
|
||||
I/O. This configuration was created to support the "DB-DP11212 PIC32
|
||||
@ -501,6 +526,8 @@ Where <subdir> is one of the following:
|
||||
"DB_DP11215 PIC32 Storage Demo Board" and has only be testing on that
|
||||
board.
|
||||
|
||||
Comparison to nsh
|
||||
-----------------
|
||||
Below summarizes the key configuration differences between the 'nsh'
|
||||
and the 'upnsh' configurations:
|
||||
|
||||
@ -511,6 +538,8 @@ Where <subdir> is one of the following:
|
||||
CONFIG_CDCACM=y : The CDC/ACM serial device class is enabled
|
||||
CONFIG_CDCACM_CONSOLE=y : The CDC/ACM serial device is the console
|
||||
|
||||
Using the Prolifics PL2303 Emulation
|
||||
------------------------------------
|
||||
You could also use the non-standard PL2303 serial device instead of
|
||||
the standard CDC/ACM serial device by changing:
|
||||
|
||||
|
@ -355,6 +355,8 @@ CONFIG_DEBUG_VERBOSE=n
|
||||
CONFIG_DEBUG_SYMBOLS=n
|
||||
CONFIG_DEBUG_SCHED=n
|
||||
CONFIG_DEBUG_USB=n
|
||||
CONFIG_DEBUG_FS=n
|
||||
CONFIG_DEBUG_SPI=n
|
||||
|
||||
CONFIG_HAVE_CXX=n
|
||||
CONFIG_HAVE_CXXINITIALIZE=n
|
||||
@ -910,7 +912,7 @@ CONFIG_NSH_DISABLEBG=n
|
||||
CONFIG_NSH_ROMFSETC=n
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
CONFIG_NSH_TELNET=n
|
||||
CONFIG_NSH_ARCHINIT=n
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_NSH_DHCPC=n
|
||||
CONFIG_NSH_NOMAC=n
|
||||
@ -929,7 +931,7 @@ CONFIG_NSH_FATMOUNTPT=/tmp
|
||||
#
|
||||
# Architecture-specific NSH options
|
||||
#
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=1
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=2
|
||||
CONFIG_NSH_MMCSDSLOTNO=0
|
||||
CONFIG_NSH_MMCSDMINOR=0
|
||||
|
||||
|
@ -766,7 +766,7 @@ CONFIG_NSH_DISABLEBG=n
|
||||
CONFIG_NSH_ROMFSETC=n
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
CONFIG_NSH_TELNET=n
|
||||
CONFIG_NSH_ARCHINIT=n
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_NSH_DHCPC=n
|
||||
CONFIG_NSH_NOMAC=n
|
||||
@ -785,7 +785,7 @@ CONFIG_NSH_FATMOUNTPT=/tmp
|
||||
#
|
||||
# Architecture-specific NSH options
|
||||
#
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=1
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=2
|
||||
CONFIG_NSH_MMCSDSLOTNO=0
|
||||
CONFIG_NSH_MMCSDMINOR=0
|
||||
|
||||
|
@ -69,9 +69,9 @@
|
||||
* notification will be enabled when pic32mx_gpioattach() is called.
|
||||
*/
|
||||
|
||||
#define GPIO_SW1 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN_3)
|
||||
#define GPIO_SW2 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN_2)
|
||||
#define GPIO_SW3 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN_4)
|
||||
#define GPIO_SW1 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN3)
|
||||
#define GPIO_SW2 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN2)
|
||||
#define GPIO_SW3 (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN4)
|
||||
|
||||
/* Change notification numbers:
|
||||
* RB3 -> CN5
|
||||
@ -91,7 +91,7 @@
|
||||
|
||||
static const uint16_t g_buttonset[NUM_BUTTONS] =
|
||||
{
|
||||
BUTTON_SW1 BUTTON_SW2, BUTTON_SW3
|
||||
GPIO_SW1 GPIO_SW2, GPIO_SW3
|
||||
}
|
||||
|
||||
/* Change notification number for each button */
|
||||
|
@ -63,7 +63,7 @@
|
||||
#ifdef CONFIG_ARCH_BOARD_SUREPIC32MX
|
||||
# define CONFIG_NSH_HAVEMMCSD 1
|
||||
# define CONFIG_NSH_HAVEUSBHOST 1
|
||||
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 1
|
||||
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 2
|
||||
# error "The Sure PIC32MX MMC/SD is on SPI2"
|
||||
# undef CONFIG_NSH_MMCSDSPIPORTNO
|
||||
# define CONFIG_NSH_MMCSDSPIPORTNO 2
|
||||
|
@ -2,7 +2,7 @@
|
||||
* configs/sure-pic32mx/src/up_spi.c
|
||||
* arch/arm/src/board/up_spi.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -57,22 +57,47 @@
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* 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
|
||||
/* The Sure PIC32MX has an SD slot connected on SPI2:
|
||||
*
|
||||
* SPI
|
||||
* SCK2/PMA5/CN8/RG6 SCK SD connector SCK, FLASH (U1) SCK*
|
||||
* SDI2/PMA4/CN9/RG7 SDI SD connector DO, FLASH (U1) SO*
|
||||
* SDO2/PMA3/CN10/RG8 SDO SD connector DI, FLASH (U1) SI*
|
||||
*
|
||||
* Chip Select. Pulled up on-board
|
||||
* TDO/AN11/PMA12/RB11 SD_CS SD connector CS
|
||||
*
|
||||
* Status inputs. All pulled up on-board
|
||||
*
|
||||
* TCK/AN12/PMA11/RB12 SD_CD SD connector CD
|
||||
* TDI/AN13/PMA10/RB13 SD_WD SD connector WD
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SPI_DEBUG
|
||||
#define GPIO_SD_CS (GPIO_OUTPUT|GPIO_VALUE_ONE|GPIO_PORTB|GPIO_PIN11)
|
||||
#define GPIO_SD_CD (GPIO_INPUT|GPIO_INT|GPIO_PORTB|GPIO_PIN12)
|
||||
#define GPIO_SD_WD (GPIO_INPUT|GPIO_PORTB|GPIO_PIN13)
|
||||
|
||||
/* Change notification numbers -- Not available for SD_CD. */
|
||||
|
||||
/* The following enable debug output from this file.
|
||||
*
|
||||
* CONFIG_DEBUG_SPI && CONFIG_DEBUG - Define to enable basic SPI debug
|
||||
* CONFIG_DEBUG_VERBOSE - Define to enable verbose SPI debug
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_SPI
|
||||
# undef CONFIG_DEBUG_VERBOSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_SPI
|
||||
# define spidbg lldbg
|
||||
# ifdef CONFIG_SPI_VERBOSE
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define spivdbg lldbg
|
||||
# else
|
||||
# define spivdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# undef CONFIG_SPI_VERBOSE
|
||||
# define spidbg(x...)
|
||||
# define spivdbg(x...)
|
||||
#endif
|
||||
@ -95,11 +120,13 @@
|
||||
|
||||
void weak_function pic32mx_spiinitialize(void)
|
||||
{
|
||||
/* Configure the SPI2 chip select GPIOs */
|
||||
/* Configure the SPI2 chip select (CS) GPIO output, and the card detect (CD) and
|
||||
* write protect (WP) inputs.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PIC32MX_SPI2
|
||||
# warning "Missing logic"
|
||||
#endif
|
||||
pic32mx_configgpio(GPIO_SD_CS);
|
||||
pic32mx_configgpio(GPIO_SD_CD);
|
||||
pic32mx_configgpio(GPIO_SD_WD);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
@ -128,17 +155,40 @@ void weak_function pic32mx_spiinitialize(void)
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PIC32MX_SPI2
|
||||
void pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
void pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
spivdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
/* The SD card chip select is pulled high and active low */
|
||||
|
||||
if (devid == SPIDEV_MMCSD)
|
||||
{
|
||||
pic32mx_gpiowrite(GPIO_SD_CS, !selected);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
spidbg("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
uint8_t ret = 0;
|
||||
|
||||
/* Card detect is pull up on-board. If a low value is sensed then the card must
|
||||
* be present.
|
||||
*/
|
||||
|
||||
if (!pic32mx_gpioread(GPIO_SD_CD))
|
||||
{
|
||||
ret = SPI_STATUS_PRESENT;
|
||||
|
||||
/* It seems that a high value indicatest the the card is write protected. */
|
||||
|
||||
if (pic32mx_gpioread(GPIO_SD_WD))
|
||||
{
|
||||
ret |= SPI_STATUS_WRPROTECTED;
|
||||
}
|
||||
}
|
||||
|
||||
spivdbg("Returning %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_PIC32MX_SPI2 */
|
||||
|
@ -2,7 +2,7 @@
|
||||
* configs/sure-pic32mx/src/up_usbdev.c
|
||||
* arch/arm/src/board/up_usbdev.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
|
@ -929,7 +929,7 @@ CONFIG_NSH_FATMOUNTPT=/tmp
|
||||
#
|
||||
# Architecture-specific NSH options
|
||||
#
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=1
|
||||
CONFIG_NSH_MMCSDSPIPORTNO=2
|
||||
CONFIG_NSH_MMCSDSLOTNO=0
|
||||
CONFIG_NSH_MMCSDMINOR=0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user