1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2018-02-08     Zhangyihong  the first version
9  */
10 
11 #ifndef __DRV_TOUCH_H__
12 #define __DRV_TOUCH_H__
13 
14 #include "rtthread.h"
15 #include "rtdevice.h"
16 
17 #define TOUCH_DBG_LEVEL DBG_INFO
18 
19 #define IIC_RETRY_NUM 2
20 
21 #define TOUCH_EVENT_UP      (0x01)
22 #define TOUCH_EVENT_DOWN    (0x02)
23 #define TOUCH_EVENT_MOVE    (0x03)
24 #define TOUCH_EVENT_NONE    (0x80)
25 
26 struct touch_message
27 {
28     rt_uint16_t x;
29     rt_uint16_t y;
30     rt_uint8_t event;
31 };
32 typedef struct touch_message *touch_msg_t;
33 
34 struct touch_ops
35 {
36     void (* isr_enable)(rt_bool_t);
37     rt_err_t (* read_point)(touch_msg_t);
38     void (* init)(struct rt_i2c_bus_device *);
39     void (* deinit)(void);
40 };
41 typedef struct touch_ops *touch_ops_t;
42 
43 struct touch_drivers
44 {
45     rt_list_t       list;
46     unsigned char   address;
47     rt_bool_t (*probe)(struct rt_i2c_bus_device *i2c_bus);
48     rt_sem_t        isr_sem;
49     touch_ops_t     ops;
50     void           *user_data;
51 };
52 typedef struct touch_drivers *touch_drv_t;
53 
54 extern void rt_touch_drivers_register(touch_drv_t drv);
55 #endif
56