Hi Li yong,
Please notice that for US2.0 the max packet size for control transfer is 64B. If you want to implement a specifc control transfer, following is the operation you should follow:
First, the user call-back function should be defined as the same format as the function pointer in USB_CTRL_TYPE.
USB_PARAM_CB_T USB_ReqVendor, then this call-back function should be assigned to this pointer of the USB_Handle during initialization.
For the call-back function USB_ReqVendor:
typedef ErrorCode_t (*USB_PARAM_CB_T) (USBD_HANDLE_T hUsb, uint32_t param1);
The first parameter is the USB_Handler, the second one is the USB_EVENT defined as below.
enum USBD_EVENT_T {
USB_EVT_SETUP =1, /**< 1 Setup Packet received */
USB_EVT_OUT, /**< 2 OUT Packet received */
USB_EVT_IN, /**< 3 IN Packet sent */
USB_EVT_OUT_NAK, /**< 4 OUT Packet - Not Acknowledged */
USB_EVT_IN_NAK, /**< 5 IN Packet - Not Acknowledged */
USB_EVT_OUT_STALL, /**< 6 OUT Packet - Stalled */
USB_EVT_IN_STALL, /**< 7 IN Packet - Stalled */
USB_EVT_OUT_DMA_EOT, /**< 8 DMA OUT EP - End of Transfer */
USB_EVT_IN_DMA_EOT, /**< 9 DMA IN EP - End of Transfer */
USB_EVT_OUT_DMA_NDR, /**< 10 DMA OUT EP - New Descriptor Request */
USB_EVT_IN_DMA_NDR, /**< 11 DMA IN EP - New Descriptor Request */
USB_EVT_OUT_DMA_ERR, /**< 12 DMA OUT EP - Error */
USB_EVT_IN_DMA_ERR, /**< 13 DMA IN EP - Error */
USB_EVT_RESET, /**< 14 Reset event recieved */
USB_EVT_SOF, /**< 15 Start of Frame event */
USB_EVT_DEV_STATE, /**< 16 Device status events */
USB_EVT_DEV_ERROR /**< 17 Device error events */
};
During setup stage of the USB control transfer, setup package data will be stored in the SetupPacket of hUsb.
During the data stage, the data will be stored in the EP0Data of hUsb for OUT_EVENT transfer, and user also should copy data in the EP0Data of hUsb for IN_EVENT transfer.
Hope it helps!
Best Regards,
Carlos Mendoza
Technical Support Engineer