From 05738115218b3090bce9e5e3e279e0a9f5df194d Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 29 May 2012 00:54:22 +0000 Subject: Massive naming fix: STMPE11->STMPE811 git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4782 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/configs/README.txt | 38 +-- nuttx/configs/stm3220g-eval/README.txt | 6 +- nuttx/configs/stm3220g-eval/nsh/appconfig | 2 +- nuttx/configs/stm3220g-eval/nsh/defconfig | 72 ++--- nuttx/configs/stm3220g-eval/nxwm/defconfig | 72 ++--- nuttx/configs/stm3220g-eval/src/Makefile | 4 +- .../configs/stm3220g-eval/src/stm3220g-internal.h | 10 +- nuttx/configs/stm3220g-eval/src/up_stmpe11.c | 353 --------------------- nuttx/configs/stm3220g-eval/src/up_stmpe811.c | 353 +++++++++++++++++++++ nuttx/configs/stm3240g-eval/README.txt | 6 +- nuttx/configs/stm3240g-eval/nsh/appconfig | 2 +- nuttx/configs/stm3240g-eval/nsh/defconfig | 72 ++--- nuttx/configs/stm3240g-eval/nxwm/defconfig | 72 ++--- nuttx/configs/stm3240g-eval/src/Makefile | 4 +- .../configs/stm3240g-eval/src/stm3240g-internal.h | 10 +- nuttx/configs/stm3240g-eval/src/up_stmpe11.c | 353 --------------------- nuttx/configs/stm3240g-eval/src/up_stmpe811.c | 353 +++++++++++++++++++++ 17 files changed, 891 insertions(+), 891 deletions(-) delete mode 100644 nuttx/configs/stm3220g-eval/src/up_stmpe11.c create mode 100644 nuttx/configs/stm3220g-eval/src/up_stmpe811.c delete mode 100644 nuttx/configs/stm3240g-eval/src/up_stmpe11.c create mode 100644 nuttx/configs/stm3240g-eval/src/up_stmpe811.c (limited to 'nuttx/configs') diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index fc85e89e1..56659fe36 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -784,41 +784,41 @@ defconfig -- This is a configuration file similar to the Linux there are multiple TSC2007 touchscreens, this setting will enable multiple touchscreens with the same driver. - CONFIG_INPUT_STMPE11 - Enables support for the STMPE11 driver (Needs CONFIG_INPUT) - CONFIG_STMPE11_SPI + CONFIG_INPUT_STMPE811 + Enables support for the STMPE811 driver (Needs CONFIG_INPUT) + CONFIG_STMPE811_SPI Enables support for the SPI interface (not currenly supported) - CONFIG_STMPE11_I2C + CONFIG_STMPE811_I2C Enables support for the I2C interface - CONFIG_STMPE11_MULTIPLE - Can be defined to support multiple STMPE11 devices on board. - CONFIG_STMPE11_ACTIVELOW + CONFIG_STMPE811_MULTIPLE + Can be defined to support multiple STMPE811 devices on board. + CONFIG_STMPE811_ACTIVELOW Interrupt is generated by an active low signal (or falling edge). - CONFIG_STMPE11_EDGE + CONFIG_STMPE811_EDGE Interrupt is generated on an edge (vs. on the active level) - CONFIG_STMPE11_NPOLLWAITERS + CONFIG_STMPE811_NPOLLWAITERS Maximum number of threads that can be waiting on poll() (ignored if CONFIG_DISABLE_POLL is set). - CONFIG_STMPE11_TSC_DISABLE + CONFIG_STMPE811_TSC_DISABLE Disable driver touchscreen functionality. - CONFIG_STMPE11_ADC_DISABLE + CONFIG_STMPE811_ADC_DISABLE Disable driver ADC functionality. - CONFIG_STMPE11_GPIO_DISABLE + CONFIG_STMPE811_GPIO_DISABLE Disable driver GPIO functionlaity. - CONFIG_STMPE11_GPIOINT_DISABLE + CONFIG_STMPE811_GPIOINT_DISABLE Disable driver GPIO interrupt functionality (ignored if GPIO functionality is disabled). - CONFIG_STMPE11_SWAPXY + CONFIG_STMPE811_SWAPXY Reverse the meaning of X and Y to handle different LCD orientations. - CONFIG_STMPE11_TEMP_DISABLE + CONFIG_STMPE811_TEMP_DISABLE Disable driver temperature sensor functionality. - CONFIG_STMPE11_REGDEBUG + CONFIG_STMPE811_REGDEBUG Enabled very low register-level debug output. Requires CONFIG_DEBUG. - CONFIG_STMPE11_THRESHX and CONFIG_STMPE11_THRESHY - STMPE11 touchscreen data comes in a a very high rate. New touch positions + CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY + STMPE811 touchscreen data comes in a a very high rate. New touch positions will only be reported when the X or Y data changes by these thresholds. This trades reduces data rate for some loss in dragging accuracy. The - STMPE11 is configure for 12-bit values so the raw ranges are 0-4095. So + STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So for example, if your display is 320x240, then THRESHX=13 and THRESHY=17 would correspond to one pixel. Default: 12 diff --git a/nuttx/configs/stm3220g-eval/README.txt b/nuttx/configs/stm3220g-eval/README.txt index fd4d7f76d..4a75d5a1a 100644 --- a/nuttx/configs/stm3220g-eval/README.txt +++ b/nuttx/configs/stm3220g-eval/README.txt @@ -386,10 +386,10 @@ There are 2 possible SRAM configurations: I/O Expanders ============= -The STM3220G-EVAL has two STMPE11QTR I/O expanders on board both connected to +The STM3220G-EVAL has two STMPE811QTR I/O expanders on board both connected to the STM32 via I2C1. They share a common interrupt line: PI2. -STMPE11 U24, I2C address 0x41 (7-bit) +STMPE811 U24, I2C address 0x41 (7-bit) ------ ---- ---------------- -------------------------------------------- STPE11 PIN BOARD SIGNAL BOARD CONNECTION ------ ---- ---------------- -------------------------------------------- @@ -402,7 +402,7 @@ STPE11 PIN BOARD SIGNAL BOARD CONNECTION IN1 EXP_IO11 IN0 EXP_IO12 -STMPE11 U29, I2C address 0x44 (7-bit) +STMPE811 U29, I2C address 0x44 (7-bit) ------ ---- ---------------- -------------------------------------------- STPE11 PIN BOARD SIGNAL BOARD CONNECTION ------ ---- ---------------- -------------------------------------------- diff --git a/nuttx/configs/stm3220g-eval/nsh/appconfig b/nuttx/configs/stm3220g-eval/nsh/appconfig index e74f5abc0..5f7490ccb 100644 --- a/nuttx/configs/stm3220g-eval/nsh/appconfig +++ b/nuttx/configs/stm3220g-eval/nsh/appconfig @@ -80,7 +80,7 @@ ifeq ($(CONFIG_WATCHDOG),y) CONFIGURED_APPS += examples/watchdog endif -ifeq ($(CONFIG_INPUT_STMPE11),y) +ifeq ($(CONFIG_INPUT_STMPE811),y) CONFIGURED_APPS += examples/touchscreen endif diff --git a/nuttx/configs/stm3220g-eval/nsh/defconfig b/nuttx/configs/stm3220g-eval/nsh/defconfig index f226d0524..6643057d7 100644 --- a/nuttx/configs/stm3220g-eval/nsh/defconfig +++ b/nuttx/configs/stm3220g-eval/nsh/defconfig @@ -944,66 +944,66 @@ CONFIG_INPUT=n CONFIG_INPUT_TSC2007=n # -# STMPE11 input device configuration +# STMPE811 input device configuration # # Prerequisites: CONFIG_INPUT=y # Other settings that effect the driver: CONFIG_DISABLE_POLL # -# CONFIG_INPUT_STMPE11 -# Enables support for the STMPE11 driver (Needs CONFIG_INPUT) -# CONFIG_STMPE11_SPI +# CONFIG_INPUT_STMPE811 +# Enables support for the STMPE811 driver (Needs CONFIG_INPUT) +# CONFIG_STMPE811_SPI # Enables support for the SPI interface (not currenly supported) -# CONFIG_STMPE11_I2C +# CONFIG_STMPE811_I2C # Enables support for the I2C interface -# CONFIG_STMPE11_MULTIPLE -# Can be defined to support multiple STMPE11 devices on board. -# CONFIG_STMPE11_ACTIVELOW +# CONFIG_STMPE811_MULTIPLE +# Can be defined to support multiple STMPE811 devices on board. +# CONFIG_STMPE811_ACTIVELOW # Interrupt is generated by an active low signal (or falling edge). -# CONFIG_STMPE11_EDGE +# CONFIG_STMPE811_EDGE # Interrupt is generated on an edge (vs. on the active level) -# CONFIG_STMPE11_NPOLLWAITERS +# CONFIG_STMPE811_NPOLLWAITERS # Maximum number of threads that can be waiting on poll() (ignored if # CONFIG_DISABLE_POLL is set). -# CONFIG_STMPE11_TSC_DISABLE +# CONFIG_STMPE811_TSC_DISABLE # Disable driver touchscreen functionality. -# CONFIG_STMPE11_ADC_DISABLE +# CONFIG_STMPE811_ADC_DISABLE # Disable driver ADC functionality. -# CONFIG_STMPE11_GPIO_DISABLE +# CONFIG_STMPE811_GPIO_DISABLE # Disable driver GPIO functionality. -# CONFIG_STMPE11_GPIOINT_DISABLE +# CONFIG_STMPE811_GPIOINT_DISABLE # Disable driver GPIO interrupt functionality (ignored if GPIO functionality is # disabled). -# CONFIG_STMPE11_SWAPXY +# CONFIG_STMPE811_SWAPXY # Reverse the meaning of X and Y to handle different LCD orientations. # For the STM3220G-EVAL, X and Y should be swapped in PORTRAIT modes -# CONFIG_STMPE11_TEMP_DISABLE +# CONFIG_STMPE811_TEMP_DISABLE # Disable driver temperature sensor functionality. -# CONFIG_STMPE11_REGDBUG +# CONFIG_STMPE811_REGDBUG # Enabled very low register-level debug output. Requires CONFIG_DEBUG. -# CONFIG_STMPE11_THRESHX and CONFIG_STMPE11_THRESHY -# STMPE11 touchscreen data comes in a a very high rate. New touch positions +# CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY +# STMPE811 touchscreen data comes in a a very high rate. New touch positions # will only be reported when the X or Y data changes by these thresholds. # This trades reduces data rate for some loss in dragging accuracy. The -# STMPE11 is configure for 12-bit values so the raw ranges are 0-4095. So +# STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So # for example, if your display is 320x240, then THRESHX=13 and THRESHY=17 # would correspond to one pixel. Default: 12 # -CONFIG_INPUT_STMPE11=n -CONFIG_STMPE11_SPI=n -CONFIG_STMPE11_I2C=y -CONFIG_STMPE11_MULTIPLE=y -CONFIG_STMPE11_ACTIVELOW=y -CONFIG_STMPE11_EDGE=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 -CONFIG_STMPE11_THRESHX=26 -CONFIG_STMPE11_THRESHY=34 +CONFIG_INPUT_STMPE811=n +CONFIG_STMPE811_SPI=n +CONFIG_STMPE811_I2C=y +CONFIG_STMPE811_MULTIPLE=y +CONFIG_STMPE811_ACTIVELOW=y +CONFIG_STMPE811_EDGE=y +#CONFIG_STMPE811_NPOLLWAITERS +CONFIG_STMPE811_TSC_DISABLE=n +CONFIG_STMPE811_ADC_DISABLE=y +CONFIG_STMPE811_GPIO_DISABLE=y +CONFIG_STMPE811_GPIOINT_DISABLE=y +CONFIG_STMPE811_SWAPXY=y +CONFIG_STMPE811_TEMP_DISABLE=y +CONFIG_STMPE811_REGDEBUG=n +CONFIG_STMPE811_THRESHX=26 +CONFIG_STMPE811_THRESHY=34 # # USB Device Configuration diff --git a/nuttx/configs/stm3220g-eval/nxwm/defconfig b/nuttx/configs/stm3220g-eval/nxwm/defconfig index 7c6a19dd6..ba55a2b95 100644 --- a/nuttx/configs/stm3220g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3220g-eval/nxwm/defconfig @@ -945,66 +945,66 @@ CONFIG_INPUT=y CONFIG_INPUT_TSC2007=n # -# STMPE11 input device configuration +# STMPE811 input device configuration # # Prerequisites: CONFIG_INPUT=y # Other settings that effect the driver: CONFIG_DISABLE_POLL # -# CONFIG_INPUT_STMPE11 -# Enables support for the STMPE11 driver (Needs CONFIG_INPUT) -# CONFIG_STMPE11_SPI +# CONFIG_INPUT_STMPE811 +# Enables support for the STMPE811 driver (Needs CONFIG_INPUT) +# CONFIG_STMPE811_SPI # Enables support for the SPI interface (not currenly supported) -# CONFIG_STMPE11_I2C +# CONFIG_STMPE811_I2C # Enables support for the I2C interface -# CONFIG_STMPE11_MULTIPLE -# Can be defined to support multiple STMPE11 devices on board. -# CONFIG_STMPE11_ACTIVELOW +# CONFIG_STMPE811_MULTIPLE +# Can be defined to support multiple STMPE811 devices on board. +# CONFIG_STMPE811_ACTIVELOW # Interrupt is generated by an active low signal (or falling edge). -# CONFIG_STMPE11_EDGE +# CONFIG_STMPE811_EDGE # Interrupt is generated on an edge (vs. on the active level) -# CONFIG_STMPE11_NPOLLWAITERS +# CONFIG_STMPE811_NPOLLWAITERS # Maximum number of threads that can be waiting on poll() (ignored if # CONFIG_DISABLE_POLL is set). -# CONFIG_STMPE11_TSC_DISABLE +# CONFIG_STMPE811_TSC_DISABLE # Disable driver touchscreen functionality. -# CONFIG_STMPE11_ADC_DISABLE +# CONFIG_STMPE811_ADC_DISABLE # Disable driver ADC functionality. -# CONFIG_STMPE11_GPIO_DISABLE +# CONFIG_STMPE811_GPIO_DISABLE # Disable driver GPIO functionality. -# CONFIG_STMPE11_GPIOINT_DISABLE +# CONFIG_STMPE811_GPIOINT_DISABLE # Disable driver GPIO interrupt functionality (ignored if GPIO functionality is # disabled). -# CONFIG_STMPE11_SWAPXY +# CONFIG_STMPE811_SWAPXY # Reverse the meaning of X and Y to handle different LCD orientations. # For the STM3220G-EVAL, X and Y should be swapped in PORTRAIT modes -# CONFIG_STMPE11_TEMP_DISABLE +# CONFIG_STMPE811_TEMP_DISABLE # Disable driver temperature sensor functionality. -# CONFIG_STMPE11_REGDBUG +# CONFIG_STMPE811_REGDBUG # Enabled very low register-level debug output. Requires CONFIG_DEBUG. -# CONFIG_STMPE11_THRESHX and CONFIG_STMPE11_THRESHY -# STMPE11 touchscreen data comes in a a very high rate. New touch positions +# CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY +# STMPE811 touchscreen data comes in a a very high rate. New touch positions # will only be reported when the X or Y data changes by these thresholds. # This trades reduces data rate for some loss in dragging accuracy. The -# STMPE11 is configure for 12-bit values so the raw ranges are 0-4095. So +# STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So # for example, if your display is 320x240, then THRESHX=13 and THRESHY=17 # would correspond to one pixel. Default: 12 # -CONFIG_INPUT_STMPE11=y -CONFIG_STMPE11_SPI=n -CONFIG_STMPE11_I2C=y -CONFIG_STMPE11_MULTIPLE=y -CONFIG_STMPE11_ACTIVELOW=y -CONFIG_STMPE11_EDGE=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 -CONFIG_STMPE11_THRESHX=39 -CONFIG_STMPE11_THRESHY=51 +CONFIG_INPUT_STMPE811=y +CONFIG_STMPE811_SPI=n +CONFIG_STMPE811_I2C=y +CONFIG_STMPE811_MULTIPLE=y +CONFIG_STMPE811_ACTIVELOW=y +CONFIG_STMPE811_EDGE=y +#CONFIG_STMPE811_NPOLLWAITERS +CONFIG_STMPE811_TSC_DISABLE=n +CONFIG_STMPE811_ADC_DISABLE=y +CONFIG_STMPE811_GPIO_DISABLE=y +CONFIG_STMPE811_GPIOINT_DISABLE=y +CONFIG_STMPE811_SWAPXY=n +CONFIG_STMPE811_TEMP_DISABLE=y +CONFIG_STMPE811_REGDEBUG=n +CONFIG_STMPE811_THRESHX=39 +CONFIG_STMPE811_THRESHY=51 # # USB Device Configuration diff --git a/nuttx/configs/stm3220g-eval/src/Makefile b/nuttx/configs/stm3220g-eval/src/Makefile index 44cc7f1d1..96ad0d10c 100644 --- a/nuttx/configs/stm3220g-eval/src/Makefile +++ b/nuttx/configs/stm3220g-eval/src/Makefile @@ -84,8 +84,8 @@ ifeq ($(CONFIG_WATCHDOG),y) CSRCS += up_watchdog.c endif -ifeq ($(CONFIG_INPUT_STMPE11),y) -CSRCS += up_stmpe11.c +ifeq ($(CONFIG_INPUT_STMPE811),y) +CSRCS += up_stmpe811.c endif COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/nuttx/configs/stm3220g-eval/src/stm3220g-internal.h b/nuttx/configs/stm3220g-eval/src/stm3220g-internal.h index dcb7c7e1b..2391f3c4a 100644 --- a/nuttx/configs/stm3220g-eval/src/stm3220g-internal.h +++ b/nuttx/configs/stm3220g-eval/src/stm3220g-internal.h @@ -138,10 +138,10 @@ #define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN5) #define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN11) -/* The STM3220G-EVAL has two STMPE11QTR I/O expanders on board both connected +/* The STM3220G-EVAL has two STMPE811QTR I/O expanders on board both connected * to the STM32 via I2C1. They share a common interrupt line: PI2. * - * STMPE11 U24, I2C address 0x41 (7-bit) + * STMPE811 U24, I2C address 0x41 (7-bit) * ------ ---- ---------------- -------------------------------------------- * STPE11 PIN BOARD SIGNAL BOARD CONNECTION * ------ ---- ---------------- -------------------------------------------- @@ -154,7 +154,7 @@ * IN1 EXP_IO11 * IN0 EXP_IO12 * - * STMPE11 U29, I2C address 0x44 (7-bit) + * STMPE811 U29, I2C address 0x44 (7-bit) * ------ ---- ---------------- -------------------------------------------- * STPE11 PIN BOARD SIGNAL BOARD CONNECTION * ------ ---- ---------------- -------------------------------------------- @@ -168,8 +168,8 @@ * IN0 EXP_IO8 */ -#define STMPE11_ADDR1 0x41 -#define STMPE11_ADDR2 0x44 +#define STMPE811_ADDR1 0x41 +#define STMPE811_ADDR2 0x44 #define GPIO_IO_EXPANDER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTI|GPIO_PIN2) diff --git a/nuttx/configs/stm3220g-eval/src/up_stmpe11.c b/nuttx/configs/stm3220g-eval/src/up_stmpe11.c deleted file mode 100644 index eee765364..000000000 --- a/nuttx/configs/stm3220g-eval/src/up_stmpe11.c +++ /dev/null @@ -1,353 +0,0 @@ -/************************************************************************************ - * configs/stm3220g-eval/src/up_touchscreen.c - * arch/arm/src/board/up_touchscreen.c - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "stm32_internal.h" -#include "stm3220g-internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifdef CONFIG_INPUT_STMPE11 -#ifndef CONFIG_INPUT -# error "STMPE11 support requires CONFIG_INPUT" -#endif - -#ifndef CONFIG_STM32_I2C1 -# error "STMPE11 support requires CONFIG_STM32_I2C1" -#endif - -#ifndef CONFIG_STMPE11_I2C -# error "Only the STMPE11 I2C interface is supported" -#endif - -#ifdef CONFIG_STMPE11_SPI -# error "Only the STMPE11 SPI interface is supported" -#endif - -#ifndef CONFIG_STMPE11_FREQUENCY -# define CONFIG_STMPE11_FREQUENCY 100000 -#endif - -#ifndef CONFIG_STMPE11_I2CDEV -# define CONFIG_STMPE11_I2CDEV 1 -#endif - -#if CONFIG_STMPE11_I2CDEV != 1 -# error "CONFIG_STMPE11_I2CDEV must be one" -#endif - -#ifndef CONFIG_STMPE11_DEVMINOR -# define CONFIG_STMPE11_DEVMINOR 0 -#endif - -/* Board definitions ********************************************************/ -/* The STM3220G-EVAL has two STMPE11QTR I/O expanders on board both connected - * to the STM32 via I2C1. They share a common interrupt line: PI2. - * - * STMPE11 U24, I2C address 0x41 (7-bit) - * ------ ---- ---------------- -------------------------------------------- - * STPE11 PIN BOARD SIGNAL BOARD CONNECTION - * ------ ---- ---------------- -------------------------------------------- - * Y- TouchScreen_Y- LCD Connector XL - * X- TouchScreen_X- LCD Connector XR - * Y+ TouchScreen_Y+ LCD Connector XD - * X+ TouchScreen_X+ LCD Connector XU - * IN3 EXP_IO9 - * IN2 EXP_IO10 - * IN1 EXP_IO11 - * IN0 EXP_IO12 - * - * STMPE11 U29, I2C address 0x44 (7-bit) - * ------ ---- ---------------- -------------------------------------------- - * STPE11 PIN BOARD SIGNAL BOARD CONNECTION - * ------ ---- ---------------- -------------------------------------------- - * Y- EXP_IO1 - * X- EXP_IO2 - * Y+ EXP_IO3 - * X+ EXP_IO4 - * IN3 EXP_IO5 - * IN2 EXP_IO6 - * IN1 EXP_IO7 - * IN0 EXP_IO8 - */ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct stm32_stmpe11config_s -{ - /* Configuration structure as seen by the STMPE11 driver */ - - struct stmpe11_config_s config; - - /* Additional private definitions only known to this driver */ - - STMPE11_HANDLE handle; /* The STMPE11 driver handle */ - xcpt_t handler; /* The STMPE11 interrupt handler */ -}; - -/**************************************************************************** - * Static Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the STMPE11 driver from differences in GPIO - * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. - * - * attach - Attach the STMPE11 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - */ - -static int stmpe11_attach(FAR struct stmpe11_config_s *state, xcpt_t isr); -static void stmpe11_enable(FAR struct stmpe11_config_s *state, bool enable); -static void stmpe11_clear(FAR struct stmpe11_config_s *state); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the STMPE11 - * driver. This structure provides information about the configuration - * of the STMPE11 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. The - * memory must be writable because, under certain circumstances, the driver - * may modify frequency or X plate resistance values. - */ - -#ifndef CONFIG_STMPE11_TSC_DISABLE -static struct stm32_stmpe11config_s g_stmpe11config = -{ - .config = - { -#ifdef CONFIG_STMPE11_I2C - .address = STMPE11_ADDR1, -#endif - .frequency = CONFIG_STMPE11_FREQUENCY, - -#ifdef CONFIG_STMPE11_MULTIPLE - .irq = STM32_IRQ_EXTI2, -#endif - .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B), - .ctrl2 = ADC_CTRL2_ADC_FREQ_3p25, - - .attach = stmpe11_attach, - .enable = stmpe11_enable, - .clear = stmpe11_clear, - }, - .handler = NULL, -}; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the STMPE11 driver from differences in GPIO - * interrupt handling by varying boards and MCUs. - * - * attach - Attach the STMPE11 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - */ - -static int stmpe11_attach(FAR struct stmpe11_config_s *state, xcpt_t isr) -{ - FAR struct stm32_stmpe11config_s *priv = (FAR struct stm32_stmpe11config_s *)state; - - ivdbg("Saving handler %p\n", isr); - DEBUGASSERT(priv); - - /* Just save the handler. We will use it when EXTI interruptsare enabled */ - - priv->handler = isr; - return OK; -} - -static void stmpe11_enable(FAR struct stmpe11_config_s *state, bool enable) -{ - FAR struct stm32_stmpe11config_s *priv = (FAR struct stm32_stmpe11config_s *)state; - irqstate_t flags; - - /* Attach and enable, or detach and disable. Enabling and disabling GPIO - * interrupts is a multi-step process so the safest thing is to keep - * interrupts disabled during the reconfiguratino. - */ - - flags = irqsave(); - if (enable) - { - /* Configure the EXTI interrupt using the SAVED handler */ - - (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, true, true, true, priv->handler); - } - else - { - /* Configure the EXTI interrupt with a NULL handler to disable it */ - - (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL); - } - irqrestore(flags); -} - -static void stmpe11_clear(FAR struct stmpe11_config_s *state) -{ - /* Does nothing */ -} - -/**************************************************************************** - * 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) -{ -#ifndef CONFIG_STMPE11_TSC_DISABLE - FAR struct i2c_dev_s *dev; - int ret; - - idbg("minor %d\n", minor); - DEBUGASSERT(minor == 0); - - /* Check if we are already initialized */ - - if (!g_stmpe11config.handle) - { - ivdbg("Initializing\n"); - - /* Configure 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; - } - - /* 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; -#else - return -ENOSYS; -#endif -} - -/**************************************************************************** - * 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 STMPE11 device yet */ -} - -#endif /* CONFIG_INPUT_STMPE11 */ - diff --git a/nuttx/configs/stm3220g-eval/src/up_stmpe811.c b/nuttx/configs/stm3220g-eval/src/up_stmpe811.c new file mode 100644 index 000000000..b07cc52bf --- /dev/null +++ b/nuttx/configs/stm3220g-eval/src/up_stmpe811.c @@ -0,0 +1,353 @@ +/************************************************************************************ + * configs/stm3220g-eval/src/up_touchscreen.c + * arch/arm/src/board/up_touchscreen.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "stm32_internal.h" +#include "stm3220g-internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +#ifndef CONFIG_INPUT +# error "STMPE811 support requires CONFIG_INPUT" +#endif + +#ifndef CONFIG_STM32_I2C1 +# error "STMPE811 support requires CONFIG_STM32_I2C1" +#endif + +#ifndef CONFIG_STMPE811_I2C +# error "Only the STMPE811 I2C interface is supported" +#endif + +#ifdef CONFIG_STMPE811_SPI +# error "Only the STMPE811 SPI interface is supported" +#endif + +#ifndef CONFIG_STMPE811_FREQUENCY +# define CONFIG_STMPE811_FREQUENCY 100000 +#endif + +#ifndef CONFIG_STMPE811_I2CDEV +# define CONFIG_STMPE811_I2CDEV 1 +#endif + +#if CONFIG_STMPE811_I2CDEV != 1 +# error "CONFIG_STMPE811_I2CDEV must be one" +#endif + +#ifndef CONFIG_STMPE811_DEVMINOR +# define CONFIG_STMPE811_DEVMINOR 0 +#endif + +/* Board definitions ********************************************************/ +/* The STM3220G-EVAL has two STMPE811QTR I/O expanders on board both connected + * to the STM32 via I2C1. They share a common interrupt line: PI2. + * + * STMPE811 U24, I2C address 0x41 (7-bit) + * ------ ---- ---------------- -------------------------------------------- + * STPE11 PIN BOARD SIGNAL BOARD CONNECTION + * ------ ---- ---------------- -------------------------------------------- + * Y- TouchScreen_Y- LCD Connector XL + * X- TouchScreen_X- LCD Connector XR + * Y+ TouchScreen_Y+ LCD Connector XD + * X+ TouchScreen_X+ LCD Connector XU + * IN3 EXP_IO9 + * IN2 EXP_IO10 + * IN1 EXP_IO11 + * IN0 EXP_IO12 + * + * STMPE811 U29, I2C address 0x44 (7-bit) + * ------ ---- ---------------- -------------------------------------------- + * STPE11 PIN BOARD SIGNAL BOARD CONNECTION + * ------ ---- ---------------- -------------------------------------------- + * Y- EXP_IO1 + * X- EXP_IO2 + * Y+ EXP_IO3 + * X+ EXP_IO4 + * IN3 EXP_IO5 + * IN2 EXP_IO6 + * IN1 EXP_IO7 + * IN0 EXP_IO8 + */ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct stm32_stmpe811config_s +{ + /* Configuration structure as seen by the STMPE811 driver */ + + struct stmpe811_config_s config; + + /* Additional private definitions only known to this driver */ + + STMPE811_HANDLE handle; /* The STMPE811 driver handle */ + xcpt_t handler; /* The STMPE811 interrupt handler */ +}; + +/**************************************************************************** + * Static Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks + * to isolate the STMPE811 driver from differences in GPIO + * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. + * + * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + */ + +static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr); +static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable); +static void stmpe811_clear(FAR struct stmpe811_config_s *state); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the STMPE811 + * driver. This structure provides information about the configuration + * of the STMPE811 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. The + * memory must be writable because, under certain circumstances, the driver + * may modify frequency or X plate resistance values. + */ + +#ifndef CONFIG_STMPE811_TSC_DISABLE +static struct stm32_stmpe811config_s g_stmpe811config = +{ + .config = + { +#ifdef CONFIG_STMPE811_I2C + .address = STMPE811_ADDR1, +#endif + .frequency = CONFIG_STMPE811_FREQUENCY, + +#ifdef CONFIG_STMPE811_MULTIPLE + .irq = STM32_IRQ_EXTI2, +#endif + .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B), + .ctrl2 = ADC_CTRL2_ADC_FREQ_3p25, + + .attach = stmpe811_attach, + .enable = stmpe811_enable, + .clear = stmpe811_clear, + }, + .handler = NULL, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the STMPE811 driver from differences in GPIO + * interrupt handling by varying boards and MCUs. + * + * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + */ + +static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr) +{ + FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state; + + ivdbg("Saving handler %p\n", isr); + DEBUGASSERT(priv); + + /* Just save the handler. We will use it when EXTI interruptsare enabled */ + + priv->handler = isr; + return OK; +} + +static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable) +{ + FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state; + irqstate_t flags; + + /* Attach and enable, or detach and disable. Enabling and disabling GPIO + * interrupts is a multi-step process so the safest thing is to keep + * interrupts disabled during the reconfiguratino. + */ + + flags = irqsave(); + if (enable) + { + /* Configure the EXTI interrupt using the SAVED handler */ + + (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, true, true, true, priv->handler); + } + else + { + /* Configure the EXTI interrupt with a NULL handler to disable it */ + + (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL); + } + irqrestore(flags); +} + +static void stmpe811_clear(FAR struct stmpe811_config_s *state) +{ + /* Does nothing */ +} + +/**************************************************************************** + * 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) +{ +#ifndef CONFIG_STMPE811_TSC_DISABLE + FAR struct i2c_dev_s *dev; + int ret; + + idbg("minor %d\n", minor); + DEBUGASSERT(minor == 0); + + /* Check if we are already initialized */ + + if (!g_stmpe811config.handle) + { + ivdbg("Initializing\n"); + + /* Configure the STMPE811 interrupt pin as an input */ + + (void)stm32_configgpio(GPIO_IO_EXPANDER); + + /* Get an instance of the I2C interface */ + + dev = up_i2cinitialize(CONFIG_STMPE811_I2CDEV); + if (!dev) + { + idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE811_I2CDEV); + return -ENODEV; + } + + /* Instantiate the STMPE811 driver */ + + g_stmpe811config.handle = + stmpe811_instantiate(dev, (FAR struct stmpe811_config_s *)&g_stmpe811config); + if (!g_stmpe811config.handle) + { + idbg("Failed to instantiate the STMPE811 driver\n"); + return -ENODEV; + } + + /* Initialize and register the I2C touchscreen device */ + + ret = stmpe811_register(g_stmpe811config.handle, CONFIG_STMPE811_DEVMINOR); + if (ret < 0) + { + idbg("Failed to register STMPE driver: %d\n", ret); + /* up_i2cuninitialize(dev); */ + return -ENODEV; + } + } + + return OK; +#else + return -ENOSYS; +#endif +} + +/**************************************************************************** + * 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 STMPE811 device yet */ +} + +#endif /* CONFIG_INPUT_STMPE811 */ + diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt index 64d5608f3..acf94fadc 100755 --- a/nuttx/configs/stm3240g-eval/README.txt +++ b/nuttx/configs/stm3240g-eval/README.txt @@ -500,10 +500,10 @@ There are 4 possible SRAM configurations: I/O Expanders ============= -The STM3240G-EVAL has two STMPE11QTR I/O expanders on board both connected to +The STM3240G-EVAL has two STMPE811QTR I/O expanders on board both connected to the STM32 via I2C1. They share a common interrupt line: PI2. -STMPE11 U24, I2C address 0x41 (7-bit) +STMPE811 U24, I2C address 0x41 (7-bit) ------ ---- ---------------- -------------------------------------------- STPE11 PIN BOARD SIGNAL BOARD CONNECTION ------ ---- ---------------- -------------------------------------------- @@ -516,7 +516,7 @@ STPE11 PIN BOARD SIGNAL BOARD CONNECTION IN1 EXP_IO11 IN0 EXP_IO12 -STMPE11 U29, I2C address 0x44 (7-bit) +STMPE811 U29, I2C address 0x44 (7-bit) ------ ---- ---------------- -------------------------------------------- STPE11 PIN BOARD SIGNAL BOARD CONNECTION ------ ---- ---------------- -------------------------------------------- diff --git a/nuttx/configs/stm3240g-eval/nsh/appconfig b/nuttx/configs/stm3240g-eval/nsh/appconfig index f126b0d80..fdef72ccd 100644 --- a/nuttx/configs/stm3240g-eval/nsh/appconfig +++ b/nuttx/configs/stm3240g-eval/nsh/appconfig @@ -80,7 +80,7 @@ ifeq ($(CONFIG_WATCHDOG),y) CONFIGURED_APPS += examples/watchdog endif -ifeq ($(CONFIG_INPUT_STMPE11),y) +ifeq ($(CONFIG_INPUT_STMPE811),y) CONFIGURED_APPS += examples/touchscreen endif diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 26b29a51d..a3e31622b 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -954,66 +954,66 @@ CONFIG_INPUT=n CONFIG_INPUT_TSC2007=n # -# STMPE11 input device configuration +# STMPE811 input device configuration # # Prerequisites: CONFIG_INPUT=y # Other settings that effect the driver: CONFIG_DISABLE_POLL # -# CONFIG_INPUT_STMPE11 -# Enables support for the STMPE11 driver (Needs CONFIG_INPUT) -# CONFIG_STMPE11_SPI +# CONFIG_INPUT_STMPE811 +# Enables support for the STMPE811 driver (Needs CONFIG_INPUT) +# CONFIG_STMPE811_SPI # Enables support for the SPI interface (not currenly supported) -# CONFIG_STMPE11_I2C +# CONFIG_STMPE811_I2C # Enables support for the I2C interface -# CONFIG_STMPE11_MULTIPLE -# Can be defined to support multiple STMPE11 devices on board. -# CONFIG_STMPE11_ACTIVELOW +# CONFIG_STMPE811_MULTIPLE +# Can be defined to support multiple STMPE811 devices on board. +# CONFIG_STMPE811_ACTIVELOW # Interrupt is generated by an active low signal (or falling edge). -# CONFIG_STMPE11_EDGE +# CONFIG_STMPE811_EDGE # Interrupt is generated on an edge (vs. on the active level) -# CONFIG_STMPE11_NPOLLWAITERS +# CONFIG_STMPE811_NPOLLWAITERS # Maximum number of threads that can be waiting on poll() (ignored if # CONFIG_DISABLE_POLL is set). -# CONFIG_STMPE11_TSC_DISABLE +# CONFIG_STMPE811_TSC_DISABLE # Disable driver touchscreen functionality. -# CONFIG_STMPE11_ADC_DISABLE +# CONFIG_STMPE811_ADC_DISABLE # Disable driver ADC functionality. -# CONFIG_STMPE11_GPIO_DISABLE +# CONFIG_STMPE811_GPIO_DISABLE # Disable driver GPIO functionality. -# CONFIG_STMPE11_GPIOINT_DISABLE +# CONFIG_STMPE811_GPIOINT_DISABLE # Disable driver GPIO interrupt functionality (ignored if GPIO functionality is # disabled). -# CONFIG_STMPE11_SWAPXY +# CONFIG_STMPE811_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 +# CONFIG_STMPE811_TEMP_DISABLE # Disable driver temperature sensor functionality. -# CONFIG_STMPE11_REGDBUG +# CONFIG_STMPE811_REGDBUG # Enabled very low register-level debug output. Requires CONFIG_DEBUG. -# CONFIG_STMPE11_THRESHX and CONFIG_STMPE11_THRESHY -# STMPE11 touchscreen data comes in a a very high rate. New touch positions +# CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY +# STMPE811 touchscreen data comes in a a very high rate. New touch positions # will only be reported when the X or Y data changes by these thresholds. # This trades reduces data rate for some loss in dragging accuracy. The -# STMPE11 is configure for 12-bit values so the raw ranges are 0-4095. So +# STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So # for example, if your display is 320x240, then THRESHX=13 and THRESHY=17 # would correspond to one pixel. Default: 12 # -CONFIG_INPUT_STMPE11=n -CONFIG_STMPE11_SPI=n -CONFIG_STMPE11_I2C=y -CONFIG_STMPE11_MULTIPLE=y -CONFIG_STMPE11_ACTIVELOW=y -CONFIG_STMPE11_EDGE=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 -CONFIG_STMPE11_THRESHX=26 -CONFIG_STMPE11_THRESHY=34 +CONFIG_INPUT_STMPE811=n +CONFIG_STMPE811_SPI=n +CONFIG_STMPE811_I2C=y +CONFIG_STMPE811_MULTIPLE=y +CONFIG_STMPE811_ACTIVELOW=y +CONFIG_STMPE811_EDGE=y +#CONFIG_STMPE811_NPOLLWAITERS +CONFIG_STMPE811_TSC_DISABLE=n +CONFIG_STMPE811_ADC_DISABLE=y +CONFIG_STMPE811_GPIO_DISABLE=y +CONFIG_STMPE811_GPIOINT_DISABLE=y +CONFIG_STMPE811_SWAPXY=y +CONFIG_STMPE811_TEMP_DISABLE=y +CONFIG_STMPE811_REGDEBUG=n +CONFIG_STMPE811_THRESHX=26 +CONFIG_STMPE811_THRESHY=34 # # USB Device Configuration diff --git a/nuttx/configs/stm3240g-eval/nxwm/defconfig b/nuttx/configs/stm3240g-eval/nxwm/defconfig index c449042e6..38739b35b 100644 --- a/nuttx/configs/stm3240g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3240g-eval/nxwm/defconfig @@ -956,66 +956,66 @@ CONFIG_INPUT=y CONFIG_INPUT_TSC2007=n # -# STMPE11 input device configuration +# STMPE811 input device configuration # # Prerequisites: CONFIG_INPUT=y # Other settings that effect the driver: CONFIG_DISABLE_POLL # -# CONFIG_INPUT_STMPE11 -# Enables support for the STMPE11 driver (Needs CONFIG_INPUT) -# CONFIG_STMPE11_SPI +# CONFIG_INPUT_STMPE811 +# Enables support for the STMPE811 driver (Needs CONFIG_INPUT) +# CONFIG_STMPE811_SPI # Enables support for the SPI interface (not currenly supported) -# CONFIG_STMPE11_I2C +# CONFIG_STMPE811_I2C # Enables support for the I2C interface -# CONFIG_STMPE11_MULTIPLE -# Can be defined to support multiple STMPE11 devices on board. -# CONFIG_STMPE11_ACTIVELOW +# CONFIG_STMPE811_MULTIPLE +# Can be defined to support multiple STMPE811 devices on board. +# CONFIG_STMPE811_ACTIVELOW # Interrupt is generated by an active low signal (or falling edge). -# CONFIG_STMPE11_EDGE +# CONFIG_STMPE811_EDGE # Interrupt is generated on an edge (vs. on the active level) -# CONFIG_STMPE11_NPOLLWAITERS +# CONFIG_STMPE811_NPOLLWAITERS # Maximum number of threads that can be waiting on poll() (ignored if # CONFIG_DISABLE_POLL is set). -# CONFIG_STMPE11_TSC_DISABLE +# CONFIG_STMPE811_TSC_DISABLE # Disable driver touchscreen functionality. -# CONFIG_STMPE11_ADC_DISABLE +# CONFIG_STMPE811_ADC_DISABLE # Disable driver ADC functionality. -# CONFIG_STMPE11_GPIO_DISABLE +# CONFIG_STMPE811_GPIO_DISABLE # Disable driver GPIO functionality. -# CONFIG_STMPE11_GPIOINT_DISABLE +# CONFIG_STMPE811_GPIOINT_DISABLE # Disable driver GPIO interrupt functionality (ignored if GPIO functionality is # disabled). -# CONFIG_STMPE11_SWAPXY +# CONFIG_STMPE811_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 +# CONFIG_STMPE811_TEMP_DISABLE # Disable driver temperature sensor functionality. -# CONFIG_STMPE11_REGDBUG +# CONFIG_STMPE811_REGDBUG # Enabled very low register-level debug output. Requires CONFIG_DEBUG. -# CONFIG_STMPE11_THRESHX and CONFIG_STMPE11_THRESHY -# STMPE11 touchscreen data comes in a a very high rate. New touch positions +# CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY +# STMPE811 touchscreen data comes in a a very high rate. New touch positions # will only be reported when the X or Y data changes by these thresholds. # This trades reduces data rate for some loss in dragging accuracy. The -# STMPE11 is configure for 12-bit values so the raw ranges are 0-4095. So +# STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So # for example, if your display is 320x240, then THRESHX=13 and THRESHY=17 # would correspond to one pixel. Default: 12 # -CONFIG_INPUT_STMPE11=y -CONFIG_STMPE11_SPI=n -CONFIG_STMPE11_I2C=y -CONFIG_STMPE11_MULTIPLE=y -CONFIG_STMPE11_ACTIVELOW=y -CONFIG_STMPE11_EDGE=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 -CONFIG_STMPE11_THRESHX=39 -CONFIG_STMPE11_THRESHY=51 +CONFIG_INPUT_STMPE811=y +CONFIG_STMPE811_SPI=n +CONFIG_STMPE811_I2C=y +CONFIG_STMPE811_MULTIPLE=y +CONFIG_STMPE811_ACTIVELOW=y +CONFIG_STMPE811_EDGE=y +#CONFIG_STMPE811_NPOLLWAITERS +CONFIG_STMPE811_TSC_DISABLE=n +CONFIG_STMPE811_ADC_DISABLE=y +CONFIG_STMPE811_GPIO_DISABLE=y +CONFIG_STMPE811_GPIOINT_DISABLE=y +CONFIG_STMPE811_SWAPXY=n +CONFIG_STMPE811_TEMP_DISABLE=y +CONFIG_STMPE811_REGDEBUG=n +CONFIG_STMPE811_THRESHX=39 +CONFIG_STMPE811_THRESHY=51 # # USB Device Configuration diff --git a/nuttx/configs/stm3240g-eval/src/Makefile b/nuttx/configs/stm3240g-eval/src/Makefile index 548c1c8c0..0e901a4d1 100644 --- a/nuttx/configs/stm3240g-eval/src/Makefile +++ b/nuttx/configs/stm3240g-eval/src/Makefile @@ -88,8 +88,8 @@ ifeq ($(CONFIG_WATCHDOG),y) CSRCS += up_watchdog.c endif -ifeq ($(CONFIG_INPUT_STMPE11),y) -CSRCS += up_stmpe11.c +ifeq ($(CONFIG_INPUT_STMPE811),y) +CSRCS += up_stmpe811.c endif COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h b/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h index 3dfd79912..c71aee75f 100644 --- a/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h +++ b/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h @@ -138,10 +138,10 @@ #define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN5) #define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN11) -/* The STM3240G-EVAL has two STMPE11QTR I/O expanders on board both connected +/* The STM3240G-EVAL has two STMPE811QTR I/O expanders on board both connected * to the STM32 via I2C1. They share a common interrupt line: PI2. * - * STMPE11 U24, I2C address 0x41 (7-bit) + * STMPE811 U24, I2C address 0x41 (7-bit) * ------ ---- ---------------- -------------------------------------------- * STPE11 PIN BOARD SIGNAL BOARD CONNECTION * ------ ---- ---------------- -------------------------------------------- @@ -154,7 +154,7 @@ * IN1 EXP_IO11 * IN0 EXP_IO12 * - * STMPE11 U29, I2C address 0x44 (7-bit) + * STMPE811 U29, I2C address 0x44 (7-bit) * ------ ---- ---------------- -------------------------------------------- * STPE11 PIN BOARD SIGNAL BOARD CONNECTION * ------ ---- ---------------- -------------------------------------------- @@ -168,8 +168,8 @@ * IN0 EXP_IO8 */ -#define STMPE11_ADDR1 0x41 -#define STMPE11_ADDR2 0x44 +#define STMPE811_ADDR1 0x41 +#define STMPE811_ADDR2 0x44 #define GPIO_IO_EXPANDER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTI|GPIO_PIN2) diff --git a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c deleted file mode 100644 index 72482c92c..000000000 --- a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c +++ /dev/null @@ -1,353 +0,0 @@ -/************************************************************************************ - * configs/stm3240g-eval/src/up_touchscreen.c - * arch/arm/src/board/up_touchscreen.c - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "stm32_internal.h" -#include "stm3240g-internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifdef CONFIG_INPUT_STMPE11 -#ifndef CONFIG_INPUT -# error "STMPE11 support requires CONFIG_INPUT" -#endif - -#ifndef CONFIG_STM32_I2C1 -# error "STMPE11 support requires CONFIG_STM32_I2C1" -#endif - -#ifndef CONFIG_STMPE11_I2C -# error "Only the STMPE11 I2C interface is supported" -#endif - -#ifdef CONFIG_STMPE11_SPI -# error "Only the STMPE11 SPI interface is supported" -#endif - -#ifndef CONFIG_STMPE11_FREQUENCY -# define CONFIG_STMPE11_FREQUENCY 100000 -#endif - -#ifndef CONFIG_STMPE11_I2CDEV -# define CONFIG_STMPE11_I2CDEV 1 -#endif - -#if CONFIG_STMPE11_I2CDEV != 1 -# error "CONFIG_STMPE11_I2CDEV must be one" -#endif - -#ifndef CONFIG_STMPE11_DEVMINOR -# define CONFIG_STMPE11_DEVMINOR 0 -#endif - -/* Board definitions ********************************************************/ -/* The STM3240G-EVAL has two STMPE11QTR I/O expanders on board both connected - * to the STM32 via I2C1. They share a common interrupt line: PI2. - * - * STMPE11 U24, I2C address 0x41 (7-bit) - * ------ ---- ---------------- -------------------------------------------- - * STPE11 PIN BOARD SIGNAL BOARD CONNECTION - * ------ ---- ---------------- -------------------------------------------- - * Y- TouchScreen_Y- LCD Connector XL - * X- TouchScreen_X- LCD Connector XR - * Y+ TouchScreen_Y+ LCD Connector XD - * X+ TouchScreen_X+ LCD Connector XU - * IN3 EXP_IO9 - * IN2 EXP_IO10 - * IN1 EXP_IO11 - * IN0 EXP_IO12 - * - * STMPE11 U29, I2C address 0x44 (7-bit) - * ------ ---- ---------------- -------------------------------------------- - * STPE11 PIN BOARD SIGNAL BOARD CONNECTION - * ------ ---- ---------------- -------------------------------------------- - * Y- EXP_IO1 - * X- EXP_IO2 - * Y+ EXP_IO3 - * X+ EXP_IO4 - * IN3 EXP_IO5 - * IN2 EXP_IO6 - * IN1 EXP_IO7 - * IN0 EXP_IO8 - */ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct stm32_stmpe11config_s -{ - /* Configuration structure as seen by the STMPE11 driver */ - - struct stmpe11_config_s config; - - /* Additional private definitions only known to this driver */ - - STMPE11_HANDLE handle; /* The STMPE11 driver handle */ - xcpt_t handler; /* The STMPE11 interrupt handler */ -}; - -/**************************************************************************** - * Static Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the STMPE11 driver from differences in GPIO - * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. - * - * attach - Attach the STMPE11 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - */ - -static int stmpe11_attach(FAR struct stmpe11_config_s *state, xcpt_t isr); -static void stmpe11_enable(FAR struct stmpe11_config_s *state, bool enable); -static void stmpe11_clear(FAR struct stmpe11_config_s *state); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the STMPE11 - * driver. This structure provides information about the configuration - * of the STMPE11 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. The - * memory must be writable because, under certain circumstances, the driver - * may modify frequency or X plate resistance values. - */ - -#ifndef CONFIG_STMPE11_TSC_DISABLE -static struct stm32_stmpe11config_s g_stmpe11config = -{ - .config = - { -#ifdef CONFIG_STMPE11_I2C - .address = STMPE11_ADDR1, -#endif - .frequency = CONFIG_STMPE11_FREQUENCY, - -#ifdef CONFIG_STMPE11_MULTIPLE - .irq = STM32_IRQ_EXTI2, -#endif - .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B), - .ctrl2 = ADC_CTRL2_ADC_FREQ_3p25, - - .attach = stmpe11_attach, - .enable = stmpe11_enable, - .clear = stmpe11_clear, - }, - .handler = NULL, -}; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the STMPE11 driver from differences in GPIO - * interrupt handling by varying boards and MCUs. - * - * attach - Attach the STMPE11 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - */ - -static int stmpe11_attach(FAR struct stmpe11_config_s *state, xcpt_t isr) -{ - FAR struct stm32_stmpe11config_s *priv = (FAR struct stm32_stmpe11config_s *)state; - - ivdbg("Saving handler %p\n", isr); - DEBUGASSERT(priv); - - /* Just save the handler. We will use it when EXTI interruptsare enabled */ - - priv->handler = isr; - return OK; -} - -static void stmpe11_enable(FAR struct stmpe11_config_s *state, bool enable) -{ - FAR struct stm32_stmpe11config_s *priv = (FAR struct stm32_stmpe11config_s *)state; - irqstate_t flags; - - /* Attach and enable, or detach and disable. Enabling and disabling GPIO - * interrupts is a multi-step process so the safest thing is to keep - * interrupts disabled during the reconfiguratino. - */ - - flags = irqsave(); - if (enable) - { - /* Configure the EXTI interrupt using the SAVED handler */ - - (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, true, true, true, priv->handler); - } - else - { - /* Configure the EXTI interrupt with a NULL handler to disable it */ - - (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL); - } - irqrestore(flags); -} - -static void stmpe11_clear(FAR struct stmpe11_config_s *state) -{ - /* Does nothing */ -} - -/**************************************************************************** - * 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) -{ -#ifndef CONFIG_STMPE11_TSC_DISABLE - FAR struct i2c_dev_s *dev; - int ret; - - idbg("minor %d\n", minor); - DEBUGASSERT(minor == 0); - - /* Check if we are already initialized */ - - if (!g_stmpe11config.handle) - { - ivdbg("Initializing\n"); - - /* Configure 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; - } - - /* 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; -#else - return -ENOSYS; -#endif -} - -/**************************************************************************** - * 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 STMPE11 device yet */ -} - -#endif /* CONFIG_INPUT_STMPE11 */ - diff --git a/nuttx/configs/stm3240g-eval/src/up_stmpe811.c b/nuttx/configs/stm3240g-eval/src/up_stmpe811.c new file mode 100644 index 000000000..a64d62825 --- /dev/null +++ b/nuttx/configs/stm3240g-eval/src/up_stmpe811.c @@ -0,0 +1,353 @@ +/************************************************************************************ + * configs/stm3240g-eval/src/up_touchscreen.c + * arch/arm/src/board/up_touchscreen.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "stm32_internal.h" +#include "stm3240g-internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +#ifndef CONFIG_INPUT +# error "STMPE811 support requires CONFIG_INPUT" +#endif + +#ifndef CONFIG_STM32_I2C1 +# error "STMPE811 support requires CONFIG_STM32_I2C1" +#endif + +#ifndef CONFIG_STMPE811_I2C +# error "Only the STMPE811 I2C interface is supported" +#endif + +#ifdef CONFIG_STMPE811_SPI +# error "Only the STMPE811 SPI interface is supported" +#endif + +#ifndef CONFIG_STMPE811_FREQUENCY +# define CONFIG_STMPE811_FREQUENCY 100000 +#endif + +#ifndef CONFIG_STMPE811_I2CDEV +# define CONFIG_STMPE811_I2CDEV 1 +#endif + +#if CONFIG_STMPE811_I2CDEV != 1 +# error "CONFIG_STMPE811_I2CDEV must be one" +#endif + +#ifndef CONFIG_STMPE811_DEVMINOR +# define CONFIG_STMPE811_DEVMINOR 0 +#endif + +/* Board definitions ********************************************************/ +/* The STM3240G-EVAL has two STMPE811QTR I/O expanders on board both connected + * to the STM32 via I2C1. They share a common interrupt line: PI2. + * + * STMPE811 U24, I2C address 0x41 (7-bit) + * ------ ---- ---------------- -------------------------------------------- + * STPE11 PIN BOARD SIGNAL BOARD CONNECTION + * ------ ---- ---------------- -------------------------------------------- + * Y- TouchScreen_Y- LCD Connector XL + * X- TouchScreen_X- LCD Connector XR + * Y+ TouchScreen_Y+ LCD Connector XD + * X+ TouchScreen_X+ LCD Connector XU + * IN3 EXP_IO9 + * IN2 EXP_IO10 + * IN1 EXP_IO11 + * IN0 EXP_IO12 + * + * STMPE811 U29, I2C address 0x44 (7-bit) + * ------ ---- ---------------- -------------------------------------------- + * STPE11 PIN BOARD SIGNAL BOARD CONNECTION + * ------ ---- ---------------- -------------------------------------------- + * Y- EXP_IO1 + * X- EXP_IO2 + * Y+ EXP_IO3 + * X+ EXP_IO4 + * IN3 EXP_IO5 + * IN2 EXP_IO6 + * IN1 EXP_IO7 + * IN0 EXP_IO8 + */ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct stm32_stmpe811config_s +{ + /* Configuration structure as seen by the STMPE811 driver */ + + struct stmpe811_config_s config; + + /* Additional private definitions only known to this driver */ + + STMPE811_HANDLE handle; /* The STMPE811 driver handle */ + xcpt_t handler; /* The STMPE811 interrupt handler */ +}; + +/**************************************************************************** + * Static Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks + * to isolate the STMPE811 driver from differences in GPIO + * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. + * + * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + */ + +static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr); +static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable); +static void stmpe811_clear(FAR struct stmpe811_config_s *state); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the STMPE811 + * driver. This structure provides information about the configuration + * of the STMPE811 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. The + * memory must be writable because, under certain circumstances, the driver + * may modify frequency or X plate resistance values. + */ + +#ifndef CONFIG_STMPE811_TSC_DISABLE +static struct stm32_stmpe811config_s g_stmpe811config = +{ + .config = + { +#ifdef CONFIG_STMPE811_I2C + .address = STMPE811_ADDR1, +#endif + .frequency = CONFIG_STMPE811_FREQUENCY, + +#ifdef CONFIG_STMPE811_MULTIPLE + .irq = STM32_IRQ_EXTI2, +#endif + .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B), + .ctrl2 = ADC_CTRL2_ADC_FREQ_3p25, + + .attach = stmpe811_attach, + .enable = stmpe811_enable, + .clear = stmpe811_clear, + }, + .handler = NULL, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the STMPE811 driver from differences in GPIO + * interrupt handling by varying boards and MCUs. + * + * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt + */ + +static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr) +{ + FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state; + + ivdbg("Saving handler %p\n", isr); + DEBUGASSERT(priv); + + /* Just save the handler. We will use it when EXTI interruptsare enabled */ + + priv->handler = isr; + return OK; +} + +static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable) +{ + FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state; + irqstate_t flags; + + /* Attach and enable, or detach and disable. Enabling and disabling GPIO + * interrupts is a multi-step process so the safest thing is to keep + * interrupts disabled during the reconfiguratino. + */ + + flags = irqsave(); + if (enable) + { + /* Configure the EXTI interrupt using the SAVED handler */ + + (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, true, true, true, priv->handler); + } + else + { + /* Configure the EXTI interrupt with a NULL handler to disable it */ + + (void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL); + } + irqrestore(flags); +} + +static void stmpe811_clear(FAR struct stmpe811_config_s *state) +{ + /* Does nothing */ +} + +/**************************************************************************** + * 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) +{ +#ifndef CONFIG_STMPE811_TSC_DISABLE + FAR struct i2c_dev_s *dev; + int ret; + + idbg("minor %d\n", minor); + DEBUGASSERT(minor == 0); + + /* Check if we are already initialized */ + + if (!g_stmpe811config.handle) + { + ivdbg("Initializing\n"); + + /* Configure the STMPE811 interrupt pin as an input */ + + (void)stm32_configgpio(GPIO_IO_EXPANDER); + + /* Get an instance of the I2C interface */ + + dev = up_i2cinitialize(CONFIG_STMPE811_I2CDEV); + if (!dev) + { + idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE811_I2CDEV); + return -ENODEV; + } + + /* Instantiate the STMPE811 driver */ + + g_stmpe811config.handle = + stmpe811_instantiate(dev, (FAR struct stmpe811_config_s *)&g_stmpe811config); + if (!g_stmpe811config.handle) + { + idbg("Failed to instantiate the STMPE811 driver\n"); + return -ENODEV; + } + + /* Initialize and register the I2C touchscreen device */ + + ret = stmpe811_register(g_stmpe811config.handle, CONFIG_STMPE811_DEVMINOR); + if (ret < 0) + { + idbg("Failed to register STMPE driver: %d\n", ret); + /* up_i2cuninitialize(dev); */ + return -ENODEV; + } + } + + return OK; +#else + return -ENOSYS; +#endif +} + +/**************************************************************************** + * 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 STMPE811 device yet */ +} + +#endif /* CONFIG_INPUT_STMPE811 */ + -- cgit v1.2.3