mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-06 16:51:36 +00:00
tiny_usb: rename Kconfig name
1. Renamed Kconfig file of tinyusb (distinguish tinyusb stack from usb peripheral) 2. bugfix/typofix/doc update of tinyusb
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "hal/gpio_ll.h"
|
||||
#include "hal/usb_hal.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "descriptors_control.h"
|
||||
#include "tusb.h"
|
||||
#include "tusb_tasks.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
|
||||
const static char *TAG = "TinyUSB";
|
||||
|
||||
@@ -57,62 +55,30 @@ static void configure_pins(usb_hal_context_t *usb)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the tinyUSB driver.
|
||||
*
|
||||
* Note: Do not change any Custom descriptor, but
|
||||
* if it used it is recomended to define: bDeviceClass = TUSB_CLASS_MISC,
|
||||
* bDeviceSubClass = MISC_SUBCLASS_COMMON and bDeviceClass = TUSB_CLASS_MISC
|
||||
* to match with Interface Association Descriptor (IAD) for CDC
|
||||
*
|
||||
* @param config if equal to NULL the default descriptor will be used
|
||||
* @return esp_err_t Errors during the initialization
|
||||
*/
|
||||
esp_err_t tinyusb_driver_install(const tinyusb_config_t *config)
|
||||
{
|
||||
tusb_desc_device_t *descriptor;
|
||||
int res;
|
||||
char **string_descriptor;
|
||||
ESP_LOGI(TAG, "Driver installation...");
|
||||
|
||||
periph_module_reset(PERIPH_USB_MODULE);
|
||||
tusb_desc_device_t *dev_descriptor;
|
||||
const char **string_descriptor;
|
||||
ESP_RETURN_ON_FALSE(config, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
// Enable APB CLK to USB peripheral
|
||||
periph_module_enable(PERIPH_USB_MODULE);
|
||||
|
||||
// Hal init
|
||||
periph_module_reset(PERIPH_USB_MODULE);
|
||||
// Initialize HAL layer
|
||||
usb_hal_context_t hal = {
|
||||
.use_external_phy = config->external_phy
|
||||
};
|
||||
usb_hal_init(&hal);
|
||||
configure_pins(&hal);
|
||||
|
||||
if (config->descriptor == NULL) {
|
||||
descriptor = &descriptor_kconfig;
|
||||
} else {
|
||||
descriptor = config->descriptor;
|
||||
}
|
||||
dev_descriptor = config->descriptor ? config->descriptor : &descriptor_kconfig;
|
||||
string_descriptor = config->string_descriptor ? config->string_descriptor : descriptor_str_kconfig;
|
||||
|
||||
tusb_set_descriptor(dev_descriptor, string_descriptor);
|
||||
|
||||
if (config->string_descriptor == NULL) {
|
||||
string_descriptor = descriptor_str_kconfig;
|
||||
} else {
|
||||
string_descriptor = config->string_descriptor;
|
||||
}
|
||||
|
||||
tusb_set_descriptor(descriptor,
|
||||
string_descriptor);
|
||||
|
||||
if (!tusb_init()) {
|
||||
ESP_LOGE(TAG, "Can't initialize the TinyUSB stack.");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#if !CONFIG_USB_DO_NOT_CREATE_TASK
|
||||
res = tusb_run_task();
|
||||
if (res != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Can't create the TinyUSB task.");
|
||||
return res;
|
||||
}
|
||||
ESP_RETURN_ON_FALSE(tusb_init(), ESP_FAIL, TAG, "Init TinyUSB stack failed");
|
||||
#if !CONFIG_TINYUSB_NO_DEFAULT_TASK
|
||||
ESP_RETURN_ON_ERROR(tusb_run_task(), TAG, "Run TinyUSB task failed");
|
||||
#endif
|
||||
ESP_LOGI(TAG, "Driver installed");
|
||||
ESP_LOGI(TAG, "TinyUSB Driver installed");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user