mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
The STMPE11/touchscreen is now fully functional on the STM3240G-EVAL
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4715 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -4688,6 +4688,10 @@ build
|
||||
<code>CONFIG_STMPE11_MULTIPLE </code>:
|
||||
Can be defined to support multiple STMPE11 devices on board.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_ACTIVELOW</code>:
|
||||
Interrupt is generated by an active low signal.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_NPOLLWAITERS</code>:
|
||||
Maximum number of threads that can be waiting on poll() (ignored if
|
||||
@@ -4707,12 +4711,20 @@ build
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_GPIOINT_DISABLE</code>:
|
||||
Disable driver GPIO interrupt functionlality (ignored if GPIO
|
||||
Disable driver GPIO interrupt functionality (ignored if GPIO
|
||||
functionality is disabled).
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_SWAPXY</code>:
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_TEMP_DISABLE</code>:
|
||||
Disable driver temperature sensor functionlaity.
|
||||
Disable driver temperature sensor functionality.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_STMPE11_REGDEBUG</code>:
|
||||
Enabled very low register-level debug output. Requires <code>CONFIG_DEBUG</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -106,10 +106,10 @@
|
||||
/* Interrupt wait timeout in seconds and milliseconds */
|
||||
|
||||
#if !defined(CONFIG_STM32_I2CTIMEOSEC) && !defined(CONFIG_STM32_I2CTIMEOMS)
|
||||
# define CONFIG_STM32_I2CTIMEOSEC 0
|
||||
# define CONFIG_STM32_I2CTIMEOSEC 0
|
||||
# define CONFIG_STM32_I2CTIMEOMS 500 /* Default is 500 milliseconds */
|
||||
#elif !defined(CONFIG_STM32_I2CTIMEOSEC)
|
||||
# define CONFIG_STM32_I2CTIMEOSEC 0 /* User provided milliseconds */
|
||||
# define CONFIG_STM32_I2CTIMEOSEC 0 /* User provided milliseconds */
|
||||
#elif !defined(CONFIG_STM32_I2CTIMEOMS)
|
||||
# define CONFIG_STM32_I2CTIMEOMS 0 /* User provided seconds */
|
||||
#endif
|
||||
|
||||
+8
-2
@@ -792,6 +792,8 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
Enables support for the I2C interface
|
||||
CONFIG_STMPE11_MULTIPLE
|
||||
Can be defined to support multiple STMPE11 devices on board.
|
||||
CONFIG_STMPE11_ACTIVELOW
|
||||
Interrupt is generated by an active low signal.
|
||||
CONFIG_STMPE11_NPOLLWAITERS
|
||||
Maximum number of threads that can be waiting on poll() (ignored if
|
||||
CONFIG_DISABLE_POLL is set).
|
||||
@@ -802,10 +804,14 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
CONFIG_STMPE11_GPIO_DISABLE
|
||||
Disable driver GPIO functionlaity.
|
||||
CONFIG_STMPE11_GPIOINT_DISABLE
|
||||
Disable driver GPIO interrupt functionlality (ignored if GPIO
|
||||
Disable driver GPIO interrupt functionality (ignored if GPIO
|
||||
functionality is disabled).
|
||||
CONFIG_STMPE11_SWAPXY
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
CONFIG_STMPE11_TEMP_DISABLE
|
||||
Disable driver temperature sensor functionlaity.
|
||||
Disable driver temperature sensor functionality.
|
||||
CONFIG_STMPE11_REGDEBUG
|
||||
Enabled very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
|
||||
Analog Devices
|
||||
|
||||
|
||||
@@ -967,6 +967,8 @@ CONFIG_INPUT_TSC2007=n
|
||||
# Enables support for the I2C interface
|
||||
# CONFIG_STMPE11_MULTIPLE
|
||||
# Can be defined to support multiple STMPE11 devices on board.
|
||||
# CONFIG_STMPE11_ACTIVELOW
|
||||
# Interrupt is generated by an active low signal.
|
||||
# CONFIG_STMPE11_NPOLLWAITERS
|
||||
# Maximum number of threads that can be waiting on poll() (ignored if
|
||||
# CONFIG_DISABLE_POLL is set).
|
||||
@@ -975,23 +977,31 @@ CONFIG_INPUT_TSC2007=n
|
||||
# CONFIG_STMPE11_ADC_DISABLE
|
||||
# Disable driver ADC functionality.
|
||||
# CONFIG_STMPE11_GPIO_DISABLE
|
||||
# Disable driver GPIO functionlaity.
|
||||
# Disable driver GPIO functionality.
|
||||
# CONFIG_STMPE11_GPIOINT_DISABLE
|
||||
# Disable driver GPIO interrupt functionlality (ignored if GPIO functionality is
|
||||
# Disable driver GPIO interrupt functionality (ignored if GPIO functionality is
|
||||
# disabled).
|
||||
# CONFIG_STMPE11_SWAPXY
|
||||
# Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
# For the STM3240G-EVAL, X and Y should be swapped in PORTRAIT modes
|
||||
# CONFIG_STMPE11_TEMP_DISABLE
|
||||
# Disable driver temperature sensor functionlaity.
|
||||
# Disable driver temperature sensor functionality.
|
||||
# CONFIG_STMPE11_REGDBUG
|
||||
# Enabled very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
#
|
||||
CONFIG_INPUT_STMPE11=n
|
||||
CONFIG_STMPE11_SPI=n
|
||||
CONFIG_STMPE11_I2C=y
|
||||
CONFIG_STMPE11_MULTIPLE=y
|
||||
CONFIG_STMPE11_ACTIVELOW=y
|
||||
#CONFIG_STMPE11_NPOLLWAITERS
|
||||
CONFIG_STMPE11_TSC_DISABLE=n
|
||||
CONFIG_STMPE11_ADC_DISABLE=y
|
||||
CONFIG_STMPE11_GPIO_DISABLE=y
|
||||
CONFIG_STMPE11_GPIOINT_DISABLE=y
|
||||
CONFIG_STMPE11_SWAPXY=y
|
||||
CONFIG_STMPE11_TEMP_DISABLE=y
|
||||
CONFIG_STMPE11_REGDEBUG=n
|
||||
|
||||
#
|
||||
# USB Device Configuration
|
||||
@@ -1128,11 +1138,11 @@ CONFIG_USBMSC_REMOVABLE=y
|
||||
# CONFIG_NXTK_BORDERWIDTH
|
||||
# Specifies with with of the border (in pixels) used with
|
||||
# framed windows. The default is 4.
|
||||
# CONFIG_NXTK_BORDERCOLOR1 and CONFIG_NXTK_BORDERCOLOR2
|
||||
# CONFIG_NXTK_BORDERCOLOR1, CONFIG_NXTK_BORDERCOLOR2, CONFIG_NXTK_BORDERCOLOR3
|
||||
# Specify the colors of the border used with framed windows.
|
||||
# CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so
|
||||
# is normally darker. The default is medium and dark grey,
|
||||
# respectively
|
||||
# CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so is normally darker.
|
||||
# CONFIG_NXTK_BORDERCOLOR3 is the shiny side color and so is normally brighter.
|
||||
# The default is mediumdark grey, and light grey, respectively
|
||||
# CONFIG_NXTK_AUTORAISE
|
||||
# If set, a window will be raised to the top if the mouse position
|
||||
# is over a visible portion of the window. Default: A mouse
|
||||
@@ -1313,7 +1323,7 @@ CONFIG_LCD_RPORTRAIT=y
|
||||
# STM3240G-EVAL specific LCD settings
|
||||
#
|
||||
CONFIG_STM32_ILI9320_DISABLE=n
|
||||
CONFIG_STM32_ILI9325_DISABLE=n
|
||||
CONFIG_STM32_ILI9325_DISABLE=y
|
||||
|
||||
#
|
||||
# Settings for examples/uip
|
||||
|
||||
@@ -967,6 +967,8 @@ CONFIG_INPUT_TSC2007=n
|
||||
# Enables support for the I2C interface
|
||||
# CONFIG_STMPE11_MULTIPLE
|
||||
# Can be defined to support multiple STMPE11 devices on board.
|
||||
# CONFIG_STMPE11_ACTIVELOW
|
||||
# Interrupt is generated by an active low signal.
|
||||
# CONFIG_STMPE11_NPOLLWAITERS
|
||||
# Maximum number of threads that can be waiting on poll() (ignored if
|
||||
# CONFIG_DISABLE_POLL is set).
|
||||
@@ -975,23 +977,31 @@ CONFIG_INPUT_TSC2007=n
|
||||
# CONFIG_STMPE11_ADC_DISABLE
|
||||
# Disable driver ADC functionality.
|
||||
# CONFIG_STMPE11_GPIO_DISABLE
|
||||
# Disable driver GPIO functionlaity.
|
||||
# Disable driver GPIO functionality.
|
||||
# CONFIG_STMPE11_GPIOINT_DISABLE
|
||||
# Disable driver GPIO interrupt functionlality (ignored if GPIO functionality is
|
||||
# Disable driver GPIO interrupt functionality (ignored if GPIO functionality is
|
||||
# disabled).
|
||||
# CONFIG_STMPE11_SWAPXY
|
||||
# Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
# For the STM3240G-EVAL, X and Y should be swapped in PORTRAIT modes
|
||||
# CONFIG_STMPE11_TEMP_DISABLE
|
||||
# Disable driver temperature sensor functionlaity.
|
||||
# Disable driver temperature sensor functionality.
|
||||
# CONFIG_STMPE11_REGDBUG
|
||||
# Enabled very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
#
|
||||
CONFIG_INPUT_STMPE11=n
|
||||
CONFIG_STMPE11_SPI=n
|
||||
CONFIG_STMPE11_I2C=y
|
||||
CONFIG_STMPE11_MULTIPLE=y
|
||||
CONFIG_STMPE11_ACTIVELOW=y
|
||||
#CONFIG_STMPE11_NPOLLWAITERS
|
||||
CONFIG_STMPE11_TSC_DISABLE=n
|
||||
CONFIG_STMPE11_ADC_DISABLE=y
|
||||
CONFIG_STMPE11_GPIO_DISABLE=y
|
||||
CONFIG_STMPE11_GPIOINT_DISABLE=y
|
||||
CONFIG_STMPE11_SWAPXY=n
|
||||
CONFIG_STMPE11_TEMP_DISABLE=y
|
||||
CONFIG_STMPE11_REGDEBUG=n
|
||||
|
||||
#
|
||||
# USB Device Configuration
|
||||
|
||||
@@ -181,7 +181,7 @@ static struct stm32_stmpe11config_s g_stmpe11config =
|
||||
#ifdef CONFIG_STMPE11_MULTIPLE
|
||||
.irq = STM32_IRQ_EXTI2,
|
||||
#endif
|
||||
.ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80|ADC_CTRL1_MOD_12B|ADC_CTRL1_REF_SEL),
|
||||
.ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B),
|
||||
.ctrl2 = ADC_CTRL2_ADC_FREQ_3p25,
|
||||
|
||||
.attach = stmpe11_attach,
|
||||
@@ -262,39 +262,44 @@ int arch_tcinitialize(void)
|
||||
FAR struct i2c_dev_s *dev;
|
||||
int ret;
|
||||
|
||||
ivdbg("Initializing\n");
|
||||
/* Check if we are already initialized */
|
||||
|
||||
/* Configure and enable the STMPE11 interrupt pin as an input */
|
||||
|
||||
(void)stm32_configgpio(GPIO_IO_EXPANDER);
|
||||
|
||||
/* Get an instance of the I2C interface */
|
||||
|
||||
dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV);
|
||||
if (!dev)
|
||||
{
|
||||
idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Instantiate the STMPE11 driver */
|
||||
|
||||
g_stmpe11config.handle =
|
||||
stmpe11_instantiate(dev, (FAR struct stmpe11_config_s *)&g_stmpe11config);
|
||||
if (!g_stmpe11config.handle)
|
||||
{
|
||||
idbg("Failed to instantiate the STMPE11 driver\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
ivdbg("Initializing\n");
|
||||
|
||||
/* Initialize and register the I2C touschscreen device */
|
||||
/* Configure the STMPE11 interrupt pin as an input */
|
||||
|
||||
ret = stmpe11_register(dev, CONFIG_STMPE11_DEVMINOR);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("Failed to register STMPE driver: %d\n", ret);
|
||||
/* up_i2cuninitialize(dev); */
|
||||
return -ENODEV;
|
||||
(void)stm32_configgpio(GPIO_IO_EXPANDER);
|
||||
|
||||
/* Get an instance of the I2C interface */
|
||||
|
||||
dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV);
|
||||
if (!dev)
|
||||
{
|
||||
idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Instantiate the STMPE11 driver */
|
||||
|
||||
g_stmpe11config.handle =
|
||||
stmpe11_instantiate(dev, (FAR struct stmpe11_config_s *)&g_stmpe11config);
|
||||
if (!g_stmpe11config.handle)
|
||||
{
|
||||
idbg("Failed to instantiate the STMPE11 driver\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Initialize and register the I2C touchscreen device */
|
||||
|
||||
ret = stmpe11_register(g_stmpe11config.handle, CONFIG_STMPE11_DEVMINOR);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("Failed to register STMPE driver: %d\n", ret);
|
||||
/* up_i2cuninitialize(dev); */
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -148,8 +148,8 @@ struct stmpe11_dev_s
|
||||
uint8_t minor; /* Touchscreen minor device number */
|
||||
volatile bool penchange; /* An unreported event is buffered */
|
||||
|
||||
uint32_t threshx; /* Thresholded X value */
|
||||
uint32_t threshy; /* Thresholded Y value */
|
||||
uint16_t threshx; /* Thresholded X value */
|
||||
uint16_t threshy; /* Thresholded Y value */
|
||||
sem_t waitsem; /* Used to wait for the availability of data */
|
||||
|
||||
struct work_s work; /* Supports the interrupt handling "bottom half" */
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/input/stmpe11.h>
|
||||
|
||||
@@ -92,7 +92,9 @@ static void stmpe11_worker(FAR void *arg)
|
||||
FAR struct stmpe11_dev_s *priv = (FAR struct stmpe11_dev_s *)arg;
|
||||
uint8_t regval;
|
||||
|
||||
/* Get the globl interrupt status */
|
||||
DEBUGASSERT(priv && priv->config);
|
||||
|
||||
/* Get the global interrupt status */
|
||||
|
||||
regval = stmpe11_getreg8(priv, STMPE11_INT_STA);
|
||||
|
||||
@@ -132,16 +134,16 @@ static void stmpe11_worker(FAR void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clear any other residual, unhandled pending interrupt */
|
||||
/* Clear any other residual, unhandled pending interrupt */
|
||||
|
||||
if (regval != 0)
|
||||
{
|
||||
stmpe11_putreg8(priv, STMPE11_INT_STA, regval);
|
||||
}
|
||||
if (regval != 0)
|
||||
{
|
||||
stmpe11_putreg8(priv, STMPE11_INT_STA, regval);
|
||||
}
|
||||
|
||||
/* Clear the STMPE11 global interrupt */
|
||||
/* Re-enable the STMPE11 GPIO interrupt */
|
||||
|
||||
priv->config->clear(priv->config);
|
||||
priv->config->enable(priv->config, true);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -244,7 +246,7 @@ static void stmpe11_reset(FAR struct stmpe11_dev_s *priv)
|
||||
|
||||
/* Wait a bit */
|
||||
|
||||
up_mdelay(20);
|
||||
usleep(20*1000);
|
||||
|
||||
/* Then power on again. All registers will be in their reset state. */
|
||||
|
||||
@@ -285,12 +287,6 @@ STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
|
||||
uint8_t regval;
|
||||
int ret;
|
||||
|
||||
/* On entry the following is assumed:
|
||||
*
|
||||
* I2C initialization ready
|
||||
* GPIO pins already configured.
|
||||
*/
|
||||
|
||||
/* Allocate the device state structure */
|
||||
|
||||
#ifdef CONFIG_STMPE11_MULTIPLE
|
||||
@@ -314,10 +310,20 @@ STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
|
||||
/* Initialize the device state structure */
|
||||
|
||||
sem_init(&priv->exclsem, 0, 1);
|
||||
priv->config = config;
|
||||
|
||||
#ifdef CONFIG_STMPE11_SPI
|
||||
priv->spi = dev;
|
||||
#else
|
||||
priv->i2c = dev;
|
||||
|
||||
/* Set the I2C address and frequency. REVISIT: This logic would be
|
||||
* insufficient if we share the I2C bus with any other devices that also
|
||||
* modify the address and frequency.
|
||||
*/
|
||||
|
||||
I2C_SETADDRESS(dev, config->address, 7);
|
||||
I2C_SETFREQUENCY(dev, config->frequency);
|
||||
#endif
|
||||
|
||||
/* Read and verify the STMPE11 chip ID */
|
||||
@@ -335,10 +341,14 @@ STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
|
||||
|
||||
stmpe11_reset(priv);
|
||||
|
||||
/* Configure the interrupt output pin to generate interrupts on high level. */
|
||||
/* Configure the interrupt output pin to generate interrupts on high or low level. */
|
||||
|
||||
regval = stmpe11_getreg8(priv, STMPE11_INT_CTRL);
|
||||
regval |= INT_CTRL_INT_POLARITY; /* Pin polarity: Active high */
|
||||
#ifdef CONFIG_STMPE11_ACTIVELOW
|
||||
regval &= ~INT_CTRL_INT_POLARITY; /* Pin polarity: Active low / falling edge */
|
||||
#else
|
||||
regval |= INT_CTRL_INT_POLARITY; /* Pin polarity: Active high / rising edge */
|
||||
#endif
|
||||
regval &= ~INT_CTRL_INT_TYPE; /* Level interrupt */
|
||||
stmpe11_putreg8(priv, STMPE11_INT_CTRL, regval);
|
||||
|
||||
@@ -409,6 +419,9 @@ uint8_t stmpe11_getreg8(FAR struct stmpe11_dev_s *priv, uint8_t regaddr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STMPE11_REGDEBUG
|
||||
dbg("%02x->%02x\n", regaddr, regval);
|
||||
#endif
|
||||
return regval;
|
||||
}
|
||||
#endif
|
||||
@@ -434,6 +447,10 @@ void stmpe11_putreg8(FAR struct stmpe11_dev_s *priv,
|
||||
uint8_t txbuffer[2];
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_STMPE11_REGDEBUG
|
||||
dbg("%02x<-%02x\n", regaddr, regval);
|
||||
#endif
|
||||
|
||||
/* Setup to the data to be transferred. Two bytes: The STMPE11 register
|
||||
* address followed by one byte of data.
|
||||
*/
|
||||
@@ -507,7 +524,10 @@ uint16_t stmpe11_getreg16(FAR struct stmpe11_dev_s *priv, uint8_t regaddr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint16_t)rxbuffer[0] << 16 | (uint16_t)rxbuffer[1];
|
||||
#ifdef CONFIG_STMPE11_REGDEBUG
|
||||
dbg("%02x->%02x%02x\n", regaddr, rxbuffer[0], rxbuffer[1]);
|
||||
#endif
|
||||
return (uint16_t)rxbuffer[0] << 8 | (uint16_t)rxbuffer[1];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+42
-28
@@ -139,7 +139,7 @@ static inline void stmpe11_tscinitialize(FAR struct stmpe11_dev_s *priv);
|
||||
|
||||
/* This the the vtable that supports the character driver interface */
|
||||
|
||||
static const struct file_operations stmpe11_fops =
|
||||
static const struct file_operations g_stmpe11fops =
|
||||
{
|
||||
stmpe11_open, /* open */
|
||||
stmpe11_close, /* close */
|
||||
@@ -464,6 +464,7 @@ static ssize_t stmpe11_read(FAR struct file *filep, FAR char *buffer, size_t len
|
||||
struct stmpe11_sample_s sample;
|
||||
int ret;
|
||||
|
||||
ivdbg("len=%d\n", len);
|
||||
DEBUGASSERT(filep);
|
||||
inode = filep->f_inode;
|
||||
|
||||
@@ -741,7 +742,9 @@ errout:
|
||||
|
||||
static inline void stmpe11_tscinitialize(FAR struct stmpe11_dev_s *priv)
|
||||
{
|
||||
uint8_t regval = 0;
|
||||
uint8_t regval;
|
||||
|
||||
ivdbg("Initializing touchscreen controller\n");
|
||||
|
||||
/* Enable TSC and ADC functions */
|
||||
|
||||
@@ -831,8 +834,10 @@ static inline void stmpe11_tscinitialize(FAR struct stmpe11_dev_s *priv)
|
||||
int stmpe11_register(STMPE11_HANDLE handle, int minor)
|
||||
{
|
||||
FAR struct stmpe11_dev_s *priv = (FAR struct stmpe11_dev_s *)handle;
|
||||
char devname[DEV_NAMELEN];
|
||||
int ret;
|
||||
|
||||
ivdbg("handle=%p minor=%d\n", handle, minor);
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to the device structure */
|
||||
@@ -854,25 +859,34 @@ int stmpe11_register(STMPE11_HANDLE handle, int minor)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Update the configuration structure to show that the TSC function is allocated */
|
||||
/* Initialize the TS structure to their default values */
|
||||
|
||||
priv->inuse |= TSC_PIN_SET; /* Pins 4-7 are now in-use */
|
||||
priv->flags |= STMPE11_FLAGS_TSC_INITIALIZED; /* TSC function is initialized */
|
||||
priv->minor = minor; /* Save the minor number */
|
||||
priv->minor = minor;
|
||||
priv->penchange = false;
|
||||
priv->threshx = 0;
|
||||
priv->threshy = 0;
|
||||
|
||||
/* Register the character driver */
|
||||
|
||||
snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
|
||||
ret = register_driver(devname, &g_stmpe11fops, 0666, priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("Failed to register driver %s: %d\n", devname, ret);
|
||||
sem_post(&priv->exclsem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Initialize the touchscreen controller */
|
||||
|
||||
stmpe11_tscinitialize(priv);
|
||||
|
||||
/* Initialize the TS structure to their default values */
|
||||
/* Inidicate that the touchscreen controller was successfully initialized */
|
||||
|
||||
priv->penchange = false;
|
||||
priv->threshx = 0;
|
||||
priv->threshy = 0;
|
||||
|
||||
priv->flags |= STMPE11_FLAGS_GPIO_INITIALIZED;
|
||||
priv->inuse |= TSC_PIN_SET; /* Pins 4-7 are now in-use */
|
||||
priv->flags |= STMPE11_FLAGS_TSC_INITIALIZED; /* TSC function is initialized */
|
||||
sem_post(&priv->exclsem);
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -894,6 +908,7 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
|
||||
uint16_t x; /* X position */
|
||||
uint16_t y; /* Y position */
|
||||
|
||||
ivdbg("Sampling\n");
|
||||
ASSERT(priv != NULL);
|
||||
|
||||
/* Get a pointer the callbacks for convenience (and so the code is not so
|
||||
@@ -903,10 +918,9 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
|
||||
config = priv->config;
|
||||
DEBUGASSERT(config != NULL);
|
||||
|
||||
/* Check if the Touch detect event happened */
|
||||
/* Check for pen up or down from the TSC_STA ibit n the STMPE11_TSC_CTRL register. */
|
||||
|
||||
pendown = (stmpe11_getreg8(priv, STMPE11_TSC_CTRL) & STMPE11_TSC_CTRL) != 0;
|
||||
pendown = (stmpe11_getreg8(priv, STMPE11_TSC_CTRL) & TSC_CTRL_TSC_STA) != 0;
|
||||
|
||||
/* Handle the change from pen down to pen up */
|
||||
|
||||
@@ -918,17 +932,22 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
|
||||
|
||||
if (priv->sample.contact == CONTACT_NONE)
|
||||
{
|
||||
goto errout;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read the next x and y positions */
|
||||
|
||||
#ifdef CONFIG_STMPE11_SWAPXY
|
||||
x = stmpe11_getreg16(priv, STMPE11_TSC_DATAX);
|
||||
y = stmpe11_getreg16(priv, STMPE11_TSC_DATAY);
|
||||
#else
|
||||
x = stmpe11_getreg16(priv, STMPE11_TSC_DATAY);
|
||||
y = stmpe11_getreg16(priv, STMPE11_TSC_DATAX);
|
||||
#endif
|
||||
|
||||
/* Perform a threasholding operation so that the results will be more stable */
|
||||
/* Perform a thresholding operation so that the results will be more stable */
|
||||
|
||||
xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x);
|
||||
ydiff = y > priv->threshy ? (y - priv->threshy) : (priv->threshy - y);
|
||||
@@ -949,13 +968,13 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
|
||||
/* Update the Z pression index */
|
||||
|
||||
priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ);
|
||||
|
||||
/* Clear the interrupt pending bit and enable the FIFO again */
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01);
|
||||
stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00);
|
||||
}
|
||||
|
||||
/* Clear the interrupt pending bit and enable the FIFO again */
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01);
|
||||
stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00);
|
||||
|
||||
/* Note the availability of new measurements */
|
||||
|
||||
if (pendown)
|
||||
@@ -987,14 +1006,9 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
|
||||
priv->sample.id = priv->id;
|
||||
priv->penchange = true;
|
||||
|
||||
/* Notify any waiters that nes STMPE11 data is available */
|
||||
/* Notify any waiters that new STMPE11 data is available */
|
||||
|
||||
stmpe11_notify(priv);
|
||||
|
||||
/* Exit, re-enabling STMPE11 interrupts */
|
||||
|
||||
errout:
|
||||
config->enable(config, true);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE11 && !CONFIG_STMPE11_TSC_DISABLE */
|
||||
|
||||
@@ -108,7 +108,7 @@ static int lm75_ioctl(FAR struct file *filep,int cmd,unsigned long arg);
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct file_operations lm75_fops =
|
||||
static const struct file_operations g_lm75fops =
|
||||
{
|
||||
lm75_open,
|
||||
lm75_close,
|
||||
@@ -526,7 +526,7 @@ int lm75_register(FAR const char *devpath, FAR struct i2c_dev_s *i2c, uint8_t ad
|
||||
|
||||
/* Register the character driver */
|
||||
|
||||
ret = register_driver(devpath, &lm75_fops, 0555, priv);
|
||||
ret = register_driver(devpath, &g_lm75fops, 0666, priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("Failed to register driver: %d\n", ret);
|
||||
|
||||
@@ -76,12 +76,16 @@
|
||||
* CONFIG_STMPE11_ADC_DISABLE
|
||||
* Disable driver ADC functionality.
|
||||
* CONFIG_STMPE11_GPIO_DISABLE
|
||||
* Disable driver GPIO functionlaity.
|
||||
* Disable driver GPIO functionality.
|
||||
* CONFIG_STMPE11_GPIOINT_DISABLE
|
||||
* Disable driver GPIO interrupt functionlality (ignored if GPIO functionality is
|
||||
* disabled).
|
||||
* CONFIG_STMPE11_SWAPXY
|
||||
* Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
* CONFIG_STMPE11_TEMP_DISABLE
|
||||
* Disable driver temperature sensor functionlaity.
|
||||
* Disable driver temperature sensor functionality.
|
||||
* CONFIG_STMPE11_REGDEBUG
|
||||
* Enabled very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
*/
|
||||
|
||||
/* The STMPE811 interfaces with the target CPU via a I2C or SPI interface. The pin IN_1
|
||||
@@ -123,6 +127,12 @@
|
||||
# error "Work queue support required. CONFIG_SCHED_WORKQUEUE must be selected."
|
||||
#endif
|
||||
|
||||
/* Debug output */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_STMPE11_REGDEBUG
|
||||
#endif
|
||||
|
||||
/* I2C **************************************************************************************/
|
||||
/* STMPE11 Address: The STMPE11 may have 7-bit address 0x41 or 0x44, depending upon the
|
||||
* state of the ADDR0 pin.
|
||||
@@ -324,7 +334,7 @@
|
||||
# define TSC_CFG_SETTLING_10MS (5 << TSC_CFG_SETTLING_SHIFT)
|
||||
# define TSC_CFG_SETTLING_50MS (6 << TSC_CFG_SETTLING_SHIFT)
|
||||
# define TSC_CFG_SETTLING_100MS (7 << TSC_CFG_SETTLING_SHIFT)
|
||||
#define TSC_CFG_TOUCH_DELAY_SHIFT (1) /* Bits 3-5: Touch detect delay */
|
||||
#define TSC_CFG_TOUCH_DELAY_SHIFT (3) /* Bits 3-5: Touch detect delay */
|
||||
#define TSC_CFG_TOUCH_DELAY_MASK (7 << TSC_CFG_TOUCH_DELAY_SHIFT)
|
||||
# define TSC_CFG_TOUCH_DELAY_10US (0 << TSC_CFG_TOUCH_DELAY_SHIFT)
|
||||
# define TSC_CFG_TOUCH_DELAY_50US (1 << TSC_CFG_TOUCH_DELAY_SHIFT)
|
||||
|
||||
Reference in New Issue
Block a user