mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
Beginning of an SMTPE11 touchscreen/IO expander driver
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4700 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+91
-91
@@ -1,91 +1,91 @@
|
|||||||
NXWidgets
|
NXWidgets
|
||||||
=========
|
=========
|
||||||
|
|
||||||
In order to better support NuttX based platforms, a special graphical user
|
In order to better support NuttX based platforms, a special graphical user
|
||||||
interface has been created called NXWidgets. NXWidgets is written in C++
|
interface has been created called NXWidgets. NXWidgets is written in C++
|
||||||
and integrates seamlessly with the NuttX NX graphics subsystem in order
|
and integrates seamlessly with the NuttX NX graphics subsystem in order
|
||||||
to provide graphic objects, or "widgets," in the NX Graphics Subsystem
|
to provide graphic objects, or "widgets," in the NX Graphics Subsystem
|
||||||
|
|
||||||
Some of the features of NXWidgets include:
|
Some of the features of NXWidgets include:
|
||||||
|
|
||||||
o Conservative C++
|
o Conservative C++
|
||||||
|
|
||||||
NXWidgets is written entirely in C++ but using only selected “embedded
|
NXWidgets is written entirely in C++ but using only selected “embedded
|
||||||
friendly” C++ constructs that are fully supported under NuttX. No
|
friendly” C++ constructs that are fully supported under NuttX. No
|
||||||
additional C++ support libraries are required.
|
additional C++ support libraries are required.
|
||||||
|
|
||||||
o NX Integration
|
o NX Integration
|
||||||
|
|
||||||
NXWidgets integrate seamlessly with the NX graphics system. Think of the
|
NXWidgets integrate seamlessly with the NX graphics system. Think of the
|
||||||
X server under Linux … the NX graphics system is like a tiny X server
|
X server under Linux … the NX graphics system is like a tiny X server
|
||||||
that provides windowing under NuttX. By adding NXWidgets, you can support
|
that provides windowing under NuttX. By adding NXWidgets, you can support
|
||||||
graphics objects like buttons and text boxes in the NX windows and toolbars.
|
graphics objects like buttons and text boxes in the NX windows and toolbars.
|
||||||
|
|
||||||
o Small Footprint
|
o Small Footprint
|
||||||
|
|
||||||
NXWidgets is tailored for use MCUs in embedded applications. It is ideally
|
NXWidgets is tailored for use MCUs in embedded applications. It is ideally
|
||||||
suited for mid- and upper-range of most MCU families. A complete NXWidgets
|
suited for mid- and upper-range of most MCU families. A complete NXWidgets
|
||||||
is possible in as little as 40Kb of FLASH and maybe 4Kb of SRAM.
|
is possible in as little as 40Kb of FLASH and maybe 4Kb of SRAM.
|
||||||
|
|
||||||
o Output Devices
|
o Output Devices
|
||||||
|
|
||||||
NXWidgets will work on the high-end frame buffer devices as well as on LCDs
|
NXWidgets will work on the high-end frame buffer devices as well as on LCDs
|
||||||
connected via serial or parallel ports to a small MCU.
|
connected via serial or parallel ports to a small MCU.
|
||||||
|
|
||||||
o Input Devices
|
o Input Devices
|
||||||
|
|
||||||
NXWidgets will accept position and selection inputs from a mouse or a
|
NXWidgets will accept position and selection inputs from a mouse or a
|
||||||
touchscreen. It will also support character input from a keyboard such as a
|
touchscreen. It will also support character input from a keyboard such as a
|
||||||
USB keyboard. NXWidgets supports on very special widget called CKeypad that
|
USB keyboard. NXWidgets supports on very special widget called CKeypad that
|
||||||
will provide keyboard input via an on-screen keypad that can be operated
|
will provide keyboard input via an on-screen keypad that can be operated
|
||||||
via mouse or touchscreen inputs.
|
via mouse or touchscreen inputs.
|
||||||
|
|
||||||
o Many Graphic Objects
|
o Many Graphic Objects
|
||||||
|
|
||||||
Some of the graphic objects supported by NXWidgets include labels, buttons,
|
Some of the graphic objects supported by NXWidgets include labels, buttons,
|
||||||
text boxes, button arrays, check boxes, cycle buttons, images, sliders,
|
text boxes, button arrays, check boxes, cycle buttons, images, sliders,
|
||||||
scrollable list boxes, progress bars, and more.
|
scrollable list boxes, progress bars, and more.
|
||||||
|
|
||||||
Note: Many of the fundamental classed in NxWidgets derive from the Antony
|
Note: Many of the fundamental classed in NxWidgets derive from the Antony
|
||||||
Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
|
Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
|
||||||
license. See the COPYING file for details.
|
license. See the COPYING file for details.
|
||||||
|
|
||||||
Directory Structure
|
Directory Structure
|
||||||
===================
|
===================
|
||||||
|
|
||||||
libnxwidgets
|
libnxwidgets
|
||||||
|
|
||||||
The source code, header files, and build environment for NxWidgets is
|
The source code, header files, and build environment for NxWidgets is
|
||||||
provided in this directory.
|
provided in this directory.
|
||||||
|
|
||||||
UnitTests
|
UnitTests
|
||||||
|
|
||||||
Provides a collection of unit-level tests for many of the individual
|
Provides a collection of unit-level tests for many of the individual
|
||||||
widgets provided by libnxwidgets.
|
widgets provided by libnxwidgets.
|
||||||
|
|
||||||
nxwm
|
nxwm
|
||||||
|
|
||||||
This directory holds a tiny desktop for small embedded devices with a
|
This directory holds a tiny desktop for small embedded devices with a
|
||||||
touchscreen,. NxWM. NxWM is truly multiple window manager but only one
|
touchscreen,. NxWM. NxWM is true multiple window manager but only one
|
||||||
window is displayed at a time. This simplification helps performance on
|
window is displayed at a time. This simplification helps performance on
|
||||||
LCD based products (in the same way that a tiled window manager helps)
|
LCD based products (in the same way that a tiled window manager helps)
|
||||||
and also makes the best use of small displays. It is awkward from a
|
and also makes the best use of small displays. It is awkward from a
|
||||||
human factors point-of-view trying to manage multiple windows on a
|
human factors point-of-view trying to manage multiple windows on a
|
||||||
small display.
|
small display.
|
||||||
|
|
||||||
The window manager consists of a task bar with icons representing the
|
The window manager consists of a task bar with icons representing the
|
||||||
running tasks. If you touch the tasks icon, it comes to the top. Each
|
running tasks. If you touch the tas'ks icon, it comes to the top. Each
|
||||||
window has a toolbar with (1) a title, (2) a minimize button, and (3) a
|
window has a toolbar with (1) a title, (2) a minimize button, and (3) a
|
||||||
stop application button using the standard icons for these things.
|
stop application button using the standard icons for these things.
|
||||||
|
|
||||||
There is always a start window that is available in the task bar. When
|
There is always a start window that is available in the task bar. When
|
||||||
you touch the start window icon, it brings up the start window containing
|
you touch the start window icon, it brings up the start window containing
|
||||||
icons representing all of the available applications. If you touch an
|
icons representing all of the available applications. If you touch an
|
||||||
icon in the start window, it will be started and added to the task bar.
|
icon in the start window, it will be started and added to the task bar.
|
||||||
|
|
||||||
There is a base class that defines an add-on application and an
|
There is a base class that defines an add-on application and an
|
||||||
interface that supports incorporation of new application. The only
|
interface that supports incorporation of new application. The only
|
||||||
application that is provided is NxConsole. This is an NSH session
|
application that is provided is NxConsole. This is an NSH session
|
||||||
running in a window. I should be able to select the NX icon in the start
|
running in a window. You should be able to select the NX icon in the start
|
||||||
menu and create as many NSH sessions in windows as I want. (keybard input
|
menu and create as many NSH sessions in windows as you want. (keybard input
|
||||||
still comes through serial).
|
still comes through serial).
|
||||||
|
|||||||
@@ -2708,4 +2708,6 @@
|
|||||||
position, not an offset.
|
position, not an offset.
|
||||||
* graphics/nxtk/nxtk_drawframe.c: Framed windows are now drawn in three
|
* graphics/nxtk/nxtk_drawframe.c: Framed windows are now drawn in three
|
||||||
colors (instead of just two).
|
colors (instead of just two).
|
||||||
|
* drivers/input/stmpe11_*: Beginning of a driver to support STMicro STMPE11
|
||||||
|
IO Expander and touchscreen driver.
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ ifeq ($(CONFIG_INPUT_ADS7843E),y)
|
|||||||
CSRCS += ads7843e.c
|
CSRCS += ads7843e.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_INPUT_STMPE11),y)
|
||||||
|
CSRCS += stmpe11_base.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Include input device driver build support
|
# Include input device driver build support
|
||||||
|
|
||||||
DEPPATH += --dep-path input
|
DEPPATH += --dep-path input
|
||||||
|
|||||||
+117
-10
@@ -44,28 +44,135 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
|
#include <nuttx/wqueue.h>
|
||||||
|
#include <nuttx/input/stmpe11.h>
|
||||||
|
|
||||||
|
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE11)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
/* Configuration ****************************************************************************/
|
||||||
|
/* Reference counting is partially implemented, but not needed in the current design.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef CONFIG_STMPE11_REFCNT
|
||||||
|
|
||||||
|
/* No support for the SPI interface yet */
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_SPI
|
||||||
|
# error "Only the STMPE11 I2C interface is supported by this driver"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Driver support ***************************************************************************/
|
||||||
|
/* This format is used to construct the /dev/input[n] device driver path. It defined here
|
||||||
|
* so that it will be used consistently in all places.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEV_FORMAT "/dev/input%d"
|
||||||
|
#define DEV_NAMELEN 16
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
/* This describes the state of one contact */
|
||||||
|
|
||||||
|
enum stmpe11_contact_3
|
||||||
|
{
|
||||||
|
CONTACT_NONE = 0, /* No contact */
|
||||||
|
CONTACT_DOWN, /* First contact */
|
||||||
|
CONTACT_MOVE, /* Same contact, possibly different position */
|
||||||
|
CONTACT_UP, /* Contact lost */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This structure describes the results of one STMPE11 sample */
|
||||||
|
|
||||||
|
struct stmpe11_sample_s
|
||||||
|
{
|
||||||
|
uint8_t id; /* Sampled touch point ID */
|
||||||
|
uint8_t contact; /* Contact state (see enum stmpe11_contact_e) */
|
||||||
|
uint16_t x; /* Measured X position */
|
||||||
|
uint16_t y; /* Measured Y position */
|
||||||
|
uint16_t z; /* Measured Z position */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This structure represents the state of the SMTPE11 driver */
|
||||||
|
|
||||||
|
struct stmpe11_dev_s
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_STMPE11_MULTIPLE
|
||||||
|
FAR struct stmpe11_dev_s *flink; /* Supports a singly linked list of drivers */
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_STMPE11_REFCNT
|
||||||
|
uint8_t crefs; /* Number of times the device has been opened */
|
||||||
|
#endif
|
||||||
|
uint8_t nwaiters; /* Number of threads waiting for STMPE11 data */
|
||||||
|
uint8_t inuse; /* SMTPE11 pins in use */
|
||||||
|
uint8_t id; /* Current touch point ID (TSC only) */
|
||||||
|
uint8_t minor; /* Touchscreen minor device number (TSC only) */
|
||||||
|
volatile bool penchange; /* An unreported event is buffered (TSC only) */
|
||||||
|
sem_t devsem; /* Manages exclusive access to this structure */
|
||||||
|
sem_t waitsem; /* Used to wait for the availability of data */
|
||||||
|
uint32_t threshx; /* Thresholded X value (TSC only) */
|
||||||
|
uint32_t threshy; /* Thresholded Y value (TSC only) */
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_SPI
|
||||||
|
FAR struct spi_dev_s *spi; /* Saved SPI driver instance */
|
||||||
|
#else
|
||||||
|
FAR struct i2c_dev_s *i2c; /* Saved I2C driver instance */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FAR struct stmpe11_config_s *config; /* Board configuration data (TSC only) */
|
||||||
|
struct work_s work; /* Supports the interrupt handling "bottom half" */
|
||||||
|
struct stmpe11_sample_s sample; /* Last sampled touch point data (TSC only) */
|
||||||
|
|
||||||
|
/* The following is a list if poll structures of threads waiting for
|
||||||
|
* driver events. The 'struct pollfd' reference for each open is also
|
||||||
|
* retained in the f_priv field of the 'struct file'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
|
struct pollfd *fds[CONFIG_STMPE11_NPOLLWAITERS];
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
/********************************************************************************************
|
||||||
#define EXTERN extern "C"
|
* Name: stmpe11_getreg8
|
||||||
extern "C" {
|
*
|
||||||
#else
|
* Description:
|
||||||
#define EXTERN extern
|
* Read from an 8-bit STMPE11 register
|
||||||
#endif
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
#undef EXTERN
|
static uint8_t stmpe11_getreg8(FAR struct stmpe11_dev_s *priv, uint8_t regaddr);
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_putreg8
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Write a value to an 8-bit STMPE11 register
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
void stmpe11_putreg8(FAR struct stmpe11_dev_s *priv, uint8_t regaddr, uint8_t regval);
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_getreg16
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Read 16-bits of data from an STMPE-11 register
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
uint16_t stmpe11_getreg16(FAR struct stmpe11_dev_s *priv, uint8_t regaddr);
|
||||||
|
|
||||||
|
#endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE11 */
|
||||||
#endif /* __DRIVERS_INPUT_STMPE11_H */
|
#endif /* __DRIVERS_INPUT_STMPE11_H */
|
||||||
|
|||||||
@@ -0,0 +1,366 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/input/stmpe11_base.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* "STMPE811 S-Touch® advanced resistive touchscreen controller with 8-bit
|
||||||
|
* GPIO expander," Doc ID 14489 Rev 6, CD00186725, STMicroelectronics"
|
||||||
|
*
|
||||||
|
* 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 <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/input/stmpe11.h>
|
||||||
|
|
||||||
|
#include "stmpe11.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE11)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* If only a single STMPE11 device is supported, then the driver state
|
||||||
|
* structure may as well be pre-allocated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_STMPE11_MULTIPLE
|
||||||
|
static struct stmpe11_dev_s g_stmpe11;
|
||||||
|
|
||||||
|
/* Otherwise, we will need to maintain allocated driver instances in a list */
|
||||||
|
|
||||||
|
#else
|
||||||
|
static struct stmpe11_dev_s *g_stmpe11list;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_checkid
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Read and verify the STMPE11 chip ID
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int stmpe11_checkid(FAR struct stmpe11_dev_s *priv)
|
||||||
|
{
|
||||||
|
uint16_t devid = 0;
|
||||||
|
|
||||||
|
/* Read device ID */
|
||||||
|
|
||||||
|
devid = stmpe11_getreg8(priv, STMPE11_CHIP_ID);
|
||||||
|
devid = (uint32_t)(devid << 8);
|
||||||
|
devid |= (uint32_t)stmpe11_getreg8(priv, STMPE11_CHIP_ID+1);
|
||||||
|
ivdbg("devid: %04x\n", devid);
|
||||||
|
|
||||||
|
if (devid != (uint16_t)CHIP_ID)
|
||||||
|
{
|
||||||
|
/* ID is not Correct */
|
||||||
|
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_reset
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Reset the STMPE11
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void stmpe11_reset(FAR struct stmpe11_dev_s *priv)
|
||||||
|
{
|
||||||
|
/* Power Down the STMPE11 */
|
||||||
|
|
||||||
|
stmpe11_putreg8(priv, STMPE11_SYS_CTRL1, SYS_CTRL1_SOFTRESET);
|
||||||
|
|
||||||
|
/* Wait a bit */
|
||||||
|
|
||||||
|
up_mdelay(20);
|
||||||
|
|
||||||
|
/* Then power on again. All registers will be in their reset state. */
|
||||||
|
|
||||||
|
stmpe11_putreg8(priv, STMPE11_SYS_CTRL1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_instantiate
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Instantiate and configure the STMPE11 device driver to use the provided
|
||||||
|
* I2C or SPIdevice instance.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - An I2C or SPI driver instance
|
||||||
|
* config - Persistant board configuration data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* A non-zero handle is returned on success. This handle may then be used
|
||||||
|
* to configure the STMPE11 driver as necessary. A NULL handle value is
|
||||||
|
* returned on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_SPI
|
||||||
|
STMPE11_HANDLE stmpe11_instantiate(FAR struct spi_dev_s *dev,
|
||||||
|
FAR struct stmpe11_config_s *config)
|
||||||
|
#else
|
||||||
|
STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
|
||||||
|
FAR struct stmpe11_config_s *config)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
FAR struct stmpe11_dev_s *priv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* On entry the following is assumed:
|
||||||
|
*
|
||||||
|
* I2C initialization ready
|
||||||
|
* GPIO pins already configured.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Allocate the device state structure */
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_MULTIPLE
|
||||||
|
priv = (FAR struct stmpe11_dev_s *)kzalloc(sizeof(struct stmpe11_dev_s));
|
||||||
|
if (!priv)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And save the device structure in the list of STMPE11 so that we can find it later */
|
||||||
|
|
||||||
|
priv->flink = g_stmpe11list;
|
||||||
|
g_stmpe11list = priv;
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Use the one-and-only STMPE11 driver instance */
|
||||||
|
|
||||||
|
priv = &g_stmpe11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the device state structure */
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_SPI
|
||||||
|
priv->spi = dev;
|
||||||
|
#else
|
||||||
|
priv->i2c = dev;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Read and verify the STMPE11 chip ID */
|
||||||
|
|
||||||
|
ret = stmpe11_checkid(priv);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_STMPE11_MULTIPLE
|
||||||
|
kfree(priv);
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate STMPE11 Software reset */
|
||||||
|
|
||||||
|
stmpe11_reset(priv);
|
||||||
|
return (STMPE11_HANDLE)priv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_getreg8
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Read from an 8-bit STMPE11 register
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_I2C
|
||||||
|
uint8_t stmpe11_getreg8(FAR struct stmpe11_dev_s *priv, uint8_t regaddr)
|
||||||
|
{
|
||||||
|
/* 8-bit data read sequence:
|
||||||
|
*
|
||||||
|
* Start - I2C_Write_Address - STMPE11_Reg_Address -
|
||||||
|
* Repeated_Start - I2C_Read_Address - STMPE11_Read_Data - STOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct i2c_msg_s msg[2];
|
||||||
|
uint8_t regval;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Setup 8-bit STMPE11 address write message */
|
||||||
|
|
||||||
|
msg[0].addr = priv->config->address; /* 7-bit address */
|
||||||
|
msg[0].flags = 0; /* Write transaction, beginning with START */
|
||||||
|
msg[0].buffer = ®addr; /* Transfer from this address */
|
||||||
|
msg[0].length = 1; /* Send one byte following the address
|
||||||
|
* (no STOP) */
|
||||||
|
|
||||||
|
/* Set up the 8-bit STMPE11 data read message */
|
||||||
|
|
||||||
|
msg[1].addr = priv->config->address; /* 7-bit address */
|
||||||
|
msg[1].flags = I2C_M_READ; /* Read transaction, beginning with Re-START */
|
||||||
|
msg[1].buffer = ®val; /* Transfer to this address */
|
||||||
|
msg[1].length = 1; /* Receive one byte following the address
|
||||||
|
* (then STOP) */
|
||||||
|
|
||||||
|
/* Perform the transfer */
|
||||||
|
|
||||||
|
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return regval;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_putreg8
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Write a value to an 8-bit STMPE11 register
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_I2C
|
||||||
|
void stmpe11_putreg8(FAR struct stmpe11_dev_s *priv,
|
||||||
|
uint8_t regaddr, uint8_t regval)
|
||||||
|
{
|
||||||
|
/* 8-bit data read sequence:
|
||||||
|
*
|
||||||
|
* Start - I2C_Write_Address - STMPE11_Reg_Address - STMPE11_Write_Data - STOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct i2c_msg_s msg;
|
||||||
|
uint8_t txbuffer[2];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Setup to the data to be transferred. Two bytes: The STMPE11 register
|
||||||
|
* address followed by one byte of data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
txbuffer[0] = regaddr;
|
||||||
|
txbuffer[1] = regval;
|
||||||
|
|
||||||
|
/* Setup 8-bit STMPE11 address write message */
|
||||||
|
|
||||||
|
msg.addr = priv->config->address; /* 7-bit address */
|
||||||
|
msg.flags = 0; /* Write transaction, beginning with START */
|
||||||
|
msg.buffer = txbuffer; /* Transfer from this address */
|
||||||
|
msg.length = 2; /* Send two byte following the address
|
||||||
|
* (then STOP) */
|
||||||
|
|
||||||
|
/* Perform the transfer */
|
||||||
|
|
||||||
|
ret = I2C_TRANSFER(priv->i2c, &msg, 1);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stmpe11_getreg16
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Read 16-bits of data from an STMPE-11 register
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STMPE11_I2C
|
||||||
|
uint16_t stmpe11_getreg16(FAR struct stmpe11_dev_s *priv, uint8_t regaddr)
|
||||||
|
{
|
||||||
|
/* 16-bit data read sequence:
|
||||||
|
*
|
||||||
|
* Start - I2C_Write_Address - STMPE11_Reg_Address -
|
||||||
|
* Repeated_Start - I2C_Read_Address - STMPE11_Read_Data_1 -
|
||||||
|
* STMPE11_Read_Data_2 - STOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
struct i2c_msg_s msg[2];
|
||||||
|
uint8_t rxbuffer[2];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Setup 8-bit STMPE11 address write message */
|
||||||
|
|
||||||
|
msg[0].addr = priv->config->address; /* 7-bit address */
|
||||||
|
msg[0].flags = 0; /* Write transaction, beginning with START */
|
||||||
|
msg[0].buffer = ®addr; /* Transfer from this address */
|
||||||
|
msg[0].length = 1; /* Send one byte following the address
|
||||||
|
* (no STOP) */
|
||||||
|
|
||||||
|
/* Set up the 8-bit STMPE11 data read message */
|
||||||
|
|
||||||
|
msg[1].addr = priv->config->address; /* 7-bit address */
|
||||||
|
msg[1].flags = I2C_M_READ; /* Read transaction, beginning with Re-START */
|
||||||
|
msg[1].buffer = rxbuffer; /* Transfer to this address */
|
||||||
|
msg[1].length = 2; /* Receive two bytes following the address
|
||||||
|
* (then STOP) */
|
||||||
|
|
||||||
|
/* Perform the transfer */
|
||||||
|
|
||||||
|
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint16_t)rxbuffer[0] << 16 | (uint16_t)rxbuffer[1];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE11 */
|
||||||
|
|
||||||
@@ -49,6 +49,8 @@
|
|||||||
#include <nuttx/i2c.h>
|
#include <nuttx/i2c.h>
|
||||||
#include <nuttx/spi.h>
|
#include <nuttx/spi.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE11)
|
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE11)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@@ -77,8 +79,13 @@
|
|||||||
* in getting the right configuration.
|
* in getting the right configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_I2C_TRANSFER
|
#ifdef CONFIG_STMPE11_I2C
|
||||||
# error "CONFIG_I2C_TRANSFER is required in the I2C configuration"
|
# ifndef CONFIG_I2C
|
||||||
|
# error "CONFIG_I2C is required in the I2C support"
|
||||||
|
# endif
|
||||||
|
# ifndef CONFIG_I2C_TRANSFER
|
||||||
|
# error "CONFIG_I2C_TRANSFER is required in the I2C configuration"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_DISABLE_SIGNALS
|
#ifdef CONFIG_DISABLE_SIGNALS
|
||||||
@@ -149,7 +156,7 @@
|
|||||||
#define STMPE11_ADC_DATACH6 0x3c /* ADC channel 6 (16-bit) */
|
#define STMPE11_ADC_DATACH6 0x3c /* ADC channel 6 (16-bit) */
|
||||||
#define STMPE11_ADC_DATACH7 0x3e /* ADC channel 7 (16-bit) */
|
#define STMPE11_ADC_DATACH7 0x3e /* ADC channel 7 (16-bit) */
|
||||||
#define STMPE11_TSC_CTRL 0x40 /* 4-wire touchscreen controller setup */
|
#define STMPE11_TSC_CTRL 0x40 /* 4-wire touchscreen controller setup */
|
||||||
#define STMPE11_TSWC_CFG 0x41 /* Touchscreen controller configuration */
|
#define STMPE11_TSC_CFG 0x41 /* Touchscreen controller configuration */
|
||||||
#define STMPE11_WDW_TRX 0x42 /* Window setup for top right X (16-bit) */
|
#define STMPE11_WDW_TRX 0x42 /* Window setup for top right X (16-bit) */
|
||||||
#define STMPE11_WDW_TRY 0x44 /* Window setup for top right Y (16-bit) */
|
#define STMPE11_WDW_TRY 0x44 /* Window setup for top right Y (16-bit) */
|
||||||
#define STMPE11_WDW_BLX 0x46 /* Window setup for bottom left X (16-bit) */
|
#define STMPE11_WDW_BLX 0x46 /* Window setup for bottom left X (16-bit) */
|
||||||
@@ -336,33 +343,78 @@
|
|||||||
#define TEMP_CTRL_THRES_EN (1 << 3) /* Bit 3: Threshold enable */
|
#define TEMP_CTRL_THRES_EN (1 << 3) /* Bit 3: Threshold enable */
|
||||||
#define TEMP_CTRL_THRES_RANGE (1 << 4) /* Bit 4: temperature threshold enable, 0='>=' 1='<' */
|
#define TEMP_CTRL_THRES_RANGE (1 << 4) /* Bit 4: temperature threshold enable, 0='>=' 1='<' */
|
||||||
|
|
||||||
|
/* GPIO Configuration ***********************************************************************/
|
||||||
|
/* The STMPE11 GPIO interfaces take an 8-bit bit-encoded parameter to describe the GPIO pin.
|
||||||
|
* The following definitions describe the bit-encoding of that parameter.
|
||||||
|
*
|
||||||
|
* 7654 3210
|
||||||
|
* ---- ----
|
||||||
|
* MIRF VPPP
|
||||||
|
*
|
||||||
|
* Input Pins: 1IRF .PPP
|
||||||
|
*
|
||||||
|
* Output Pins: 0.RF VPPP
|
||||||
|
*
|
||||||
|
* Bits 7 is the pin direction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STMPE11_GPIO_INPUT (1 << 7) /* Input pin (possibly interrupting) */
|
||||||
|
#define STMPE11_GPIO_INPUT (0) /* Configure as in input pin (possibly interrupting) */
|
||||||
|
|
||||||
|
/* Bit 6 indicates that the pin will generate an interrupt (inputs only) */
|
||||||
|
|
||||||
|
#define STMPE11_GPIO_IN (1 << 6) /* Input interrupting pin */
|
||||||
|
|
||||||
|
/* The bits 4-5 select the rising and/or the falling edge detection. */
|
||||||
|
|
||||||
|
#define STMPE11_GPIO_RISING (1 << 5) /* Input interrupting pin */
|
||||||
|
#define STMPE11_GPIO_FALLING (1 << 4) /* Input interrupting pin */
|
||||||
|
|
||||||
|
/* Bit 3 is the initial value for output pins */
|
||||||
|
|
||||||
|
#define STMPE11_GPIO_ONE (1 << 3) /* The initial value is logic 1 */
|
||||||
|
#define STMPE11_GPIO_ZERO (0) /* The initial value is logic 0 */
|
||||||
|
|
||||||
|
/* Bits 0-2 is the pin number */
|
||||||
|
|
||||||
|
#define STMPE11_GPIO_PIN_SHIFT (0)
|
||||||
|
#define STMPE11_GPIO_PIN_MASK (7 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN0 (0 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN1 (1 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN2 (2 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN3 (3 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN4 (4 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN5 (5 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN6 (6 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
# define STMPE11_GPIO_PIN7 (7 << STMPE11_GPIO_PIN_SHIFT)
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
/* A reference to a structure of this type must be passed to the STMPE11 driver when the
|
||||||
/* A reference to a structure of this type must be passed to the STMPE11
|
* driver is instantiaed. This structure provides information about the configuration of the
|
||||||
* driver. This structure provides information about the configuration
|
* STMPE11 and provides some board-specific hooks.
|
||||||
* of the STMPE11 and provides some board-specific hooks.
|
|
||||||
*
|
*
|
||||||
* Memory for this structure is provided by the caller. It is not copied
|
* Memory for this structure is provided by the caller. It is not copied by the driver
|
||||||
* by the driver and is presumed to persist while the driver is active. The
|
* and is presumed to persist while the driver is active. The memory must be writable
|
||||||
* memory must be writable because, under certain circumstances, the driver
|
* because, under certain circumstances, the driver may modify the frequency.
|
||||||
* may modify the frequency.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct stmpe11_config_s
|
struct stmpe11_config_s
|
||||||
{
|
{
|
||||||
/* Device characterization */
|
/* Device characterization */
|
||||||
|
|
||||||
uint8_t address; /* 7-bit I2C address (only bits 0-6 used) */
|
#ifdef CONFIG_STMPE11_I2C
|
||||||
uint32_t frequency; /* I2C frequency */
|
uint8_t address; /* 7-bit I2C address (only bits 0-6 used) */
|
||||||
|
#endif
|
||||||
|
uint32_t frequency; /* I2C or SPI frequency */
|
||||||
|
|
||||||
/* If multiple STMPE11 devices are supported, then an IRQ number must
|
/* If multiple STMPE11 devices are supported, then an IRQ number must
|
||||||
* be provided for each so that their interrupts can be distinguished.
|
* be provided for each so that their interrupts can be distinguished.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_STMPE11_MULTIPLE
|
#ifndef CONFIG_STMPE11_MULTIPLE
|
||||||
int irq; /* IRQ number received by interrupt handler. */
|
int irq; /* IRQ number received by interrupt handler. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
||||||
@@ -374,7 +426,7 @@ struct stmpe11_config_s
|
|||||||
* attach - Attach the STMPE11 interrupt handler to the GPIO interrupt
|
* attach - Attach the STMPE11 interrupt handler to the GPIO interrupt
|
||||||
* enable - Enable or disable the GPIO interrupt
|
* enable - Enable or disable the GPIO interrupt
|
||||||
* clear - Acknowledge/clear any pending GPIO interrupt
|
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||||
* pendown - Return the state of the pen down GPIO input
|
* pendown - Return the state of the pen down GPIO input (TSC only)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*attach)(FAR struct stmpe11_config_s *state, xcpt_t isr);
|
int (*attach)(FAR struct stmpe11_config_s *state, xcpt_t isr);
|
||||||
@@ -383,6 +435,14 @@ struct stmpe11_config_s
|
|||||||
bool (*pendown)(FAR struct stmpe11_config_s *state);
|
bool (*pendown)(FAR struct stmpe11_config_s *state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Since the STMPE11 is a multi-function device, no functionality is assumed when the device
|
||||||
|
* is first created. Rather, a multi-step initialization is required. When
|
||||||
|
* stmpe11_register is called, it returns a handle of the following type. That handle may
|
||||||
|
* then be used to enable a configure the STMPE11 functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef FAR void *STMPE11_HANDLE;
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
@@ -395,34 +455,124 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
* Name: stmpe11_register
|
* Name: stmpe11_instantiate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the STMPE11 to use the provided I2C device instance. This
|
* Instantiate and configure the STMPE11 device driver to use the provided I2C or SPI
|
||||||
* will register the driver as /dev/inputN where N is the minor device
|
* device instance.
|
||||||
* number
|
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* dev - An I2C or SPI driver instance
|
* dev - An I2C or SPI driver instance
|
||||||
* config - Persistant board configuration data
|
* config - Persistant board configuration data
|
||||||
* minor - The input device minor number
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero is returned on success. Otherwise, a negated errno value is
|
* A non-zero handle is returned on success. This handle may then be used to configure
|
||||||
* returned to indicate the nature of the failure.
|
* the STMPE11 driver as necessary. A NULL handle value is returned on failure.
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STMPE11_SPI
|
#ifdef CONFIG_STMPE11_SPI
|
||||||
EXTERN int stmpe11_register(FAR struct spi_dev_s *dev,
|
EXTERN STMPE11_HANDLE stmpe11_instantiate(FAR struct spi_dev_s *dev,
|
||||||
FAR struct stmpe11_config_s *config,
|
FAR struct stmpe11_config_s *config);
|
||||||
int minor);
|
|
||||||
#else
|
#else
|
||||||
EXTERN int stmpe11_register(FAR struct i2c_dev_s *dev,
|
EXTERN STMPE11_HANDLE stmpe11_instantiate(FAR struct i2c_dev_s *dev,
|
||||||
FAR struct stmpe11_config_s *config,
|
FAR struct stmpe11_config_s *config);
|
||||||
int minor);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable TSC functionality. GPIO4-7 must be available. This function will register the
|
||||||
|
* touchsceen driver as /dev/inputN where N is the minor device number
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle previously returned by stmpe11_register
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int stmpe11_register(STMPE11_HANDLE handle, int minor);
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_gpioconfig
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure an STMPE11 GPIO pin
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle previously returned by stmpe11_register
|
||||||
|
* pinconfig - Bit-encoded pin configuration
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is returned to indicate
|
||||||
|
* the nature of the failure.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int stmpe11_gpioconfig(STMPE11_HANDLE handle, uint8_t pinconfig);
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_gpiowrite
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set or clear the GPIO output
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle previously returned by stmpe11_register
|
||||||
|
* pinconfig - Bit-encoded pin configuration
|
||||||
|
* value = true: write logic '1'; false: write logic '0;
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is returned to indicate
|
||||||
|
* the nature of the failure.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int stmpe11_gpiowrite(STMPE11_HANDLE handle, uint8_t pinconfig, bool value);
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_gpioread
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set or clear the GPIO output
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle previously returned by stmpe11_register
|
||||||
|
* pinconfig - Bit-encoded pin configuration
|
||||||
|
* value - The location to return the state of the GPIO pin
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is returned to indicate
|
||||||
|
* the nature of the failure.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int stmpe11_gpioread(STMPE11_HANDLE handle, uint8_t pinconfig, bool *value);
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
* Name: stmpe11_gpioattach
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach to a GPIO interrupt input pin and enable interrrupts on the pin
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle previously returned by stmpe11_register
|
||||||
|
* pinconfig - Bit-encoded pin configuration
|
||||||
|
* handler - The handler that will be called when the interrupt occurs.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is returned to indicate
|
||||||
|
* the nature of the failure.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int stmpe11_gpioread(STMPE11_HANDLE handle, uint8_t pinconfig, bool *value);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,12 @@
|
|||||||
#define TSIOC_SETFREQUENCY _TSIOC(0x0003) /* arg: Pointer to uint32_t frequency value */
|
#define TSIOC_SETFREQUENCY _TSIOC(0x0003) /* arg: Pointer to uint32_t frequency value */
|
||||||
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to uint32_t frequency value */
|
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to uint32_t frequency value */
|
||||||
|
|
||||||
|
/* Specific touchscreen drivers may support additional, device specific ioctal
|
||||||
|
* commands, beginning with this value:
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TSIOC_USER 0x0005 /* Lowest, unused TSC ioctl command */
|
||||||
|
|
||||||
/* These definitions provide the meaning of all of the bits that may be
|
/* These definitions provide the meaning of all of the bits that may be
|
||||||
* reported in the struct touch_point_s flags.
|
* reported in the struct touch_point_s flags.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user