diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-10-03 15:09:47 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-10-03 15:09:47 +0000 |
commit | c93d6b613e5133e72269fb35cfb8f84dfd67b7ef (patch) | |
tree | a362f54d803ac4f89c4ddac7aa6167c229dae979 /nuttx | |
parent | 802c7ab706cb6f91e2632b5d3df755d8a2dce231 (diff) |
Add SAM3U board-specific SPI support
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4011 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx')
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_internal.h | 2 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sam3u/sam3u_internal.h | 64 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sam3u/sam3u_spi.c | 5 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/Makefile | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/sam3uek_internal.h | 492 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_boot.c | 226 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_buttons.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_lcd.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_leds.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_mmcsd.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_nsh.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_spi.c | 77 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_usbdev.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/configs/sam3u-ek/src/up_usbstrg.c | 0 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/touchscreen/defconfig | 6 | ||||
-rw-r--r-- | nuttx/include/nuttx/spi.h | 25 |
16 files changed, 480 insertions, 417 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h b/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h index f2b15bbd35..06bf3a9f4c 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h @@ -2,7 +2,7 @@ * arch/arm/src/lpc17xx/lpc17_internal.h * * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/nuttx/arch/arm/src/sam3u/sam3u_internal.h b/nuttx/arch/arm/src/sam3u/sam3u_internal.h index d8f1797a2d..d50d596354 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_internal.h +++ b/nuttx/arch/arm/src/sam3u/sam3u_internal.h @@ -2,7 +2,7 @@ * arch/arm/src/sam3u/sam3u_internal.h * * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -248,8 +248,27 @@ #define GPIO_SPI0_MISO (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN13) #define GPIO_SPI0_MOSI (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN14) #define GPIO_SPI0_SPCK (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN15) -//#define GPIO_SPI0_NPCS2_PC14 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN14) -#define GPIO_SPI0_NPCS2_PC14 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOC|GPIO_OUTPUT_CLEAR|GPIO_PIN14) +#if 0 +# define GPIO_SPI0_NPCS0 (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN16) +# define GPIO_SPI0_NPCS1_1 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN0) +# define GPIO_SPI0_NPCS1_2 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN3) +# define GPIO_SPI0_NPCS1_3 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN19) +# define GPIO_SPI0_NPCS2_1 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN1) +# define GPIO_SPI0_NPCS2_2 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN4) +# define GPIO_SPI0_NPCS2_3 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN14) +# define GPIO_SPI0_NPCS3_1 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN19) +# define GPIO_SPI0_NPCS3_2 (GPIO_PERIPHB|GPIO_CFG_DEFAULT|GPIO_PORT_PIOC|GPIO_PIN5) +#else +# define GPIO_SPI0_NPCS0 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOA|GPIO_PIN16) +# define GPIO_SPI0_NPCS1_1 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOA|GPIO_PIN0) +# define GPIO_SPI0_NPCS1_2 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN3) +# define GPIO_SPI0_NPCS1_3 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN19) +# define GPIO_SPI0_NPCS2_1 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOA|GPIO_PIN1) +# define GPIO_SPI0_NPCS2_2 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN4) +# define GPIO_SPI0_NPCS2_3 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN14) +# define GPIO_SPI0_NPCS3_1 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOA|GPIO_PIN19) +# define GPIO_SPI0_NPCS3_2 (GPIO_OUTPUT|GPIO_CFG_PULLUP|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN5) +#endif #define GPIO_SSC_TD (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN26) #define GPIO_SSC_TK (GPIO_PERIPHA|GPIO_CFG_DEFAULT|GPIO_PORT_PIOA|GPIO_PIN28) @@ -753,6 +772,45 @@ EXTERN void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); EXTERN void sdio_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect); +/**************************************************************************** + * Name: sam3u_spiselect, sam3u_spistatus, and sam3u_spicmddata + * + * Description: + * These external functions must be provided by board-specific logic. They + * are implementations of the select, status, and cmddata methods of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi.h). All + * other methods including up_spiinitialize()) are provided by common SAM3U + * logic. To use this common SPI logic on your board: + * + * 1. Provide logic in sam3u_boardinitialize() to configure SPI chip select + * pins. + * 2. Provide sam3u_spiselect() and sam3u_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 + * sam3u_spicmddata() functions in your board-specific logic. This + * function will perform cmd/data selection operations using GPIOs in + * the way your board is configured. + * 3. Add a call to up_spiinitialize() in your low level application + * initialization logic + * 4. The handle returned by up_spiinitialize() may then be used to bind the + * SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +struct spi_dev_s; +enum spi_dev_e; + +#ifdef CONFIG_SAM3U_SPI +EXTERN void sam3u_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); +EXTERN uint8_t sam3u_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid); +#ifdef CONFIG_SPI_CMDDATA +EXTERN int sam3u_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); +#endif +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/nuttx/arch/arm/src/sam3u/sam3u_spi.c b/nuttx/arch/arm/src/sam3u/sam3u_spi.c index 546f8b55de..3646134d10 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_spi.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_spi.c @@ -506,12 +506,13 @@ FAR struct spi_dev_s *up_spiinitialize(int port) #endif putreg32(regval, SAM3U_PMC_PCER); - /* Configure multiplexed pins as connected on the board. */ + /* Configure multiplexed pins as connected on the board. Chip select pins + * must be configured by board-specific logic. + */ sam3u_configgpio(GPIO_SPI0_MISO); sam3u_configgpio(GPIO_SPI0_MOSI); sam3u_configgpio(GPIO_SPI0_SPCK); - sam3u_configgpio(GPIO_SPI0_NPCS2_PC14); /* Execute a software reset of the SPI twice */ diff --git a/nuttx/configs/sam3u-ek/src/Makefile b/nuttx/configs/sam3u-ek/src/Makefile index 2bfa7693ea..2bfa7693ea 100755..100644 --- a/nuttx/configs/sam3u-ek/src/Makefile +++ b/nuttx/configs/sam3u-ek/src/Makefile diff --git a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h index 1e79a86f1e..2bc6d397df 100755..100644 --- a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h +++ b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h @@ -1,246 +1,246 @@ -/************************************************************************************
- * configs/sam3uek_eval/src/sam3uek_internal.h
- * arch/arm/src/board/sam3uek_internal.n
- *
- * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ************************************************************************************/
-
-#ifndef __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H
-#define __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H
-
-/************************************************************************************
- * Included Files
- ************************************************************************************/
-
-#include <nuttx/config.h>
-#include <nuttx/compiler.h>
-
-#include <stdint.h>
-
-#include <nuttx/irq.h>
-
-/************************************************************************************
- * Definitions
- ************************************************************************************/
-
-/* External Memory Usage ************************************************************/
-/* LCD on CS2 */
-
-#define LCD_BASE SAM3U_EXTCS2_BASE
-
-/* Touchscreen controller (TSC) */
-
-#define CONFIG_TSC_ADS7843 1 /* ADS7843 present on board */
-#define CONFIG_TSC_SPI 0 /* On SPI0 */
-
-/* SAM3U-EK GPIO Pin Definitions ****************************************************/
-
-/* LCD:
- * LCD Module Pin Out: AT91SAM3U PIO:
- * -------------------------------------------- --------------------------------------
- * Pin Symbol Function LCD PeriphA PeriphB Extra
- * ---- ------ -------------------------------- -------------- -------- ------- ------
- * 1 GND Ground N/A --- --- ---
- * 2 CS Chip Select PC16 NCS2 PWML3 AD12BAD5
- * 3 RS Register select signal PB8 (see A1) CTS0 A1 AD3
- * 4 WR Write operation signal PB23 (NWE) NWR0/NEW PCK1 ---
- * 5 RD Read operation signal PB19 (NRD) NRD PWML2 ---
- * 6 DB0 Data bus PB9 D0 DTR0 ---
- * 7 DB1 Data bus PB10 D1 DSR0 ---
- * 8 DB2 Data bus PB11 D2 DCD0 ---
- * 9 DB3 Data bus PB12 D3 RI0 ---
- * 10 DB4 Data bus PB13 D4 PWMH0 ---
- * 11 DB5 Data bus PB14 D5 PWMH1 ---
- * 12 DB6 Data bus PB15 D6 PWMH2 ---
- * 13 DB7 Data bus PB16 D7 PMWH3 ---
- * 14 DB8 Data bus PB25 D8 PWML0 ---
- * 15 DB9 Data bus PB26 D9 PWML1 ---
- * 16 DB10 Data bus PB27 D10 PWML2 ---
- * 17 DB11 Data bus PB28 D11 PWML3 ---
- * 18 DB12 Data bus PB29 D12 --- ---
- * 19 DB13 Data bus PB30 D13 --- ---
- * 20 DB14 Data bus PB31 D14 --- ---
- * 21 DB15 Data bus PB6 TIOA1 D15 AD1
- * 22 NC No connection N/A --- --- ---
- * 23 NC No connection N/A --- --- ---
- * 24 RESET Reset signal N/A --- --- ---
- * 25 GND Ground N/A --- --- ---
- * 26 X+ Touch panel X_RIGHT PA15 SPCK PWMH2 ---
- * 27 Y+ Touch panel Y_UP PA14 MOSI --- ---
- * 28 X- Touch panel X_LEFT PA13 MISO --- ---
- * 29 Y- Touch panel Y_DOWN PC14 A3 NPCS2 ---
- * 30 GND Ground N/A --- --- ---
- * 31 VDD1 Power supply for digital IO Pad N/A --- --- ---
- * 32 VDD2 Power supply for analog circuit N/A --- --- ---
- * 33 A1 Power supply for backlight PB8 (see RS) CTS0 A1 AD3
- * 34 A2 Power supply for backlight N/A --- --- ---
- * 35 A3 Power supply for backlight N/A --- --- ---
- * 36 A4 Power supply for backlight N/A --- --- ---
- * 37 NC No connection N/A --- --- ---
- * 38 NC No connection N/A --- --- ---
- * 39 K Backlight ground N/A --- --- ---
- */
-
-#define GPIO_LCD_NCS2 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOC|GPIO_PIN16)
-#define GPIO_LCD_RS (GPIO_PERIPHB|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN8)
-#define GPIO_LCD_NWE (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN23)
-#define GPIO_LCD_NRD (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN19)
-
-#define GPIO_LCD_D0 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN9)
-#define GPIO_LCD_D1 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN10)
-#define GPIO_LCD_D2 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN11)
-#define GPIO_LCD_D3 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN12)
-#define GPIO_LCD_D4 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN13)
-#define GPIO_LCD_D5 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN14)
-#define GPIO_LCD_D6 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN15)
-#define GPIO_LCD_D7 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN16)
-#define GPIO_LCD_D8 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN25)
-#define GPIO_LCD_D9 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN26)
-#define GPIO_LCD_D10 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN27)
-#define GPIO_LCD_D11 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN28)
-#define GPIO_LCD_D12 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN29)
-#define GPIO_LCD_D13 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN30)
-#define GPIO_LCD_D14 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN31)
-#define GPIO_LCD_D15 (GPIO_PERIPHB|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN6)
-
-/* LCD Backlight pin definition. */
-
-#define GPIO_LCD_BKL (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN19)
-
-/* Touchscreen controller (TSC) */
-
-#define GPIO_TCS_IRQ (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6)
-#define GPIO_TCS_BUSY (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6)
-
-/* LEDs */
-
-#define GPIO_LED0 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_CLEAR|GPIO_PIN0)
-#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_SET|GPIO_PIN1)
-#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_SET|GPIO_PIN2)
-
-/* BUTTONS */
-
-#define GPIO_BUTTON1 (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_CFG_DEGLITCH|GPIO_PORT_PIOA|GPIO_PIN18)
-#define GPIO_BUTTON2 (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_CFG_DEGLITCH|GPIO_PORT_PIOA|GPIO_PIN19)
-
-#define IRQ_BUTTON1 SAM3U_IRQ_PA18
-#define IRQ_BUTTON2 SAM3U_IRQ_PA19
-
-/* SD Card Detect */
-
-#define GPIO_MCI_CD (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN25)
-
-/* SPI Chip Selects */
-
-/* Chip select pin connected to the touchscreen controller. */
-
-#define GPIO_TSC_NPCS GPIO_SPI0_NPCS2_PC14
-
-/************************************************************************************
- * Public Types
- ************************************************************************************/
-
-/************************************************************************************
- * Public data
- ************************************************************************************/
-
-#ifndef __ASSEMBLY__
-
-/************************************************************************************
- * Public Functions
- ************************************************************************************/
-
-/************************************************************************************
- * Name: sam3u_spiinitialize
- *
- * Description:
- * Called to configure SPI chip select GPIO pins for the SAM3U-EK board.
- *
- ************************************************************************************/
-
-extern void weak_function sam3u_spiinitialize(void);
-
-/************************************************************************************
- * Name: sam3u_usbinitialize
- *
- * Description:
- * Called to setup USB-related GPIO pins for the SAM3U-EK board.
- *
- ************************************************************************************/
-
-extern void weak_function sam3u_usbinitialize(void);
-
-/****************************************************************************
- * Name: sam3u_hsmciinit
- *
- * Description:
- * Initialize HSMCI support
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAM3U_HSMCI
-extern int weak_function sam3u_hsmciinit(void);
-#else
-# define sam3u_hsmciinit()
-#endif
-
-/****************************************************************************
- * Name: sam3u_cardinserted
- *
- * Description:
- * Check if a card is inserted into the selected HSMCI slot
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAM3U_HSMCI
-extern bool sam3u_cardinserted(unsigned char slot);
-#else
-# define sam3u_cardinserted(slot) (false)
-#endif
-
-/****************************************************************************
- * Name: sam3u_writeprotected
- *
- * Description:
- * Check if a card is inserted into the selected HSMCI slot
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAM3U_HSMCI
-extern bool sam3u_writeprotected(unsigned char slot);
-#else
-# define sam3u_writeprotected(slot) (false)
-#endif
-
-#endif /* __ASSEMBLY__ */
-#endif /* __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H */
-
+/************************************************************************************ + * configs/sam3uek_eval/src/sam3uek_internal.h + * arch/arm/src/board/sam3uek_internal.n + * + * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H +#define __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/compiler.h> + +#include <stdint.h> + +#include <nuttx/irq.h> + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/* External Memory Usage ************************************************************/ +/* LCD on CS2 */ + +#define LCD_BASE SAM3U_EXTCS2_BASE + +/* Touchscreen controller (TSC) */ + +#define CONFIG_TSC_ADS7843 1 /* ADS7843 present on board */ +#define CONFIG_TSC_SPI 0 /* On SPI0 */ + +/* SAM3U-EK GPIO Pin Definitions ****************************************************/ + +/* LCD: + * LCD Module Pin Out: AT91SAM3U PIO: + * -------------------------------------------- -------------------------------------- + * Pin Symbol Function LCD PeriphA PeriphB Extra + * ---- ------ -------------------------------- -------------- -------- ------- ------ + * 1 GND Ground N/A --- --- --- + * 2 CS Chip Select PC16 NCS2 PWML3 AD12BAD5 + * 3 RS Register select signal PB8 (see A1) CTS0 A1 AD3 + * 4 WR Write operation signal PB23 (NWE) NWR0/NEW PCK1 --- + * 5 RD Read operation signal PB19 (NRD) NRD PWML2 --- + * 6 DB0 Data bus PB9 D0 DTR0 --- + * 7 DB1 Data bus PB10 D1 DSR0 --- + * 8 DB2 Data bus PB11 D2 DCD0 --- + * 9 DB3 Data bus PB12 D3 RI0 --- + * 10 DB4 Data bus PB13 D4 PWMH0 --- + * 11 DB5 Data bus PB14 D5 PWMH1 --- + * 12 DB6 Data bus PB15 D6 PWMH2 --- + * 13 DB7 Data bus PB16 D7 PMWH3 --- + * 14 DB8 Data bus PB25 D8 PWML0 --- + * 15 DB9 Data bus PB26 D9 PWML1 --- + * 16 DB10 Data bus PB27 D10 PWML2 --- + * 17 DB11 Data bus PB28 D11 PWML3 --- + * 18 DB12 Data bus PB29 D12 --- --- + * 19 DB13 Data bus PB30 D13 --- --- + * 20 DB14 Data bus PB31 D14 --- --- + * 21 DB15 Data bus PB6 TIOA1 D15 AD1 + * 22 NC No connection N/A --- --- --- + * 23 NC No connection N/A --- --- --- + * 24 RESET Reset signal N/A --- --- --- + * 25 GND Ground N/A --- --- --- + * 26 X+ Touch panel X_RIGHT PA15 SPCK PWMH2 --- + * 27 Y+ Touch panel Y_UP PA14 MOSI --- --- + * 28 X- Touch panel X_LEFT PA13 MISO --- --- + * 29 Y- Touch panel Y_DOWN PC14 A3 NPCS2 --- + * 30 GND Ground N/A --- --- --- + * 31 VDD1 Power supply for digital IO Pad N/A --- --- --- + * 32 VDD2 Power supply for analog circuit N/A --- --- --- + * 33 A1 Power supply for backlight PB8 (see RS) CTS0 A1 AD3 + * 34 A2 Power supply for backlight N/A --- --- --- + * 35 A3 Power supply for backlight N/A --- --- --- + * 36 A4 Power supply for backlight N/A --- --- --- + * 37 NC No connection N/A --- --- --- + * 38 NC No connection N/A --- --- --- + * 39 K Backlight ground N/A --- --- --- + */ + +#define GPIO_LCD_NCS2 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOC|GPIO_PIN16) +#define GPIO_LCD_RS (GPIO_PERIPHB|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN8) +#define GPIO_LCD_NWE (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN23) +#define GPIO_LCD_NRD (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN19) + +#define GPIO_LCD_D0 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN9) +#define GPIO_LCD_D1 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN10) +#define GPIO_LCD_D2 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN11) +#define GPIO_LCD_D3 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN12) +#define GPIO_LCD_D4 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN13) +#define GPIO_LCD_D5 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN14) +#define GPIO_LCD_D6 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN15) +#define GPIO_LCD_D7 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN16) +#define GPIO_LCD_D8 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN25) +#define GPIO_LCD_D9 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN26) +#define GPIO_LCD_D10 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN27) +#define GPIO_LCD_D11 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN28) +#define GPIO_LCD_D12 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN29) +#define GPIO_LCD_D13 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN30) +#define GPIO_LCD_D14 (GPIO_PERIPHA|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN31) +#define GPIO_LCD_D15 (GPIO_PERIPHB|GPIO_CFG_PULLUP|GPIO_PORT_PIOB|GPIO_PIN6) + +/* LCD Backlight pin definition. */ + +#define GPIO_LCD_BKL (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_OUTPUT_CLEAR|GPIO_PORT_PIOC|GPIO_PIN19) + +/* Touchscreen controller (TSC) */ + +#define GPIO_TCS_IRQ (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6) +#define GPIO_TCS_BUSY (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6) + +/* LEDs */ + +#define GPIO_LED0 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_CLEAR|GPIO_PIN0) +#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_SET|GPIO_PIN1) +#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CFG_DEFAULT|GPIO_PORT_PIOB|GPIO_OUTPUT_SET|GPIO_PIN2) + +/* BUTTONS */ + +#define GPIO_BUTTON1 (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_CFG_DEGLITCH|GPIO_PORT_PIOA|GPIO_PIN18) +#define GPIO_BUTTON2 (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_CFG_DEGLITCH|GPIO_PORT_PIOA|GPIO_PIN19) + +#define IRQ_BUTTON1 SAM3U_IRQ_PA18 +#define IRQ_BUTTON2 SAM3U_IRQ_PA19 + +/* SD Card Detect */ + +#define GPIO_MCI_CD (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN25) + +/* SPI Chip Selects */ + +/* Chip select pin connected to the touchscreen controller and to ZigBee module connector. */ + +#define GPIO_TSC_NPCS2 GPIO_SPI0_NPCS2_3 + +/************************************************************************************ + * Public Types + ************************************************************************************/ + +/************************************************************************************ + * Public data + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam3u_spiinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the SAM3U-EK board. + * + ************************************************************************************/ + +extern void weak_function sam3u_spiinitialize(void); + +/************************************************************************************ + * Name: sam3u_usbinitialize + * + * Description: + * Called to setup USB-related GPIO pins for the SAM3U-EK board. + * + ************************************************************************************/ + +extern void weak_function sam3u_usbinitialize(void); + +/**************************************************************************** + * Name: sam3u_hsmciinit + * + * Description: + * Initialize HSMCI support + * + ****************************************************************************/ + +#ifdef CONFIG_SAM3U_HSMCI +extern int weak_function sam3u_hsmciinit(void); +#else +# define sam3u_hsmciinit() +#endif + +/**************************************************************************** + * Name: sam3u_cardinserted + * + * Description: + * Check if a card is inserted into the selected HSMCI slot + * + ****************************************************************************/ + +#ifdef CONFIG_SAM3U_HSMCI +extern bool sam3u_cardinserted(unsigned char slot); +#else +# define sam3u_cardinserted(slot) (false) +#endif + +/**************************************************************************** + * Name: sam3u_writeprotected + * + * Description: + * Check if a card is inserted into the selected HSMCI slot + * + ****************************************************************************/ + +#ifdef CONFIG_SAM3U_HSMCI +extern bool sam3u_writeprotected(unsigned char slot); +#else +# define sam3u_writeprotected(slot) (false) +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIGS_SAM3U_EK_SRC_SAM3UEK_INTERNAL_H */ + diff --git a/nuttx/configs/sam3u-ek/src/up_boot.c b/nuttx/configs/sam3u-ek/src/up_boot.c index 36154f905e..a6dde5e1f0 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_boot.c +++ b/nuttx/configs/sam3u-ek/src/up_boot.c @@ -1,113 +1,113 @@ -/************************************************************************************
- * configs/sam3u-ek/src/up_boot.c
- * arch/arm/src/board/up_boot.c
- *
- * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ************************************************************************************/
-
-/************************************************************************************
- * Included Files
- ************************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <debug.h>
-
-#include <arch/board/board.h>
-
-#include "up_arch.h"
-#include "sam3uek_internal.h"
-
-/************************************************************************************
- * Definitions
- ************************************************************************************/
-
-/************************************************************************************
- * Private Functions
- ************************************************************************************/
-
-/************************************************************************************
- * Public Functions
- ************************************************************************************/
-
-/************************************************************************************
- * Name: sam3u_boardinitialize
- *
- * Description:
- * All SAM3U architectures must provide the following entry point. This entry point
- * is called early in the intitialization -- after all memory has been configured
- * and mapped but before any devices have been initialized.
- *
- ************************************************************************************/
-
-void sam3u_boardinitialize(void)
-{
- /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
- * sam3u_spiinitialize() has been brought into the link.
- */
-
-#if defined(CONFIG_SAM3U_SPI1) || defined(CONFIG_SAM3U_SPI2)
- if (sam3u_spiinitialize)
- {
- sam3u_spiinitialize();
- }
-#endif
-
- /* Initialize USB if 1) USBDEV is selected, 2) the USB controller is not
- * disabled, and 3) the weak function sam3u_usbinitialize() has been brought
- * into the build.
- */
-
-#if defined(CONFIG_USBDEV) && defined(CONFIG_SAM3U_USB)
- if (sam3u_usbinitialize)
- {
- sam3u_usbinitialize();
- }
-#endif
-
- /* Configure on-board LEDs if LED support has been selected. */
-
-#ifdef CONFIG_ARCH_LEDS
- up_ledinit();
-#endif
-
- /* Setup SD card-related PIOs if 1) HSMCI is selected and 2) the weak
- * function sam3u_hsmciinit() has been brought into the build.
- */
-
-#ifdef CONFIG_SAM3U_HSMCI
- if (sam3u_hsmciinit)
- {
- sam3u_hsmciinit();
- }
-#endif
-}
+/************************************************************************************ + * configs/sam3u-ek/src/up_boot.c + * arch/arm/src/board/up_boot.c + * + * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> + +#include <debug.h> + +#include <arch/board/board.h> + +#include "up_arch.h" +#include "sam3uek_internal.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam3u_boardinitialize + * + * Description: + * All SAM3U architectures must provide the following entry point. This entry point + * is called early in the intitialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +void sam3u_boardinitialize(void) +{ + /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function + * sam3u_spiinitialize() has been brought into the link. + */ + +#ifdef CONFIG_SAM3U_SPI + if (sam3u_spiinitialize) + { + sam3u_spiinitialize(); + } +#endif + + /* Initialize USB if 1) USBDEV is selected, 2) the USB controller is not + * disabled, and 3) the weak function sam3u_usbinitialize() has been brought + * into the build. + */ + +#if defined(CONFIG_USBDEV) && defined(CONFIG_SAM3U_USB) + if (sam3u_usbinitialize) + { + sam3u_usbinitialize(); + } +#endif + + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + up_ledinit(); +#endif + + /* Setup SD card-related PIOs if 1) HSMCI is selected and 2) the weak + * function sam3u_hsmciinit() has been brought into the build. + */ + +#ifdef CONFIG_SAM3U_HSMCI + if (sam3u_hsmciinit) + { + sam3u_hsmciinit(); + } +#endif +} diff --git a/nuttx/configs/sam3u-ek/src/up_buttons.c b/nuttx/configs/sam3u-ek/src/up_buttons.c index f56a685f80..f56a685f80 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_buttons.c +++ b/nuttx/configs/sam3u-ek/src/up_buttons.c diff --git a/nuttx/configs/sam3u-ek/src/up_lcd.c b/nuttx/configs/sam3u-ek/src/up_lcd.c index 2de563f9b9..2de563f9b9 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_lcd.c +++ b/nuttx/configs/sam3u-ek/src/up_lcd.c diff --git a/nuttx/configs/sam3u-ek/src/up_leds.c b/nuttx/configs/sam3u-ek/src/up_leds.c index c75896a364..c75896a364 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_leds.c +++ b/nuttx/configs/sam3u-ek/src/up_leds.c diff --git a/nuttx/configs/sam3u-ek/src/up_mmcsd.c b/nuttx/configs/sam3u-ek/src/up_mmcsd.c index 2f19c9cede..2f19c9cede 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_mmcsd.c +++ b/nuttx/configs/sam3u-ek/src/up_mmcsd.c diff --git a/nuttx/configs/sam3u-ek/src/up_nsh.c b/nuttx/configs/sam3u-ek/src/up_nsh.c index 842d8b7627..842d8b7627 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_nsh.c +++ b/nuttx/configs/sam3u-ek/src/up_nsh.c diff --git a/nuttx/configs/sam3u-ek/src/up_spi.c b/nuttx/configs/sam3u-ek/src/up_spi.c index 1b59f5c08f..99739983e3 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_spi.c +++ b/nuttx/configs/sam3u-ek/src/up_spi.c @@ -3,7 +3,7 @@ * arch/arm/src/board/up_spi.c * * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -52,7 +52,7 @@ #include "sam3u_internal.h" #include "sam3uek_internal.h" -#if defined(CONFIG_SAM3U_SPI1) || defined(CONFIG_SAM3U_SPI2) || defined(CONFIG_SAM3U_SPI3) +#ifdef CONFIG_SAM3U_SPI /************************************************************************************ * Definitions @@ -94,67 +94,64 @@ void weak_function sam3u_spiinitialize(void) { + /* The ZigBee module connects used NPCS0. However, there is not yet any + * ZigBee support. + */ + + /* The touchscreen connects using NPCS2 (PC14). */ + +#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E) + sam3u_configgpio(GPIO_TSC_NPCS2); +#endif } /**************************************************************************** - * Name: sam3u_spi1/2/3select and sam3u_spi1/2/3status + * Name: sam3u_spiselect, sam3u_spistatus, and sam3u_spicmddata * * Description: - * The external functions, sam3u_spi1/2/3select and sam3u_spi1/2/3status must be - * provided by board-specific logic. They are implementations of the select - * and status methods of the SPI interface defined by struct spi_ops_s (see - * include/nuttx/spi.h). All other methods (including up_spiinitialize()) - * are provided by common SAM3U logic. To use this common SPI logic on your - * board: + * These external functions must be provided by board-specific logic. They + * are implementations of the select, status, and cmddata methods of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi.h). All + * other methods including up_spiinitialize()) are provided by common SAM3U + * logic. To use this common SPI logic on your board: * * 1. Provide logic in sam3u_boardinitialize() to configure SPI chip select * pins. - * 2. Provide sam3u_spi1/2/3select() and sam3u_spi1/2/3status() functions in your - * board-specific logic. These functions will perform chip selection and - * status operations using GPIOs in the way your board is configured. - * 3. Add a calls to up_spiinitialize() in your low level application + * 2. Provide sam3u_spiselect() and sam3u_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 + * sam3u_spicmddata() functions in your board-specific logic. This + * function will perform cmd/data selection operations using GPIOs in + * the way your board is configured. + * 3. Add a call to up_spiinitialize() in your low level application * initialization logic * 4. The handle returned by up_spiinitialize() may then be used to bind the - * SPI driver to higher level logic (e.g., calling + * SPI driver to higher level logic (e.g., calling * mmcsd_spislotinitialize(), for example, will bind the SPI driver to * the SPI MMC/SD driver). * ****************************************************************************/ -#ifdef CONFIG_SAM3U_SPI1 -void sam3u_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) +#ifdef CONFIG_SAM3U_SPI +void sam3u_spiselect(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"); -} - -uint8_t sam3u_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) -{ - return SPI_STATUS_PRESENT; -} -#endif -#ifdef CONFIG_SAM3U_SPI2 -void sam3u_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"); -} +#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E) + if (devid == SPIDEV_TOUCHSCREEN) + { + /* Assert the CS pin to the OLED display */ -uint8_t sam3u_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) -{ - return SPI_STATUS_PRESENT; -} + (void)lpc17_gpiowrite(GPIO_TSC_NPCS2, !selected); + } #endif - -#ifdef CONFIG_SAM3U_SPI3 -void sam3u_spi3select(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"); } -uint8_t sam3u_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +uint8_t sam3u_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid) { - return SPI_STATUS_PRESENT; + return 0; } #endif -#endif /* CONFIG_SAM3U_SPI1 || CONFIG_SAM3U_SPI2 || CONFIG_SAM3U_SPI3 */ +#endif /* CONFIG_SAM3U_SPI */ diff --git a/nuttx/configs/sam3u-ek/src/up_usbdev.c b/nuttx/configs/sam3u-ek/src/up_usbdev.c index 9d97d65b55..9d97d65b55 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_usbdev.c +++ b/nuttx/configs/sam3u-ek/src/up_usbdev.c diff --git a/nuttx/configs/sam3u-ek/src/up_usbstrg.c b/nuttx/configs/sam3u-ek/src/up_usbstrg.c index e758e3b91a..e758e3b91a 100755..100644 --- a/nuttx/configs/sam3u-ek/src/up_usbstrg.c +++ b/nuttx/configs/sam3u-ek/src/up_usbstrg.c diff --git a/nuttx/configs/sam3u-ek/touchscreen/defconfig b/nuttx/configs/sam3u-ek/touchscreen/defconfig index 5696729600..f169291937 100755 --- a/nuttx/configs/sam3u-ek/touchscreen/defconfig +++ b/nuttx/configs/sam3u-ek/touchscreen/defconfig @@ -180,6 +180,12 @@ CONFIG_USART2_2STOP=0 CONFIG_USART3_2STOP=0 # +# Input device configuration +# +CONFIG_INPUT=y +CONFIG_INPUT_ADS7843E=y + +# # General build options # # CONFIG_RRLOAD_BINARY - make the rrload binary format used with diff --git a/nuttx/include/nuttx/spi.h b/nuttx/include/nuttx/spi.h index 9e904d5008..c5a9d0ff33 100644 --- a/nuttx/include/nuttx/spi.h +++ b/nuttx/include/nuttx/spi.h @@ -1,8 +1,8 @@ /**************************************************************************** * include/nuttx/spi.h * - * Copyright(C) 2008-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright(C) 2008-2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -347,22 +347,23 @@ typedef void (*spi_mediachange_t)(FAR void *arg); enum spi_dev_e { - SPIDEV_NONE = 0, /* Not a valid value */ - SPIDEV_MMCSD, /* Select SPI MMC/SD device */ - SPIDEV_FLASH, /* Select SPI FLASH device */ - SPIDEV_ETHERNET, /* Select SPI ethernet device */ - SPIDEV_DISPLAY, /* Select SPI LCD/OLED display device */ - SPIDEV_WIRELESS /* Select SPI Wireless device */ + SPIDEV_NONE = 0, /* Not a valid value */ + SPIDEV_MMCSD, /* Select SPI MMC/SD device */ + SPIDEV_FLASH, /* Select SPI FLASH device */ + SPIDEV_ETHERNET, /* Select SPI ethernet device */ + SPIDEV_DISPLAY, /* Select SPI LCD/OLED display device */ + SPIDEV_WIRELESS, /* Select SPI Wireless device */ + SPIDEV_TOUCHSCREEN /* Select SPI touchscreen device */ }; /* Certain SPI devices may required differnt clocking modes */ enum spi_mode_e { - SPIDEV_MODE0 = 0, /* CPOL=0 CHPHA=0 */ - SPIDEV_MODE1, /* CPOL=0 CHPHA=1 */ - SPIDEV_MODE2, /* CPOL=1 CHPHA=0 */ - SPIDEV_MODE3 /* CPOL=1 CHPHA=1 */ + SPIDEV_MODE0 = 0, /* CPOL=0 CHPHA=0 */ + SPIDEV_MODE1, /* CPOL=0 CHPHA=1 */ + SPIDEV_MODE2, /* CPOL=1 CHPHA=0 */ + SPIDEV_MODE3 /* CPOL=1 CHPHA=1 */ }; /* The SPI vtable */ |