tinyusb.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #include "esp_err.h"
  9. #include "tusb.h"
  10. #include "tusb_option.h"
  11. #include "tusb_config.h"
  12. #include "tinyusb_types.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * @brief Configuration structure of the tinyUSB core
  18. */
  19. typedef struct {
  20. union {
  21. const tusb_desc_device_t *device_descriptor; /*!< Pointer to a device descriptor. If set to NULL, the TinyUSB device will use a default device descriptor whose values are set in Kconfig */
  22. const tusb_desc_device_t *descriptor __attribute__((deprecated)); /*!< Alias to `device_descriptor` for backward compatibility */
  23. };
  24. const char **string_descriptor; /*!< Pointer to an array of string descriptors */
  25. bool external_phy; /*!< Should USB use an external PHY */
  26. const uint8_t *configuration_descriptor; /*!< Pointer to a configuration descriptor. If set to NULL, TinyUSB device will use a default configuration descriptor whose values are set in Kconfig */
  27. } tinyusb_config_t;
  28. /**
  29. * @brief This is an all-in-one helper function, including:
  30. * 1. USB device driver initialization
  31. * 2. Descriptors preparation
  32. * 3. TinyUSB stack initialization
  33. * 4. Creates and start a task to handle usb events
  34. *
  35. * @note Don't change Custom descriptor, but if it has to be done,
  36. * Suggest to define as follows in order to match the Interface Association Descriptor (IAD):
  37. * bDeviceClass = TUSB_CLASS_MISC,
  38. * bDeviceSubClass = MISC_SUBCLASS_COMMON,
  39. *
  40. * @param config tinyusb stack specific configuration
  41. * @retval ESP_ERR_INVALID_ARG Install driver and tinyusb stack failed because of invalid argument
  42. * @retval ESP_FAIL Install driver and tinyusb stack failed because of internal error
  43. * @retval ESP_OK Install driver and tinyusb stack successfully
  44. */
  45. esp_err_t tinyusb_driver_install(const tinyusb_config_t *config);
  46. // TODO esp_err_t tinyusb_driver_uninstall(void); (IDF-1474)
  47. #ifdef __cplusplus
  48. }
  49. #endif