drv_touch.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2006-2022, 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. #ifndef __DRV_TOUCH_H__
  11. #define __DRV_TOUCH_H__
  12. #include "rtthread.h"
  13. #include "rtdevice.h"
  14. #define TOUCH_DBG_LEVEL DBG_LOG
  15. #define IIC_RETRY_NUM 2
  16. #define TOUCH_EVENT_UP (0x01)
  17. #define TOUCH_EVENT_DOWN (0x02)
  18. #define TOUCH_EVENT_MOVE (0x03)
  19. #define TOUCH_EVENT_NONE (0x80)
  20. struct touch_message
  21. {
  22. rt_uint16_t x;
  23. rt_uint16_t y;
  24. rt_uint8_t event;
  25. };
  26. typedef struct touch_message *touch_msg_t;
  27. struct touch_ops
  28. {
  29. void (* isr_enable)(rt_bool_t);
  30. rt_err_t (* read_point)(touch_msg_t);
  31. void (* init)(struct rt_i2c_bus_device *);
  32. void (* deinit)(void);
  33. };
  34. typedef struct touch_ops *touch_ops_t;
  35. struct touch_drivers
  36. {
  37. rt_list_t list;
  38. unsigned char address;
  39. rt_bool_t (*probe)(struct rt_i2c_bus_device *i2c_bus);
  40. rt_sem_t isr_sem;
  41. touch_ops_t ops;
  42. void *user_data;
  43. };
  44. typedef struct touch_drivers *touch_drv_t;
  45. extern void rt_touch_drivers_register(touch_drv_t drv);
  46. #endif