XilinxProcessorIPLib/drivers/usbpsu/examples/xusb_freertos_class_keyboard.c
void prvKeyboardTask(void *pvParameters)
{
	struct Usb_DevData *InstancePtr = pvParameters;
	u16 MaxPktSize;
	u8 SendKey = 1;
	u8 NoKeyData[8] = {0, 0, 0, 0, 0, 0, 0, 0};

	if ((InstancePtr->Speed == USB_SPEED_SUPER) ||
			(InstancePtr->Speed == USB_SPEED_HIGH))
		MaxPktSize = 0x400;
	else
		MaxPktSize = 0x40;

	xSemaphore = xSemaphoreCreateBinary();
	xSemaphoreGive(xSemaphore);

	EpEnable(InstancePtr->PrivateData, KEYBOARD_EP, USB_EP_DIR_IN,
			MaxPktSize, USB_EP_TYPE_INTERRUPT);

	while (1) {

		xSemaphoreTake(xSemaphore, portMAX_DELAY);
		if (SendKey) {
			static char KeyData[8] = {2, 0, 0, 0, 0, 0, 0, 0};

			/* get key from serial and send key */
			KeyData[2] = (inbyte() - ('a' - 4));
			EpBufferSend(InstancePtr->PrivateData, KEYBOARD_EP,
					(u8 *)&KeyData[0], 8);
			SendKey = 0;
		} else {
			/* send key release */
			EpBufferSend(InstancePtr->PrivateData, KEYBOARD_EP,
					(u8 *)&NoKeyData[0], 8);
			SendKey = 1;
		}
	}
}
/****************************************************************************/
/**
* This task implements keyboard functionality. task will get
* host and act accordingly
*
* @param	pvParameters private parameters.
*
* @note		None.
*
*****************************************************************************/
This task implements keyboard functionality. task will get
host and act accordingly
This task implements keyboard functionality . task will get host and act accordingly
void prvKeyboardTask(void *pvParameters)
{
	struct Usb_DevData *InstancePtr = pvParameters;
	u16 MaxPktSize;
	u8 SendKey = 1;
	u8 NoKeyData[8] = {0, 0, 0, 0, 0, 0, 0, 0};
	if ((InstancePtr->Speed == USB_SPEED_SUPER) ||
			(InstancePtr->Speed == USB_SPEED_HIGH))
		MaxPktSize = 0x400;
	else
		MaxPktSize = 0x40;
	xSemaphore = xSemaphoreCreateBinary();
	xSemaphoreGive(xSemaphore);
	EpEnable(InstancePtr->PrivateData, KEYBOARD_EP, USB_EP_DIR_IN,
			MaxPktSize, USB_EP_TYPE_INTERRUPT);
	while (1) {
		xSemaphoreTake(xSemaphore, portMAX_DELAY);
		if (SendKey) {
			static char KeyData[8] = {2, 0, 0, 0, 0, 0, 0, 0};
			KeyData[2] = (inbyte() - ('a' - 4));
			EpBufferSend(InstancePtr->PrivateData, KEYBOARD_EP,
					(u8 *)&KeyData[0], 8);
			SendKey = 0;
		} else {
			EpBufferSend(InstancePtr->PrivateData, KEYBOARD_EP,
					(u8 *)&NoKeyData[0], 8);
			SendKey = 1;
		}
	}
}
void prvKeyboardTask ( void * pvParameters ) { struct Usb_DevData * InstancePtr = pvParameters ; u16 MaxPktSize ; u8 SendKey = 1 ; u8 NoKeyData [ 8 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; if ( ( InstancePtr -> Speed == USB_SPEED_SUPER ) || ( InstancePtr -> Speed == USB_SPEED_HIGH ) ) MaxPktSize = 0x400 ; else MaxPktSize = 0x40 ; xSemaphore = xSemaphoreCreateBinary ( ) ; xSemaphoreGive ( xSemaphore ) ; EpEnable ( InstancePtr -> PrivateData , KEYBOARD_EP , USB_EP_DIR_IN , MaxPktSize , USB_EP_TYPE_INTERRUPT ) ; while ( 1 ) { xSemaphoreTake ( xSemaphore , portMAX_DELAY ) ; if ( SendKey ) { static char KeyData [ 8 ] = { 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; KeyData [ 2 ] = ( inbyte ( ) - ( ' ' - 4 ) ) ; EpBufferSend ( InstancePtr -> PrivateData , KEYBOARD_EP , ( u8 * ) & KeyData [ 0 ] , 8 ) ; SendKey = 0 ; } else { EpBufferSend ( InstancePtr -> PrivateData , KEYBOARD_EP , ( u8 * ) & NoKeyData [ 0 ] , 8 ) ; SendKey = 1 ; } } }
This task implements keyboard functionality.
This task implements keyboard functionality .
/* get key from serial and send key */ /* send key release */