1 /* 2 * COPYRIGHT (C) 2012-2024, Shanghai Real-Thread Technology Co., Ltd 3 * All rights reserved. 4 * Change Logs: 5 * Date Author Notes 6 * 2018-02-08 RT-Thread the first version 7 */ 8 9 #ifndef __DRV_TOUCH_H__ 10 #define __DRV_TOUCH_H__ 11 12 #include <stddef.h> 13 #include "rtthread.h" 14 #include "rtdevice.h" 15 16 #define TOUCH_POLL_MODE (1 << 0) 17 #define TOUCH_INT_MODE (1 << 1) 18 19 struct touch_ops 20 { 21 void (*init)(struct rt_i2c_bus_device *); 22 void (*deinit)(void); 23 rt_err_t (*read_point)(struct rt_touch_data *touch_data, rt_size_t touch_num); 24 }; 25 typedef struct touch_ops *touch_ops_t; 26 27 struct touch_driver 28 { 29 rt_slist_t list; 30 rt_bool_t (*probe)(struct rt_i2c_bus_device *i2c_bus); 31 rt_tick_t read_interval; 32 rt_uint32_t check_mode; 33 touch_ops_t ops; 34 void *user_data; 35 }; 36 typedef struct touch_driver *touch_driver_t; 37 38 rt_err_t rt_touch_drivers_register(touch_driver_t drv); 39 40 int rt_touch_read(rt_uint16_t addr, void *cmd_buf, size_t cmd_len, void *data_buf, size_t data_len); 41 int rt_touch_write(rt_uint16_t addr, void *data_buf, size_t data_len); 42 void touch_coord_convert(int *x, int *y, int range_x, int range_y, int flag); 43 #endif 44