From eeb40dc600f57c21882ca85bfe6fdbec78a170e7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Feb 2018 11:18:35 -0600 Subject: [PATCH] drivers/lcd: Extend FT80x touchscreen initialization; add more touchscreen-related definitions. --- .../viewtool-stm32f107/src/stm32_ads7843e.c | 8 ++++++-- configs/viewtool-stm32f107/src/stm32_ft80x.c | 8 ++++---- drivers/lcd/ft80x.c | 19 ++++++++++++++----- include/nuttx/lcd/ft80x.h | 14 +++++++++++++- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/configs/viewtool-stm32f107/src/stm32_ads7843e.c b/configs/viewtool-stm32f107/src/stm32_ads7843e.c index 448f1ca6b3..e5e85a402b 100644 --- a/configs/viewtool-stm32f107/src/stm32_ads7843e.c +++ b/configs/viewtool-stm32f107/src/stm32_ads7843e.c @@ -199,14 +199,18 @@ static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable) flags = enter_critical_section(); if (enable && priv->handler) { - /* Configure the EXTI interrupt using the SAVED handler */ + /* Configure the EXTI interrupt using the saved handler */ (void)stm32_gpiosetevent(GPIO_LCDTP_IRQ, true, true, true, priv->handler, NULL); } else { - /* Configure the EXTI interrupt with a NULL handler to disable it */ + /* Configure the EXTI interrupt with a NULL handler to disable it. + * + * REVISIT: There is a problem here... interrupts received while + * the EXTI is de-configured will not pend but will be lost. + */ (void)stm32_gpiosetevent(GPIO_LCDTP_IRQ, false, false, false, NULL, NULL); diff --git a/configs/viewtool-stm32f107/src/stm32_ft80x.c b/configs/viewtool-stm32f107/src/stm32_ft80x.c index f684a13232..61691e5b2b 100644 --- a/configs/viewtool-stm32f107/src/stm32_ft80x.c +++ b/configs/viewtool-stm32f107/src/stm32_ft80x.c @@ -202,9 +202,9 @@ static void ft80x_enable(FAR const struct ft80x_config_s *lower, flags = enter_critical_section(); if (enable && priv->handler) { - /* Configure the EXTI interrupt using the SAVED handler */ + /* Configure the EXTI interrupt using the saved handler */ - (void)stm32_gpiosetevent(GPIO_LCDTP_IRQ, true, true, true, + (void)stm32_gpiosetevent(GPIO_FT80X_INT, true, true, true, priv->handler, priv->arg); } else @@ -212,10 +212,10 @@ static void ft80x_enable(FAR const struct ft80x_config_s *lower, /* Configure the EXTI interrupt with a NULL handler to disable it. * * REVISIT: There is a problem here... interrupts received while - * the EXIT is de-configured will not pend but will be lost. + * the EXTI is de-configured will not pend but will be lost. */ - (void)stm32_gpiosetevent(GPIO_LCDTP_IRQ, false, false, false, + (void)stm32_gpiosetevent(GPIO_FT80X_INT, false, false, false, NULL, NULL); } diff --git a/drivers/lcd/ft80x.c b/drivers/lcd/ft80x.c index 25f759f948..46ff000a3a 100644 --- a/drivers/lcd/ft80x.c +++ b/drivers/lcd/ft80x.c @@ -1388,19 +1388,28 @@ static int ft80x_initialize(FAR struct ft80x_dev_s *priv) DEBUGASSERT(priv->lower->op_frequency <= 30000000); priv->frequency = priv->lower->op_frequency; - /* Configure touch threshold. - * REVISIT: For FT800 set REG_TOUCH_RZTHRESH to 1200. - */ + /* Configure touch mode. Using default touch mode of FRAME_SYNC (~60Hz) */ + + ft80x_write_byte(priv, FT80X_REG_TOUCH_MODE, TOUCH_MODE_FRAMESYNC); #if defined(CONFIG_LCD_FT800) - /* Configure the REG_TOUCH_RZTHRESH the value 1200 may need to be tweaked + /* Configure the touch threshold. The value 1200 may need to be tweaked * for your application. */ ft80x_write_hword(priv, FT80X_REG_TOUCH_RZTHRESH, 1200); #elif defined(CONFIG_LCD_FT801) -# warning Missing logic +#ifdef CONFIG_LCD_FT801_MULTITOUCH + /* Selected extended mode */ + + ft80x_write_byte(priv, FT80X_REG_CTOUCH_EXTENDED, 0); +#else + /* Selected compatibility mode */ + + ft80x_write_byte(priv, FT80X_REG_CTOUCH_EXTENDED, 1); +#endif + #else # error No FT80x device configured #endif diff --git a/include/nuttx/lcd/ft80x.h b/include/nuttx/lcd/ft80x.h index 604d646e2e..db8ef5f69c 100644 --- a/include/nuttx/lcd/ft80x.h +++ b/include/nuttx/lcd/ft80x.h @@ -349,7 +349,7 @@ /* 0x1024d0 – 0x1024d4 Reserved */ # define FT80X_REG_CTOUCH_EXTENDED 0x1024f4 /* Set capacitive touch operation mode: * 0: extended mode (multi-touch) - * 0: 1: FT800 compatibility mode (single touch) */ + * 1: FT800 compatibility mode (single touch) */ # define FT80X_REG_CTOUCH_REG 0x1024f8 /* CTPM configure register write * Bits [7:0]: configure register address * Bits [15:8]: configure register value */ @@ -415,6 +415,18 @@ #define TOUCH_TAG_MASK 0xff /* Bits 0-7: Tag of touched graphic object */ +/* FT80X_REG_TOUCH_MODE */ + +#define TOUCH_MODE_OFF 0 /* Acquisition stopped, touch detection + * interrupt is still valid. */ +#define TOUCH_MODE_ONESHOT 1 /* Perform acquisition once every write of 1 + * to REG_TOUCH_MODE. */ +#define TOUCH_MODE_FRAMESYNC 2 /* Perform acquisition for every frame sync + * (~60 data acquisition/second). */ +#define TOUCH_MODE_CONTINUOUS 3 /* Perform acquisition continuously at + * approximately 1000 data acquisition / + * second. */ + /* Interrupts *******************************************************************************/ /* The interrupt output pin is enabled by REG_INT_EN. When REG_INT_EN is 0, INT_N is * tri-state (pulled to high by external pull-up resistor). When REG_INT_EN is 1, INT_N is