diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-04-01 22:00:37 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-04-01 22:00:37 +0000 |
commit | 87590afa9ca772243c261e6c1b8478565bd2771a (patch) | |
tree | d7a3161c5dea29510630f239e027dc32bac968fc | |
parent | f7122813d51018e5d3460a30596d2320a08ef740 (diff) | |
download | nuttx-87590afa9ca772243c261e6c1b8478565bd2771a.tar.gz nuttx-87590afa9ca772243c261e6c1b8478565bd2771a.tar.bz2 nuttx-87590afa9ca772243c261e6c1b8478565bd2771a.zip |
More naming changes associated with earlier renaming of LP17xx up_spiinitialize; LPC178x SSP support; Open1788 SSP and touchscreen support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5811 42af7a65-404d-4744-a932-0658087f49c3
35 files changed, 861 insertions, 98 deletions
diff --git a/apps/examples/README.txt b/apps/examples/README.txt index ff22580d0..fe16ada85 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -1509,7 +1509,7 @@ examples/touchscreen CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN - Build the touchscreen test as an NSH built-in function. Default: Built as a standalone problem CONFIG_EXAMPLES_TOUCHSCREEN_MINOR - The minor device number. Minor=N - correspnds to touchscreen device /dev/input0. Note this value must + corresponds to touchscreen device /dev/input0. Note this value must with CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH. Default 0. CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH - The path to the touchscreen device. This must be consistent with CONFIG_EXAMPLES_TOUCHSCREEN_MINOR. @@ -1523,13 +1523,12 @@ examples/touchscreen The following additional configurations must be set in the NuttX configuration file: - CONFIG_INPUTP=y + CONFIG_INPUT=y (Plus any touchscreen-specific settings). The following must also be defined in your apps configuration file: - CONFIGURED_APPS += examples/tiff - CONFIGURED_APPS += graphics/tiff + CONFIGURED_APPS += examples/touchscreen The board-specific logic must provide the following interfaces that will be called by the example in order to initialize and uninitialize the diff --git a/apps/examples/touchscreen/Kconfig b/apps/examples/touchscreen/Kconfig index e8d8728d8..18ece4923 100644 --- a/apps/examples/touchscreen/Kconfig +++ b/apps/examples/touchscreen/Kconfig @@ -10,4 +10,39 @@ config EXAMPLES_TOUCHSCREEN Enable the touchscreen example if EXAMPLES_TOUCHSCREEN + +config EXAMPLES_TOUCHSCREEN_BUILTIN + bool "NSH built-in application" + default y + depends on NSH_BUILTIN_APPS + ---help--- + Build the touchscreen test as an NSH built-in function. Default: + Built as a standalone problem unless NSH_BUILTIN_APPS is defined. + Then the default is to build as an NSH built-in application. + +config EXAMPLES_TOUCHSCREEN_MINOR + int "Touchscreen minor device number" + default 0 + ---help--- + The minor device number. Minor=N corresponds to touchscreen device + /dev/input0. Note this value must with EXAMPLES_TOUCHSCREEN_DEVPATH. + Default 0. + +config EXAMPLES_TOUCHSCREEN_DEVPATH + string "Touchscreen device path" + default "/dev/input0" + ---help--- + The path to the touchscreen device. This must be consistent with + EXAMPLES_TOUCHSCREEN_MINOR. Default: "/dev/input0" + +config EXAMPLES_TOUCHSCREEN_NSAMPLES + int "Number of samples" + default 0 + depends on !EXAMPLES_TOUCHSCREEN_BUILTIN + ---help--- + If EXAMPLES_TOUCHSCREEN_BUILTIN is defined, then the number of + samples is provided on the command line and this value is ignored. + Otherwise, this number of samples is collected and the program + terminates. Default: Zero (Samples are collected indefinitely). + endif diff --git a/apps/examples/touchscreen/tc.h b/apps/examples/touchscreen/tc.h index dddff11c3..055353ddd 100644 --- a/apps/examples/touchscreen/tc.h +++ b/apps/examples/touchscreen/tc.h @@ -42,7 +42,6 @@ #include <nuttx/config.h> - /**************************************************************************** * Definitions ****************************************************************************/ @@ -50,7 +49,7 @@ /* CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN - Build the touchscreen test as * an NSH built-in function. Default: Built as a standalone problem * CONFIG_EXAMPLES_TOUCHSCREEN_MINOR - The minor device number. Minor=N - * correspnds to touchscreen device /dev/input0. Note this value must + * corresponds to touchscreen device /dev/input0. Note this value must * with CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH. Default 0. * CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH - The path to the touchscreen * device. This must be consistent with CONFIG_EXAMPLES_TOUCHSCREEN_MINOR. @@ -58,8 +57,8 @@ * CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES - If CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN * is defined, then the number of samples is provided on the command line * and this value is ignored. Otherwise, this number of samples is - * collected and the program terminates. Default: Samples are collected - * indefinitely. + * collected and the program terminates. Default: Zero (Samples are collected + * indefinitely). */ #ifndef CONFIG_INPUT @@ -78,6 +77,10 @@ # define CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH "/dev/input0" #endif +#ifndef CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES +# define CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES 0 +#endif + /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS diff --git a/apps/examples/touchscreen/tc_main.c b/apps/examples/touchscreen/tc_main.c index 79b6b65a3..d49902612 100644 --- a/apps/examples/touchscreen/tc_main.c +++ b/apps/examples/touchscreen/tc_main.c @@ -88,7 +88,7 @@ int tc_main(int argc, char *argv[]) { struct touch_sample_s sample; ssize_t nbytes; -#if defined(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN) || defined(CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES) +#if defined(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN) || CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES > 0 long nsamples; #endif int fd; @@ -106,7 +106,7 @@ int tc_main(int argc, char *argv[]) nsamples = strtol(argv[1], NULL, 10); } message("tc_main: nsamples: %d\n", nsamples); -#elif defined(CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES) +#elif CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES > 0 message("tc_main: nsamples: %d\n", CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES); #endif @@ -141,7 +141,7 @@ int tc_main(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN) for (; nsamples > 0; nsamples--) -#elif defined(CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES) +#elif CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES > 0 for (nsamples = 0; nsamples < CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES; nsamples++) #else for (;;) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0407e5501..bcd80fd73 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -4483,9 +4483,9 @@ which is apparently disabled in sleep mode; up_idle() always enters sleep mode (2013-03-31). * arch/arm/src/stm32: Add architecure support for the STM32 F427/F437 - chips. Contributed by Mike Smith (2014-4-01). + chips. Contributed by Mike Smith (2013-4-01). * configs/zkit-arm-1769/src/up_can.c: Add support for both CAN1 - and CAN2. Contributed by M.Kannan (2014-4-01). + and CAN2. Contributed by M.Kannan (2013-4-01). * arch/arm/src/lpc17xx/lpc17_spi.c and lpc17_ssp.c and configs/olimex-lpc1766stk, nucleus2g, zkit-arm-1769, and lpcxpresso-lpc1768: The initialization function for both the LPC17xx @@ -4495,13 +4495,19 @@ LPC17xx (and also as does other architectures like STM32 that have USARTs that can serve as SPI interfaces as well). These were renamed to lpc17_spiinitialize() and lpc17_sspinitialize() in this case. - Problem reported by M. Kannan (2014-4-01). + Problem reported by M. Kannan (2013-4-01). * arch/arm/src/lpc17xx/lpc17_gpdma.c and lpc17_idle.c: In sleep mode, DMA can only be performed from peripheral SRAM. CPU SRAM is shutdown in sleep mode. In order to simplify DMA memory allocation, the LPC17xx - IDLE will not hold off going to sleep mode if there is a DMA in progress - (2014-4-01). + IDLE will now hold off going to sleep mode if there is a DMA in progress + (2013-4-01). * configs/open1788/src/lpc17_autoleds.c: Reversed sense of the IDLE LCD. It is now off when the LPC17 is sleeping and on when awake. That is much more useful because it provides a good visual indication of the - dynamic CPU load (2014-4-01). + dynamic CPU load (2013-4-01). + * configs/open1788/src/lpc17_touchscreen.c and lpc17_ssp.c: Add + support for the touschscreen on the WaveShare LCD (2013-4-01). + * configs/several: There were already some functions called + lpc17_sspinitialize(). So they had to be renamed (2013-4-01). + * arch/arm/src/lpc17xx/lpc17_ssp.c: Adapted to work the the LPC178x + family (2013-4-01). diff --git a/nuttx/arch/arm/src/lpc17xx/chip/lpc178x_iocon.h b/nuttx/arch/arm/src/lpc17xx/chip/lpc178x_iocon.h index cf2620ebe..e584adad6 100755 --- a/nuttx/arch/arm/src/lpc17xx/chip/lpc178x_iocon.h +++ b/nuttx/arch/arm/src/lpc17xx/chip/lpc178x_iocon.h @@ -312,15 +312,15 @@ #define IOCON_FUNC_MASK (7 << IOCON_FUNC_SHIFT) #define IOCON_MODE_SHIFT (3) /* Bits 3-4: Type D,A,W */ #define IOCON_MODE_MASK (3 << IOCON_MODE_SHIFT ) -#define IOCON_HYS_SHIFT (5) /* Bit 5: Type D,W */ +#define IOCON_HYS_SHIFT (5) /* Bit 5: Type D,W */ #define IOCON_HYS_MASK (1 << IOCON_HYS_SHIFT) -#define IOCON_INV_SHIFT (6) /* Bit 6: Typ D,A,I,W */ +#define IOCON_INV_SHIFT (6) /* Bit 6: Type D,A,I,W */ #define IOCON_INV_MASK (1 << IOCON_INV_SHIFT) #define IOCON_ADMODE_SHIFT (7) /* Bit 7: Type A */ #define IOCON_ADMODE_MASK (1 << IOCON_ADMODE_SHIFT) #define IOCON_FILTER_SHIFT (8) /* Bit 8: Type A */ #define IOCON_FILTER_MASK (1 << IOCON_FILTER_SHIFT) -#define IOCON_SLEW_SHIFT (9) /* Bit 9: Type W*/ +#define IOCON_SLEW_SHIFT (9) /* Bit 9: Type W */ #define IOCON_SLEW_MASK (1 << IOCON_SLEW_SHIFT) #define IOCON_HIDRIVE_SHIFT (9) /* Bit 9: Type I */ #define IOCON_HIDRIVE_MASK (1 << IOCON_HIDRIVE_SHIFT) diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.h b/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.h index a5d07f11d..cfe940614 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.h +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.h @@ -193,7 +193,7 @@ #define GPIO_IOCON_TYPE_I_MASK (0x00000347) /* I2C/USB P0:27-28, P5:2-3 */ #define GPIO_IOCON_TYPE_W_MASK (0x000007ff) /* I2S P0:7-9 */ -#define GPIO_IOCON_MASK (0x00FF0000) +#define GPIO_IOCON_MASK (0x00ff0000) # define GPIO_HYSTERESIS (1 << 16) /* Bit 16: HYSTERESIS: 0-Disable, 1-Enabled */ # define GPIO_INVERT (1 << 17) /* Bit 17: Input: 0-Not Inverted, 1-Inverted */ # define GPIO_SLEW (1 << 18) /* Bit 18: Rate Control: 0-Standard mode, 1-Fast mode */ @@ -259,7 +259,7 @@ #define GPIO_VALUE_ONE GPIO_VALUE #define GPIO_VALUE_ZERO (0) -/* Port number: PPP (0-5) */ +/* Port number: PPP (0-5) */ #define GPIO_PORT_SHIFT (5) /* Bit 5-7: Port number */ #define GPIO_PORT_MASK (7 << GPIO_PORT_SHIFT) @@ -272,7 +272,7 @@ #define GPIO_NPORTS 6 -/* Pin number: NNNNN (0-31) */ +/* Pin number: NNNNN (0-31) */ #define GPIO_PIN_SHIFT 0 /* Bits 0-4: GPIO number: 0-31 */ #define GPIO_PIN_MASK (31 << GPIO_PIN_SHIFT) diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c b/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c index 81b182e6c..3c9a51904 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c @@ -58,7 +58,8 @@ #include "lpc17_gpio.h" #include "lpc17_ssp.h" -#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) +#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) || \ + defined(CONFIG_LPC17_SSP2) /**************************************************************************** * Definitions @@ -91,6 +92,7 @@ #endif /* SSP Clocking *************************************************************/ +#if defined(LPC176x) /* The CPU clock by 1, 2, 4, or 8 to get the SSP peripheral clock (SSP_CLOCK). * SSP_CLOCK may be further divided by 2-254 to get the SSP clock. If we * want a usable range of 4KHz to 25MHz for the SSP, then: @@ -102,12 +104,22 @@ * use the CCLK undivided to get the SSP_CLOCK. */ -#if LPC17_CCLK > 100000000 -# error "CCLK <= 100,000,000 assumed" -#endif +# if LPC17_CCLK > 100000000 +# error "CCLK <= 100,000,000 assumed" +# endif + +# define SSP_PCLKSET_DIV SYSCON_PCLKSEL_CCLK +# define SSP_CLOCK LPC17_CCLK + +/* All peripherals are clocked by the same peripheral clock in the LPC178x + * family. + */ + +#elif defined(LPC178x) -#define SSP_PCLKSET_DIV SYSCON_PCLKSEL_CCLK -#define SSP_CLOCK LPC17_CCLK +# define SSP_CLOCK BOARD_PCLK_FREQUENCY + +#endif /**************************************************************************** * Private Types @@ -161,6 +173,9 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp0initialize(void); #ifdef CONFIG_LPC17_SSP1 static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void); #endif +#ifdef CONFIG_LPC17_SSP2 +static inline FAR struct lpc17_sspdev_s *lpc17_ssp2initialize(void); +#endif /**************************************************************************** * Private Data @@ -234,6 +249,40 @@ static struct lpc17_sspdev_s g_ssp1dev = }; #endif /* CONFIG_LPC17_SSP1 */ +#ifdef CONFIG_LPC17_SSP2 +static const struct spi_ops_s g_spi2ops = +{ +#ifndef CONFIG_SPI_OWNBUS + .lock = ssp_lock, +#endif + .select = lpc17_ssp2select, /* Provided externally */ + .setfrequency = ssp_setfrequency, + .setmode = ssp_setmode, + .setbits = ssp_setbits, + .status = lpc17_ssp2status, /* Provided externally */ +#ifdef CONFIG_SPI_CMDDATA + .cmddata = lpc17_ssp2cmddata, /* Provided externally */ +#endif + .send = ssp_send, + .sndblock = ssp_sndblock, + .recvblock = ssp_recvblock, +#ifdef CONFIG_SPI_CALLBACK + .registercallback = lpc17_ssp2register, /* Provided externally */ +#else + .registercallback = 0, /* Not implemented */ +#endif +}; + +static struct lpc17_sspdev_s g_ssp2dev = +{ + .spidev = { &g_spi2ops }, + .sspbase = LPC17_SSP2_BASE, +#ifdef CONFIG_LPC17_SSP_INTERRUPTS + .sspirq = LPC17_IRQ_SSP2, +#endif +}; +#endif /* CONFIG_LPC17_SSP2 */ + /**************************************************************************** * Public Data ****************************************************************************/ @@ -741,10 +790,12 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp0initialize(void) /* Configure clocking */ +#ifdef LPC176x regval = getreg32(LPC17_SYSCON_PCLKSEL1); regval &= ~SYSCON_PCLKSEL1_SSP0_MASK; regval |= (SSP_PCLKSET_DIV << SYSCON_PCLKSEL1_SSP0_SHIFT); putreg32(regval, LPC17_SYSCON_PCLKSEL1); +#endif /* Enable peripheral clocking to SSP0 */ @@ -793,10 +844,12 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void) /* Configure clocking */ +#ifdef LPC176x regval = getreg32(LPC17_SYSCON_PCLKSEL0); regval &= ~SYSCON_PCLKSEL0_SSP1_MASK; regval |= (SSP_PCLKSET_DIV << SYSCON_PCLKSEL0_SSP1_SHIFT); putreg32(regval, LPC17_SYSCON_PCLKSEL0); +#endif /* Enable peripheral clocking to SSP0 and SSP1 */ @@ -810,6 +863,59 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void) #endif /**************************************************************************** + * Name: lpc17_ssp2initialize + * + * Description: + * Initialize the SSP2 + * + * Input Parameter: + * None + * + * Returned Value: + * Valid SPI device structure reference on succcess; a NULL on failure + * + ****************************************************************************/ + +#ifdef CONFIG_LPC17_SSP2 +static inline FAR struct lpc17_sspdev_s *lpc17_ssp2initialize(void) +{ + irqstate_t flags; + uint32_t regval; + + /* Configure multiplexed pins as connected on the board. Chip select + * pins must be configured by board-specific logic. All SSP2 pins have + * multiple, alternative pin selection. Definitions in the board.h file + * must be provided to resolve the board-specific pin configuration like: + * + * #define GPIO_SSP2_SCK GPIO_SSP2_SCK_1 + */ + + flags = irqsave(); + lpc17_configgpio(GPIO_SSP2_SCK); + lpc17_configgpio(GPIO_SSP2_MISO); + lpc17_configgpio(GPIO_SSP2_MOSI); + + /* Configure clocking */ + +#ifdef LPC176x + regval = getreg32(LPC17_SYSCON_PCLKSEL0); + regval &= ~SYSCON_PCLKSEL0_SSP2_MASK; + regval |= (SSP_PCLKSET_DIV << SYSCON_PCLKSEL0_SSP2_SHIFT); + putreg32(regval, LPC17_SYSCON_PCLKSEL0); +#endif + + /* Enable peripheral clocking to SSP0 and SSP1 */ + + regval = getreg32(LPC17_SYSCON_PCONP); + regval |= SYSCON_PCONP_PCSSP2; + putreg32(regval, LPC17_SYSCON_PCONP); + irqrestore(flags); + + return &g_ssp2dev; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -847,6 +953,11 @@ FAR struct spi_dev_s *lpc17_sspinitialize(int port) priv = lpc17_ssp1initialize(); break; #endif +#ifdef CONFIG_LPC17_SSP2 + case 2: + priv = lpc17_ssp2initialize(); + break; +#endif default: return NULL; } diff --git a/nuttx/configs/lincoln60/src/lincoln60_internal.h b/nuttx/configs/lincoln60/src/lincoln60_internal.h index 022522e39..5f9891883 100644 --- a/nuttx/configs/lincoln60/src/lincoln60_internal.h +++ b/nuttx/configs/lincoln60/src/lincoln60_internal.h @@ -91,14 +91,14 @@ ****************************************************************************/ /**************************************************************************** - * Name: lpc17_sspinitialize + * Name: lincoln60_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the Lincoln 60 board. * ****************************************************************************/ -extern void weak_function lpc17_sspinitialize(void); +void weak_function lincoln60_sspinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_LINCOLN60_SRC_LINCOLN60_INTERNAL_H */ diff --git a/nuttx/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h b/nuttx/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h index 3e7dfa4e5..01a838e1c 100644 --- a/nuttx/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h +++ b/nuttx/configs/lpcxpresso-lpc1768/src/lpcxpresso_internal.h @@ -222,14 +222,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: lpcxpresso_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the LPCXpresso board. * ************************************************************************************/ -extern void weak_function lpc17_sspinitialize(void); +void weak_function lpcxpresso_sspinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_LPCXPRESSO_LPC1768_SRC_LPCXPRESSO_INTERNAL_H */ diff --git a/nuttx/configs/lpcxpresso-lpc1768/src/up_boot.c b/nuttx/configs/lpcxpresso-lpc1768/src/up_boot.c index 9766569a9..53e4c2a9d 100644 --- a/nuttx/configs/lpcxpresso-lpc1768/src/up_boot.c +++ b/nuttx/configs/lpcxpresso-lpc1768/src/up_boot.c @@ -75,13 +75,13 @@ void lpc17_boardinitialize(void) { /* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak - * function lpc17_sspinitialize() has been brought into the link. + * function lpcxpresso_sspinitialize() has been brought into the link. */ #if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) - if (lpc17_sspinitialize) + if (lpcxpresso_sspinitialize) { - lpc17_sspinitialize(); + lpcxpresso_sspinitialize(); } #endif diff --git a/nuttx/configs/lpcxpresso-lpc1768/src/up_ssp.c b/nuttx/configs/lpcxpresso-lpc1768/src/up_ssp.c index ff5908753..014da6f1e 100644 --- a/nuttx/configs/lpcxpresso-lpc1768/src/up_ssp.c +++ b/nuttx/configs/lpcxpresso-lpc1768/src/up_ssp.c @@ -94,18 +94,18 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: lpcxpresso_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the LPCXpresso. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void) +void weak_function lpcxpresso_sspinitialize(void) { /* Configure the SPI-based microSD CS GPIO */ - ssp_dumpgpio("lpc17_sspinitialize() Entry)"); + ssp_dumpgpio("lpcxpresso_sspinitialize() Entry)"); /* Configure card detect and chip select for the SD slot. NOTE: Jumper J55 must * be set correctly for the SD slot chip select. @@ -124,7 +124,7 @@ void weak_function lpc17_sspinitialize(void) #endif #endif - ssp_dumpgpio("lpc17_sspinitialize() Exit"); + ssp_dumpgpio("lpcxpresso_sspinitialize() Exit"); } /************************************************************************************ diff --git a/nuttx/configs/mbed/src/mbed_internal.h b/nuttx/configs/mbed/src/mbed_internal.h index 6b966b47a..947799d3c 100644 --- a/nuttx/configs/mbed/src/mbed_internal.h +++ b/nuttx/configs/mbed/src/mbed_internal.h @@ -80,14 +80,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: mbed_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the NUCLEUS-2G board. * ************************************************************************************/ -extern void weak_function lpc17_sspinitialize(void); +void weak_function mbed_sspinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_MBED_SRC_MBED_INTERNAL_H */ diff --git a/nuttx/configs/nucleus2g/src/nucleus2g_internal.h b/nuttx/configs/nucleus2g/src/nucleus2g_internal.h index 168b9aa1d..48f176697 100644 --- a/nuttx/configs/nucleus2g/src/nucleus2g_internal.h +++ b/nuttx/configs/nucleus2g/src/nucleus2g_internal.h @@ -140,16 +140,16 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: nucleus2g_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the NUCLEUS-2G board. * ************************************************************************************/ -extern void weak_function lpc17_sspinitialize(void); +void weak_function nucleus2g_sspinitialize(void); -extern void up_relayinit(void); +void up_relayinit(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_NUCLEUS2G_SRC_NUCLEUS2G_INTERNAL_H */ diff --git a/nuttx/configs/nucleus2g/src/up_boot.c b/nuttx/configs/nucleus2g/src/up_boot.c index 7c1242c33..ee2855c2f 100644 --- a/nuttx/configs/nucleus2g/src/up_boot.c +++ b/nuttx/configs/nucleus2g/src/up_boot.c @@ -93,13 +93,13 @@ void lpc17_boardinitialize(void) #endif /* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak - * function lpc17_sspinitialize() has been brought into the link. + * function nucleus2g_sspinitialize() has been brought into the link. */ #if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) - if (lpc17_sspinitialize) + if (nucleus2g_sspinitialize) { - lpc17_sspinitialize(); + nucleus2g_sspinitialize(); } #endif diff --git a/nuttx/configs/nucleus2g/src/up_ssp.c b/nuttx/configs/nucleus2g/src/up_ssp.c index 435378bba..7a3d16a46 100644 --- a/nuttx/configs/nucleus2g/src/up_ssp.c +++ b/nuttx/configs/nucleus2g/src/up_ssp.c @@ -94,18 +94,18 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: nucleus2g_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the Nucleus 2G. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void) +void weak_function nucleus2g_sspinitialize(void) { /* Configure the SPI-based microSD CS GPIO */ - ssp_dumpgpio("lpc17_sspinitialize() Entry)"); + ssp_dumpgpio("nucleus2g_sspinitialize() Entry)"); /* SSP0 connects only to the MMC/SD slot on the Nucleus 1G board. * P0[15]/TXD1/SCK0/SCK MMC_CLK @@ -127,7 +127,7 @@ void weak_function lpc17_sspinitialize(void) #ifdef CONFIG_LPC17_SSP1 # warning "SSP1 chip selects not known" #endif - ssp_dumpgpio("lpc17_sspinitialize() Exit"); + ssp_dumpgpio("nucleus2g_sspinitialize() Exit"); } /************************************************************************************ diff --git a/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h b/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h index 31159de52..86f65ed9e 100644 --- a/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h +++ b/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h @@ -252,14 +252,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: lpc1766stk_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the Olimex LPC1766-STK board. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void); +void weak_function lpc1766stk_sspinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_OLIMEX_LPC1766STK_SRC_LPC1766STK_INTERNAL_H */ diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_boot.c b/nuttx/configs/olimex-lpc1766stk/src/up_boot.c index 9f4200004..0d265eaad 100644 --- a/nuttx/configs/olimex-lpc1766stk/src/up_boot.c +++ b/nuttx/configs/olimex-lpc1766stk/src/up_boot.c @@ -75,13 +75,13 @@ void lpc17_boardinitialize(void) { /* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak - * function lpc17_sspinitialize() has been brought into the link. + * function lpc1766stk_sspinitialize() has been brought into the link. */ #if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) - if (lpc17_sspinitialize) + if (lpc1766stk_sspinitialize) { - lpc17_sspinitialize(); + lpc1766stk_sspinitialize(); } #endif diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c b/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c index 792910a1a..2fd75c665 100644 --- a/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c +++ b/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c @@ -212,14 +212,14 @@ static int ssp1_cdinterrupt(int irq, FAR void *context) ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: lpc1766stk_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the LPC1766-STK. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void) +void weak_function lpc1766stk_sspinitialize(void) { /* Configure the SSP0 chip select GPIOs. Only the Nokia LCD is connected to SSP0 */ diff --git a/nuttx/configs/open1788/README.txt b/nuttx/configs/open1788/README.txt index 45d5ae167..61a01c3a7 100644 --- a/nuttx/configs/open1788/README.txt +++ b/nuttx/configs/open1788/README.txt @@ -324,7 +324,17 @@ CONFIGURATION CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : Buildroot toolchain CONFIG_ARMV7M_OABI_TOOLCHAIN=y : Older, OABI toolchain - 3. At the end of the build, there will be several files in the top-level + 3. This configuration has DMA-based SD card support enabled by + default. That support can be disabled as follow: + + CONFIG_LPC17_GPDMA=n : No DMA + CONFIG_ARCH_DMA=n + CONFIG_LPC17_SDCARD=n : No SD card driver + CONFIG_SDIO_DMA=n : No SD card DMA + CONFIG_MMCSD=n : No MMC/SD driver support + CONFIG_FS_FAT=n : No FAT file system support + + 4. At the end of the build, there will be several files in the top-level NuttX build directory: PASS1: @@ -346,7 +356,7 @@ CONFIGURATION load objects twice to account for write failures. I have not yet found a simple foolproof way to reliably get the code into FLASH. - 4. Combining .hex files. If you plan to use the .hex files with your + 5. Combining .hex files. If you plan to use the .hex files with your debugger or FLASH utility, then you may need to combine the two hex files into a single .hex file. Here is how you can do that. @@ -415,7 +425,17 @@ CONFIGURATION 3. This NSH has support for built-in applications enabled, however, no built-in configurations are built in the defulat configuration. - 4. This configuration has been used for verifying SDRAM by modifying + 4. This configuration has DMA-based SD card support enabled by + default. That support can be disabled as follow: + + CONFIG_LPC17_GPDMA=n : No DMA + CONFIG_ARCH_DMA=n + CONFIG_LPC17_SDCARD=n : No SD card driver + CONFIG_SDIO_DMA=n : No SD card DMA + CONFIG_MMCSD=n : No MMC/SD driver support + CONFIG_FS_FAT=n : No FAT file system support + + 5. This configuration has been used for verifying SDRAM by modifying the configuration in the following ways: CONFIG_LPC17_EMC=y : Enable the EMC @@ -428,6 +448,39 @@ CONFIGURATION freely executed against the SRAM memory beginning at address 0xa000:0000 (CS0). + 6. This configuration has been used for verifying the touchscreen on + on the 4.3" LCD module by modifying the configuration in the + following ways: + + CONFIG_INPUT=y : Enable support for input devices + CONFIG_GPIO_IRQ=y : GPIO interrupt support + CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2048 + CONFIG_SPI=y : Enable SPI support + CONFIG_SPI_EXCHANGE=n : exchange() method is not supported + CONFIG_LPC17_SSP1=y : Enable support for SSP1 + CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test + CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y + + Defaults should be okay for related touchscreen settings. + + You will also have to disable SD card support to use this test. The + SD card detect (CD) signal is on P0[13]. This signal is shared. It + is also used for MOSI1 and USB_UP_LED. The CD pin may be disconnected. + There is a jumper on board that enables the CD pin. + + CONFIG_LPC17_GPDMA=n : No DMA + CONFIG_ARCH_DMA=n + CONFIG_LPC17_SDCARD=n : No SD card driver + CONFIG_SDIO_DMA=n : No SD card DMA + CONFIG_MMCSD=n : No MMC/SD driver support + CONFIG_FS_FAT=n : No FAT file system support + + For touchscreen debug output: + + CONFIG_DEBUG=y + CONFIG_DEBUG_VERBOSE=y + CONFIG_DEBUG_INPUT=y + nxlines ------- Configures the graphics example located at examples/nsh. This diff --git a/nuttx/configs/open1788/include/board.h b/nuttx/configs/open1788/include/board.h index 9a3995077..421476cab 100644 --- a/nuttx/configs/open1788/include/board.h +++ b/nuttx/configs/open1788/include/board.h @@ -387,6 +387,32 @@ * PWR --- Connected to P2[0] */ +/* XPT2046 Touchscreen: + * + * -------------- -------------------- ------------ -------------- + * XTPT2046 Module Module Open1788 LED + * Signal Connector Connector + * -------------- -------------------- ------------ -------------- + * Pin 11 PENIRQ\ PENIRQ (pulled high) PORT3 Pin 1 P2.15 PENIRQ + * Pin 12 DOUT MISO PORT3 Pin 4 P1.18 MISO1 + * Pin 13 BUSY BUSY (pulled high) PORT3 Pin 9 P2.14 BUSY + * Pin 14 DIN MOSI PORT3 Pin 3 P0.13 MOSI1 + * Pin 15 CS\ SSEL (pulled high) PORT3 Pin 6 P1.8 GPIO + * Pin 16 DCLK SCK PORT3 Pin 5 P1.19 SCK1 + * -------------- -------------------- ------------ -------------- + */ + + +#define GPIO_SSP1_MISO GPIO_SSP1_MISO_3 +#define GPIO_SSP1_MOSI GPIO_SSP1_MOSI_2 +#define GPIO_SSP1_SCK GPIO_SSP1_SCK_2 + +#define GPIO_SSP1_SSEL_1 (GPIO_ALT2 | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN6) +#define GPIO_SSP1_SSEL_2 (GPIO_ALT2 | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN14) +#define GPIO_SSP1_SSEL_3 (GPIO_ALT5 | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN26) +#define GPIO_SSP1_SSEL_4 (GPIO_ALT3 | GPIO_PULLUP | GPIO_PORT4 | GPIO_PIN21) + + /************************************************************************************ * Public Types ************************************************************************************/ diff --git a/nuttx/configs/open1788/src/Makefile b/nuttx/configs/open1788/src/Makefile index af8272263..e25402ba9 100644 --- a/nuttx/configs/open1788/src/Makefile +++ b/nuttx/configs/open1788/src/Makefile @@ -38,7 +38,7 @@ CFLAGS += -I$(TOPDIR)/sched ASRCS = -CSRCS = lpc17_boardinitialize.c +CSRCS = lpc17_boardinitialize.c lpc17_ssp.c ifeq ($(CONFIG_ARCH_EXTNOR),y) CSRCS += lpc17_norinitialize.c @@ -70,6 +70,10 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += lpc17_buttons.c endif +ifeq ($(CONFIG_INPUT_ADS7843E),y) + CSRCS += lpc17_touchscreen.c +endif + AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/nuttx/configs/open1788/src/lpc17_boardinitialize.c b/nuttx/configs/open1788/src/lpc17_boardinitialize.c index 896c38cf6..3a696fe04 100644 --- a/nuttx/configs/open1788/src/lpc17_boardinitialize.c +++ b/nuttx/configs/open1788/src/lpc17_boardinitialize.c @@ -80,24 +80,24 @@ void lpc17_boardinitialize(void) #ifdef CONFIG_LPC17_EMC lpc17_emcinitialize(); #ifdef CONFIG_ARCH_EXTDRAM - lpc17_sdram_initialize(); + open1788_sdram_initialize(); #endif #ifdef CONFIG_ARCH_EXTNOR - lpc17_nor_initialize(); + open1788_nor_initialize(); #endif #ifdef CONFIG_ARCH_EXTNAND - lpc17_nand_initialize(); + open1788_nand_initialize(); #endif #endif /* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak - * function lpc17_sspinitialize() has been brought into the link. + * function open1788_sspinitialize() has been brought into the link. */ #if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) - if (lpc17_sspinitialize) + if (open1788_sspinitialize) { - lpc17_sspinitialize(); + open1788_sspinitialize(); } #endif @@ -110,7 +110,7 @@ void lpc17_boardinitialize(void) /* Configure the LCD GPIOs if LCD support has been selected. */ #ifdef CONFIG_LPC17_LCD - lpc17_lcdinitialize(); + open1788_lcd_initialize(); #endif } diff --git a/nuttx/configs/open1788/src/lpc17_lcd.c b/nuttx/configs/open1788/src/lpc17_lcd.c index 7c70e2ebd..934f20525 100644 --- a/nuttx/configs/open1788/src/lpc17_lcd.c +++ b/nuttx/configs/open1788/src/lpc17_lcd.c @@ -63,14 +63,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_lcdinitialize + * Name: open1788_lcd_initialize * * Description: * Initialize the LCD. Setup backlight (initially off) * ************************************************************************************/ -void lpc17_lcdinitialize(void) +void open1788_lcd_initialize(void) { /* Configure the LCD backlight (and turn the backlight off) */ diff --git a/nuttx/configs/open1788/src/lpc17_nandinitialize.c b/nuttx/configs/open1788/src/lpc17_nandinitialize.c index aa66b0d41..a0d658759 100644 --- a/nuttx/configs/open1788/src/lpc17_nandinitialize.c +++ b/nuttx/configs/open1788/src/lpc17_nandinitialize.c @@ -64,14 +64,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_nand_initialize + * Name: open1788_nand_initialize * * Description: * Initialize NAND FLASH * ************************************************************************************/ -void lpc17_nand_initialize(void) +void open1788_nand_initialize(void) { uint32_t regval; diff --git a/nuttx/configs/open1788/src/lpc17_norinitialize.c b/nuttx/configs/open1788/src/lpc17_norinitialize.c index 5c4e4714a..8cf21d540 100644 --- a/nuttx/configs/open1788/src/lpc17_norinitialize.c +++ b/nuttx/configs/open1788/src/lpc17_norinitialize.c @@ -64,14 +64,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_nor_initialize + * Name: open1788_nor_initialize * * Description: * Initialize NOR FLASH * ************************************************************************************/ -void lpc17_nor_initialize(void) +void open1788_nor_initialize(void) { uint32_t regval; diff --git a/nuttx/configs/open1788/src/lpc17_nsh.c b/nuttx/configs/open1788/src/lpc17_nsh.c index 6611e601a..559909a42 100644 --- a/nuttx/configs/open1788/src/lpc17_nsh.c +++ b/nuttx/configs/open1788/src/lpc17_nsh.c @@ -45,6 +45,7 @@ #include <debug.h> #include <errno.h> +#include <nuttx/arch.h> #include <nuttx/sdio.h> #include <nuttx/mmcsd.h> #include <nuttx/usb/usbhost.h> diff --git a/nuttx/configs/open1788/src/lpc17_sdraminitialize.c b/nuttx/configs/open1788/src/lpc17_sdraminitialize.c index 10196b18c..818f1ade4 100644 --- a/nuttx/configs/open1788/src/lpc17_sdraminitialize.c +++ b/nuttx/configs/open1788/src/lpc17_sdraminitialize.c @@ -99,14 +99,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sdram_initialize + * Name: open1788_sdram_initialize * * Description: * Initialize SDRAM * ************************************************************************************/ -void lpc17_sdram_initialize(void) +void open1788_sdram_initialize(void) { uint32_t regval; #ifdef CONFIG_ARCH_SDRAM_16BIT diff --git a/nuttx/configs/open1788/src/lpc17_ssp.c b/nuttx/configs/open1788/src/lpc17_ssp.c new file mode 100644 index 000000000..e27894e72 --- /dev/null +++ b/nuttx/configs/open1788/src/lpc17_ssp.c @@ -0,0 +1,205 @@ +/**************************************************************************** + * configs/open1788/src/lpc17_ssp.c + * arch/arm/src/board/lpc17_ssp.c + * + * Copyright (C) 2013 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 <stdint.h> +#include <stdbool.h> +#include <debug.h> + +#include <nuttx/spi.h> + +#include <arch/board/board.h> + +#include "up_arch.h" +#include "chip.h" +#include "lpc17_gpio.h" +#include "lpc17_ssp.h" +#include "open1788.h" + +#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) || \ + defined(CONFIG_LPC17_SSP2) + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Debug ********************************************************************/ + +#ifdef CONFIG_DEBUG_SPI +# define sspdbg lldbg +# ifdef CONFIG_DEBUG_VERBOSE +# define sspvdbg lldbg +# else +# define sspvdbg(x...) +# endif +#else +# define sspdbg(x...) +# define sspvdbg(x...) +#endif + +/* Dump GPIO registers */ + +#ifdef CONFIG_DEBUG_VERBOSE +# define ssp_dumpgpio(p,m) lpc17_dumpgpio(p,m) +#else +# define ssp_dumpgpio(p,m) +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: open1788_sspinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the LPC1766-STK. + * + ****************************************************************************/ + +void weak_function open1788_sspinitialize(void) +{ + /* Configure the SSP0 chip select GPIOs. */ + +#ifdef CONFIG_LPC17_SSP0 +#endif + + /* Configure SSP1 chip select GPIOs. This includes the touchscreen on the + * the LCD module. + */ + +#ifdef CONFIG_LPC17_SSP1 + ssp_dumpgpio(GPIO_TC_CS, "BEFORE SSP1 Initialization"); + lpc17_configgpio(GPIO_TC_CS); + ssp_dumpgpio(GPIO_TC_CS, "AFTER SSP1 Initialization"); +#endif + + /* Configure the SSP2 chip select GPIOs. */ + +#ifdef CONFIG_LPC17_SSP2 +#endif +} + +/************************************************************************************ + * Name: lpc17_ssp0/1/2select and lpc17_ssp0/1/2status + * + * Description: + * The external functions, lpc17_ssp0/1/2select and lpc17_ssp0/1/2status + * 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 lpc17_sspinitialize()) + * are provided by common LPC17xx logic. To use this common SPI logic on your + * board: + * + * 1. Provide logic in lpc17_boardinitialize() to configure SPI/SSP chip select + * pins. + * 2. Provide lpc17_ssp0/1/2select() and lpc17_ssp0/1/2status() 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 lpc17_sspinitialize() in your low level application + * initialization logic + * 4. The handle returned by lpc17_sspinitialize() 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). + * + ************************************************************************************/ + +#ifdef CONFIG_LPC17_SSP0 +void lpc17_ssp0select(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"); +} + +uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +{ + sspdbg("Returning nothing\n"); + return 0; +} +#endif + +#ifdef CONFIG_LPC17_SSP1 +void lpc17_ssp1select(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"); + if (devid == SPIDEV_TOUCHSCREEN) + { + /* Assert/de-assert the CS pin to the card */ + + ssp_dumpgpio(GPIO_TC_CS, "lpc17_ssp1select() Entry"); + lpc17_gpiowrite(GPIO_TC_CS, !selected); + ssp_dumpgpio(GPIO_TC_CS, "lpc17_ssp1select() Exit"); + } +} + +uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +{ + sspdbg("Returning nothing\n"); + return 0; +} +#endif + +#ifdef CONFIG_LPC17_SSP2 +void lpc17_ssp2select(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"); +} + +uint8_t lpc17_ssp2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +{ + sspdbg("Returning nothing\n"); + return 0; +} +#endif + +#endif /* CONFIG_LPC17_SSP0 || CONFIG_LPC17_SSP1 || CONFIG_LPC17_SSP2 */ diff --git a/nuttx/configs/open1788/src/lpc17_touchscreen.c b/nuttx/configs/open1788/src/lpc17_touchscreen.c new file mode 100644 index 000000000..1ee8d6237 --- /dev/null +++ b/nuttx/configs/open1788/src/lpc17_touchscreen.c @@ -0,0 +1,298 @@ +/************************************************************************************ + * configs/open1788/src/lpc17_touchscreen.c + * arch/arm/src/board/lpc17_touchscreen.c + * + * Copyright (C) 2013 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 <stdbool.h> +#include <stdio.h> +#include <debug.h> +#include <assert.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/irq.h> +#include <nuttx/spi.h> +#include <nuttx/input/touchscreen.h> +#include <nuttx/input/ads7843e.h> + +#include "lpc17_gpio.h" +#include "lpc17_ssp.h" +#include "open1788.h" + +#ifdef CONFIG_INPUT_ADS7843E + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_INPUT +# error "Touchscreen support requires CONFIG_INPUT" +#endif + +#ifndef CONFIG_LPC17_SSP1 +# error "Touchscreen support requires CONFIG_LPC17_SSP1" +#endif + +#ifndef CONFIG_GPIO_IRQ +# error "Touchscreen support requires CONFIG_GPIO_IRQ" +#endif + +#ifndef CONFIG_ADS7843E_FREQUENCY +# define CONFIG_ADS7843E_FREQUENCY 500000 +#endif + +#ifndef CONFIG_ADS7843E_SPIDEV +# define CONFIG_ADS7843E_SPIDEV 3 +#endif + +#if CONFIG_ADS7843E_SPIDEV != 3 +# error "CONFIG_ADS7843E_SPIDEV must be three" +#endif + +#ifndef CONFIG_ADS7843E_DEVMINOR +# define CONFIG_ADS7843E_DEVMINOR 0 +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the ADS7843E driver from differences in GPIO + * interrupt handling by varying boards and MCUs. If possible, + * interrupts should be configured on both rising and falling edges + * so that contact and loss-of-contact events can be detected. + * + * attach - Attach the ADS7843E interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + * pendown - Return the state of the pen down GPIO input + */ + +static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t isr); +static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable); +static void tsc_clear(FAR struct ads7843e_config_s *state); +static bool tsc_busy(FAR struct ads7843e_config_s *state); +static bool tsc_pendown(FAR struct ads7843e_config_s *state); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the ADS7843E + * driver. This structure provides information about the configuration + * of the ADS7843E and provides some board-specific hooks. + * + * Memory for this structure is provided by the caller. It is not copied + * by the driver and is presumed to persist while the driver is active. + */ + +static struct ads7843e_config_s g_tscinfo = +{ + .frequency = CONFIG_ADS7843E_FREQUENCY, + .attach = tsc_attach, + .enable = tsc_enable, + .clear = tsc_clear, + .busy = tsc_busy, + .pendown = tsc_pendown, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the ADS7843E driver from differences in GPIO + * interrupt handling by varying boards and MCUs. If possible, + * interrupts should be configured on both rising and falling edges + * so that contact and loss-of-contact events can be detected. + * + * attach - Attach the ADS7843E interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + * pendown - Return the state of the pen down GPIO input + */ + +static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t handler) +{ + /* Attach then enable the touchscreen interrupt handler */ + + (void)irq_attach(LPC17_IRQ_PENIRQ, handler); + return OK; +} + +static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable) +{ + ivdbg("enable:%d\n", enable); + if (enable) + { + up_enable_irq(LPC17_IRQ_PENIRQ); + } + else + { + up_disable_irq(LPC17_IRQ_PENIRQ); + } +} + +static void tsc_clear(FAR struct ads7843e_config_s *state) +{ + /* Does nothing */ +} + +static bool tsc_busy(FAR struct ads7843e_config_s *state) +{ +#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE) + static bool last = (bool)-1; +#endif + + /* REVISIT: This might need to be inverted */ + + bool busy = lpc17_gpioread(GPIO_TC_BUSY); +#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE) + if (busy != last) + { + ivdbg("busy:%d\n", busy); + last = busy; + } +#endif + + return busy; +} + +static bool tsc_pendown(FAR struct ads7843e_config_s *state) +{ + /* XPT2046 uses an an internal pullup resistor. The PENIRQ output goes low + * due to the current path through the touch screen to ground, which + * initiates an interrupt to the processor via TP_INT. + */ + + bool pendown = !lpc17_gpioread(GPIO_TC_PENIRQ); + ivdbg("pendown:%d\n", pendown); + return pendown; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: arch_tcinitialize + * + * Description: + * Each board that supports a touchscreen device must provide this + * function. This function is called by application-specific, setup logic + * to configure the touchscreen device. This function will register the + * driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int arch_tcinitialize(int minor) +{ + FAR struct spi_dev_s *dev; + int ret; + + idbg("minor %d\n", minor); + DEBUGASSERT(minor == 0); + + /* Configure and enable the ADS7843E PENIRQ pin as an interrupting input. */ + + (void)lpc17_configgpio(GPIO_TC_PENIRQ); + + /* Configure the ADS7843E BUSY pin as a normal input. */ + + (void)lpc17_configgpio(GPIO_TC_BUSY); + + /* Get an instance of the SPI interface */ + + dev = lpc17_sspinitialize(CONFIG_ADS7843E_SPIDEV); + if (!dev) + { + idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + return -ENODEV; + } + + /* Initialize and register the SPI touschscreen device */ + + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + /* up_spiuninitialize(dev); */ + return -ENODEV; + } + + return OK; +} + +/**************************************************************************** + * Name: arch_tcuninitialize + * + * Description: + * Each board that supports a touchscreen device must provide this function. + * This function is called by application-specific, setup logic to + * uninitialize the touchscreen device. + * + * Input Parameters: + * None + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void arch_tcuninitialize(void) +{ + /* No support for un-initializing the touchscreen ADS7843E device yet */ +} + +#endif /* CONFIG_INPUT_ADS7843E */ + diff --git a/nuttx/configs/open1788/src/open1788.h b/nuttx/configs/open1788/src/open1788.h index b1349eae4..e70eebe5d 100644 --- a/nuttx/configs/open1788/src/open1788.h +++ b/nuttx/configs/open1788/src/open1788.h @@ -116,6 +116,28 @@ #define GPIO_LCD_BL (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN1) +/* XPT2046 Touchscreen **************************************************************/ +/* -------------- -------------------- ------------ -------------- + * XTPT2046 Module Module Open1788 LED + * Signal Connector Connector + * -------------- -------------------- ------------ -------------- + * Pin 11 PENIRQ\ PENIRQ (pulled high) PORT3 Pin 1 P2.15 PENIRQ + * Pin 12 DOUT MISO PORT3 Pin 4 P1.18 MISO1 + * Pin 13 BUSY BUSY (pulled high) PORT3 Pin 9 P2.14 BUSY + * Pin 14 DIN MOSI PORT3 Pin 3 P0.13 MOSI1 + * Pin 15 CS\ SSEL (pulled high) PORT3 Pin 6 P1.8 GPIO + * Pin 16 DCLK SCK PORT3 Pin 5 P1.19 SCK1 + * -------------- -------------------- ------------ -------------- + * + * Pins are configured as floating because there are pullups on the module. + */ + +#define GPIO_TC_PENIRQ (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN15) +#define GPIO_TC_BUSY (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN14) +#define GPIO_TC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN8) + +#define LPC17_IRQ_PENIRQ LPC17_IRQ_P2p15 + /************************************************************************************ * Public Types ************************************************************************************/ @@ -131,17 +153,17 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: open1788_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the WaveShare Open1788 board. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void); +void weak_function open1788_sspinitialize(void); /************************************************************************************ - * Name: lpc17_sdram_initialize + * Name: open1788_sdram_initialize * * Description: * Initialize SDRAM @@ -150,11 +172,11 @@ void weak_function lpc17_sspinitialize(void); #ifdef CONFIG_LPC17_EMC #ifdef CONFIG_ARCH_EXTDRAM -void lpc17_sdram_initialize(void); +void open1788_sdram_initialize(void); #endif /************************************************************************************ - * Name: lpc17_nor_initialize + * Name: open1788_nor_initialize * * Description: * Initialize NOR FLASH @@ -162,11 +184,11 @@ void lpc17_sdram_initialize(void); ************************************************************************************/ #ifdef CONFIG_ARCH_EXTNOR -void lpc17_nor_initialize(void); +void open1788_nor_initialize(void); #endif /************************************************************************************ - * Name: lpc17_nand_initialize + * Name: open1788_nand_initialize * * Description: * Initialize NAND FLASH @@ -174,12 +196,12 @@ void lpc17_nor_initialize(void); ************************************************************************************/ #ifdef CONFIG_ARCH_EXTNAND -void lpc17_nand_initialize(void); +void open1788_nand_initialize(void); #endif #endif /* CONFIG_LPC17_EMC */ /************************************************************************************ - * Name: lpc17_lcdinitialize + * Name: open1788_lcd_initialize * * Description: * Initialize the LCD. Setup backlight (initially off) @@ -187,7 +209,7 @@ void lpc17_nand_initialize(void); ************************************************************************************/ #ifdef CONFIG_LPC17_LCD -void lpc17_lcdinitialize(void); +void open1788_lcd_initialize(void); #endif /************************************************************************************ diff --git a/nuttx/configs/zkit-arm-1769/src/up_boot.c b/nuttx/configs/zkit-arm-1769/src/up_boot.c index de7863eb1..96f8af645 100644 --- a/nuttx/configs/zkit-arm-1769/src/up_boot.c +++ b/nuttx/configs/zkit-arm-1769/src/up_boot.c @@ -79,13 +79,13 @@ void lpc17_boardinitialize(void) { /* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak - * function lpc17_sspinitialize() has been brought into the link. + * function zkit_sspinitialize() has been brought into the link. */ #if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) - if (lpc17_sspinitialize) + if (zkit_sspinitialize) { - lpc17_sspinitialize(); + zkit_sspinitialize(); } #endif diff --git a/nuttx/configs/zkit-arm-1769/src/up_lcd.c b/nuttx/configs/zkit-arm-1769/src/up_lcd.c index c76566674..aa5859791 100644 --- a/nuttx/configs/zkit-arm-1769/src/up_lcd.c +++ b/nuttx/configs/zkit-arm-1769/src/up_lcd.c @@ -117,7 +117,7 @@ int up_lcdinitialize(void) spi = lpc17_sspinitialize(0); if (!spi) { - glldbg("Failed to initialize SSI port 0\n"); + glldbg("Failed to initialize SSP port 0\n"); return 0; } diff --git a/nuttx/configs/zkit-arm-1769/src/up_ssp.c b/nuttx/configs/zkit-arm-1769/src/up_ssp.c index dda71690a..9ae175280 100644 --- a/nuttx/configs/zkit-arm-1769/src/up_ssp.c +++ b/nuttx/configs/zkit-arm-1769/src/up_ssp.c @@ -95,18 +95,18 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: zkit_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the LM3S6965 Eval Kit. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void) +void weak_function zkit_sspinitialize(void) { /* Configure the SPI-based microSD CS GPIO */ - ssp_dumpgpio("lpc17_sspinitialize() Entry)"); + ssp_dumpgpio("zkit_sspinitialize() Entry)"); /* Configure card detect and chip select for the SD slot. NOTE: Jumper J55 must * be set correctly for the SD slot chip select. @@ -125,7 +125,7 @@ void weak_function lpc17_sspinitialize(void) #endif #endif /* CONFIG_LPC17_SSP0 */ - ssp_dumpgpio("lpc17_sspinitialize() Exit"); + ssp_dumpgpio("zkit_sspinitialize() Exit"); } /************************************************************************************ diff --git a/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h b/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h index 613f99dc8..b666c8387 100644 --- a/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h +++ b/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h @@ -231,14 +231,14 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_sspinitialize + * Name: zkit_sspinitialize * * Description: * Called to configure SPI chip select GPIO pins for the LPCXpresso board. * ************************************************************************************/ -void weak_function lpc17_sspinitialize(void); +void weak_function zkit_sspinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_ZKITARM_LPC1768_SRC_ZKITARM_INTERNAL_H */ |