Skip to content

Commit f3d06eb

Browse files
committed
Merge branch 'fix/prune_dependencies_for_usb_cdc_4g_module' into 'master'
fix(example): prune dependencies for the usb host example See merge request ae_group/esp-iot-solution!1384
2 parents eba3a70 + 5245a1f commit f3d06eb

File tree

9 files changed

+61
-53
lines changed

9 files changed

+61
-53
lines changed

.gitlab/ci/build.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,7 @@ build_example_usb_host_usb_camera_mic_spk:
918918
extends:
919919
- .build_examples_template
920920
- .rules:build:example_usb_host_usb_camera_mic_spk
921-
parallel:
922-
matrix:
923-
- IMAGE: espressif/idf:release-v4.4
924-
- IMAGE: espressif/idf:release-v5.1
921+
- .build_idf_version_greater_equal_v5_0
925922
variables:
926923
EXAMPLE_DIR: examples/usb/host/usb_camera_mic_spk
927924

@@ -984,10 +981,7 @@ build_example_usb_host_usb_msc_ota:
984981
extends:
985982
- .build_examples_template
986983
- .rules:build:example_usb_host_usb_msc_ota
987-
parallel:
988-
matrix:
989-
- IMAGE: espressif/idf:release-v5.0
990-
- IMAGE: espressif/idf:release-v5.1
984+
- .build_idf_version_greater_equal_v5_0
991985
variables:
992986
EXAMPLE_DIR: examples/usb/host/usb_msc_ota
993987

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
dependencies:
2-
idf: ">=4.4.1"
2+
idf: ">=5.0"
33
usb_stream:
44
version: ">=1.0.5"
55
override_path: "../../../../../components/usb/usb_stream"
6-
espressif/esp32_s3_usb_otg:
7-
version: "^1.5.1"
8-
rules:
9-
- if: "target in [esp32s3]"

examples/usb/host/usb_camera_mic_spk/main/main.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -11,12 +11,10 @@
1111
#include "freertos/FreeRTOS.h"
1212
#include "freertos/event_groups.h"
1313
#include "freertos/task.h"
14+
#include "driver/gpio.h"
1415
#include "esp_err.h"
1516
#include "esp_log.h"
1617
#include "usb_stream.h"
17-
#ifdef CONFIG_ESP32_S3_USB_OTG
18-
#include "bsp/esp-bsp.h"
19-
#endif
2018

2119
static const char *TAG = "uvc_mic_spk_demo";
2220
/****************** configure the example working mode *******************************/
@@ -219,8 +217,32 @@ static void stream_state_changed_cb(usb_stream_state_t event, void *arg)
219217
void app_main(void)
220218
{
221219
#ifdef CONFIG_ESP32_S3_USB_OTG
222-
bsp_usb_mode_select_host();
223-
bsp_usb_host_power_mode(BSP_USB_HOST_POWER_MODE_USB_DEV, true);
220+
// USB mode select host
221+
const gpio_config_t io_config = {
222+
.pin_bit_mask = BIT64(GPIO_NUM_18),
223+
.mode = GPIO_MODE_OUTPUT,
224+
.pull_up_en = GPIO_PULLUP_DISABLE,
225+
.pull_down_en = GPIO_PULLDOWN_DISABLE,
226+
.intr_type = GPIO_INTR_DISABLE
227+
};
228+
ESP_ERROR_CHECK(gpio_config(&io_config));
229+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_18, 1));
230+
231+
// Set host usb dev power mode
232+
const gpio_config_t power_io_config = {
233+
.pin_bit_mask = BIT64(GPIO_NUM_17) | BIT64(GPIO_NUM_12) | BIT64(GPIO_NUM_13),
234+
.mode = GPIO_MODE_OUTPUT,
235+
.pull_up_en = GPIO_PULLUP_DISABLE,
236+
.pull_down_en = GPIO_PULLDOWN_DISABLE,
237+
.intr_type = GPIO_INTR_DISABLE
238+
};
239+
ESP_ERROR_CHECK(gpio_config(&power_io_config));
240+
241+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Configure the limiter 500mA
242+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 0));
243+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_13, 0)); // Turn power off
244+
vTaskDelay(pdMS_TO_TICKS(10));
245+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 1)); // Turn on usb dev power mode
224246
#endif
225247
esp_log_level_set("*", ESP_LOG_INFO);
226248
esp_log_level_set("httpd_txrx", ESP_LOG_INFO);

