usbd_hid.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. ******************************************************************************
  3. * @file usbd_hid.h
  4. * @author MCD Application Team
  5. * @version V2.4.1
  6. * @date 19-June-2015
  7. * @brief Header file for the usbd_hid_core.c file.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. #ifndef __USB_HID_H
  28. #define __USB_HID_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include "usbd_ioreq.h"
  33. #define HID_EPIN_ADDR 0x82
  34. #define HID_EPIN_SIZE 0x40
  35. // Not sequential to allow the MSC to have the 2nd transmit fifo. See
  36. // USBD_LL_Init
  37. #define HID_EPOUT_ADDR 0x02
  38. #define HID_EPOUT_SIZE 0x40
  39. #define USB_HID_DESC_SIZ 9
  40. #define HID_GENERIC_REPORT_DESC_SIZE 37
  41. #define HID_DESCRIPTOR_TYPE 0x21
  42. #define HID_REPORT_DESC 0x22
  43. #define HID_FS_BINTERVAL 0x20 // 32ms
  44. #define HID_HS_BINTERVAL 0x9
  45. #define HID_REQ_SET_PROTOCOL 0x0B
  46. #define HID_REQ_GET_PROTOCOL 0x03
  47. #define HID_REQ_SET_IDLE 0x0A
  48. #define HID_REQ_GET_IDLE 0x02
  49. #define HID_REQ_SET_REPORT 0x09
  50. #define HID_REQ_GET_REPORT 0x01
  51. typedef enum
  52. {
  53. HID_IDLE = 0,
  54. HID_BUSY,
  55. }
  56. HID_StateTypeDef;
  57. typedef struct
  58. {
  59. uint32_t Protocol;
  60. uint32_t IdleState;
  61. uint32_t AltSetting;
  62. HID_StateTypeDef state;
  63. __ALIGN_BEGIN uint8_t rxBuffer[HID_EPOUT_SIZE] __ALIGN_END;
  64. __ALIGN_BEGIN uint8_t txBuffer[HID_EPOUT_SIZE] __ALIGN_END;
  65. int reportReady;
  66. }
  67. USBD_HID_HandleTypeDef;
  68. uint8_t USBD_HID_IsBusy(USBD_HandleTypeDef *pdev);
  69. uint8_t USBD_HID_SendReport (
  70. USBD_HandleTypeDef *pdev,
  71. const uint8_t *report,
  72. uint16_t len);
  73. uint8_t USBD_HID_IsReportReady(USBD_HandleTypeDef *pdev);
  74. uint8_t USBD_HID_GetReport(USBD_HandleTypeDef *pdev,
  75. uint8_t *report,
  76. uint8_t maxLen);
  77. uint32_t USBD_HID_GetPollingInterval (USBD_HandleTypeDef *pdev);
  78. const uint8_t* USBD_HID_GetReportDesc();
  79. const uint8_t* USBD_HID_GetDesc();
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif