mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 06:33:33 +08:00
Add STMPE11 touchscreen logic
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4703 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -49,6 +49,9 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_INPUT_STMPE11),y)
|
||||
CSRCS += stmpe11_base.c
|
||||
ifneq ($(CONFIG_INPUT_STMPE11_TSC_DISABLE),y)
|
||||
CSRCS += stmpe11_tsc.c
|
||||
endif
|
||||
ifneq ($(CONFIG_INPUT_STMPE11_GPIO_DISABLE),y)
|
||||
CSRCS += stmpe11_gpio.c
|
||||
endif
|
||||
|
||||
@@ -113,7 +113,7 @@ struct stmpe11_sample_s
|
||||
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 */
|
||||
uint8_t z; /* Measured Z index */
|
||||
};
|
||||
|
||||
/* This structure represents the state of the SMTPE11 driver */
|
||||
@@ -216,11 +216,11 @@ uint16_t stmpe11_getreg16(FAR struct stmpe11_dev_s *priv, uint8_t regaddr);
|
||||
********************************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STMPE11_TSC_DISABLE
|
||||
void stmpe11_tscint(FAR struct stmpe11_dev_s *priv) weak_function;
|
||||
void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv) weak_function;
|
||||
#endif
|
||||
|
||||
/********************************************************************************************
|
||||
* Name: stmpe11_gpioint
|
||||
* Name: stmpe11_gpioworker
|
||||
*
|
||||
* Description:
|
||||
* Handle GPIO interrupt events (this function actually executes in the context of the
|
||||
@@ -229,7 +229,7 @@ void stmpe11_tscint(FAR struct stmpe11_dev_s *priv) weak_function;
|
||||
********************************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_STMPE11_GPIO_DISABLE) && !defined(CONFIG_STMPE11_GPIOINT_DISABLE)
|
||||
void stmpe11_gpioint(FAR struct stmpe11_dev_s *priv) weak_function;
|
||||
void stmpe11_gpioworker(FAR struct stmpe11_dev_s *priv) weak_function;
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE11 */
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/input/stmpe11.h>
|
||||
|
||||
#include "stmpe11.h"
|
||||
@@ -71,15 +72,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stmpe11_adctiming
|
||||
* Name: stmpe11_adcinitialize
|
||||
*
|
||||
* Description:
|
||||
* Configure overall ADC timing that applies to all pins.
|
||||
* Configure for ADC mode operation. Set overall ADC ADC timing that
|
||||
* applies to all pins.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle previously returned by stmpe11_instantiate
|
||||
* ctrl1 - The value of the ADC_CRTL1 register (see above).
|
||||
* ctrl2 - The value of the ADC_CRTL2 register (see above).
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
@@ -87,7 +87,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stmpe11_adctiming(STMPE11_HANDLE handle, uint8_t ctrl1, uint8_t ctrl2)
|
||||
int stmpe11_adcinitialize(STMPE11_HANDLE handle)
|
||||
{
|
||||
FAR struct stmpe11_dev_s *priv = (FAR struct stmpe11_dev_s *)handle;
|
||||
uint8_t regval;
|
||||
@@ -111,10 +111,17 @@ int stmpe11_adctiming(STMPE11_HANDLE handle, uint8_t ctrl1, uint8_t ctrl2)
|
||||
regval &= ~SYS_CTRL2_ADC_OFF;
|
||||
stmpe11_putreg8(priv, STMPE11_SYS_CTRL2, regval);
|
||||
|
||||
/* Configure the ADC properties */
|
||||
/* Select Sample Time, bit number and ADC Reference */
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_ADC_CTRL1, ctrl1);
|
||||
stmpe11_putreg8(priv, STMPE11_ADC_CTRL2, ctrl2);
|
||||
stmpe11_putreg8(priv, STMPE11_ADC_CTRL1, priv->config->ctrl1);
|
||||
|
||||
/* Wait for 20 ms */
|
||||
|
||||
up_mdelay(20);
|
||||
|
||||
/* Select the ADC clock speed */
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_ADC_CTRL2, priv->config->ctrl2);
|
||||
|
||||
/* Mark ADC initialized */
|
||||
|
||||
|
||||
@@ -102,9 +102,11 @@ static void stmpe11_worker(FAR void *arg)
|
||||
{
|
||||
/* Dispatch the touchscreen interrupt if it was brought into the link */
|
||||
|
||||
if (stmpe11_tscint)
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (stmpe11_tscworker)
|
||||
#endif
|
||||
{
|
||||
stmpe11_tscint(priv);
|
||||
stmpe11_tscworker(priv);
|
||||
}
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_INT_STA, (INT_TOUCH_DET|INT_FIFO_TH|INT_FIFO_OFLOW));
|
||||
@@ -117,9 +119,11 @@ static void stmpe11_worker(FAR void *arg)
|
||||
{
|
||||
/* Dispatch the GPIO interrupt if it was brought into the link */
|
||||
|
||||
if (stmpe11_gpioint)
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (stmpe11_gpioworker)
|
||||
#endif
|
||||
{
|
||||
stmpe11_gpioint(priv);
|
||||
stmpe11_gpioworker(priv);
|
||||
}
|
||||
|
||||
stmpe11_putreg8(priv, STMPE11_INT_STA, INT_GPIO);
|
||||
|
||||
@@ -397,7 +397,7 @@ int stmpe11_gpioattach(STMPE11_HANDLE handle, uint8_t pinconfig,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stmpe11_gpioint
|
||||
* Name: stmpe11_gpioworker
|
||||
*
|
||||
* Description:
|
||||
* Handle GPIO interrupt events (this function actually executes in the
|
||||
@@ -406,7 +406,7 @@ int stmpe11_gpioattach(STMPE11_HANDLE handle, uint8_t pinconfig,
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STMPE11_GPIOINT_DISABLE
|
||||
void stmpe11_gpioint(FAR struct stmpe11_dev_s *priv)
|
||||
void stmpe11_gpioworker(FAR struct stmpe11_dev_s *priv)
|
||||
{
|
||||
uint8_t regval;
|
||||
uint8_t pinmask;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user