diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-06-16 10:09:21 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-06-16 10:09:21 -0600 |
commit | 71b4709004ce55e2fe546b5a3f77b7b76064c78b (patch) | |
tree | cda598355a27e715cc56ed3e23fcfc916dc5f268 /nuttx/configs/sam3u-ek | |
parent | 1b19a9fffccfd15713798d73b884f3c80a7b1041 (diff) | |
download | px4-nuttx-71b4709004ce55e2fe546b5a3f77b7b76064c78b.tar.gz px4-nuttx-71b4709004ce55e2fe546b5a3f77b7b76064c78b.tar.bz2 px4-nuttx-71b4709004ce55e2fe546b5a3f77b7b76064c78b.zip |
Re-architected SAM3/4 SPI interface; Change BUSY bit handling in the ADS7843E driver
Diffstat (limited to 'nuttx/configs/sam3u-ek')
-rw-r--r-- | nuttx/configs/sam3u-ek/README.txt | 14 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/src/sam3u-ek.h | 18 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/src/up_spi.c | 50 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/src/up_touchscreen.c | 14 |
4 files changed, 31 insertions, 65 deletions
diff --git a/nuttx/configs/sam3u-ek/README.txt b/nuttx/configs/sam3u-ek/README.txt index 59aa65144..32d994329 100644 --- a/nuttx/configs/sam3u-ek/README.txt +++ b/nuttx/configs/sam3u-ek/README.txt @@ -572,20 +572,24 @@ Configuration sub-directories application. You can enable the touchscreen and test by modifying the default configuration in the following ways: - Drivers: + Device Drivers + CONFIG_SPI=y : Enable SPI support + CONFIG_SPI_EXCHANGE=y : The exchange() method is supported + CONFIG_SPI_OWNBUS=y : Smaller code if this is the only SPI device + CONFIG_INPUT=y : Enable support for input devices CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2048 - CONFIG_ADS7843E_SPIDEV=0 : Use SPI for communication + CONFIG_ADS7843E_SPIDEV=2 : Use SPI CS 2 for communication CONFIG_ADS7843E_SPIMODE=0 : Use SPI mode 0 CONFIG_ADS7843E_THRESHX=39 : These will probably need to be tuned CONFIG_ADS7843E_THRESHY=51 - CONFIG_SPI=y : Enable SPI support - CONFIG_SPI_EXCHANGE=n : exchange() method is not supported + + System Type -> Peripherals: + CONFIG_SAM34_SPI=y : Enable support for SPI System Type: CONFIG_GPIO_IRQ=y : GPIO interrupt support CONFIG_GPIOA_IRQ=y : Enable GPIO interrupts from port A - CONFIG_SAM34_SPI=y : Enable support for SPI RTOS Features: CONFIG_DISABLE_SIGNALS=n : Signals are required diff --git a/nuttx/configs/sam3u-ek/src/sam3u-ek.h b/nuttx/configs/sam3u-ek/src/sam3u-ek.h index 909abc42a..af68df42a 100644 --- a/nuttx/configs/sam3u-ek/src/sam3u-ek.h +++ b/nuttx/configs/sam3u-ek/src/sam3u-ek.h @@ -190,6 +190,7 @@ #define GPIO_TSC_NPCS2 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ GPIO_PORT_PIOC | GPIO_PIN14) +#define TSC_CSNUM 2 /************************************************************************************ * Public Types @@ -225,13 +226,13 @@ void weak_function sam_spiinitialize(void); void weak_function sam_usbinitialize(void); -/**************************************************************************** +/************************************************************************************ * Name: sam_hsmciinit * * Description: * Initialize HSMCI support * - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_SAM34_HSMCI int weak_function sam_hsmciinit(void); @@ -239,21 +240,21 @@ int weak_function sam_hsmciinit(void); # define sam_hsmciinit() #endif -/**************************************************************************** +/************************************************************************************ * Name: up_ledinit - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_ARCH_LEDS void up_ledinit(void); #endif -/**************************************************************************** +/************************************************************************************ * Name: sam_cardinserted * * Description: * Check if a card is inserted into the selected HSMCI slot * - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_SAM34_HSMCI bool sam_cardinserted(unsigned char slot); @@ -261,13 +262,13 @@ bool sam_cardinserted(unsigned char slot); # define sam_cardinserted(slot) (false) #endif -/**************************************************************************** +/************************************************************************************ * Name: sam_writeprotected * * Description: * Check if a card is inserted into the selected HSMCI slot * - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_SAM34_HSMCI bool sam_writeprotected(unsigned char slot); @@ -277,4 +278,3 @@ bool sam_writeprotected(unsigned char slot); #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM3U_EK_SRC_SAM3U_EK_H */ - diff --git a/nuttx/configs/sam3u-ek/src/up_spi.c b/nuttx/configs/sam3u-ek/src/up_spi.c index b14029f5d..5d4073237 100644 --- a/nuttx/configs/sam3u-ek/src/up_spi.c +++ b/nuttx/configs/sam3u-ek/src/up_spi.c @@ -107,28 +107,25 @@ void weak_function sam_spiinitialize(void) } /**************************************************************************** - * Name: sam_spicsnumber, sam_spiselect, sam_spistatus, and sam_spicmddata + * Name: sam_spiselect, sam_spistatus, and sam_spicmddata * * Description: * These external functions must be provided by board-specific logic. They * include: * - * o sam_spicsnumber and sam_spiselect which are helper functions to - * manage the board-specific aspects of the unique SAM3U chip select - * architecture. + * o sam_spiselect is a functions tomanage the board-specific chip selects * o sam_spistatus and sam_spicmddata: Implementations of the status * and cmddata methods of the SPI interface defined by struct spi_ops_ * (see include/nuttx/spi.h). All other methods including - * up_spiinitialize()) are provided by common SAM3U logic. + * up_spiinitialize()) are provided by common SAM3/4 logic. * * To use this common SPI logic on your board: * * 1. Provide logic in sam_boardinitialize() to configure SPI chip select * pins. - * 2. Provide sam_spicsnumber(), sam_spiselect() and sam_spistatus() - * functions in your board-specific logic. These functions will perform - * chip selection and status operations using GPIOs in the way your board - * is configured. + * 2. Provide sam_spiselect() and sam_spistatus() functions in your board- + * specific logic. These functions will perform chip selection and + * status operations using GPIOs in the way your board is configured. * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide * sam_spicmddata() functions in your board-specific logic. This * function will perform cmd/data selection operations using GPIOs in @@ -143,41 +140,6 @@ void weak_function sam_spiinitialize(void) ****************************************************************************/ /**************************************************************************** - * Name: sam_spicsnumber - * - * Description: - * The SAM3U has 4 CS registers for controlling device features. This - * function must be provided by board-specific code. Given a logical device - * ID, this function returns a number from 0 to 3 that identifies one of - * these SAM3U CS resources. - * - * Input Parameters: - * devid - Identifies the (logical) device - * - * Returned Values: - * On success, a CS number from 0 to 3 is returned; A negated errno may - * be returned on a failure. - * - ****************************************************************************/ - -int sam_spicsnumber(enum spi_dev_e devid) -{ - int cs = -EINVAL; - -#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E) - if (devid == SPIDEV_TOUCHSCREEN) - { - /* Assert the CS pin to the OLED display */ - - cs = 2; - } -#endif - - spidbg("devid: %d CS: %d\n", (int)devid, cs); - return cs; -} - -/**************************************************************************** * Name: sam_spiselect * * Description: diff --git a/nuttx/configs/sam3u-ek/src/up_touchscreen.c b/nuttx/configs/sam3u-ek/src/up_touchscreen.c index ea2ad3d0a..46a814c6f 100644 --- a/nuttx/configs/sam3u-ek/src/up_touchscreen.c +++ b/nuttx/configs/sam3u-ek/src/up_touchscreen.c @@ -75,11 +75,11 @@ #endif #ifndef CONFIG_ADS7843E_SPIDEV -# define CONFIG_ADS7843E_SPIDEV 0 +# define CONFIG_ADS7843E_SPIDEV TSC_CSNUM #endif -#if CONFIG_ADS7843E_SPIDEV != 0 -# error "CONFIG_ADS7843E_SPIDEV must be zero" +#if CONFIG_ADS7843E_SPIDEV != TSC_CSNUM +# error "CONFIG_ADS7843E_SPIDEV must have the same value as TSC_CSNUM" #endif #ifndef CONFIG_ADS7843E_DEVMINOR @@ -247,12 +247,12 @@ int arch_tcinitialize(int minor) sam_gpioirq(GPIO_TCS_IRQ); - /* Get an instance of the SPI interface */ + /* Get an instance of the SPI interface for the touchscreen chip select */ - dev = up_spiinitialize(CONFIG_ADS7843E_SPIDEV); + dev = up_spiinitialize(TSC_CSNUM); if (!dev) { - idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + idbg("Failed to initialize SPI chip select %d\n", TSC_CSNUM); return -ENODEV; } @@ -261,7 +261,7 @@ int arch_tcinitialize(int minor) ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); if (ret < 0) { - idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + idbg("Failed to initialize SPI chip select %d\n", TSC_CSNUM); /* up_spiuninitialize(dev); */ return -ENODEV; } |