Skip to content

Commit 272a9a1

Browse files
committed
Merge branch 'fix/usb_extern_lcd_example_uac' into 'master'
fix(usb_extern_lcd): Optimize audio output See merge request ae_group/esp-iot-solution!1303
2 parents ad34908 + de885ec commit 272a9a1

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

examples/usb/device/usb_extend_screen/main/Kconfig.projbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ menu "Example Configuration"
7373

7474
config USB_TASK_PRIORITY
7575
int "USB Task Priority"
76-
default 5
76+
default 6
7777
range 1 15
7878
help
7979
TinyUSB main task priority
8080

8181
config VENDOR_TASK_PRIORITY
8282
int "Vendor Task Priority"
83-
default 10
83+
default 5
8484
range 1 15
8585
help
8686
Task to receive JPG data from PC

examples/usb/device/usb_extend_screen/main/app_uac.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ esp_err_t app_uac_init(void)
5757
.set_mute_cb = uac_device_set_mute_cb,
5858
.set_volume_cb = uac_device_set_volume_cb,
5959
.cb_ctx = NULL,
60+
#if CONFIG_UAC_SPEAKER_CHANNEL_NUM > 0
6061
.spk_itf_num = ITF_NUM_AUDIO_STREAMING_SPK,
62+
#endif
63+
#if CONFIG_UAC_MIC_CHANNEL_NUM > 0
6164
.mic_itf_num = ITF_NUM_AUDIO_STREAMING_MIC,
65+
#endif
6266
};
6367

6468
uac_device_init(&config);

examples/usb/device/usb_extend_screen/main/app_vendor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ void tud_vendor_rx_cb(uint8_t itf, uint8_t const* buffer, uint16_t bufsize)
121121
skip_frame = true;
122122
buffer_skip(&skip_frame_info, read_res - sizeof(udisp_frame_header_t));
123123
ESP_LOGE(TAG, "Get frame is null");
124+
// Feed the task dog
125+
vTaskDelay(1 / portTICK_PERIOD_MS);
124126
}
125127
break;
126128
}
@@ -146,6 +148,6 @@ void tud_vendor_rx_cb(uint8_t itf, uint8_t const* buffer, uint16_t bufsize)
146148

147149
esp_err_t app_vendor_init(void)
148150
{
149-
xTaskCreatePinnedToCore(transfer_task, "transfer_task", 4096, NULL, CONFIG_VENDOR_TASK_PRIORITY, NULL, 0);
151+
xTaskCreatePinnedToCore(transfer_task, "transfer_task", 4096, NULL, CONFIG_VENDOR_TASK_PRIORITY, NULL, 1);
150152
return ESP_OK;
151153
}

examples/usb/device/usb_extend_screen/main/tusb/usb_descriptors.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance)
9494
}
9595
#endif
9696

97+
enum {
98+
STR_INDEX_VENDOR = 4,
99+
#if CFG_TUD_HID
100+
STR_INDEX_HID,
101+
#endif
102+
#if CFG_TUD_AUDIO
103+
STR_INDEX_AUDIO,
104+
#endif
105+
};
106+
97107
//--------------------------------------------------------------------+
98108
// Configuration Descriptor
99109
//--------------------------------------------------------------------+
@@ -107,14 +117,14 @@ uint8_t const desc_fs_configuration[] = {
107117
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0, 100),
108118
// Interface number, string index, EP Out & IN address, EP size
109119
#if CFG_TUD_VENDOR
110-
TUD_VENDOR_DESCRIPTOR(ITF_NUM_VENDOR, 4, EPNUM_VENDOR, 0x80 | EPNUM_VENDOR, CFG_TUD_VENDOR_EPSIZE),
120+
TUD_VENDOR_DESCRIPTOR(ITF_NUM_VENDOR, STR_INDEX_VENDOR, EPNUM_VENDOR, 0x80 | EPNUM_VENDOR, CFG_TUD_VENDOR_EPSIZE),
111121
#endif
112122
#if CFG_TUD_HID
113123
// Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval
114-
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 5, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), (0x80 | EPNUM_HID_DATA), CFG_TUD_HID_EP_BUFSIZE, 10),
124+
TUD_HID_DESCRIPTOR(ITF_NUM_HID, STR_INDEX_HID, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), (0x80 | EPNUM_HID_DATA), CFG_TUD_HID_EP_BUFSIZE, 10),
115125
#endif
116126
#if CFG_TUD_AUDIO
117-
TUD_AUDIO_DESCRIPTOR(ITF_NUM_AUDIO_CONTROL, 6, EPNUM_AUDIO_OUT, (0x80 | EPNUM_AUDIO_IN), (0x80 | EPNUM_AUDIO_FB)),
127+
TUD_AUDIO_DESCRIPTOR(ITF_NUM_AUDIO_CONTROL, STR_INDEX_AUDIO, EPNUM_AUDIO_OUT, (0x80 | EPNUM_AUDIO_IN), (0x80 | EPNUM_AUDIO_FB)),
118128
#endif
119129
};
120130

examples/usb/device/usb_extend_screen/main/tusb/usb_descriptors.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#pragma once
2828
#include "tusb.h"
29+
#include "sdkconfig.h"
2930

3031
enum {
3132
REPORT_ID_TOUCH = 1,
@@ -40,8 +41,12 @@ enum {
4041
#endif
4142
#if CFG_TUD_AUDIO
4243
ITF_NUM_AUDIO_CONTROL,
44+
#if CONFIG_UAC_SPEAKER_CHANNEL_NUM > 0
4345
ITF_NUM_AUDIO_STREAMING_SPK,
46+
#endif
47+
#if CONFIG_UAC_MIC_CHANNEL_NUM > 0
4448
ITF_NUM_AUDIO_STREAMING_MIC,
49+
#endif
4550
#endif
4651
ITF_NUM_TOTAL,
4752
};

examples/usb/device/usb_extend_screen/sdkconfig.defaults

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ CONFIG_COMPILER_OPTIMIZATION_PERF=y
77
CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y
88
CONFIG_FREERTOS_HZ=1000
99
CONFIG_USB_DEVICE_UAC_AS_PART=y
10+
11+
CONFIG_UAC_SPK_TASK_PRIORITY=6
12+
CONFIG_UAC_MIC_TASK_PRIORITY=6

examples/usb/device/usb_extend_screen/sdkconfig.defaults.esp32s3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Compiler options
33
#
44
CONFIG_COMPILER_OPTIMIZATION_PERF=y
5+
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
56

67
#
78
# ESP PSRAM

0 commit comments

Comments
 (0)