descriptors_control.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <string.h>
  16. #include "usb_descriptors.h"
  17. /* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
  18. * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
  19. *
  20. * Auto ProductID layout's Bitmap:
  21. * [MSB] HID | MSC | CDC [LSB]
  22. */
  23. #define EPNUM_MSC 0x03
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. //------------- HID Report Descriptor -------------//
  28. #if CFG_TUD_HID
  29. enum {
  30. REPORT_ID_KEYBOARD = 1,
  31. REPORT_ID_MOUSE
  32. };
  33. #endif
  34. //------------- Configuration Descriptor -------------//
  35. enum {
  36. # if CFG_TUD_CDC
  37. ITF_NUM_CDC = 0,
  38. ITF_NUM_CDC_DATA,
  39. # endif
  40. # if CFG_TUD_MSC
  41. ITF_NUM_MSC,
  42. # endif
  43. # if CFG_TUD_HID
  44. ITF_NUM_HID,
  45. # endif
  46. ITF_NUM_TOTAL
  47. };
  48. enum {
  49. CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN +
  50. CFG_TUD_HID * TUD_HID_DESC_LEN
  51. };
  52. bool tusb_desc_set;
  53. void tusb_set_descriptor(tusb_desc_device_t *desc, char **str_desc);
  54. tusb_desc_device_t *tusb_get_active_desc(void);
  55. char **tusb_get_active_str_desc(void);
  56. void tusb_clear_descriptor(void);
  57. #ifdef __cplusplus
  58. }
  59. #endif