|
8 | 8 | #include <string.h> |
9 | 9 | #include "freertos/FreeRTOS.h" |
10 | 10 | #include "freertos/task.h" |
| 11 | +#include "driver/gpio.h" |
11 | 12 | #include "esp_log.h" |
12 | 13 | #include "iot_usbh_cdc.h" |
13 | | -#ifdef CONFIG_ESP32_S3_USB_OTG |
14 | | -#include "bsp/esp-bsp.h" |
15 | | -#endif |
16 | 14 |
|
17 | 15 | static const char *TAG = "cdc_basic_demo"; |
18 | 16 |
|
@@ -62,8 +60,32 @@ static void usb_disconnect_callback(usbh_cdc_handle_t cdc_handle, void *user_dat |
62 | 60 | void app_main(void) |
63 | 61 | { |
64 | 62 | #ifdef CONFIG_ESP32_S3_USB_OTG |
65 | | - bsp_usb_mode_select_host(); |
66 | | - bsp_usb_host_power_mode(BSP_USB_HOST_POWER_MODE_USB_DEV, true); |
| 63 | + // USB mode select host |
| 64 | + const gpio_config_t io_config = { |
| 65 | + .pin_bit_mask = BIT64(GPIO_NUM_18), |
| 66 | + .mode = GPIO_MODE_OUTPUT, |
| 67 | + .pull_up_en = GPIO_PULLUP_DISABLE, |
| 68 | + .pull_down_en = GPIO_PULLDOWN_DISABLE, |
| 69 | + .intr_type = GPIO_INTR_DISABLE |
| 70 | + }; |
| 71 | + ESP_ERROR_CHECK(gpio_config(&io_config)); |
| 72 | + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_18, 1)); |
| 73 | + |
| 74 | + // Set host usb dev power mode |
| 75 | + const gpio_config_t power_io_config = { |
| 76 | + .pin_bit_mask = BIT64(GPIO_NUM_17) | BIT64(GPIO_NUM_12) | BIT64(GPIO_NUM_13), |
| 77 | + .mode = GPIO_MODE_OUTPUT, |
| 78 | + .pull_up_en = GPIO_PULLUP_DISABLE, |
| 79 | + .pull_down_en = GPIO_PULLDOWN_DISABLE, |
| 80 | + .intr_type = GPIO_INTR_DISABLE |
| 81 | + }; |
| 82 | + ESP_ERROR_CHECK(gpio_config(&power_io_config)); |
| 83 | + |
| 84 | + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Configure the limiter 500mA |
| 85 | + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 0)); |
| 86 | + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_13, 0)); // Turn power off |
| 87 | + vTaskDelay(pdMS_TO_TICKS(10)); |
| 88 | + ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 1)); // Turn on usb dev power mode |
67 | 89 | #endif |
68 | 90 | /* install usbh cdc driver with skip_init_usb_host_driver */ |
69 | 91 | usbh_cdc_driver_config_t config = { |
|
0 commit comments