From 0f72f7085182b9038e0037c3b949458ac3306fdc Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 8 May 2012 22:10:29 +0000 Subject: 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 --- apps/examples/touchscreen/tc_main.c | 4 +- nuttx/Documentation/NuttxPortingGuide.html | 16 ++++++- nuttx/arch/arm/src/stm32/stm32_i2c.c | 4 +- nuttx/configs/README.txt | 10 +++- nuttx/configs/stm3240g-eval/nsh/defconfig | 26 +++++++---- nuttx/configs/stm3240g-eval/nxwm/defconfig | 16 +++++-- nuttx/configs/stm3240g-eval/src/up_stmpe11.c | 57 ++++++++++++----------- nuttx/drivers/input/stmpe11.h | 4 +- nuttx/drivers/input/stmpe11_base.c | 58 ++++++++++++++++-------- nuttx/drivers/input/stmpe11_tsc.c | 68 +++++++++++++++++----------- nuttx/drivers/sensors/lm75.c | 4 +- nuttx/include/nuttx/input/stmpe11.h | 16 +++++-- 12 files changed, 186 insertions(+), 97 deletions(-) diff --git a/apps/examples/touchscreen/tc_main.c b/apps/examples/touchscreen/tc_main.c index 6db6af992..162025c79 100644 --- a/apps/examples/touchscreen/tc_main.c +++ b/apps/examples/touchscreen/tc_main.c @@ -122,7 +122,7 @@ int MAIN_NAME(int argc, char *argv[]) * external to this test. */ - message(MAIN_STRING "Initializing external touschscreen device\n"); + message(MAIN_STRING "Initializing external touchscreen device\n"); ret = arch_tcinitialize(CONFIG_EXAMPLES_TOUCHSCREEN_MINOR); if (ret != OK) { @@ -133,6 +133,7 @@ int MAIN_NAME(int argc, char *argv[]) /* Open the touchscreen device for reading */ + message(MAIN_STRING "Opening %s\n", CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH); fd = open(CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, O_RDONLY); if (fd < 0) { @@ -162,6 +163,7 @@ int MAIN_NAME(int argc, char *argv[]) /* Read one sample */ + ivdbg("Reading...\n"); nbytes = read(fd, &sample, sizeof(struct touch_sample_s)); ivdbg("Bytes read: %d\n", nbytes); diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 4c3e93a6a..0eec8d12a 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -4688,6 +4688,10 @@ build 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 @@ -4707,12 +4711,20 @@ build
  • 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.
  • diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c index db8f6da4c..4f55a5709 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -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 diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 2cffc0750..6bd459801 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -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 diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index fc3d1a955..9aa23b036 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -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 diff --git a/nuttx/configs/stm3240g-eval/nxwm/defconfig b/nuttx/configs/stm3240g-eval/nxwm/defconfig index 72fcaace0..ce1be631e 100644 --- a/nuttx/configs/stm3240g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3240g-eval/nxwm/defconfig @@ -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 diff --git a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c index 66e844c01..a9402eda7 100644 --- a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c +++ b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c @@ -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 */ + if (!g_stmpe11config.handle) + { + ivdbg("Initializing\n"); - (void)stm32_configgpio(GPIO_IO_EXPANDER); + /* Configure the STMPE11 interrupt pin as an input */ - /* Get an instance of the I2C interface */ + (void)stm32_configgpio(GPIO_IO_EXPANDER); - dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV); - if (!dev) - { - idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV); - return -ENODEV; - } + /* Get an instance of the I2C interface */ - /* Instantiate the STMPE11 driver */ + dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV); + if (!dev) + { + idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV); + return -ENODEV; + } - 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; - } + /* Instantiate the STMPE11 driver */ - /* Initialize and register the I2C touschscreen device */ + 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; + } - ret = stmpe11_register(dev, CONFIG_STMPE11_DEVMINOR); - if (ret < 0) - { - idbg("Failed to register STMPE driver: %d\n", ret); - /* up_i2cuninitialize(dev); */ - 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; diff --git a/nuttx/drivers/input/stmpe11.h b/nuttx/drivers/input/stmpe11.h index 6876fa141..9ca31e52a 100644 --- a/nuttx/drivers/input/stmpe11.h +++ b/nuttx/drivers/input/stmpe11.h @@ -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" */ diff --git a/nuttx/drivers/input/stmpe11_base.c b/nuttx/drivers/input/stmpe11_base.c index cabd33db2..f9f52fae9 100644 --- a/nuttx/drivers/input/stmpe11_base.c +++ b/nuttx/drivers/input/stmpe11_base.c @@ -43,10 +43,10 @@ #include +#include #include #include -#include #include #include @@ -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 diff --git a/nuttx/drivers/input/stmpe11_tsc.c b/nuttx/drivers/input/stmpe11_tsc.c index b6d9c3d62..a452d8798 100644 --- a/nuttx/drivers/input/stmpe11_tsc.c +++ b/nuttx/drivers/input/stmpe11_tsc.c @@ -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 */ - - priv->penchange = false; - priv->threshx = 0; - priv->threshy = 0; + /* Inidicate that the touchscreen controller was successfully initialized */ - 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,12 +968,12 @@ 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 */ + /* Clear the interrupt pending bit and enable the FIFO again */ - stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01); - stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00); - } + stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01); + stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00); /* Note the availability of new measurements */ @@ -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 */ diff --git a/nuttx/drivers/sensors/lm75.c b/nuttx/drivers/sensors/lm75.c index cd83f645b..8e1a0fb4b 100644 --- a/nuttx/drivers/sensors/lm75.c +++ b/nuttx/drivers/sensors/lm75.c @@ -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); diff --git a/nuttx/include/nuttx/input/stmpe11.h b/nuttx/include/nuttx/input/stmpe11.h index 27eef46ee..5ecc53af1 100644 --- a/nuttx/include/nuttx/input/stmpe11.h +++ b/nuttx/include/nuttx/input/stmpe11.h @@ -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) -- cgit v1.2.3