XilinxProcessorIPLib/drivers/usbpsu/examples/xusb_ch9_composite.c
u32 Usb_Ch9SetupCfgDescReply(struct Usb_DevData *InstancePtr, u8 *BufPtr,
		u32 BufLen)
{
	s32 Status;
	u8 *config;
	u32 CfgDescLen;
	USBCH9_DATA *ch9_ptr =
		(USBCH9_DATA *)Get_DrvData(InstancePtr->PrivateData);
	struct dfu_if *DFU = &((struct composite_dev *)(ch9_ptr->data_ptr))->f_dfu;

	Status = IsSuperSpeed(InstancePtr);
	if (Status != XST_SUCCESS) {
		/* USB 2.0 */
		if (DFU->is_dfu == 1) {
			config = (u8 *)&DFUconfig2;
			CfgDescLen  = sizeof(DFU_USB_CONFIG);
		} else {
			config = (u8 *)&config2;
			CfgDescLen  = sizeof(USB_CONFIG);
		}
	} else {
		/* USB 3.0 */
		if (DFU->is_dfu == 1) {
			config = (u8 *)&DFUconfig3;
			CfgDescLen  = sizeof(DFU_USB30_CONFIG);
		} else {
			config = (u8 *)&config3;
			CfgDescLen  = sizeof(USB30_CONFIG);
		}
	}

	/* Check buffer pointer is OK and buffer is big enough. */
	if (!BufPtr)
		return 0;

	if (BufLen < sizeof(USB_STD_CFG_DESC))
		return 0;

	memcpy(BufPtr, config, CfgDescLen);

	return CfgDescLen;
}
/*****************************************************************************/
/**
*
* This function returns the configuration descriptor for the device.
*
* @param	InstancePtr is a pointer to the Usb_DevData instance.
* @param	BufPtr is the pointer to the buffer that is to be filled with
*		the descriptor.
* @param	BufLen is the size of the provided buffer.
*
* @return	Length of the descriptor in the buffer on success.
*		0 on error.
*
******************************************************************************/
This function returns the configuration descriptor for the device.
This function returns the configuration descriptor for the device .
u32 Usb_Ch9SetupCfgDescReply(struct Usb_DevData *InstancePtr, u8 *BufPtr,
		u32 BufLen)
{
	s32 Status;
	u8 *config;
	u32 CfgDescLen;
	USBCH9_DATA *ch9_ptr =
		(USBCH9_DATA *)Get_DrvData(InstancePtr->PrivateData);
	struct dfu_if *DFU = &((struct composite_dev *)(ch9_ptr->data_ptr))->f_dfu;
	Status = IsSuperSpeed(InstancePtr);
	if (Status != XST_SUCCESS) {
		if (DFU->is_dfu == 1) {
			config = (u8 *)&DFUconfig2;
			CfgDescLen  = sizeof(DFU_USB_CONFIG);
		} else {
			config = (u8 *)&config2;
			CfgDescLen  = sizeof(USB_CONFIG);
		}
	} else {
		if (DFU->is_dfu == 1) {
			config = (u8 *)&DFUconfig3;
			CfgDescLen  = sizeof(DFU_USB30_CONFIG);
		} else {
			config = (u8 *)&config3;
			CfgDescLen  = sizeof(USB30_CONFIG);
		}
	}
	if (!BufPtr)
		return 0;
	if (BufLen < sizeof(USB_STD_CFG_DESC))
		return 0;
	memcpy(BufPtr, config, CfgDescLen);
	return CfgDescLen;
}
u32 Usb_Ch9SetupCfgDescReply ( struct Usb_DevData * InstancePtr , u8 * BufPtr , u32 BufLen ) { s32 Status ; u8 * config ; u32 CfgDescLen ; USBCH9_DATA * ch9_ptr = ( USBCH9_DATA * ) Get_DrvData ( InstancePtr -> PrivateData ) ; struct dfu_if * DFU = & ( ( struct composite_dev * ) ( ch9_ptr -> data_ptr ) ) -> f_dfu ; Status = IsSuperSpeed ( InstancePtr ) ; if ( Status != XST_SUCCESS ) { if ( DFU -> is_dfu == 1 ) { config = ( u8 * ) & DFUconfig2 ; CfgDescLen = sizeof ( DFU_USB_CONFIG ) ; } else { config = ( u8 * ) & config2 ; CfgDescLen = sizeof ( USB_CONFIG ) ; } } else { if ( DFU -> is_dfu == 1 ) { config = ( u8 * ) & DFUconfig3 ; CfgDescLen = sizeof ( DFU_USB30_CONFIG ) ; } else { config = ( u8 * ) & config3 ; CfgDescLen = sizeof ( USB30_CONFIG ) ; } } if ( ! BufPtr ) return 0 ; if ( BufLen < sizeof ( USB_STD_CFG_DESC ) ) return 0 ; memcpy ( BufPtr , config , CfgDescLen ) ; return CfgDescLen ; }
This function returns the configuration descriptor for the device.
This function returns the configuration descriptor for the device .
/* USB 2.0 */ /* USB 3.0 */ /* Check buffer pointer is OK and buffer is big enough. */