* drivers/input/ads7843e.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
* "Touch Screen Controller, ADS7843," Burr-Brown Products from Texas
* Instruments, SBAS090B, September 2000, Revised May 2002"
*
* See also:
* "Low Voltage I/O Touch Screen Controller, TSC2046," Burr-Brown Products
* from Texas Instruments, SBAS265F, October 2002, Revised August 2007."
*
* "XPT2046 Data Sheet," Shenzhen XPTek Technology Co., Ltd, 2007
*/
#ifndef __DRIVERS_INPUT_ADS7843E_H
#define __DRIVERS_INPUT_ADS7843E_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <poll.h>
#include <nuttx/wqueue.h>
#include <nuttx/wdog.h>
#include <nuttx/clock.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
#include <nuttx/spi/spi.h>
#include <nuttx/input/ads7843e.h>
* Pre-processor Definitions
****************************************************************************/
* design.
*/
#undef CONFIG_ADS7843E_REFCNT
#define ADS7843E_CMD_PD0 (1 << 0)
#define ADS7843E_CMD_PD1 (1 << 1)
#define ADS7843E_CMD_SER (1 << 2)
#define ADS7843E_CMD_MODE8 (1 << 3)
#define ADS7843E_CMD_CHAN_SHIFT (4)
#define ADS7843E_CMD_CHAN_MASK (7 << ADS7843E_CMD_CHAN_SHIFT)
#define ADS7843E_CMD_START (1 << 7)
#define ADS7843_CMD_YPOSITION \
((1 << ADS7843E_CMD_CHAN_SHIFT)| ADS7843E_CMD_START | ADS7843E_CMD_PD0 | ADS7843E_CMD_PD1)
#define ADS7843_CMD_XPOSITION \
((5 << ADS7843E_CMD_CHAN_SHIFT)| ADS7843E_CMD_START | ADS7843E_CMD_PD0 | ADS7843E_CMD_PD1)
#define ADS7843_CMD_ENABPENIRQ \
((1 << ADS7843E_CMD_CHAN_SHIFT)| ADS7843E_CMD_START)
* defined here so that it will be used consistently in all places.
*/
#define DEV_FORMAT "/dev/input%d"
#define DEV_NAMELEN 16
#define ADS7843E_WDOG_DELAY MSEC2TICK(50)
* Public Types
****************************************************************************/
enum ads7843e_contact_e
{
CONTACT_NONE = 0,
CONTACT_DOWN,
CONTACT_MOVE,
CONTACT_UP,
};
struct ads7843e_sample_s
{
uint8_t id;
uint8_t contact;
bool valid;
uint16_t x;
uint16_t y;
};
struct ads7843e_dev_s
{
#ifdef CONFIG_ADS7843E_MULTIPLE
FAR struct ads7843e_dev_s *flink;
#endif
#ifdef CONFIG_ADS7843E_REFCNT
uint8_t crefs;
#endif
uint8_t nwaiters;
uint8_t id;
volatile bool penchange;
uint16_t threshx;
uint16_t threshy;
mutex_t devlock;
sem_t waitsem;
FAR struct ads7843e_config_s *config;
FAR struct spi_dev_s *spi;
struct work_s work;
struct ads7843e_sample_s sample;
struct wdog_s wdog;
* driver events. The 'struct pollfd' reference for each open is also
* retained in the f_priv field of the 'struct file'.
*/
FAR struct pollfd *fds[CONFIG_ADS7843E_NPOLLWAITERS];
};
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif