24
24
#include "usb_msd.h"
25
25
26
26
27
+ #ifndef MIN
28
+ #define MIN (x , y ) (((x) < (y)) ? (x) : (y))
29
+ #endif
27
30
28
31
#if STM32_USB_USE_OTG2 && STM32_USE_USB_OTG2_HS
29
32
#define USB_MAX_PACKET_SIZE 512
33
+ #define USB_CDC_DESCRIPTOR_MAX_PACKET_SIZE MIN(512, SERIAL_USB_BUFFERS_SIZE)
30
34
#define USB_CDC_INTERUPT_INTERVAL 0x10
31
35
#else
32
36
#define USB_MAX_PACKET_SIZE 64
@@ -161,12 +165,12 @@ static const uint8_t msd_configuration_descriptor_data[] = {
161
165
/* Endpoint 3 Descriptor. */
162
166
USB_DESC_ENDPOINT (USB_CDC_DATA_AVAILABLE_EP , /* bEndpointAddress.*/
163
167
0x02 , /* bmAttributes (Bulk). */
164
- USB_MAX_PACKET_SIZE , /* wMaxPacketSize. */
168
+ USB_CDC_DESCRIPTOR_MAX_PACKET_SIZE , /* wMaxPacketSize. */
165
169
0x00 ), /* bInterval. */
166
170
/* Endpoint 1 Descriptor. */
167
171
USB_DESC_ENDPOINT (USB_CDC_DATA_REQUEST_EP |0x80 , /* bEndpointAddress.*/
168
172
0x02 , /* bmAttributes (Bulk). */
169
- USB_MAX_PACKET_SIZE , /* wMaxPacketSize. */
173
+ USB_CDC_DESCRIPTOR_MAX_PACKET_SIZE , /* wMaxPacketSize. */
170
174
0x00 ), /* bInterval. */
171
175
172
176
@@ -324,8 +328,8 @@ static const USBEndpointConfig epCDC1config = {
324
328
NULL ,
325
329
sduDataTransmitted ,
326
330
sduDataReceived ,
327
- 0x0040 ,
328
- 0x0040 ,
331
+ USB_CDC_DESCRIPTOR_MAX_PACKET_SIZE ,
332
+ USB_CDC_DESCRIPTOR_MAX_PACKET_SIZE ,
329
333
& epCDC1instate ,
330
334
& epCDC1outstate ,
331
335
2 ,
@@ -369,7 +373,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
369
373
case USB_EVENT_ADDRESS :
370
374
return ;
371
375
case USB_EVENT_CONFIGURED :
372
- chSysLockFromIsr ()
376
+ chSysLockFromIsr ();
373
377
msdp -> reconfigured_or_reset_event = TRUE;
374
378
usbInitEndpointI (usbp , msdp -> ms_ep_number , & epDataConfig );
375
379
@@ -386,7 +390,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
386
390
387
391
/* signal that the device is connected */
388
392
chEvtBroadcastI (& msdp -> evt_connected );
389
- chSysUnlockFromIsr ()
393
+ chSysUnlockFromIsr ();
390
394
return ;
391
395
case USB_EVENT_SUSPEND :
392
396
return ;
0 commit comments