XilinxProcessorIPLib/drivers/usbpsu/examples/xusb_freertos_audio_example.c
static int XUsbAudioExample(struct Usb_DevData *UsbInstPtr,
		struct audio_dev *dev, u16 DeviceId, u16 UsbIntrId)
{
	s32 Status;
	Usb_Config *UsbConfigPtr;

	xil_printf("FreeRTOS Xilinx Audio Start...\r\n");

	UsbConfigPtr = LookupConfig(DeviceId);
	if (NULL == UsbConfigPtr) {
		xil_printf("LookupConfig failed\r\n");
		return XST_FAILURE;
	}

	Status = CfgInitialize(UsbInstPtr, UsbConfigPtr,
			UsbConfigPtr->BaseAddress);
	if (XST_SUCCESS != Status) {
		xil_printf("CfgInitialize failed: %d\r\n", Status);
		return XST_FAILURE;
	}

	/* Hook up chapter9 handler */
	Set_Ch9Handler(UsbInstPtr->PrivateData, Ch9Handler);

	/* Assign the data to USB driver */
	Set_DrvData(UsbInstPtr->PrivateData, &iso_data);

	EpConfigure(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_IN,
			USB_EP_TYPE_ISOCHRONOUS);
	EpConfigure(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_OUT,
			USB_EP_TYPE_ISOCHRONOUS);

	Status = ConfigureDevice(UsbInstPtr->PrivateData, &Buffer[0],
			MEMORY_SIZE);
	if (XST_SUCCESS != Status) {
		xil_printf("ConfigureDevice failed: %d\r\n", Status);
		return XST_FAILURE;
	}

	/*
	 * set endpoint handlers
	 * XUsbPsu_IsoInHandler -  to be called when data is sent
	 * XUsbPsu_IsoOutHandler -  to be called when data is received
	 */
	SetEpHandler(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_IN,
			Usb_IsoInHandler);

	SetEpHandler(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_OUT,
			Usb_IsoOutHandler);

	/* Setup interrupts */
	SetupInterruptSystem(UsbInstPtr->PrivateData, UsbIntrId);

	set_audio_transfer_size(&audio_dev);

	/* Start the controller so that Host can see our device */
	Usb_Start(UsbInstPtr->PrivateData);

	while (1) {
		BaseType_t Ret;
		u32 Notification;

		Ret = xTaskNotifyWait(0x00, 0x00, &Notification, portMAX_DELAY);
		if (Ret == pdTRUE) {
			if (Notification & RECORD_START)
				xTaskCreate(prvRecordTask,
						(const char *) "Record Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr,
						tskIDLE_PRIORITY + 2,
						&(dev->xRecordTask));

			if (Notification & PLAY_START)
				xTaskCreate(prvPlayBackTask,
						(const char *) "PlayBack Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr,
						tskIDLE_PRIORITY + 2,
						&(dev->xPlayTask));

			if (Notification & RECORD_STOP) {
				StreamOff(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_IN);
				EpDisable(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_IN);
				vSemaphoreDelete(dev->xSemaphoreRecord);
				vTaskDelete(dev->xRecordTask);
			}

			if (Notification & PLAY_STOP) {
				StreamOff(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_OUT);
				EpDisable(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_OUT);
				vSemaphoreDelete(dev->xSemaphorePlay);
				vTaskDelete(dev->xPlayTask);
			}
		}
	}

