drv_touch.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef __DRV_TOUCH_H__
  9. #define __DRV_TOUCH_H__
  10. #include <stddef.h>
  11. #include "rtthread.h"
  12. #include "rtdevice.h"
  13. #define TOUCH_POLL_MODE (1 << 0)
  14. #define TOUCH_INT_MODE (1 << 1)
  15. struct touch_ops
  16. {
  17. void (*init)(struct rt_i2c_bus_device *);
  18. void (*deinit)(void);
  19. rt_err_t (*read_point)(struct rt_touch_data *touch_data, rt_size_t touch_num);
  20. };
  21. typedef struct touch_ops *touch_ops_t;
  22. struct touch_driver
  23. {
  24. rt_slist_t list;
  25. rt_bool_t (*probe)(struct rt_i2c_bus_device *i2c_bus);
  26. rt_tick_t read_interval;
  27. rt_uint32_t check_mode;
  28. touch_ops_t ops;
  29. void *user_data;
  30. };
  31. typedef struct touch_driver *touch_driver_t;
  32. rt_err_t rt_touch_drivers_register(touch_driver_t drv);
  33. int rt_touch_read(rt_uint16_t addr, void *cmd_buf, size_t cmd_len, void *data_buf, size_t data_len);
  34. int rt_touch_write(rt_uint16_t addr, void *data_buf, size_t data_len);
  35. void touch_coord_convert(int *x, int *y, int range_x, int range_y, int flag);
  36. #endif