tinyusb.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 <stdbool.h>
  16. #include "tusb.h"
  17. #include "tusb_option.h"
  18. #include "tusb_config.h"
  19. #include "tinyusb_types.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* tinyusb uses buffers with type of uint8_t[] but in our driver we are reading them as a 32-bit word */
  24. #if (CFG_TUD_ENDOINT0_SIZE < 4)
  25. # define CFG_TUD_ENDOINT0_SIZE 4
  26. # warning "CFG_TUD_ENDOINT0_SIZE was too low and was set to 4"
  27. #endif
  28. #if TUSB_OPT_DEVICE_ENABLED
  29. # if CFG_TUD_HID
  30. # if (CFG_TUD_HID_BUFSIZE < 4)
  31. # define CFG_TUD_HID_BUFSIZE 4
  32. # warning "CFG_TUD_HID_BUFSIZE was too low and was set to 4"
  33. # endif
  34. # endif
  35. # if CFG_TUD_CDC
  36. # if (CFG_TUD_CDC_EP_BUFSIZE < 4)
  37. # define CFG_TUD_CDC_EP_BUFSIZE 4
  38. # warning "CFG_TUD_CDC_EP_BUFSIZE was too low and was set to 4"
  39. # endif
  40. # endif
  41. # if CFG_TUD_MSC
  42. # if (CFG_TUD_MSC_BUFSIZE < 4)
  43. # define CFG_TUD_MSC_BUFSIZE 4
  44. # warning "CFG_TUD_MSC_BUFSIZE was too low and was set to 4"
  45. # endif
  46. # endif
  47. # if CFG_TUD_MIDI
  48. # if (CFG_TUD_MIDI_EPSIZE < 4)
  49. # define CFG_TUD_MIDI_EPSIZE 4
  50. # warning "CFG_TUD_MIDI_EPSIZE was too low and was set to 4"
  51. # endif
  52. # endif
  53. # if CFG_TUD_CUSTOM_CLASS
  54. # warning "Please check that the buffer is more then 4 bytes"
  55. # endif
  56. #endif
  57. /**
  58. * @brief Configuration structure of the tinyUSB core
  59. */
  60. typedef struct {
  61. tusb_desc_device_t *descriptor; /*!< Pointer to a device descriptor */
  62. char **string_descriptor; /*!< Pointer to an array of string descriptors */
  63. bool external_phy; /*!< Should USB use an external PHY */
  64. } tinyusb_config_t;
  65. esp_err_t tinyusb_driver_install(const tinyusb_config_t *config);
  66. // TODO esp_err_t tinyusb_driver_uninstall(void); (IDF-1474)
  67. #ifdef __cplusplus
  68. }
  69. #endif