	return XST_SUCCESS;
}
/****************************************************************************/
/**
* This function is implementing USB audio example.
*
* @param	UsbInstPtr USB instance pointer.
*		dev audio device instance pointer
*		DeviceId USB Device ID
*		UsbIntrId USB Interrupt ID
*
* @return	- XST_SUCCESS if successful,
*		- XST_FAILURE if unsuccessful.
*
* @note		None.
*
*****************************************************************************/
This function is implementing USB audio example.
This function is implementing USB audio example .
static int XUsbAudioExample(struct Usb_DevData *UsbInstPtr,
		struct audio_dev *dev, u16 DeviceId, u16 UsbIntrId)
{
	s32 Status;
	Usb_Config *UsbConfigPtr;
	xil_printf("FreeRTOS Xilinx Audio Start...\r\n");
	UsbConfigPtr = LookupConfig(DeviceId);
	if (NULL == UsbConfigPtr) {
		xil_printf("LookupConfig failed\r\n");
		return XST_FAILURE;
	}
	Status = CfgInitialize(UsbInstPtr, UsbConfigPtr,
			UsbConfigPtr->BaseAddress);
	if (XST_SUCCESS != Status) {
		xil_printf("CfgInitialize failed: %d\r\n", Status);
		return XST_FAILURE;
	}
	Set_Ch9Handler(UsbInstPtr->PrivateData, Ch9Handler);
	Set_DrvData(UsbInstPtr->PrivateData, &iso_data);
	EpConfigure(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_IN,
			USB_EP_TYPE_ISOCHRONOUS);
	EpConfigure(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_OUT,
			USB_EP_TYPE_ISOCHRONOUS);
	Status = ConfigureDevice(UsbInstPtr->PrivateData, &Buffer[0],
			MEMORY_SIZE);
	if (XST_SUCCESS != Status) {
		xil_printf("ConfigureDevice failed: %d\r\n", Status);
		return XST_FAILURE;
	}
	SetEpHandler(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_IN,
			Usb_IsoInHandler);
	SetEpHandler(UsbInstPtr->PrivateData, ISO_EP, USB_EP_DIR_OUT,
			Usb_IsoOutHandler);
	SetupInterruptSystem(UsbInstPtr->PrivateData, UsbIntrId);
	set_audio_transfer_size(&audio_dev);
	Usb_Start(UsbInstPtr->PrivateData);
	while (1) {
		BaseType_t Ret;
		u32 Notification;
		Ret = xTaskNotifyWait(0x00, 0x00, &Notification, portMAX_DELAY);
		if (Ret == pdTRUE) {
			if (Notification & RECORD_START)
				xTaskCreate(prvRecordTask,
						(const char *) "Record Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr,
						tskIDLE_PRIORITY + 2,
						&(dev->xRecordTask));
			if (Notification & PLAY_START)
				xTaskCreate(prvPlayBackTask,
						(const char *) "PlayBack Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr,
						tskIDLE_PRIORITY + 2,
						&(dev->xPlayTask));
			if (Notification & RECORD_STOP) {
				StreamOff(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_IN);
				EpDisable(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_IN);
				vSemaphoreDelete(dev->xSemaphoreRecord);
				vTaskDelete(dev->xRecordTask);
			}
			if (Notification & PLAY_STOP) {
				StreamOff(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_OUT);
				EpDisable(UsbInstPtr->PrivateData, ISO_EP,
						USB_EP_DIR_OUT);
				vSemaphoreDelete(dev->xSemaphorePlay);
				vTaskDelete(dev->xPlayTask);
			}
		}
	}
	return XST_SUCCESS;
}
static int XUsbAudioExample ( struct Usb_DevData * UsbInstPtr , struct audio_dev * dev , u16 DeviceId , u16 UsbIntrId ) { s32 Status ; Usb_Config * UsbConfigPtr ; xil_printf ( " \r \n " ) ; UsbConfigPtr = LookupConfig ( DeviceId ) ; if ( NULL == UsbConfigPtr ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status = CfgInitialize ( UsbInstPtr , UsbConfigPtr , UsbConfigPtr -> BaseAddress ) ; if ( XST_SUCCESS != Status ) { xil_printf ( " \r \n " , Status ) ; return XST_FAILURE ; } Set_Ch9Handler ( UsbInstPtr -> PrivateData , Ch9Handler ) ; Set_DrvData ( UsbInstPtr -> PrivateData , & iso_data ) ; EpConfigure ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_IN , USB_EP_TYPE_ISOCHRONOUS ) ; EpConfigure ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_OUT , USB_EP_TYPE_ISOCHRONOUS ) ; Status = ConfigureDevice ( UsbInstPtr -> PrivateData , & Buffer [ 0 ] , MEMORY_SIZE ) ; if ( XST_SUCCESS != Status ) { xil_printf ( " \r \n " , Status ) ; return XST_FAILURE ; } SetEpHandler ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_IN , Usb_IsoInHandler ) ; SetEpHandler ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_OUT , Usb_IsoOutHandler ) ; SetupInterruptSystem ( UsbInstPtr -> PrivateData , UsbIntrId ) ; set_audio_transfer_size ( & audio_dev ) ; Usb_Start ( UsbInstPtr -> PrivateData ) ; while ( 1 ) { BaseType_t Ret ; u32 Notification ; Ret = xTaskNotifyWait ( 0x00 , 0x00 , & Notification , portMAX_DELAY ) ; if ( Ret == pdTRUE ) { if ( Notification & RECORD_START ) xTaskCreate ( prvRecordTask , ( const char * ) " " , configMINIMAL_STACK_SIZE , UsbInstPtr , tskIDLE_PRIORITY + 2 , & ( dev -> xRecordTask ) ) ; if ( Notification & PLAY_START ) xTaskCreate ( prvPlayBackTask , ( const char * ) " " , configMINIMAL_STACK_SIZE , UsbInstPtr , tskIDLE_PRIORITY + 2 , & ( dev -> xPlayTask ) ) ; if ( Notification & RECORD_STOP ) { StreamOff ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_IN ) ; EpDisable ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_IN ) ; vSemaphoreDelete ( dev -> xSemaphoreRecord ) ; vTaskDelete ( dev -> xRecordTask ) ; } if ( Notification & PLAY_STOP ) { StreamOff ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_OUT ) ; EpDisable ( UsbInstPtr -> PrivateData , ISO_EP , USB_EP_DIR_OUT ) ; vSemaphoreDelete ( dev -> xSemaphorePlay ) ; vTaskDelete ( dev -> xPlayTask ) ; } } } return XST_SUCCESS ; }
This function is implementing USB audio example.
This function is implementing USB audio example .
/* Hook up chapter9 handler */ /* Assign the data to USB driver */ /*
	 * set endpoint handlers
	 * XUsbPsu_IsoInHandler -  to be called when data is sent
	 * XUsbPsu_IsoOutHandler -  to be called when data is received
	 */ /* Setup interrupts */ /* Start the controller so that Host can see our device */