drv_gt911.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef __DRV_GT911_H
  11. #define __DRV_GT911_H
  12. #include <rtdevice.h>
  13. typedef enum
  14. {
  15. GT911_INT_MODE_IRQ_RISE = 0x00U,
  16. GT911_INT_MODE_IRQ_FALL = 0x01U,
  17. GT911_INT_MODE_POLL = 0x03U,
  18. } gt911_int_mode_t;
  19. typedef struct
  20. {
  21. rt_uint8_t id;
  22. rt_uint16_t pos_x;
  23. rt_uint16_t pos_y;
  24. rt_uint16_t size;
  25. } gt911_point_t;
  26. typedef struct
  27. {
  28. rt_uint8_t num_pos;
  29. gt911_point_t pos[5];
  30. } gt911_input_t;
  31. typedef struct
  32. {
  33. rt_uint8_t *tx_data;
  34. rt_uint8_t *rx_data;
  35. rt_uint16_t tx_len;
  36. rt_uint16_t rx_len;
  37. } gt911_i2c_xfer_t;
  38. typedef rt_err_t (*gt911_ops_reset_t)(void *handle);
  39. typedef rt_err_t (*gt911_ops_i2c_xfer_t)(void *handle, gt911_i2c_xfer_t *xfer);
  40. typedef struct
  41. {
  42. gt911_ops_reset_t reset;
  43. gt911_ops_i2c_xfer_t xfer;
  44. } gt911_ops_t;
  45. typedef struct
  46. {
  47. rt_uint16_t pos_x_max;
  48. rt_uint16_t pos_y_max;
  49. rt_uint8_t pos_max;
  50. rt_uint8_t fw_version;
  51. gt911_int_mode_t int_mode;
  52. gt911_ops_t ops;
  53. void *user_data;
  54. } gt911_t;
  55. typedef struct
  56. {
  57. struct rt_device parent;
  58. struct rt_i2c_bus_device *bus;
  59. gt911_t gt911;
  60. } capt_t;
  61. rt_err_t gt911_ctp_read(gt911_t *ctp, gt911_input_t *input);
  62. int drv_capt_hw_init(void);
  63. #endif /* __DRV_GT911_H */