RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
dev_touch.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2024 RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2019-05-20 tyustli the first version
9 */
10
11#ifndef __DEV_TOUCH_H__
12#define __DEV_TOUCH_H__
13
14#include <rtthread.h>
15#include "dev_pin.h"
117
122#ifdef __cplusplus
123extern "C" {
124#endif
125
126#ifdef RT_USING_RTC
127#define rt_touch_get_ts() time(RT_NULL) /* API for the touch to get the timestamp */
128#else
129#define rt_touch_get_ts() rt_tick_get() /* API for the touch to get the timestamp */
130#endif
131
132/* Touch vendor types */
133#define RT_TOUCH_VENDOR_UNKNOWN (0) /* unknown */
134#define RT_TOUCH_VENDOR_GT (1) /* GTxx series */
135#define RT_TOUCH_VENDOR_FT (2) /* FTxx series */
136
137/* Touch ic type*/
138#define RT_TOUCH_TYPE_NONE (0) /* touch ic none */
139#define RT_TOUCH_TYPE_CAPACITANCE (1) /* capacitance ic */
140#define RT_TOUCH_TYPE_RESISTANCE (2) /* resistance ic */
141
142/* Touch control cmd types */
143#define RT_TOUCH_CTRL_GET_ID (RT_DEVICE_CTRL_BASE(Touch) + 0) /* Get device id */
144#define RT_TOUCH_CTRL_GET_INFO (RT_DEVICE_CTRL_BASE(Touch) + 1) /* Get touch info */
145#define RT_TOUCH_CTRL_SET_MODE (RT_DEVICE_CTRL_BASE(Touch) + 2) /* Set touch's work mode. ex. RT_TOUCH_MODE_POLLING,RT_TOUCH_MODE_INT */
146#define RT_TOUCH_CTRL_SET_X_RANGE (RT_DEVICE_CTRL_BASE(Touch) + 3) /* Set x coordinate range */
147#define RT_TOUCH_CTRL_SET_Y_RANGE (RT_DEVICE_CTRL_BASE(Touch) + 4) /* Set y coordinate range */
148#define RT_TOUCH_CTRL_SET_X_TO_Y (RT_DEVICE_CTRL_BASE(Touch) + 5) /* Set X Y coordinate exchange */
149#define RT_TOUCH_CTRL_DISABLE_INT (RT_DEVICE_CTRL_BASE(Touch) + 6) /* Disable interrupt */
150#define RT_TOUCH_CTRL_ENABLE_INT (RT_DEVICE_CTRL_BASE(Touch) + 7) /* Enable interrupt */
151#define RT_TOUCH_CTRL_POWER_ON (RT_DEVICE_CTRL_BASE(Touch) + 8) /* Touch Power On */
152#define RT_TOUCH_CTRL_POWER_OFF (RT_DEVICE_CTRL_BASE(Touch) + 9) /* Touch Power Off */
153#define RT_TOUCH_CTRL_GET_STATUS (RT_DEVICE_CTRL_BASE(Touch) + 10) /* Get Touch Power Status */
154
155/* Touch event */
156#define RT_TOUCH_EVENT_NONE (0) /* Touch none */
157#define RT_TOUCH_EVENT_UP (1) /* Touch up event */
158#define RT_TOUCH_EVENT_DOWN (2) /* Touch down event */
159#define RT_TOUCH_EVENT_MOVE (3) /* Touch move event */
160
165{
166 rt_uint8_t type; /* The touch type */
167 rt_uint8_t vendor; /* Vendor of touchs */
168 rt_uint8_t point_num; /* Support point num */
169 rt_int32_t range_x; /* X coordinate range */
170 rt_int32_t range_y; /* Y coordinate range */
171};
172
177{
178#ifdef RT_TOUCH_PIN_IRQ
179 struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */
180#endif
181 char *dev_name; /* The name of the communication device */
183};
184
190{
191 struct rt_device parent; /* The standard device */
192 struct rt_touch_info info; /* The touch info data */
193 struct rt_touch_config config; /* The touch config data */
194
195 const struct rt_touch_ops *ops; /* The touch ops */
196 rt_err_t (*irq_handle)(rt_touch_t touch); /* Called when an interrupt is generated, registered by the driver */
197};
198
203{
204 rt_uint8_t event; /* The touch event of the data */
205 rt_uint8_t track_id; /* Track id of point */
206 rt_uint8_t width; /* Point of width */
207 rt_uint16_t x_coordinate; /* Point of x coordinate */
208 rt_uint16_t y_coordinate; /* Point of y coordinate */
209 rt_tick_t timestamp; /* The timestamp when the data was received */
210};
211
216{
217 rt_size_t (*touch_readpoint)(struct rt_touch_device *touch, void *buf, rt_size_t touch_num);
218 rt_err_t (*touch_control)(struct rt_touch_device *touch, int cmd, void *arg);
219};
220
230 const char *name,
231 rt_uint32_t flag,
232 void *data);
233
241
242#ifdef __cplusplus
243}
244#endif
245
247
248#endif /* __DEV_TOUCH_H__ */
void rt_hw_touch_isr(rt_touch_t touch)
Touch irq handle
int rt_hw_touch_register(rt_touch_t touch, const char *name, rt_uint32_t flag, void *data)
register a touch device
struct rt_touch_device * rt_touch_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned short rt_uint16_t
rt_uint32_t rt_tick_t
rt_ubase_t rt_size_t
unsigned int rt_uint32_t
signed int rt_int32_t
pin mode structure
Touch configuration
rt_uint16_t x_coordinate
rt_tick_t timestamp
rt_uint16_t y_coordinate
rt_uint8_t track_id
struct rt_touch_info info
rt_err_t(* irq_handle)(rt_touch_t touch)
struct rt_touch_config config
const struct rt_touch_ops * ops
struct rt_device parent
Touch information
rt_int32_t range_y
rt_uint8_t point_num
rt_uint8_t vendor
rt_int32_t range_x
Touch device operations
rt_err_t(* touch_control)(struct rt_touch_device *touch, int cmd, void *arg)
rt_size_t(* touch_readpoint)(struct rt_touch_device *touch, void *buf, rt_size_t touch_num)