AnsweredAssumed Answered

Suggested mod to USB 5.0 stack

Question asked by John Strohm on Dec 10, 2014
Latest reply on Dec 11, 2014 by Kan_Li

File usb_misc.h contains the following:


#define MAX_EXPECTED_CONTROL_OUT_SIZE   (76 + USB_SETUP_PKT_SIZE)

 

#if USBCFG_DEV_KHCI || USBCFG_DEV_EHCI

typedef struct usb_dev_data

{

    uint8_t             control_out[96];/* control_out must be 32 byte align,

                                        ** 96 = (((MAX_EXPECTED_CONTROL_OUT_SIZE-1)/32) + 1) * 32

                                        */

} usb_dev_data_t;

 

 

The problem is that, if MAX_EXPECTED_CONTROL_OUT_SIZE is increased, array control_out must also be resized.


This is easy enough to fix.  The modified code should be:

 

#define MAX_EXPECTED_CONTROL_OUT_SIZE   (76 + USB_SETUP_PKT_SIZE)

/* Round up to 32 byte block size

#define ROUNDED_UP_CONTROL_OUT_SIZE ((MAX_EXPECTED_CONTROL_OUT_SIZE+31)/32)

 

#if USBCFG_DEV_KHCI || USBCFG_DEV_EHCI

typedef struct usb_dev_data

{

    uint8_t             control_out[ROUNDED_UP_CONTROL_OUT_SIZE];/* control_out must be 32 byte align,

} usb_dev_data_t;

#endif

Outcomes