drv_touch.h 1.1 KB

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