mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
SSP driver fixes for the LPC178x; Fixes for Open1788 touchscreen driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5812 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -453,10 +453,11 @@ CONFIGURATION
|
|||||||
following ways:
|
following ways:
|
||||||
|
|
||||||
CONFIG_INPUT=y : Enable support for input devices
|
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_INPUT_ADS7843E=y : Enable support for the XPT2048
|
||||||
|
CONFIG_ADS7843E_SPIDEV=1 : Use SSP1 for communication
|
||||||
CONFIG_SPI=y : Enable SPI support
|
CONFIG_SPI=y : Enable SPI support
|
||||||
CONFIG_SPI_EXCHANGE=n : exchange() method is not supported
|
CONFIG_SPI_EXCHANGE=n : exchange() method is not supported
|
||||||
|
CONFIG_GPIO_IRQ=y : GPIO interrupt support
|
||||||
CONFIG_LPC17_SSP1=y : Enable support for SSP1
|
CONFIG_LPC17_SSP1=y : Enable support for SSP1
|
||||||
CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test
|
CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test
|
||||||
CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y
|
CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y
|
||||||
@@ -466,7 +467,8 @@ CONFIGURATION
|
|||||||
You will also have to disable SD card support to use this test. The
|
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
|
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.
|
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.
|
There is a jumper on board that enables the CD pin. OR, you can simply
|
||||||
|
remove the SD module so that it does not drive the CD pin.
|
||||||
|
|
||||||
CONFIG_LPC17_GPDMA=n : No DMA
|
CONFIG_LPC17_GPDMA=n : No DMA
|
||||||
CONFIG_ARCH_DMA=n
|
CONFIG_ARCH_DMA=n
|
||||||
|
|||||||
@@ -407,12 +407,6 @@
|
|||||||
#define GPIO_SSP1_MOSI GPIO_SSP1_MOSI_2
|
#define GPIO_SSP1_MOSI GPIO_SSP1_MOSI_2
|
||||||
#define GPIO_SSP1_SCK GPIO_SSP1_SCK_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
|
* Public Types
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sel
|
|||||||
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
if (devid == SPIDEV_TOUCHSCREEN)
|
if (devid == SPIDEV_TOUCHSCREEN)
|
||||||
{
|
{
|
||||||
/* Assert/de-assert the CS pin to the card */
|
/* Assert/de-assert the CS pin to the touchscreen */
|
||||||
|
|
||||||
ssp_dumpgpio(GPIO_TC_CS, "lpc17_ssp1select() Entry");
|
ssp_dumpgpio(GPIO_TC_CS, "lpc17_ssp1select() Entry");
|
||||||
lpc17_gpiowrite(GPIO_TC_CS, !selected);
|
lpc17_gpiowrite(GPIO_TC_CS, !selected);
|
||||||
|
|||||||
@@ -80,17 +80,27 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ADS7843E_SPIDEV
|
#ifndef CONFIG_ADS7843E_SPIDEV
|
||||||
# define CONFIG_ADS7843E_SPIDEV 3
|
# define CONFIG_ADS7843E_SPIDEV 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_ADS7843E_SPIDEV != 3
|
#if CONFIG_ADS7843E_SPIDEV != 1
|
||||||
# error "CONFIG_ADS7843E_SPIDEV must be three"
|
# error "CONFIG_ADS7843E_SPIDEV must be one"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ADS7843E_DEVMINOR
|
#ifndef CONFIG_ADS7843E_DEVMINOR
|
||||||
# define CONFIG_ADS7843E_DEVMINOR 0
|
# define CONFIG_ADS7843E_DEVMINOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* REVISIT: Currently, XPT2046 reports BUSY all of the time. This is
|
||||||
|
* probably GPIO setting issues. But there is this cryptic statement in
|
||||||
|
* the XPT2046 spec: "No DCLK delay required with dedicated serial port."
|
||||||
|
*
|
||||||
|
* The busy state is used by the XPT2046 driver to control the delay
|
||||||
|
* between sending the command, then reading the returned data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define XPT2046_NO_BUSY 1
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -100,12 +110,12 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
||||||
* callbacks to isolate the ADS7843E driver from differences in GPIO
|
* callbacks to isolate the XPT2046 driver from differences in GPIO
|
||||||
* interrupt handling by varying boards and MCUs. If possible,
|
* interrupt handling by varying boards and MCUs. If possible,
|
||||||
* interrupts should be configured on both rising and falling edges
|
* interrupts should be configured on both rising and falling edges
|
||||||
* so that contact and loss-of-contact events can be detected.
|
* so that contact and loss-of-contact events can be detected.
|
||||||
*
|
*
|
||||||
* attach - Attach the ADS7843E interrupt handler to the GPIO interrupt
|
* attach - Attach the XPT2046 interrupt handler to the GPIO interrupt
|
||||||
* enable - Enable or disable the GPIO interrupt
|
* enable - Enable or disable the GPIO interrupt
|
||||||
* clear - Acknowledge/clear any pending GPIO interrupt
|
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||||
* pendown - Return the state of the pen down GPIO input
|
* pendown - Return the state of the pen down GPIO input
|
||||||
@@ -121,9 +131,9 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state);
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* A reference to a structure of this type must be passed to the ADS7843E
|
/* A reference to a structure of this type must be passed to the XPT2046
|
||||||
* driver. This structure provides information about the configuration
|
* driver. This structure provides information about the configuration
|
||||||
* of the ADS7843E and provides some board-specific hooks.
|
* of the XPT2046 and provides some board-specific hooks.
|
||||||
*
|
*
|
||||||
* Memory for this structure is provided by the caller. It is not copied
|
* 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.
|
* by the driver and is presumed to persist while the driver is active.
|
||||||
@@ -144,12 +154,12 @@ static struct ads7843e_config_s g_tscinfo =
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
||||||
* callbacks to isolate the ADS7843E driver from differences in GPIO
|
* callbacks to isolate the XPT2046 driver from differences in GPIO
|
||||||
* interrupt handling by varying boards and MCUs. If possible,
|
* interrupt handling by varying boards and MCUs. If possible,
|
||||||
* interrupts should be configured on both rising and falling edges
|
* interrupts should be configured on both rising and falling edges
|
||||||
* so that contact and loss-of-contact events can be detected.
|
* so that contact and loss-of-contact events can be detected.
|
||||||
*
|
*
|
||||||
* attach - Attach the ADS7843E interrupt handler to the GPIO interrupt
|
* attach - Attach the XPT2046 interrupt handler to the GPIO interrupt
|
||||||
* enable - Enable or disable the GPIO interrupt
|
* enable - Enable or disable the GPIO interrupt
|
||||||
* clear - Acknowledge/clear any pending GPIO interrupt
|
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||||
* pendown - Return the state of the pen down GPIO input
|
* pendown - Return the state of the pen down GPIO input
|
||||||
@@ -183,6 +193,20 @@ static void tsc_clear(FAR struct ads7843e_config_s *state)
|
|||||||
|
|
||||||
static bool tsc_busy(FAR struct ads7843e_config_s *state)
|
static bool tsc_busy(FAR struct ads7843e_config_s *state)
|
||||||
{
|
{
|
||||||
|
/* The busy state is used by the XPT2046 driver to control the delay
|
||||||
|
* between sending the command, then reading the returned data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef XPT2046_NO_BUSY
|
||||||
|
/* REVISIT: Currently, XPT2046 reports BUSY all of the time. This is
|
||||||
|
* probably GPIO setting issues. But there is this cryptic statement in
|
||||||
|
* the XPT2046 spec: "No DCLK delay required with dedicated serial port."
|
||||||
|
*/
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#else /* XPT2046_NO_BUSY */
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE)
|
#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE)
|
||||||
static bool last = (bool)-1;
|
static bool last = (bool)-1;
|
||||||
#endif
|
#endif
|
||||||
@@ -199,6 +223,8 @@ static bool tsc_busy(FAR struct ads7843e_config_s *state)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return busy;
|
return busy;
|
||||||
|
|
||||||
|
#endif /* XPT2046_NO_BUSY */
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tsc_pendown(FAR struct ads7843e_config_s *state)
|
static bool tsc_pendown(FAR struct ads7843e_config_s *state)
|
||||||
@@ -237,37 +263,50 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state)
|
|||||||
|
|
||||||
int arch_tcinitialize(int minor)
|
int arch_tcinitialize(int minor)
|
||||||
{
|
{
|
||||||
|
static bool initialized = false;
|
||||||
FAR struct spi_dev_s *dev;
|
FAR struct spi_dev_s *dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
idbg("minor %d\n", minor);
|
idbg("initialized:%d minor:%d\n", initialized, minor);
|
||||||
DEBUGASSERT(minor == 0);
|
DEBUGASSERT(minor == 0);
|
||||||
|
|
||||||
/* Configure and enable the ADS7843E PENIRQ pin as an interrupting input. */
|
/* Since there is no uninitialized logic, this initialization can be
|
||||||
|
* performed only one time.
|
||||||
|
*/
|
||||||
|
|
||||||
(void)lpc17_configgpio(GPIO_TC_PENIRQ);
|
if (!initialized)
|
||||||
|
|
||||||
/* 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);
|
/* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize and register the SPI touschscreen device */
|
(void)lpc17_configgpio(GPIO_TC_PENIRQ);
|
||||||
|
|
||||||
ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR);
|
/* Configure the XPT2046 BUSY pin as a normal input. */
|
||||||
if (ret < 0)
|
|
||||||
{
|
#ifndef XPT2046_NO_BUSY
|
||||||
idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV);
|
(void)lpc17_configgpio(GPIO_TC_BUSY);
|
||||||
/* up_spiuninitialize(dev); */
|
#endif
|
||||||
return -ENODEV;
|
|
||||||
|
/* 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 touchscreen device */
|
||||||
|
|
||||||
|
ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
idbg("Failed to register touchscreen device minor=%d\n",
|
||||||
|
CONFIG_ADS7843E_DEVMINOR);
|
||||||
|
/* up_spiuninitialize(dev); */
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -291,7 +330,7 @@ int arch_tcinitialize(int minor)
|
|||||||
|
|
||||||
void arch_tcuninitialize(void)
|
void arch_tcuninitialize(void)
|
||||||
{
|
{
|
||||||
/* No support for un-initializing the touchscreen ADS7843E device yet */
|
/* No support for un-initializing the touchscreen XPT2046 device yet */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_INPUT_ADS7843E */
|
#endif /* CONFIG_INPUT_ADS7843E */
|
||||||
|
|||||||
Reference in New Issue
Block a user