hid.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**@file hid.h
  2. * @brief hid驱动头文件(做主机)
  3. * @details 结构体声明,功能函数声明
  4. * @author jieli
  5. * @date 2021-9-1
  6. * @version V1.0
  7. * @copyright Copyright(c)2010-2021 珠海市杰理科技股份有限公司
  8. *********************************************************
  9. * @attention
  10. * 硬件平台:AC632N
  11. * SDK版本:AC632N_V1.0.0_SDK
  12. * @修改日志:
  13. * <table>
  14. * <tr><th>Date <th>Version <th>Author <th>Description
  15. * <tr><td>2021-9-1 <td>1.0 <td>jieli <td>创建初始版本
  16. * </table>
  17. *
  18. *********************************************************
  19. */
  20. #ifndef __HID_H__
  21. #define __HID_H__
  22. #include "system/task.h"
  23. #include "device/device.h"
  24. #include "usb/scsi.h"
  25. #include "usb_bulk_transfer.h"
  26. #include "usb/host/usb_host.h"
  27. /**@struct report_info_t
  28. * @brief 报告描述符包含的信息结构体\n
  29. * 自定义一些私有数据信息存储在该结构体中
  30. */
  31. struct report_info_t {
  32. u8 report_id; ///<id号,不同hid设备对应不同id
  33. u8 usage; ///<描述该数据信息的用途
  34. u8 btn_start_bit; ///<鼠标按键数据起始位
  35. u8 btn_width; ///<鼠标按键数据宽度
  36. u8 xy_start_bit; ///<鼠标平移数据起始位
  37. u8 xy_width; ///<鼠标平移数据宽度
  38. u8 wheel_start_bit; ///<鼠标滚轮数据起始位
  39. u8 wheel_width; ///<鼠标滚轮数据宽度
  40. };
  41. #define MAX_REPORT_COUNT 4
  42. /**@struct hid_device_t
  43. * @brief 报告描述符包含的信息结构体\n
  44. * 自定义一些私有数据信息存储在该结构体中
  45. */
  46. struct hid_device_t {
  47. void *parent; ///<定义的parent指针,指向该hid的所属设备
  48. u8 ep_pair[4]; ///<端点对数组,数组下标存放主机端点,对应的元素存放目标端点
  49. u8 report_count; ///<报告描述符中item计数器
  50. u8 bNumEndpoints; ///<端点数量
  51. struct report_info_t report_list[MAX_REPORT_COUNT]; ///<报告描述符结构体
  52. };
  53. /**@brief USB hid设备解析
  54. * @param[in] host_dev usb_host_device定义的结构体指针
  55. * @param[in] interface_num 接口号
  56. * @param[in] *pBuf 数据指针,指向数据存放的地址
  57. * @return 接口描述符长度
  58. * @par 示例:
  59. * @code
  60. * usb_hid_parser(host_dev,interface_num,pBuf);
  61. * @encode
  62. */
  63. int usb_hid_parser(struct usb_host_device *host_dev, u8 interface_num, const u8 *pBuf);
  64. /**@brief USB hid设备信息处理
  65. * @param[in] id usb设备id号
  66. * @return 无
  67. * @par 示例:
  68. * @code
  69. * hid_process(id);
  70. * @encode
  71. */
  72. void hid_process(u32 id);
  73. #endif /*HID_H*/