diff options
| author | sakumisu <[email protected]> | 2024-05-17 21:56:56 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-05-17 22:18:21 +0800 |
| commit | 66b893e64ff2481003d811f1ac1a5887b033346e (patch) | |
| tree | 7d9f595bd0abf71020fe6e130a5fe1a7547d67cf | |
| parent | 3a3de9cb6987687e6abff846c1419b695227d958 (diff) | |
update: add langid in string desc
| -rw-r--r-- | cherryusb_config_template.h | 4 | ||||
| -rw-r--r-- | core/usbd_core.c | 19 | ||||
| -rw-r--r-- | demo/cdc_acm_msc_template.c | 5 |
3 files changed, 12 insertions, 16 deletions
diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h index 5e5a5829..2128480f 100644 --- a/cherryusb_config_template.h +++ b/cherryusb_config_template.h @@ -33,10 +33,6 @@ /* ================= USB Device Stack Configuration ================ */ -#ifndef CONFIG_USBDEV_STRING_LANGID -#define CONFIG_USBDEV_STRING_LANGID 0x0409 -#endif - /* Ep0 in and out transfer buffer */ #ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN #define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512 diff --git a/core/usbd_core.c b/core/usbd_core.c index 05152fa0..edac6a3b 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -187,22 +187,21 @@ static bool usbd_get_descriptor(uint8_t busid, uint16_t type_index, uint8_t **da desc = (uint8_t *)g_usbd_core[busid].descriptors->msosv1_descriptor->string; desc_len = g_usbd_core[busid].descriptors->msosv1_descriptor->string[0]; } else { - if (index == USB_STRING_LANGID_INDEX) { - uint16_t STRING_LANGID = CONFIG_USBDEV_STRING_LANGID; + string = g_usbd_core[busid].descriptors->string_descriptor_callback(g_usbd_core[busid].speed, index); + if (string == NULL) { + found = false; + break; + } - (*data)[0] = 0x04; + if (index == USB_STRING_LANGID_INDEX) { + (*data)[0] = 4; (*data)[1] = USB_DESCRIPTOR_TYPE_STRING; - (*data)[2] = (uint8_t)(STRING_LANGID & 0xff); - (*data)[3] = (uint8_t)((STRING_LANGID & 0xff00) >> 8); + (*data)[2] = string[0]; + (*data)[3] = string[1]; *len = 4; return true; } - string = g_usbd_core[busid].descriptors->string_descriptor_callback(g_usbd_core[busid].speed, index); - if (string == NULL) { - found = false; - break; - } uint16_t str_size = strlen(string); uint16_t total_size = 2 * str_size + 2; diff --git a/demo/cdc_acm_msc_template.c b/demo/cdc_acm_msc_template.c index a617ed30..7ab58106 100644 --- a/demo/cdc_acm_msc_template.c +++ b/demo/cdc_acm_msc_template.c @@ -63,8 +63,9 @@ static const uint8_t device_quality_descriptor[] = { }; static const char *string_descriptors[] = { + (const char[]){ 0x09, 0x04 }, /* Langid */ "CherryUSB", /* Manufacturer */ - "CherryUSB CDC DEMO", /* Product */ + "CherryUSB CDC MSC DEMO", /* Product */ "2022123456", /* Serial Number */ }; @@ -88,7 +89,7 @@ static const char *string_descriptor_callback(uint8_t speed, uint8_t index) if (index > 3) { return NULL; } - return string_descriptors[index - 1]; + return string_descriptors[index]; } const struct usb_descriptor cdc_msc_descriptor = { |
