⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbohciroothubemulation.c

📁 风河的vxworks-6.3 FOR amcc440epx BSP!
💻 C
📖 第 1 页 / 共 5 页
字号:
            			}            		/* Update the URB transfer length */            		pUrb->uTransferLength = 						USB_OHCI_GET_STATUS_REQUEST_RESPONSE_SIZE;            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		case USBHST_RECIPIENT_INTERFACE: /* Interface recipient */        		case USBHST_RECIPIENT_ENDPOINT:  /* Endpoint recipient */            		/* Update the URB transfer buffer */            		OS_MEMSET(pUrb->pTransferBuffer,                       		  0,                       		  USB_OHCI_GET_STATUS_REQUEST_RESPONSE_SIZE);            		/* Update the URB transfer length */            		pUrb->uTransferLength = 						USB_OHCI_GET_STATUS_REQUEST_RESPONSE_SIZE;            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		default:            		/* Invalid device recipient */            		pUrb->nStatus = USBHST_INVALID_REQUEST;            		break;        		};        	break;    	case USBHST_REQ_CLEAR_FEATURE: /* USB CLEAR_FEATURE request */        	/* Check the recipient of the request */        	switch (pSetupPacket->bmRequestType &                 	USB_OHCI_CONTROL_TRANSFER_REQUEST_RECIPIENT_MASK)        		{        		case USBHST_RECIPIENT_DEVICE: /* Device recipient */            		/* Check the feature selector */            		if (pSetupPacket->wValue == 						USBHST_FEATURE_DEVICE_REMOTE_WAKEUP)            			{                		/* Disable device remote wakeup */                		pOhciControllerInfo->bRemoteWakeupEnabled = FALSE;                		/*                  		 * Clear the 'Remote Wakeup Enable' bit in the HcControl                  		 * register (BEGIN)                 		 */                		/* Read the contents of the HcControl register */                		uRegisterValue =                     		USB_OHCI_REG_READ(uHostControllerIndex, 						  uBaseAddress + 						  USB_OHCI_CONTROL_REGISTER_OFFSET);                		/* Clear the 'Remote Wakeup Enable (RWE)' bit */                		uRegisterValue &= (~USB_OHCI_CONTROL_RWE);                		/* Update the contents of the HcControl register */                		USB_OHCI_REG_WRITE(uHostControllerIndex, 					     (uBaseAddress +                                              USB_OHCI_CONTROL_REGISTER_OFFSET),                           	uRegisterValue);                		/*                  		 * Clear the 'Remote Wakeup Enable' bit in the HcControl                  		 * register (END)                 		 */                		/*                 		 * Set the 'Resume Detect' bit of the interrupt disable						 * register                  		 */                		USB_OHCI_REG_WRITE(uHostControllerIndex, 							(uBaseAddress + 				 USB_OHCI_INTERRUPT_DISABLE_REGISTER_OFFSET),                          	USB_OHCI_INTERRUPT_STATUS_RESUME_DETECT);            			}            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		case USBHST_RECIPIENT_INTERFACE: /* Interface recipient */        		case USBHST_RECIPIENT_ENDPOINT:  /* Endpoint recipient */            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		default:            		/* Invalid device recipient */            		pUrb->nStatus = USBHST_INVALID_REQUEST;            		break;        		};        	break;    	case USBHST_REQ_SET_FEATURE: /* USB SET_FEATURE request */        	/* Check the recipient of the request */        	switch (pSetupPacket->bmRequestType &                 USB_OHCI_CONTROL_TRANSFER_REQUEST_RECIPIENT_MASK)        		{        		case USBHST_RECIPIENT_DEVICE: /* Device recipient */            		/* Check the feature selector */            		if (pSetupPacket->wValue == 							USBHST_FEATURE_DEVICE_REMOTE_WAKEUP)            			{                		/* Enable device remote wakeup */                		pOhciControllerInfo->bRemoteWakeupEnabled = TRUE;                		/*                  		 * Set the 'Remote Wakeup Enable' bit in the HcControl                  		 * register (BEGIN)                 		 */                		/* Read the contents of the HcControl register */                		uRegisterValue =                     		USB_OHCI_REG_READ(uHostControllerIndex,                                                  uBaseAddress +  						  USB_OHCI_CONTROL_REGISTER_OFFSET);                		/* Set the 'Remote Wakeup Enable (RWE)' bit */                		uRegisterValue |= USB_OHCI_CONTROL_RWE;                		/* Update the contents of the HcControl register */                		USB_OHCI_REG_WRITE(uHostControllerIndex, 			(uBaseAddress + USB_OHCI_CONTROL_REGISTER_OFFSET),                           	uRegisterValue);                		/*                  		 * Set the 'Remote Wakeup Enable' bit in the HcControl                  		 * register (END)                 		 */                		/*                  		 * Set the 'Resume Detect' bit of the interrupt enable 						 * register                  		 */                		USB_OHCI_REG_WRITE(uHostControllerIndex,                                        (uBaseAddress + 			               USB_OHCI_INTERRUPT_ENABLE_REGISTER_OFFSET),                          	USB_OHCI_INTERRUPT_STATUS_RESUME_DETECT);            			}            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		case USBHST_RECIPIENT_INTERFACE: /* Interface recipient */        		case USBHST_RECIPIENT_ENDPOINT:  /* Endpoint recipient */            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		default:            		/* Invalid device recipient */            		pUrb->nStatus = USBHST_INVALID_REQUEST;            		break;        		};        	break;    	case USBHST_REQ_SET_ADDRESS: /* USB SET_ADDRESS request */        	/* Check whether the address is valid */        	if (pSetupPacket->wValue == 0)        		{            	/* Invalid device address. Update the URB status */            	pUrb->nStatus = USBHST_INVALID_REQUEST;            	break;        		}        	/* Check the USB state of the root hub */        	if ((pOhciControllerInfo->uRootHubState == 					USB_OHCI_DEVICE_DEFAULT_STATE) ||            	(pOhciControllerInfo->uRootHubState == 					USB_OHCI_DEVICE_ADDRESS_STATE))        		{            	/* Update the root hub USB address */            	pOhciControllerInfo->uRootHubAddress = pSetupPacket->wValue;            	/* Update the USB state of the root hub */            	pOhciControllerInfo->uRootHubState = 					USB_OHCI_DEVICE_ADDRESS_STATE;            	/* Update the URB status */            	pUrb->nStatus = USBHST_SUCCESS;        		}        	else        		{            	/* Invalid request. Update the URB status */            	pUrb->nStatus = USBHST_INVALID_REQUEST;        		}        	break;    	case USBHST_REQ_GET_DESCRIPTOR: /* USB GET_DESCRIPTOR request */        	/* Check the descriptor type */        	switch (pSetupPacket->wValue >> USB_OHCI_GET_DESCRIPTOR_TYPE_OFFSET)        		{        		case USBHST_DEVICE_DESC:            		/* Check the length of descriptor requested */            		if (pSetupPacket->wLength >= 							USB_OHCI_ROOT_HUB_DEVICE_DESCRIPTOR_LENGTH)            			{                		/* Copy the descriptor to the URB transfer buffer */                		OS_MEMCPY(pUrb->pTransferBuffer,                          		  (PUCHAR) (&usbOhciRootHubDeviceDescriptor),                          		  USB_OHCI_ROOT_HUB_DEVICE_DESCRIPTOR_LENGTH);                		/* Update the URB transfer length */                		pUrb->uTransferLength = 							USB_OHCI_ROOT_HUB_DEVICE_DESCRIPTOR_LENGTH;            			}            		else             			{                		/* Copy the descriptor to the URB transfer buffer */                		OS_MEMCPY(pUrb->pTransferBuffer,                          		  (PUCHAR) (&usbOhciRootHubDeviceDescriptor),                          		  pSetupPacket->wLength);                		/* Update the URB transfer length */                		pUrb->uTransferLength = pSetupPacket->wLength;            			}            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		case USBHST_CONFIG_DESC:            		/* Check the length of descriptor requested */            		if (pSetupPacket->wLength >=                 			USB_OHCI_ROOT_HUB_CONFIGURATION_DESCRIPTOR_LENGTH)            			{                		/* Copy the descriptor to the URB transfer buffer */                		OS_MEMCPY(pUrb->pTransferBuffer,                          	(PUCHAR) (&usbOhciRootHubConfigurationDescriptor),                          	USB_OHCI_ROOT_HUB_CONFIGURATION_DESCRIPTOR_LENGTH);                		/* Update the URB transfer length */                		pUrb->uTransferLength =                     		USB_OHCI_ROOT_HUB_CONFIGURATION_DESCRIPTOR_LENGTH;            			}            		else             			{                		/* Copy the descriptor to the URB transfer buffer */                		OS_MEMCPY(pUrb->pTransferBuffer,                        	(PUCHAR)(&usbOhciRootHubConfigurationDescriptor),                          	pSetupPacket->wLength);                		/* Update the URB transfer length */                		pUrb->uTransferLength = pSetupPacket->wLength;            			}            		/* Update the URB status */            		pUrb->nStatus = USBHST_SUCCESS;            		break;        		default:            		/* Invalid descriptor type */            		pUrb->nStatus = USBHST_INVALID_REQUEST;            		break;        		};        	break;    	case USBHST_REQ_SET_DESCRIPTOR: /* USB SET_DESCRIPTOR request */        	/*          	 * SET_DESCRIPTOR request is not support for the root hub.          	 * Update the URB status.         	 */        	pUrb->nStatus = USBHST_INVALID_REQUEST;        	break;    	case USBHST_REQ_GET_CONFIGURATION: /* USB GET_CONFIGURATION request */        	/*          	 * Update the URB transfer buffer with the current configuration         	 * value for the root hub         	 */        	pUrb->pTransferBuffer[0] =             	pOhciControllerInfo->bCurrentConfigurationValue;        	/* Update the URB transfer length */        	pUrb->uTransferLength = 				USB_OHCI_GET_CONFIGURATION_REQUEST_RESPONSE_SIZE;        	/* Update the URB status */        	pUrb->nStatus = USBHST_SUCCESS;        	break;    	case USBHST_REQ_SET_CONFIGURATION: /* USB SET_CONFIGURATION request */        	/* Check whether the configuration value specified is valid */        	if ((pSetupPacket->wValue != 0) && (pSetupPacket->wValue != 1))        		{            	/* Invalid configuration value. Update the URB status */            	pUrb->nStatus = USBHST_INVALID_REQUEST;            	break;        		}        	/* Update the current configuration value for the root hub */        	pOhciControllerInfo->bCurrentConfigurationValue =             	(UINT8) pSetupPacket->wValue;        	/*          	 * Check the current configuration value and update the root hub         	 * device state         	 */        	if (pOhciControllerInfo->bCurrentConfigurationValue == 0)        		{            	/* Update the root hub device state to addressed */            	pOhciControllerInfo->uRootHubState = 					USB_OHCI_DEVICE_ADDRESS_STATE;        		}        	else if (pOhciControllerInfo->bCurrentConfigurationValue == 1)        		{            	/* Update the root hub device state to configured */            	pOhciControllerInfo->uRootHubState = 					USB_OHCI_DEVICE_CONFIGURED_STATE;        		}        	/* Update the URB status */        	pUrb->nStatus = USBHST_SUCCESS;        	break;    	case USBHST_REQ_GET_INTERFACE: /* USB GET_INTERFACE request */        	/* Check the interface number */        	if (pSetupPacket->wIndex != 0)        		{            	/* Invalid interface number. Update the URB status */            	pUrb->nStatus = USBHST_INVALID_REQUEST;            	break;        		}        	/*          	 * Update the URB transfer buffer with the current alternate setting         	 * value for interface 0         	 */        	pUrb->pTransferBuffer[0] = 0;        	/* Update the URB transfer length */        	pUrb->uTransferLength = 				USB_OHCI_GET_INTERFACE_REQUEST_RESPONSE_SIZE;        	/* Update the URB status */        	pUrb->nStatus = USBHST_SUCCESS;        	break;    	case USBHST_REQ_SET_INTERFACE: /* USB SET_INTERFACE request */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -