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

📄 obj_usbdesc.c

📁 基于K9 AT91RM9200 学习板的loader源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		else			pUsbDesc->GetStatus(recipient, pSetup->wIndex, pUsbDesc->pPrivateStandardData);	}	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UsbDescSetAddress              *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request sets the device     *//*     address for all device accesses  *//* ************************************ */void AT91F_UsbDescSetAddress(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState  = AT91F_UdpGetState(pUsbDesc->pUdp);	/* Check request arguments */	if ((pSetup->wValue >= 127) || pSetup->wIndex != 0 || pSetup->wLength != 0)		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ================ Configured state ================= */	else if ( (usbState & UDP_CONFG) )		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ============ Address or Default state ============= */	else {		/* Enter the address state if the value != 0 */		//AT91F_UdpEpEow(pUsbDesc->pUdp, pUsbDesc->epId);		// Wait for TX Complete		if (pUsbDesc->SetAddress)			pUsbDesc->SetAddress(pSetup->wValue, pUsbDesc->pPrivateStandardData);	}}/* ************************************ *//* AT91F_UsbDescSetConfiguration        *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request sets the device     *//*     configuration                    *//* ************************************ */void AT91F_UsbDescSetConfiguration(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState  = AT91F_UdpGetState(pUsbDesc->pUdp);	/* Check request arguments */	if ((pSetup->wValue & 0xFF00) || pSetup->wIndex != 0 || pSetup->wLength != 0)		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ================ Configured state ================= */	else if ( (usbState & UDP_CONFG) ) {		if (pSetup->wValue == 0) {			/* Device enters Address State */			AT91F_UdpSetState(pUsbDesc->pUdp, UDP_FADDEN);			AT91F_UdpEpEow(pUsbDesc->pUdp, pUsbDesc->epId);		}		else {			if (pUsbDesc->SetConfiguration)				pUsbDesc->SetConfiguration(pSetup->wValue, pUsbDesc->pPrivateStandardData);			else				AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);		}	}	/* =================== Address state ================= */	else if ( (usbState & UDP_FADDEN) ) {		if (pSetup->wValue == 0)			/* Device remains in Address State */			AT91F_UdpEpEow(pUsbDesc->pUdp, pUsbDesc->epId);		else {			if (pUsbDesc->SetConfiguration)				pUsbDesc->SetConfiguration(pSetup->wValue, pUsbDesc->pPrivateStandardData);			else				AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);		}	}	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UsbDescSetDescriptor           *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request may be used to      *//*     update existing descripotrs or   *//*     new descriptors may be added     *//* ************************************ */void AT91F_UsbDescSetDescriptor(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState  = AT91F_UdpGetState(pUsbDesc->pUdp);	/* ================ Configured or Address state ================= */	if ( ((usbState & UDP_CONFG) || (usbState & UDP_FADDEN))) {		if (pUsbDesc->SetDescriptor)			pUsbDesc->SetDescriptor (				(pSetup->wValue >> 8),   /* Descriptor type */				(pSetup->wValue & 0xFF), /* Descriptor index */				pSetup->wIndex,          /* Language ID */				pSetup->wLength,         /* Desriptor length */				pUsbDesc->pPrivateStandardData);		else			AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	}	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UsbDescSetFeature              *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request is used to set or   *//*     enable a specific feature        *//* ************************************ */void AT91F_UsbDescSetFeature(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState = AT91F_UdpGetState(pUsbDesc->pUdp);	u_int recipient = (pSetup->bmRequestType & 0x1F);	/* Check request arguments */	if (recipient > 2 || pSetup->wLength != 0)		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ================ Configured state ================= */	else if ( (usbState & UDP_CONFG) ) {		if (pUsbDesc->SetFeature)			pUsbDesc->SetFeature (recipient, pSetup->wIndex, pSetup->wValue, pUsbDesc->pPrivateStandardData);		else			AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	}	/* =================== Address state ================= */	else if ( (usbState & UDP_FADDEN) ) {		/* This request is valid in Address State only when reference endpoint 0 */		if (recipient != 2 || pSetup->wIndex != 0)			AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);		else {			if (pUsbDesc->SetFeature)				pUsbDesc->SetFeature (recipient, pSetup->wIndex, pSetup->wValue, pUsbDesc->pPrivateStandardData);			else				AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);		}	}	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UsbDescSetInterface            *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request allows the host to  *//*     select an alternate setting for  *//*     the specified interface          *//* ************************************ */void AT91F_UsbDescSetInterface(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState = AT91F_UdpGetState(pUsbDesc->pUdp);	/* Check request arguments */	if (pSetup->wLength != 0)		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ================ Configured state ================= */	else if ( (usbState & UDP_CONFG) ) {		if (pUsbDesc->SetInterface)			pUsbDesc->SetInterface (pSetup->wIndex, pSetup->wValue, pUsbDesc->pPrivateStandardData);		else			AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	}	/* =================== Address state ================= */	else if ( (usbState & UDP_FADDEN) )		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpEow(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UsbDescSynchFrame              *//*                                      *//* Arguments:                           *//*     pSetup: pointer to setup datas   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     This request is used to set and  *//*     then report an ep's synch.frame. *//* ************************************ */void AT91F_UsbDescSynchFrame(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbSetup      pSetup)    /* USB setup data Cf USB spec rev 1.1 */{	u_int usbState = AT91F_UdpGetState(pUsbDesc->pUdp);	/* Check request arguments */	if (pSetup->wValue != 0 || pSetup->wLength != 2)		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* ================ Configured state ================= */	else if ( (usbState & UDP_CONFG) ) {		if (pUsbDesc->SynchFrame)			pUsbDesc->SynchFrame (pSetup->wIndex, pUsbDesc->pPrivateStandardData);		else			AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	}	/* =================== Address state ================= */	else if ( (usbState & UDP_FADDEN) )		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);	/* =================== Default state ================= */	else		/* Device behavior not specified */		AT91F_UdpEpStall(pUsbDesc->pUdp, pUsbDesc->epId);}/* ************************************ *//* AT91F_UdpConfigure                   *//*                                      *//* Arguments:                           *//*     pEp:   pointer to endpoint       *//*            standard USB descriptor   *//* Return:                              *//*     Nothing                          *//* Description:                         *//*     Configure USB endpoints according*//*     to the endpoint descriptor       *//* ************************************ */void AT91F_UdpConfigure(	AT91PS_UsbDesc const pUsbDesc,  /* pointer to a AT91S_UsbDesc structure */	AT91PS_UsbEndpoint const pEp){	if (pEp->bEndpointAddress & (1 << 7)) {		/* IN endpoint */		switch (pEp->bmAttributes & 0x03) {		case 0:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_CONTROL);        break;		case 1:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_ISOCHRONOUS_IN); break;		case 2:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_BULK_IN);        break;		default: AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_INTERRUPT_IN);   break;		}	}	else {		/* OUT endpoint */		switch (pEp->bmAttributes & 0x03) {		case 0:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_CONTROL);         break;		case 1:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_ISOCHRONOUS_OUT); break;		case 2:  AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_BULK_OUT);        break;		default: AT91F_UdpEpConfigure(pUsbDesc->pUdp, pUsbDesc->epId, UDP_EPDS | UDP_INTERRUPT_OUT);   break;		}	}}

⌨️ 快捷键说明

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