@@ -58,7 +58,7 @@ static const uint8_t storage_usb_msc_descriptor_template[] = {
5858 // MSC Endpoint IN Descriptor
5959 0x07 , // 9 bLength
6060 0x05 , // 10 bDescriptorType (Endpoint)
61- 0xFF , // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x8 | number]
61+ 0xFF , // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number]
6262#define MSC_IN_ENDPOINT_INDEX 11
6363 0x02 , // 12 bmAttributes (Bulk)
6464 0x40 , 0x00 , // 13,14 wMaxPacketSize 64
@@ -81,12 +81,21 @@ size_t storage_usb_descriptor_length(void) {
8181 return sizeof (usb_msc_descriptor );
8282}
8383
84- size_t storage_usb_add_descriptor (uint8_t * descriptor_buf , uint8_t interface_number , uint8_t in_endpoint , uint8_t out_endpoint , uint8_t interface_string ) {
84+ static const char [] storage_interface_name = USB_INTERFACE_NAME " Mass Storage" ;
85+
86+ size_t storage_usb_add_descriptor (uint8_t * descriptor_buf , uint8_t * current_interface , uint8_t * current_endpoint , uint8_t * current_interface_string ) {
8587 memcpy (descriptor_buf , storage_usb_msc_descriptor_template , sizeof (storage_usb_msc_descriptor_template ));
86- descriptor_buf [MSC_INTERFACE_INDEX ] = interface_number ;
87- descriptor_buf [MSC_INTERFACE_STRING_INDEX ] = interface_string ;
88- descriptor_buf [MSC_IN_ENDPOINT_INDEX ] = in_endpoint_address ;
89- descriptor_buf [MSC_OUT_ENDPOINT_INDEX ] = 0x80 | out_endpoint_address ;
88+ descriptor_buf [MSC_INTERFACE_INDEX ] = * current_interface ;
89+ (* current_interface )++ ;
90+
91+ descriptor_buf [MSC_IN_ENDPOINT_INDEX ] = USB_MSC_EP_NUM_IN ? USB_MSC_EP_NUM_IN : * current_endpoint ;
92+ descriptor_buf [MSC_OUT_ENDPOINT_INDEX ] = 0x80 | (USB_MSC_EP_NUM_OUT ? USB_MSC_EP_NUM_OUT : * current_endpoint );
93+ (* current_endpoint )++ :
94+
95+ usb_add_interface_string (* current_interface_string ,);
96+ descriptor_buf [MSC_INTERFACE_STRING_INDEX ] = * current_interface_string ;
97+ (* current_interface_string )++ ;
98+
9099 return sizeof (storage_usb_msc_descriptor_template );
91100}
92101
0 commit comments