summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NxWidgets/nxwm/images/play.pngbin550 -> 233 bytes
-rw-r--r--NxWidgets/nxwm/src/ccalibration.cxx4
-rw-r--r--NxWidgets/nxwm/src/ctouchscreen.cxx4
-rw-r--r--NxWidgets/nxwm/src/glyph_play.cxx107
-rw-r--r--nuttx/ChangeLog6
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html6
-rw-r--r--nuttx/configs/README.txt4
-rw-r--r--nuttx/configs/stm3240g-eval/nsh/defconfig5
-rw-r--r--nuttx/configs/stm3240g-eval/nxwm/defconfig5
-rw-r--r--nuttx/configs/stm3240g-eval/src/up_stmpe11.c11
-rw-r--r--nuttx/drivers/input/stmpe11.h2
-rw-r--r--nuttx/drivers/input/stmpe11_base.c6
-rw-r--r--nuttx/drivers/input/stmpe11_tsc.c113
13 files changed, 155 insertions, 118 deletions
diff --git a/NxWidgets/nxwm/images/play.png b/NxWidgets/nxwm/images/play.png
index ab7c29249..02ff75414 100644
--- a/NxWidgets/nxwm/images/play.png
+++ b/NxWidgets/nxwm/images/play.png
Binary files differ
diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx
index 82c12ebb3..9ba0c0917 100644
--- a/NxWidgets/nxwm/src/ccalibration.cxx
+++ b/NxWidgets/nxwm/src/ccalibration.cxx
@@ -223,8 +223,12 @@ bool CCalibration::waitCalibrationData(struct SCalibrationData &data)
while (m_state != CALIB_COMPLETE)
{
+#ifdef CONFIG_DEBUG
int ret = sem_wait(&m_waitSem);
DEBUGASSERT(ret == 0 || errno == EINTR);
+#else
+ (void)sem_wait(&m_waitSem);
+#endif
}
// Recover the window instance contained in the full screen window
diff --git a/NxWidgets/nxwm/src/ctouchscreen.cxx b/NxWidgets/nxwm/src/ctouchscreen.cxx
index 737c7d9e3..f5e476cce 100644
--- a/NxWidgets/nxwm/src/ctouchscreen.cxx
+++ b/NxWidgets/nxwm/src/ctouchscreen.cxx
@@ -295,19 +295,19 @@ FAR void *CTouchscreen::listener(FAR void *arg)
DEBUGASSERT(sample);
ssize_t nbytes = read(This->m_touchFd, sample,
sizeof(struct touch_sample_s));
- vdbg("Received nbytes=%d\n", nbytes);
// Check for errors
if (nbytes < 0)
{
// The only expect error is to be interrupt by a signal
-
+#ifdef CONFIG_DEBUG
int errval = errno;
dbg("read %s failed: %d\n",
CONFIG_NXWM_TOUCHSCREEN_DEVPATH, errval);
DEBUGASSERT(errval == EINTR);
+#endif
}
// On a truly success read, the size of the returned data will
diff --git a/NxWidgets/nxwm/src/glyph_play.cxx b/NxWidgets/nxwm/src/glyph_play.cxx
index 1c6ce8cd9..8c16addae 100644
--- a/NxWidgets/nxwm/src/glyph_play.cxx
+++ b/NxWidgets/nxwm/src/glyph_play.cxx
@@ -56,9 +56,9 @@
* Pre-Processor Definitions
********************************************************************************************/
-#define BITMAP_NROWS 25
-#define BITMAP_NCOLUMNS 25
-#define BITMAP_NLUTCODES 6
+#define BITMAP_NROWS 24
+#define BITMAP_NCOLUMNS 24
+#define BITMAP_NLUTCODES 5
#define DARK_PLAY_ICON 1
@@ -76,13 +76,13 @@ using namespace NxWM;
static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x00a200, 0x006300, 0x004e00, 0x008100, 0x003600 /* Codes 1-5 */
+ 0x00bd00, 0x008100, 0x006300, 0x003600 /* Codes 1-4 */
};
static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x00d800, 0x008400, 0x006800, 0x00ac00, 0x004800, /* Codes 1-5 */
+ 0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
};
# else /* DARK_PLAY_ICON */
@@ -90,13 +90,13 @@ static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x00d800, 0x008400, 0x006800, 0x00ac00, 0x004800, /* Codes 1-5 */
+ 0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
};
static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x3fe13f, 0x3fa23f, 0x3f8d3f, 0x3fc03f, 0x3f753f /* Codes 1-5 */
+ 0x00fc00, 0x00c000, 0x00a200, 0x007500 /* Codes 1-4 */
};
# endif /* DARK_PLAY_ICON */
@@ -108,13 +108,13 @@ static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x0500, 0x0300, 0x0260, 0x0400, 0x01a0 /* Codes 1-5 */
+ 0x05e0, 0x0400, 0x0300, 0x01a0 /* Codes 1-4 */
};
static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x06c0, 0x0420, 0x0340, 0x0560, 0x0240, /* Codes 1-5 */
+ 0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
};
# else /* DARK_PLAY_ICON */
@@ -122,13 +122,13 @@ static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x06c0, 0x0420, 0x0340, 0x0560, 0x0240, /* Codes 0-5 */
+ 0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
};
static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x3f07, 0x3d07, 0x3c67, 0x3e07, 0x3ba7, /* Codes 0-5 */
+ 0x07e0, 0x0600, 0x0500, 0x03a0 /* Codes 1-4 */
};
# endif /* DARK_PLAY_ICON */
@@ -150,13 +150,13 @@ static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x5f, 0x3a, 0x2d, 0x4b, 0x1f /* Codes 1-5 */
+ 0x6e, 0x4b, 0x3a, 0x1f /* Codes 1-4 */
};
static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x7e, 0x4d, 0x3d, 0x64, 0x2a /* Codes 1-5 */
+ 0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
};
# else /* DARK_PLAY_ICON */
@@ -164,13 +164,13 @@ static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x7e, 0x4d, 0x3d, 0x64, 0x2a /* Codes 1-5 */
+ 0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
};
static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x9e, 0x79, 0x6c, 0x8a, 0x5e /* Codes 1-5 */
+ 0x93, 0x70, 0x5f, 0x44 /* Codes 1-4 */
};
# endif /* DARK_PLAY_ICON */
@@ -182,13 +182,13 @@ static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x14, 0x0c, 0x08, 0x10, 0x04 /* Codes 1-5 */
+ 0x14, 0x10, 0x0c, 0x04 /* Codes 1-4 */
};
static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x18, 0x10, 0x0c, 0x14, 0x08 /* Codes 1-5 */
+ 0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
};
# else /* DARK_PLAY_ICON */
@@ -196,13 +196,13 @@ static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x18, 0x10, 0x0c, 0x14, 0x08 /* Codes 0-5 */
+ 0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
};
static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
- 0x3c, 0x34, 0x30, 0x38, 0x2c /* Codes 0-5 */
+ 0x1c, 0x18, 0x14, 0x0c /* Codes 1-4 */
};
# endif /* DARK_PLAY_ICON */
@@ -213,51 +213,30 @@ static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
static const struct NXWidgets::SRlePaletteBitmapEntry g_playRleEntries[] =
{
- { 25, 0}, /* Row 0 */
- { 9, 0}, { 1, 1}, { 1, 2}, { 3, 3}, { 1, 2}, { 1, 1}, { 9, 0}, /* Row 1 */
- { 7, 0}, { 1, 1}, { 1, 3}, { 2, 2}, { 3, 1}, { 1, 4}, { 1, 3}, { 1, 5}, /* Row 2 */
- { 1, 2}, { 7, 0},
- { 6, 0}, { 1, 1}, { 1, 5}, { 1, 2}, { 7, 0}, { 1, 1}, { 1, 5}, { 1, 3}, /* Row 3 */
- { 6, 0},
- { 4, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 4}, { 9, 0}, { 1, 1}, { 1, 2}, /* Row 4 */
- { 1, 5}, { 1, 3}, { 4, 0},
- { 3, 0}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 0}, { 1, 1}, { 10, 0}, /* Row 5 */
- { 1, 4}, { 1, 5}, { 1, 2}, { 3, 0},
- { 3, 0}, { 1, 3}, { 1, 5}, { 3, 0}, { 2, 1}, { 10, 0}, { 2, 3}, { 1, 4}, /* Row 6 */
- { 2, 0},
- { 2, 0}, { 1, 1}, { 1, 5}, { 1, 4}, { 3, 0}, { 1, 1}, { 1, 4}, { 2, 1}, /* Row 7 */
- { 8, 0}, { 1, 1}, { 1, 5}, { 1, 2}, { 2, 0},
- { 2, 0}, { 1, 3}, { 1, 2}, { 4, 0}, { 1, 1}, { 5, 4}, { 7, 0}, { 1, 1}, /* Row 8 */
- { 1, 5}, { 1, 2}, { 1, 0},
- { 1, 0}, { 1, 1}, { 1, 3}, { 1, 4}, { 4, 0}, { 1, 1}, { 7, 4}, { 6, 0}, /* Row 9 */
- { 1, 2}, { 1, 3}, { 1, 0},
- { 1, 1}, { 1, 3}, { 1, 5}, { 5, 0}, { 1, 1}, { 9, 4}, { 4, 0}, { 1, 4}, /* Row 10 */
- { 1, 2}, { 1, 4},
- { 1, 1}, { 1, 3}, { 1, 4}, { 5, 0}, { 1, 1}, { 11, 4}, { 2, 0}, { 1, 4}, /* Row 11 */
- { 1, 2}, { 1, 4},
- { 1, 1}, { 1, 5}, { 1, 1}, { 5, 0}, { 1, 4}, { 9, 2}, { 2, 3}, { 1, 5}, /* Row 12 */
- { 1, 0}, { 1, 4}, { 1, 2}, { 1, 4},
- { 1, 1}, { 1, 3}, { 1, 1}, { 5, 0}, { 1, 4}, { 7, 2}, { 3, 3}, { 1, 5}, /* Row 13 */
- { 2, 0}, { 1, 4}, { 1, 2}, { 1, 4},
- { 1, 1}, { 1, 3}, { 1, 4}, { 5, 0}, { 1, 4}, { 5, 2}, { 3, 3}, { 1, 5}, /* Row 14 */
- { 4, 0}, { 1, 2}, { 1, 3}, { 1, 4},
- { 1, 0}, { 1, 2}, { 1, 3}, { 5, 0}, { 1, 4}, { 3, 2}, { 3, 3}, { 1, 5}, /* Row 15 */
- { 5, 0}, { 1, 1}, { 1, 5}, { 1, 2}, { 1, 0},
- { 2, 0}, { 1, 5}, { 1, 4}, { 4, 0}, { 1, 4}, { 2, 2}, { 2, 3}, { 1, 5}, /* Row 16 */
- { 7, 0}, { 1, 2}, { 1, 5}, { 2, 0},
- { 2, 0}, { 1, 2}, { 1, 5}, { 1, 1}, { 3, 0}, { 1, 4}, { 2, 3}, { 1, 5}, /* Row 17 */
- { 8, 0}, { 1, 1}, { 1, 3}, { 1, 2}, { 2, 0},
- { 3, 0}, { 1, 2}, { 1, 3}, { 3, 0}, { 1, 3}, { 1, 5}, { 9, 0}, { 1, 1}, /* Row 18 */
- { 2, 3}, { 3, 0},
- { 3, 0}, { 1, 1}, { 1, 5}, { 1, 2}, { 2, 0}, { 1, 5}, { 9, 0}, { 1, 1}, /* Row 19 */
- { 1, 4}, { 1, 5}, { 4, 0},
- { 4, 0}, { 1, 1}, { 1, 5}, { 1, 3}, { 10, 0}, { 1, 1}, { 1, 3}, { 1, 5}, /* Row 20 */
- { 5, 0},
- { 6, 0}, { 1, 2}, { 1, 5}, { 1, 4}, { 6, 0}, { 1, 1}, { 1, 2}, { 1, 5}, /* Row 21 */
- { 1, 2}, { 6, 0},
- { 7, 0}, { 1, 3}, { 3, 5}, { 3, 3}, { 2, 5}, { 1, 3}, { 1, 2}, { 7, 0}, /* Row 22 */
- { 9, 0}, { 1, 4}, { 2, 2}, { 1, 3}, { 2, 2}, { 1, 4}, { 9, 0}, /* Row 23 */
- { 25, 0}, /* Row 24 */
+ { 2, 1}, { 22, 0}, /* Row 0 */
+ { 2, 2}, { 2, 1}, { 20, 0}, /* Row 1 */
+ { 4, 2}, { 2, 1}, { 18, 0}, /* Row 2 */
+ { 6, 2}, { 2, 1}, { 16, 0}, /* Row 3 */
+ { 8, 2}, { 2, 1}, { 14, 0}, /* Row 4 */
+ { 10, 2}, { 2, 1}, { 12, 0}, /* Row 5 */
+ { 12, 2}, { 2, 1}, { 10, 0}, /* Row 6 */
+ { 14, 2}, { 2, 1}, { 8, 0}, /* Row 7 */
+ { 16, 2}, { 2, 1}, { 6, 0}, /* Row 8 */
+ { 18, 2}, { 2, 1}, { 4, 0}, /* Row 9 */
+ { 20, 2}, { 2, 1}, { 2, 0}, /* Row 10 */
+ { 22, 2}, { 2, 1}, /* Row 11 */
+ { 22, 3}, { 2, 4}, /* Row 12 */
+ { 20, 3}, { 2, 4}, { 2, 0}, /* Row 13 */
+ { 18, 3}, { 2, 4}, { 4, 0}, /* Row 14 */
+ { 16, 3}, { 2, 4}, { 6, 0}, /* Row 15 */
+ { 14, 3}, { 2, 4}, { 8, 0}, /* Row 16 */
+ { 12, 3}, { 2, 4}, { 10, 0}, /* Row 17 */
+ { 10, 3}, { 2, 4}, { 12, 0}, /* Row 18 */
+ { 8, 3}, { 2, 4}, { 14, 0}, /* Row 19 */
+ { 6, 3}, { 2, 4}, { 16, 0}, /* Row 20 */
+ { 4, 3}, { 2, 4}, { 18, 0}, /* Row 21 */
+ { 2, 3}, { 2, 4}, { 20, 0}, /* Row 22 */
+ { 2, 4}, { 22, 0}, /* Row 23 */
};
/********************************************************************************************
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 0f7e5af3a..b33ad446f 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2730,5 +2730,9 @@
* configs/sam3u-ek, configs/sim, arch/sim/src/up_touchscreen.c, and
apps/examples/touchscreen: Standardize the board-specific, touchscreen
initialization interfaces.
-
+ * drivers/input/stmpe11_base.c and configs/stm3240g-eval: The STMPE11-based
+ touchscreen seems to work better with edge (vs. level) interrupts
+ * drivers/input/stmpe11_tsc.c: Fix some status checks so that the touchscreen
+ interrupt handling logic does not read data if the fifo is not at the
+ threshold level.
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 0eec8d12a..4ded08f0f 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -4690,7 +4690,11 @@ build
</li>
<li>
<code>CONFIG_STMPE11_ACTIVELOW</code>:
- Interrupt is generated by an active low signal.
+ Interrupt is generated by an active low signal (or falling edge).
+ </li>
+ <li>
+ <code>CONFIG_STMPE11_EDGE</code>:
+ Interrupt is generated on an edge (vs. on the active level)
</li>
<li>
<code>CONFIG_STMPE11_NPOLLWAITERS</code>:
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 6bd459801..15ff30e11 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -793,7 +793,9 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_STMPE11_MULTIPLE
Can be defined to support multiple STMPE11 devices on board.
CONFIG_STMPE11_ACTIVELOW
- Interrupt is generated by an active low signal.
+ Interrupt is generated by an active low signal (or falling edge).
+ CONFIG_STMPE11_EDGE
+ Interrupt is generated on an edge (vs. on the active level)
CONFIG_STMPE11_NPOLLWAITERS
Maximum number of threads that can be waiting on poll() (ignored if
CONFIG_DISABLE_POLL is set).
diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig
index 5f8945075..a0131c993 100644
--- a/nuttx/configs/stm3240g-eval/nsh/defconfig
+++ b/nuttx/configs/stm3240g-eval/nsh/defconfig
@@ -968,7 +968,9 @@ CONFIG_INPUT_TSC2007=n
# CONFIG_STMPE11_MULTIPLE
# Can be defined to support multiple STMPE11 devices on board.
# CONFIG_STMPE11_ACTIVELOW
-# Interrupt is generated by an active low signal.
+# Interrupt is generated by an active low signal (or falling edge).
+# CONFIG_STMPE11_EDGE
+# Interrupt is generated on an edge (vs. on the active level)
# CONFIG_STMPE11_NPOLLWAITERS
# Maximum number of threads that can be waiting on poll() (ignored if
# CONFIG_DISABLE_POLL is set).
@@ -994,6 +996,7 @@ 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
diff --git a/nuttx/configs/stm3240g-eval/nxwm/defconfig b/nuttx/configs/stm3240g-eval/nxwm/defconfig
index 10ffa0879..3242948f3 100644
--- a/nuttx/configs/stm3240g-eval/nxwm/defconfig
+++ b/nuttx/configs/stm3240g-eval/nxwm/defconfig
@@ -968,7 +968,9 @@ CONFIG_INPUT_TSC2007=n
# CONFIG_STMPE11_MULTIPLE
# Can be defined to support multiple STMPE11 devices on board.
# CONFIG_STMPE11_ACTIVELOW
-# Interrupt is generated by an active low signal.
+# Interrupt is generated by an active low signal (or falling edge).
+# CONFIG_STMPE11_EDGE
+# Interrupt is generated on an edge (vs. on the active level)
# CONFIG_STMPE11_NPOLLWAITERS
# Maximum number of threads that can be waiting on poll() (ignored if
# CONFIG_DISABLE_POLL is set).
@@ -994,6 +996,7 @@ 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
diff --git a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c
index e06e203e7..72482c92c 100644
--- a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c
+++ b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c
@@ -49,6 +49,8 @@
#include <nuttx/input/touchscreen.h>
#include <nuttx/input/stmpe11.h>
+#include <arch/irq.h>
+
#include "stm32_internal.h"
#include "stm3240g-internal.h"
@@ -221,10 +223,14 @@ 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)
{
FAR struct stm32_stmpe11config_s *priv = (FAR struct stm32_stmpe11config_s *)state;
+ irqstate_t flags;
- /* Attach and enable, or detach and disable */
+ /* 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.
+ */
- ivdbg("IRQ:%d enable:%d\n", STM32_IRQ_EXTI2, enable);
+ flags = irqsave();
if (enable)
{
/* Configure the EXTI interrupt using the SAVED handler */
@@ -237,6 +243,7 @@ static void stmpe11_enable(FAR struct stmpe11_config_s *state, bool enable)
(void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL);
}
+ irqrestore(flags);
}
static void stmpe11_clear(FAR struct stmpe11_config_s *state)
diff --git a/nuttx/drivers/input/stmpe11.h b/nuttx/drivers/input/stmpe11.h
index 9ca31e52a..5a93f9463 100644
--- a/nuttx/drivers/input/stmpe11.h
+++ b/nuttx/drivers/input/stmpe11.h
@@ -216,7 +216,7 @@ uint16_t stmpe11_getreg16(FAR struct stmpe11_dev_s *priv, uint8_t regaddr);
********************************************************************************************/
#ifndef CONFIG_STMPE11_TSC_DISABLE
-void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv) weak_function;
+void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv, uint8_t intsta) weak_function;
#endif
/********************************************************************************************
diff --git a/nuttx/drivers/input/stmpe11_base.c b/nuttx/drivers/input/stmpe11_base.c
index f9f52fae9..34d13aeac 100644
--- a/nuttx/drivers/input/stmpe11_base.c
+++ b/nuttx/drivers/input/stmpe11_base.c
@@ -109,7 +109,7 @@ static void stmpe11_worker(FAR void *arg)
if (stmpe11_tscworker)
#endif
{
- stmpe11_tscworker(priv);
+ stmpe11_tscworker(priv, regval);
}
stmpe11_putreg8(priv, STMPE11_INT_STA, (INT_TOUCH_DET|INT_FIFO_TH|INT_FIFO_OFLOW));
@@ -349,7 +349,11 @@ STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
#else
regval |= INT_CTRL_INT_POLARITY; /* Pin polarity: Active high / rising edge */
#endif
+#ifdef CONFIG_STMPE11_EDGE
+ regval |= INT_CTRL_INT_TYPE; /* Edge interrupt */
+#else
regval &= ~INT_CTRL_INT_TYPE; /* Level interrupt */
+#endif
stmpe11_putreg8(priv, STMPE11_INT_CTRL, regval);
/* Attach the STMPE11 interrupt handler. */
diff --git a/nuttx/drivers/input/stmpe11_tsc.c b/nuttx/drivers/input/stmpe11_tsc.c
index 29dc51d02..09b06d497 100644
--- a/nuttx/drivers/input/stmpe11_tsc.c
+++ b/nuttx/drivers/input/stmpe11_tsc.c
@@ -239,14 +239,22 @@ static int stmpe11_sample(FAR struct stmpe11_dev_s *priv,
if (sample->contact == CONTACT_UP)
{
- /* Next.. no contract. Increment the ID so that next contact ID will be unique */
+ /* The sampling logic has detected pen-up in some condition other
+ * than CONTACT_NONE. Set the next state to CONTACT_NONE: Further
+ * pen-down reports will be ignored. Increment the ID so that
+ * next contact ID will be unique
+ */
priv->sample.contact = CONTACT_NONE;
priv->id++;
}
else if (sample->contact == CONTACT_DOWN)
{
- /* First report -- next report will be a movement */
+ /* The sampling logic has detected pen-up in some condition other
+ * than CONTACT_MOVE. Set the next state to CONTACT_MOVE: Further
+ * samples collected while the pen is down will reported as movement
+ * events.
+ */
priv->sample.contact = CONTACT_MOVE;
}
@@ -553,20 +561,15 @@ static ssize_t stmpe11_read(FAR struct file *filep, FAR char *buffer, size_t len
{
/* First contact */
- report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID | TOUCH_POS_VALID;
+ report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID |
+ TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
}
else /* if (sample->contact == CONTACT_MOVE) */
{
/* Movement of the same contact */
- report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID | TOUCH_POS_VALID;
- }
-
- /* A pressure measurement of zero means that pressure is not available */
-
- if (report->point[0].pressure != 0)
- {
- report->point[0].flags |= TOUCH_PRESSURE_VALID;
+ report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID |
+ TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
}
}
@@ -904,7 +907,7 @@ int stmpe11_register(STMPE11_HANDLE handle, int minor)
*
****************************************************************************/
-void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
+void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv, uint8_t intsta)
{
FAR struct stmpe11_config_s *config; /* Convenience pointer */
bool pendown; /* true: pend is down */
@@ -913,7 +916,6 @@ 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
@@ -931,18 +933,36 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
if (!pendown)
{
- /* Ignore the interrupt if the pen was already down (CONTACT_NONE == pen up and
- * already reported. CONTACT_UP == pen up, but not reported)
+ /* The pen is up.. reset thresholding variables. FIFOs will read zero if
+ * there is no data available (hence the choice of (0,0)
*/
- if (priv->sample.contact == CONTACT_NONE)
+ priv->threshx = 0;
+ priv->threshy = 0;
+
+ /* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up and
+ * already reported; CONTACT_UP == pen up, but not reported)
+ */
+
+ if (priv->sample.contact == CONTACT_NONE ||
+ priv->sample.contact == CONTACT_UP)
{
- return;
+ goto ignored;
}
+
+ /* A pen-down to up transition has been detected. CONTACT_UP indicates the
+ * initial loss of contzt. The state will be changed to CONTACT_NONE
+ * after the loss of contact is sampled.
+ */
+
+ priv->sample.contact = CONTACT_UP;
}
- else
+
+ /* The pen is down... check for data in the FIFO */
+
+ else if ((intsta & (INT_FIFO_TH|INT_FIFO_OFLOW)) != 0)
{
- /* Read the next x and y positions */
+ /* Read the next x and y positions. */
#ifdef CONFIG_STMPE11_SWAPXY
x = stmpe11_getreg16(priv, STMPE11_TSC_DATAX);
@@ -957,34 +977,32 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x);
ydiff = y > priv->threshy ? (y - priv->threshy) : (priv->threshy - y);
- /* When we see a big difference, snap to the new x/y position */
+ /* If the difference from the last sample is small, then ignore the event.
+ * REVISIT: Should a large change in pressure also generate a event?
+ */
- if (xdiff + ydiff > 5)
+ if (xdiff + ydiff < 6)
{
- priv->threshx = x;
- priv->threshy = y;
+ /* Little or no change in position... don't report */
+
+ goto ignored;
}
- /* Update the x/y position */
+ /* When we see a big difference, snap to the new x/y thresholds */
+
+ priv->threshx = x;
+ priv->threshy = y;
+
+ /* Update the x/y position in the sample data */
priv->sample.x = priv->threshx;
priv->sample.y = priv->threshy;
- /* Update the Z pression index */
+ /* Update the Z pressure index */
priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ);
- }
-
- /* Clear the interrupt pending bit and enable the FIFO again */
-
- stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01);
- stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00);
-
- /* Note the availability of new measurements */
- if (pendown)
- {
- /* If this is the first (acknowledged) pend down report, then report
+ /* If this is the first (acknowledged) pen down report, then report
* this as the first contact. If contact == CONTACT_DOWN, it will be
* set to set to CONTACT_MOVE after the contact is first sampled.
*/
@@ -996,17 +1014,20 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
priv->sample.contact = CONTACT_DOWN;
}
}
- else /* if (priv->sample.contact != CONTACT_NONE) */
+
+ /* Pen down, but no data in FIFO */
+
+ else
{
- /* The pen is up. NOTE: We know from a previous test, that this is a
- * loss of contact condition. This will be changed to CONTACT_NONE
- * after the loss of contact is sampled.
- */
+ /* Ignore the interrupt... wait until there is data in the FIFO */
- priv->sample.contact = CONTACT_UP;
+ goto ignored;
}
- /* Indicate the availability of new sample data for this ID */
+ /* We get here if (1) we just went from a pen down to a pen up state OR (2)
+ * We just get a measurement from the FIFO in a pen down state. Indicate
+ * the availability of new sample data for this ID.
+ */
priv->sample.id = priv->id;
priv->penchange = true;
@@ -1014,6 +1035,12 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv)
/* Notify any waiters that new STMPE11 data is available */
stmpe11_notify(priv);
+
+ /* Clear the interrupt pending bit and enable the FIFO again */
+
+ignored:
+ stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x01);
+ stmpe11_putreg8(priv, STMPE11_FIFO_STA, 0x00);
}
#endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE11 && !CONFIG_STMPE11_TSC_DISABLE */