From 16f55a5a195b1283cdb0a56eb29807a05eeb96b0 Mon Sep 17 00:00:00 2001 From: sakimisu <1203593632@qq.com> Date: Mon, 28 Nov 2022 21:56:30 +0800 Subject: [PATCH] split other_speed with fs and hs --- core/usbd_core.c | 20 +++++++++++++++----- core/usbd_core.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/usbd_core.c b/core/usbd_core.c index 6689e1e8..2fc8a363 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -218,12 +218,22 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l break; case USB_DESCRIPTOR_TYPE_OTHER_SPEED: - if (usbd_core_cfg.descriptors->other_speed_descriptor) { - *data = (uint8_t *)usbd_core_cfg.descriptors->other_speed_descriptor; - *len = (usbd_core_cfg.descriptors->other_speed_descriptor[CONF_DESC_wTotalLength] | - (usbd_core_cfg.descriptors->other_speed_descriptor[CONF_DESC_wTotalLength] << 8)); + if (usbd_core_cfg.speed == USB_SPEED_HIGH) { + if (usbd_core_cfg.descriptors->fs_other_speed_descriptor) { + *data = (uint8_t *)usbd_core_cfg.descriptors->fs_other_speed_descriptor; + *len = (usbd_core_cfg.descriptors->fs_other_speed_descriptor[CONF_DESC_wTotalLength] | + (usbd_core_cfg.descriptors->fs_other_speed_descriptor[CONF_DESC_wTotalLength] << 8)); + } else { + found = false; + } } else { - found = false; + if (usbd_core_cfg.descriptors->hs_other_speed_descriptor) { + *data = (uint8_t *)usbd_core_cfg.descriptors->hs_other_speed_descriptor; + *len = (usbd_core_cfg.descriptors->hs_other_speed_descriptor[CONF_DESC_wTotalLength] | + (usbd_core_cfg.descriptors->hs_other_speed_descriptor[CONF_DESC_wTotalLength] << 8)); + } else { + found = false; + } } break; diff --git a/core/usbd_core.h b/core/usbd_core.h index 61590c82..fd9a177c 100644 --- a/core/usbd_core.h +++ b/core/usbd_core.h @@ -67,7 +67,8 @@ struct usb_descriptor { const uint8_t **fs_config_descriptor; const uint8_t **hs_config_descriptor; const uint8_t *device_quality_descriptor; - const uint8_t *other_speed_descriptor; + const uint8_t *fs_other_speed_descriptor; + const uint8_t *hs_other_speed_descriptor; const char **string_descriptor; struct usb_msosv1_descriptor *msosv1_descriptor; struct usb_msosv2_descriptor *msosv2_descriptor;