How to handle CY_U3P_USB_EVENT_LMP_EXCH_FAIL event during USB enumeration from the FX3 SDK?
FX3 SDK signals the CY_U3P_USB_EVENT_LMP_EXCH_FAIL event to the user application when either of Port Capability Request or Port Configuration Request from the host is timed out. Cypress recommends a USB Interface Block restart in the user application while handling this event.
The following steps show how to handle the event for a sample application project:
1.Configure the USB Event callback to set a custom flag CY_FX_USB_RESTART_EVT_FLAG to the main application event on receiving the CY_U3P_USB_EVENT_LMP_EXCH_FAIL event.
CyU3PEventSet (&glApplnEvent, CY_FX_USB_RESTART_EVT_FLAG, CYU3P_EVENT_OR);
2. Use the CyU3PEventGet API to receive the custom event flag (CY_FX_USB_RESTART_EVT_FLAG) in the application thread entry function. Note that the event mask (evMask) should be configured to receive the CY_FX_USB_RESTART_EVT_FLAG. The CyFxAppUsbRestart() function reinitializes the USB Interface Block. The source code of CyFxAppUsbRestart() is included in the attached sample project.
/* USB block restart request */
#define CY_FX_USB_RESTART_EVT_FLAG (1 << 3)
/* Event Mask configuration */
uint32_t evMask = CY_FX_SETCONF_EVENT_FLAG | CY_FX_RESET_EVENT_FLAG | CY_FX_USB_RESTART_EVT_FLAG;
/* Handling the custom event in application thread */
status = CyU3PEventGet (&glApplnEvent, evMask, CYU3P_EVENT_OR_CLEAR, &evStat, CYU3P_WAIT_FOREVER);
if (status == CY_U3P_SUCCESS)
if (evStat & CY_FX_USB_RESTART_EVT_FLAG)
These steps are applicable to FX3, FX3S, CX3 and SD3.
The attachment, USBBulkLoopAuto.zip, is the modified version of the USBBulkLoopAuto FX3 SDK example project. Search for HANDLE_LMP_EXCH_FAIL_EVT in the cyfxbulklpauto.c file for the relevant modifications.