examples/usb/host/usb_cdc_4g_module/main/app_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
#include "ping/ping_sock.h"
3131
#endif
3232

33-
#ifdef CONFIG_ESP32_S3_USB_OTG
34-
#include "bsp/esp-bsp.h"
35-
#endif
36-
3733
static const char *TAG = "4g_main";
3834
#define LED_RED_SYSTEM_GPIO CONFIG_EXAMPLE_LED_RED_SYSTEM_GPIO
3935
#define LED_BLUE_WIFI_GPIO CONFIG_EXAMPLE_LED_BLUE_WIFI_GPIO
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies:
2-
idf: ">=4.4.1"
2+
idf: ">=5.0"
33
cmake_utilities: "0.*"
44
led_indicator:
55
override_path: "../../../../../components/led/led_indicator"
@@ -12,7 +12,3 @@ dependencies:
1212
version: "^0.9.0"
1313
rules:
1414
- if: "target in [esp32p4]"
15-
espressif/esp32_s3_usb_otg:
16-
version: "^2.0"
17-
rules:
18-
- if: "target in [esp32s3]"

examples/usb/host/usb_cdc_4g_module/partitions.csv

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/usb/host/usb_cdc_4g_module/sdkconfig.ci.esp32s3_usb_otg

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
version: 0.0.1
2-
targets:
3-
- esp32s2
4-
- esp32s3
51
dependencies:
2+
idf: ">=5.0"
63
esp_msc_ota:
74
version: "*"
85
override_path: "../../../../../components/usb/esp_msc_ota"
9-
espressif/esp32_s3_usb_otg:
10-
version: "^1.5.1"
11-
rules:
12-
- if: "target in [esp32s3]"
13-
lvgl/lvgl: #temp to workaround bsp issue
14-
version: "9.2.0"

examples/usb/host/usb_msc_ota/main/usb_msc_ota.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -11,9 +11,7 @@
1111
#include "esp_msc_host.h"
1212
#include "esp_msc_ota.h"
1313
#include "usb/usb_host.h"
14-
#ifdef CONFIG_ESP32_S3_USB_OTG
15-
#include "bsp/esp-bsp.h"
16-
#endif
14+
#include "driver/gpio.h"
1715

1816
static const char *TAG = "usb_msc_ota";
1917

@@ -75,8 +73,32 @@ static void msc_ota_event_handler(void *arg, esp_event_base_t event_base,
7573
void app_main(void)
7674
{
7775
#ifdef CONFIG_ESP32_S3_USB_OTG
78-
bsp_usb_mode_select_host();
79-
bsp_usb_host_power_mode(BSP_USB_HOST_POWER_MODE_USB_DEV, true);
76+
// USB mode select host
77+
const gpio_config_t io_config = {
78+
.pin_bit_mask = BIT64(GPIO_NUM_18),
79+
.mode = GPIO_MODE_OUTPUT,
80+
.pull_up_en = GPIO_PULLUP_DISABLE,
81+
.pull_down_en = GPIO_PULLDOWN_DISABLE,
82+
.intr_type = GPIO_INTR_DISABLE
83+
};
84+
ESP_ERROR_CHECK(gpio_config(&io_config));
85+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_18, 1));
86+
87+
// Set host usb dev power mode
88+
const gpio_config_t power_io_config = {
89+
.pin_bit_mask = BIT64(GPIO_NUM_17) | BIT64(GPIO_NUM_12) | BIT64(GPIO_NUM_13),
90+
.mode = GPIO_MODE_OUTPUT,
91+
.pull_up_en = GPIO_PULLUP_DISABLE,
92+
.pull_down_en = GPIO_PULLDOWN_DISABLE,
93+
.intr_type = GPIO_INTR_DISABLE
94+
};
95+
ESP_ERROR_CHECK(gpio_config(&power_io_config));
96+
97+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Configure the limiter 500mA
98+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 0));
99+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_13, 0)); // Turn power off
100+
vTaskDelay(pdMS_TO_TICKS(10));
101+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 1)); // Turn on usb dev power mode
80102
#endif
81103
esp_event_loop_create_default();
82104
ESP_ERROR_CHECK(esp_event_handler_register(ESP_MSC_OTA_EVENT, ESP_EVENT_ANY_ID, &msc_ota_event_handler, NULL));

0 commit comments

Comments
 (0)