diff options
Diffstat (limited to 'demo/bootuf2')
| -rw-r--r-- | demo/bootuf2/msc_bootuf2_template.c | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/demo/bootuf2/msc_bootuf2_template.c b/demo/bootuf2/msc_bootuf2_template.c index 73dfe577..65a1d1c8 100644 --- a/demo/bootuf2/msc_bootuf2_template.c +++ b/demo/bootuf2/msc_bootuf2_template.c @@ -17,35 +17,32 @@ #define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN) -#ifdef CONFIG_USB_HS -#define MSC_MAX_MPS 512 -#else -#define MSC_MAX_MPS 64 -#endif - static const uint8_t device_descriptor[] = { USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01) }; -static const uint8_t config_descriptor[] = { +static const uint8_t config_descriptor_hs[] = { USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), - MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, MSC_MAX_MPS, 0x02) + MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, USB_BULK_EP_MPS_HS, 0x02) +}; + +static const uint8_t config_descriptor_fs[] = { + USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), + MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, USB_BULK_EP_MPS_FS, 0x02) }; static const uint8_t device_quality_descriptor[] = { - /////////////////////////////////////// - /// device qualifier descriptor - /////////////////////////////////////// - 0x0a, - USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, - 0x00, - 0x02, - 0x00, - 0x00, - 0x00, - 0x40, - 0x00, - 0x00, + USB_DEVICE_QUALIFIER_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, 0x01), +}; + +static const uint8_t other_speed_config_descriptor_hs[] = { + USB_OTHER_SPEED_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), + MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, USB_BULK_EP_MPS_FS, 0x02) +}; + +static const uint8_t other_speed_config_descriptor_fs[] = { + USB_OTHER_SPEED_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), + MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, USB_BULK_EP_MPS_HS, 0x02) }; static const char *string_descriptors[] = { @@ -57,21 +54,44 @@ static const char *string_descriptors[] = { static const uint8_t *device_descriptor_callback(uint8_t speed) { + (void)speed; + return device_descriptor; } static const uint8_t *config_descriptor_callback(uint8_t speed) { - return config_descriptor; + if (speed == USB_SPEED_HIGH) { + return config_descriptor_hs; + } else if (speed == USB_SPEED_FULL) { + return config_descriptor_fs; + } else { + return NULL; + } } static const uint8_t *device_quality_descriptor_callback(uint8_t speed) { + (void)speed; + return device_quality_descriptor; } +static const uint8_t *other_speed_config_descriptor_callback(uint8_t speed) +{ + if (speed == USB_SPEED_HIGH) { + return other_speed_config_descriptor_hs; + } else if (speed == USB_SPEED_FULL) { + return other_speed_config_descriptor_fs; + } else { + return NULL; + } +} + static const char *string_descriptor_callback(uint8_t speed, uint8_t index) { + (void)speed; + if (index >= (sizeof(string_descriptors) / sizeof(char *))) { return NULL; } @@ -82,6 +102,7 @@ const struct usb_descriptor msc_bootuf2_descriptor = { .device_descriptor_callback = device_descriptor_callback, .config_descriptor_callback = config_descriptor_callback, .device_quality_descriptor_callback = device_quality_descriptor_callback, + .other_speed_descriptor_callback = other_speed_config_descriptor_callback, .string_descriptor_callback = string_descriptor_callback }; |
