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

	xil_printf("FreeRTOS Keyboard application 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, &keyboard_data);

	EpConfigure(UsbInstPtr->PrivateData, 1, USB_EP_DIR_IN,
			USB_EP_TYPE_INTERRUPT);

	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
	 * Usb_EpInHandler -  to be called when data is sent
	 */
	SetEpHandler(UsbInstPtr->PrivateData, 1, USB_EP_DIR_IN,
			Usb_EpInHandler);

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

	/* 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 & KEYBOARD_CONFIG)
				xTaskCreate(prvKeyboardTask,
						(const char *) "Keyboard Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr, tskIDLE_PRIORITY,
						&xKeyboardTask);

			if (Notification & KEYBOARD_UNCONFIG) {
				EpDisable(UsbInstPtr->PrivateData, KEYBOARD_EP,
						USB_EP_DIR_IN);

				vSemaphoreDelete(xSemaphore);
				vTaskDelete(xKeyboardTask);
			}
		}
	}

	return XST_SUCCESS;
}
/****************************************************************************/
/**
* This function is implementing USB Keyboard example.
*
* @param	UsbInstPtr USB 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 Keyboard example.
This function is implementing USB Keyboard example .
static int XUsbKeyboardExample(struct Usb_DevData *UsbInstPtr,
		u16 DeviceId, u16 UsbIntrId)
{
	s32 Status;
	Usb_Config *UsbConfigPtr;
	xil_printf("FreeRTOS Keyboard application 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, &keyboard_data);
	EpConfigure(UsbInstPtr->PrivateData, 1, USB_EP_DIR_IN,
			USB_EP_TYPE_INTERRUPT);
	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, 1, USB_EP_DIR_IN,
			Usb_EpInHandler);
	SetupInterruptSystem(UsbInstPtr->PrivateData, UsbIntrId);
	Usb_Start(UsbInstPtr->PrivateData);
	while (1) {
		BaseType_t Ret;
		u32 Notification;
		Ret = xTaskNotifyWait(0x00, 0x00, &Notification, portMAX_DELAY);
		if (Ret == pdTRUE) {
			if (Notification & KEYBOARD_CONFIG)
				xTaskCreate(prvKeyboardTask,
						(const char *) "Keyboard Task",
						configMINIMAL_STACK_SIZE,
						UsbInstPtr, tskIDLE_PRIORITY,
						&xKeyboardTask);
			if (Notification & KEYBOARD_UNCONFIG) {
				EpDisable(UsbInstPtr->PrivateData, KEYBOARD_EP,
						USB_EP_DIR_IN);
				vSemaphoreDelete(xSemaphore);
				vTaskDelete(xKeyboardTask);
			}
		}
	}
	return XST_SUCCESS;
}
static int XUsbKeyboardExample ( struct Usb_DevData * UsbInstPtr , 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 , & keyboard_data ) ; EpConfigure ( UsbInstPtr -> PrivateData , 1 , USB_EP_DIR_IN , USB_EP_TYPE_INTERRUPT ) ; Status = ConfigureDevice ( UsbInstPtr -> PrivateData , & Buffer [ 0 ] , MEMORY_SIZE ) ; if ( XST_SUCCESS != Status ) { xil_printf ( " \r \n " , Status ) ; return XST_FAILURE ; } SetEpHandler ( UsbInstPtr -> PrivateData , 1 , USB_EP_DIR_IN , Usb_EpInHandler ) ; SetupInterruptSystem ( UsbInstPtr -> PrivateData , UsbIntrId ) ; Usb_Start ( UsbInstPtr -> PrivateData ) ; while ( 1 ) { BaseType_t Ret ; u32 Notification ; Ret = xTaskNotifyWait ( 0x00 , 0x00 , & Notification , portMAX_DELAY ) ; if ( Ret == pdTRUE ) { if ( Notification & KEYBOARD_CONFIG ) xTaskCreate ( prvKeyboardTask , ( const char * ) " " , configMINIMAL_STACK_SIZE , UsbInstPtr , tskIDLE_PRIORITY , & xKeyboardTask ) ; if ( Notification & KEYBOARD_UNCONFIG ) { EpDisable ( UsbInstPtr -> PrivateData , KEYBOARD_EP , USB_EP_DIR_IN ) ; vSemaphoreDelete ( xSemaphore ) ; vTaskDelete ( xKeyboardTask ) ; } } } return XST_SUCCESS ; }
This function is implementing USB Keyboard example.
This function is implementing USB Keyboard example .
/* hook up chapter9 handler */ /* Assign the data to usb driver */ /*
	 * set endpoint handlers
	 * Usb_EpInHandler -  to be called when data is sent
	 */ /* setup interrupts */ /* Start the controller so that Host can see our device */