Fix interface iStrings.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2026-04-20 23:49:31 +02:00
parent 26de18608f
commit 50bb75bdd6
2 changed files with 20 additions and 10 deletions

View File

@@ -108,7 +108,7 @@ void execute_tasks(void) {
tud_task(); // tinyusb device task
#endif
#ifdef USB_ITF_LWIP
#if !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
#if !defined(ENABLE_EMULATION)
service_traffic();
#endif
rest_task();
@@ -119,6 +119,11 @@ void execute_tasks(void) {
static void core0_loop(void *arg) {
(void)arg;
#if defined(ESP_PLATFORM) && defined(USB_ITF_LWIP)
if (ITF_LWIP_TOTAL > 0) {
lwip_itf_init();
}
#endif
while (1) {
execute_tasks();
hwrng_task();
@@ -133,6 +138,8 @@ static void core0_loop(void *arg) {
#ifdef ESP_PLATFORM
extern tinyusb_config_t tusb_cfg;
extern const uint8_t desc_config[];
extern char *string_desc_arr[];
extern char *string_desc_itf[];
TaskHandle_t hcore0 = NULL, hcore1 = NULL;
int app_main(void) {
#else
@@ -178,13 +185,16 @@ int main(void) {
if (phy_data.usb_product_present) {
tusb_cfg.string_descriptor[2] = phy_data.usb_product;
}
static char tmps[4][32];
for (int i = 4; i < tusb_cfg.string_descriptor_count; i++) {
strlcpy(tmps[i-4], tusb_cfg.string_descriptor[2], sizeof(tmps[0]));
strlcat(tmps[i-4], " ", sizeof(tmps[0]));
strlcat(tmps[i-4], tusb_cfg.string_descriptor[i], sizeof(tmps[0]));
tusb_cfg.string_descriptor[i] = tmps[i-4];
static char tmps[5][32];
const int max_desc_slots = 8 - 6;
const int itf_desc_count = ITF_TOTAL < max_desc_slots ? ITF_TOTAL : max_desc_slots;
for (int i = 0; i < itf_desc_count; i++) {
strlcpy(tmps[i], tusb_cfg.string_descriptor[2], sizeof(tmps[0]));
strlcat(tmps[i], " ", sizeof(tmps[0]));
strlcat(tmps[i], string_desc_itf[i], sizeof(tmps[0]));
tusb_cfg.string_descriptor[i+6] = tmps[i];
}
tusb_cfg.string_descriptor_count = 6 + itf_desc_count;
tusb_cfg.configuration_descriptor = desc_config;
tinyusb_driver_install(&tusb_cfg);

View File

@@ -200,7 +200,7 @@ void usb_desc_setup(void) {
#ifdef USB_ITF_LWIP
if (ITF_LWIP != ITF_INVALID) {
TUSB_DESC_TOTAL_LEN += TUD_CDC_NCM_DESC_LEN;
const uint8_t desc_lwip[] = { TUD_CDC_NCM_DESCRIPTOR(ITF_LWIP, ITF_LWIP + 6, 5, EPNUM_LWIP_NOTIF, 64, EPNUM_LWIP, EPNUM_LWIP | TUSB_DIR_IN_MASK, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU) };
const uint8_t desc_lwip[] = { TUD_CDC_NCM_DESCRIPTOR(ITF_LWIP, ITF_LWIP + 6, 5, EPNUM_LWIP_NOTIF | TUSB_DIR_IN_MASK, 64, EPNUM_LWIP, EPNUM_LWIP | TUSB_DIR_IN_MASK, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU) };
memcpy(p, desc_lwip, sizeof(desc_lwip));
p += sizeof(desc_lwip);
}
@@ -344,7 +344,7 @@ uint8_t const *tud_descriptor_bos_cb(void) {
//--------------------------------------------------------------------+
// array of pointer to string descriptors
char *string_desc_itf[4] = {0};
char *string_desc_itf[5] = {0};
char const *string_desc_arr [] = {
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"Pol Henarejos", // 1: Manufacturer
@@ -367,7 +367,7 @@ char const *string_desc_arr [] = {
tinyusb_config_t tusb_cfg = {
.device_descriptor = &desc_device,
.string_descriptor = string_desc_arr,
.string_descriptor_count = (sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) > 8 ? 8 : (sizeof(string_desc_arr) / sizeof(string_desc_arr[0])),
.string_descriptor_count = (sizeof(string_desc_arr) / sizeof(string_desc_arr[0])),
.external_phy = false,
.configuration_descriptor = desc_config,
};