23 #define TIMEOUT_1SEC 1000
24 #define TIMEOUT_2SEC 2000
25 #define DEFAULT_TIMEOUT TIMEOUT_2SEC
28 static USBH_Ep_TypeDef *epOut = NULL;
29 static USBH_Ep_TypeDef *epIn = NULL;
32 static int timeoutFactor;
41 static void ResetRecovery(
void);
65 DEBUG_USB_API_PUTS(
"\nMSDBOT_Init(), typedef size error");
101 int timeout, result, direction, retVal;
105 result = USBH_WriteB(epOut, cbw, CBW_LEN, DEFAULT_TIMEOUT);
107 if (result != CBW_LEN)
120 timeout = DEFAULT_TIMEOUT + (len / timeoutFactor);
123 result = USBH_ReadB(epIn, data, len, timeout);
125 result = USBH_WriteB(epOut, data, len, timeout);
132 USBH_UnStallEpB(epIn);
134 USBH_UnStallEpB(epOut);
137 else if (result <= 0)
145 result = USBH_ReadB(epIn, csw, CSW_LEN, DEFAULT_TIMEOUT);
147 if (result != CSW_LEN)
152 USBH_UnStallEpB(epIn);
154 USBH_UnStallEpB(epOut);
156 result = USBH_ReadB(epIn, csw, CSW_LEN, DEFAULT_TIMEOUT);
158 if (result != CSW_LEN)
171 if (CswValid(pCbw) && CswMeaningful(pCbw))
231 static void ResetRecovery(
void)
233 USBH_ControlMsgB(&epIn->parentDevice->ep0,
243 USBH_UnStallEpB(epIn);
244 USBH_UnStallEpB(epOut);
#define USB_SETUP_DIR_H2D
uint32_t dCBWDataTransferLength
#define USB_CLASS_MSD_CSW_CMDFAILED
#define USB_CLASS_MSD_CSW_CMDPASSED
int MSDBOT_Xfer(void *cbw, void *data)
Perform an MSD Bulk Only Transfer (BOT).
int MSDBOT_Init(USBH_Ep_TypeDef *out, USBH_Ep_TypeDef *in)
MSDBOT module initialization.
#define USB_SETUP_TYPE_CLASS_MASK
Definitions for the Bulk Only Transport protocol of USB Mass Storage devices.
USB protocol stack library API for EFM32/EZR32.
#define USB_SETUP_RECIPIENT_INTERFACE
Bulk Only Transport (BOT) Command Block Wrapper (CBW) typedef.
Bulk Only Transport (BOT) Command Status Wrapper (CSW) typedef.
#define STATIC_UBUF(x, y)