1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2023-05-26 Chushicheng the first version 9 */ 10 11 #ifndef __DRV_GT911_H 12 #define __DRV_GT911_H 13 14 #include <rtdevice.h> 15 16 typedef enum 17 { 18 GT911_INT_MODE_IRQ_RISE = 0x00U, 19 GT911_INT_MODE_IRQ_FALL = 0x01U, 20 GT911_INT_MODE_POLL = 0x03U, 21 } gt911_int_mode_t; 22 23 typedef struct 24 { 25 rt_uint8_t id; 26 rt_uint16_t pos_x; 27 rt_uint16_t pos_y; 28 rt_uint16_t size; 29 } gt911_point_t; 30 31 typedef struct 32 { 33 rt_uint8_t num_pos; 34 gt911_point_t pos[5]; 35 } gt911_input_t; 36 37 typedef struct 38 { 39 rt_uint8_t *tx_data; 40 rt_uint8_t *rx_data; 41 rt_uint16_t tx_len; 42 rt_uint16_t rx_len; 43 } gt911_i2c_xfer_t; 44 45 typedef rt_err_t (*gt911_ops_reset_t)(void *handle); 46 typedef rt_err_t (*gt911_ops_i2c_xfer_t)(void *handle, gt911_i2c_xfer_t *xfer); 47 48 typedef struct 49 { 50 gt911_ops_reset_t reset; 51 gt911_ops_i2c_xfer_t xfer; 52 } gt911_ops_t; 53 54 typedef struct 55 { 56 rt_uint16_t pos_x_max; 57 rt_uint16_t pos_y_max; 58 rt_uint8_t pos_max; 59 rt_uint8_t fw_version; 60 gt911_int_mode_t int_mode; 61 gt911_ops_t ops; 62 void *user_data; 63 } gt911_t; 64 65 typedef struct 66 { 67 struct rt_device parent; 68 struct rt_i2c_bus_device *bus; 69 gt911_t gt911; 70 } capt_t; 71 72 rt_err_t gt911_ctp_read(gt911_t *ctp, gt911_input_t *input); 73 int drv_capt_hw_init(void); 74 75 #endif /* __DRV_GT911_H */ 76