summaryrefslogtreecommitdiffstats
path: root/firmware/usbstack/usb_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack/usb_storage.c')
-rw-r--r--firmware/usbstack/usb_storage.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index eb1db5d884..2a3808dd92 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -22,6 +22,7 @@
#include "system.h"
#include "usb_core.h"
#include "usb_drv.h"
+#include "usb_class_driver.h"
//#define LOGF_ENABLE
#include "logf.h"
#include "storage.h"
@@ -371,24 +372,20 @@ int usb_storage_set_first_interface(int interface)
int usb_storage_get_config_descriptor(unsigned char *dest,int max_packet_size)
{
- endpoint_descriptor.wMaxPacketSize=max_packet_size;
- interface_descriptor.bInterfaceNumber=usb_interface;
+ unsigned char *orig_dest = dest;
- memcpy(dest,&interface_descriptor,
- sizeof(struct usb_interface_descriptor));
- dest+=sizeof(struct usb_interface_descriptor);
+ interface_descriptor.bInterfaceNumber = usb_interface;
+ PACK_DESCRIPTOR(dest, interface_descriptor);
+
+ endpoint_descriptor.wMaxPacketSize = max_packet_size;
endpoint_descriptor.bEndpointAddress = ep_in;
- memcpy(dest,&endpoint_descriptor,
- sizeof(struct usb_endpoint_descriptor));
- dest+=sizeof(struct usb_endpoint_descriptor);
+ PACK_DESCRIPTOR(dest, endpoint_descriptor);
endpoint_descriptor.bEndpointAddress = ep_out;
- memcpy(dest,&endpoint_descriptor,
- sizeof(struct usb_endpoint_descriptor));
+ PACK_DESCRIPTOR(dest, endpoint_descriptor);
- return sizeof(struct usb_interface_descriptor) +
- 2*sizeof(struct usb_endpoint_descriptor);
+ return (dest - orig_dest);
}
void usb_storage_init_connection(void)