亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usb_core.c

?? STR71X源代碼包括例程與各功能的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : usb_core.c
* Author             : MCD Application Team
* Date First Issued  : 27/10/2003
* Description        : standard protocol processing (USB v1.1)
*
********************************************************************************/

#include "USB_lib.h"

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#define ValBit(VAR,Place)    (VAR & (1<<Place))
#define SetBit(VAR,Place)    ( VAR |= (1<<Place) )
#define ClrBit(VAR,Place)    ( VAR &= ((1<<Place)^255) )

BYTE *Standard_GetStatus(WORD Length);
RESULT Standard_ClearFeature(void);
RESULT Standard_SetFeature(void);

#define Send0LengthData() {	\
	_SetEPTxCount(ENDP0, 0);	\
	vSetEPTxStatus(EP_TX_VALID);	\
	}

/* cells saving status during interrupt servicing */
WORD SaveRState;
WORD SaveTState;
#define vSetEPRxStatus(st)	(SaveRState = st)
#define vSetEPTxStatus(st)	(SaveTState = st)

#define USB_StatusIn()	Send0LengthData()
#define USB_StatusOut()	vSetEPRxStatus(EP_RX_VALID)


/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_GetConfiguration
	INPUT:	Length - How many bytes are needed
	OUTPUT:	If "Length" is 0, return the length of configuration value
			If "Length" is not 0, return the data buffer address
	RETURN:	Return 0, if the request is invalid when "Length" is 0
			Return "Buffer" if the "Length" is not 0
	DESCRIPTION:
		Return the current configuration variable address

	NOTICE:
		This routine is used for devices with only one configuration,
		User should write their own routine to process GET_CONFIGURATION
		if their device has more than one configuration.
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
BYTE *Standard_GetConfiguration(WORD Length)
{
	if (Length == 0)
		return (BYTE *)sizeof(pInformation->Current_Configuration);

	return (BYTE *)&pInformation->Current_Configuration;
} /* Standard_GetConfiguration */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_SetConfiguration
	INPUT:
	OUTPUT:
	RETURN:	Return SUCCESS, if the request is performed
			Return UNSUPPORT, if the request is invalid
	DESCRIPTION:
		The class calls this routine to get the configuration value
		Then each class should configure device themself

	NOTICE:
		This routine is used for devices with only one configuration.
		User should write their own routine to process SET_CONFIGURATION
		if their device has more than one configuration.
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
RESULT Standard_SetConfiguration(void)
{
	BYTE wValue0 = pInformation->USBwValue0;
	if (wValue0 <= Device_Table.Total_Configuration) {
		/* If the number of configuration is within the range */
		pInformation->Current_Configuration = wValue0;
		return SUCCESS;
	}
	else
		return UNSUPPORT;
} /* Standard_SetConfiguration */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_GetInterface
	INPUT:	Length - How many bytes are needed
	OUTPUT:	If "Length" is 0, return the length of interface value
			If "Length" is not 0, return the data buffer address
	RETURN:	Return 0, if the request is invalid when "Length" is 0
			Return "Buffer" if the "Length" is not 0
	DESCRIPTION:
		Return the current interface variable address

	NOTICE:
		This routine is used for devices with only one configuration and one interface,
		User should write their own routine to process GET_INTERFACE
		if their device has more than one configuration or one interface
		or one alternative setting.
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
BYTE *Standard_GetInterface(WORD Length)
{
	if (Length == 0)
		return (BYTE *)sizeof(pInformation->Current_Interface);

	return (BYTE *)&pInformation->Current_Interface;
} /* Standard_GetInterface */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_SetInterface
	INPUT:
	OUTPUT:
	RETURN:	Return SUCCESS, if the request is performed
			Return UNSUPPORT, if the request is invalid
	DESCRIPTION:
		The class calls this routine to get the interface value
		Then each class should configure the interface themself

	NOTICE:
		This routine is used for devices with only one configuration and
		one interface with one alternative setting.
		User should write their own routine to process SET_INTERFACE
		if their device has more than one configuration or one interface
		or one alternative setting.
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
RESULT Standard_SetInterface(void)
{
	DEVICE_INFO		*pInfo = pInformation;
	if (pInfo->USBwValue0 != 0 || pInfo->USBwIndex0 != 0)
		return UNSUPPORT;

	/* I have only one interface & one alternative setting */
	pInfo->Current_Interface = 0;
	return SUCCESS;
} /* Standard_SetInterface */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_GetStatus
	INPUT:	Length - How many bytes are needed
	OUTPUT:	If "Length" is 0, return the length of status data
			If "Length" is not 0, return number of bytes have been copied
	RETURN:	Return 0, if the request is at end of data block,
						or is invalid when "Length" is 0
	DESCRIPTION:

	  Copy the device request data to "StatusInfo buffer"
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
WORD_BYTE StatusInfo;
#define StatusInfo0 StatusInfo.bw.bb1	/* Reverse bb0 & bb1 */
#define StatusInfo1 StatusInfo.bw.bb0
BYTE *Standard_GetStatus(WORD Length)
{
	DEVICE_INFO	*pInfo = pInformation;
	BYTE	Type_Rec;

	if (Length == 0)
		return (BYTE *)2;

	StatusInfo.w = 0;	/* Reset Status Information */

	Type_Rec = Type_Recipient;
	if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
		BYTE	Feature = pInfo->Current_Feature;

		if (ValBit(Feature, 5))
			SetBit(StatusInfo0, 1); /* Remote Wakeup enabled */

		if (ValBit(Feature, 7))
			;	/*	ClrBit(StatusInfo0, 0); */ /* Bus-powered */
		else if (ValBit(Feature, 6))
			SetBit(StatusInfo0, 0);  /* Self-powered */
	}
	else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
		BYTE	Related_Endpoint;
		BYTE	wIndex0 = pInfo->USBwIndex0;

		Related_Endpoint = ENDP0 + (wIndex0 & 0x0f);

		if (ValBit(wIndex0, 7)) {
			/* IN endpoint */
			if (_GetTxStallStatus( Related_Endpoint ))
				SetBit(StatusInfo0, 0);	/* IN Endpoint stalled */
		}
		else {
			/* OUT endpoint */
			if (_GetRxStallStatus( Related_Endpoint ))
				SetBit(StatusInfo0, 0);	/* OUT Endpoint stalled */
		}

	}
	else
		return NULL;

	return (BYTE *)&StatusInfo;
} /* Standard_GetStatus */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_ClearFeature
	INPUT:
	OUTPUT:	none
	DESCRIPTION:
		Clear or disable a specific feature
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
RESULT Standard_ClearFeature(void)
{
	DEVICE_INFO	*pInfo = pInformation;
	BYTE	Type_Rec = Type_Recipient;
	BYTE	wValue0 = pInfo->USBwValue0;

	if ( Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT) ) {
		if (wValue0 != DEVICE_REMOTE_WAKEUP)
			return UNSUPPORT;

		ClrBit(pInfo->Current_Feature, 5);
		return SUCCESS;
	}
	else if ( Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT) ) {
		DEVICE* pDev;
		BYTE	Related_Endpoint;
		BYTE	wIndex0;
		BYTE	rEP;

		if (wValue0 != ENDPOINT_STALL)
			return UNSUPPORT;

		pDev = &Device_Table;
		wIndex0 = pInfo->USBwIndex0;
		rEP = wIndex0 & ~0x80;
		if (rEP >= pDev->Total_Endpoint)
			return UNSUPPORT;

				/* EPindex should be equal to Device_Table.EP0 */
		Related_Endpoint = ENDP0 + rEP;

		if (wIndex0 & 0x80) {		/* IN endpoint */
			if (_GetTxStallStatus(Related_Endpoint ))
				_SetEPTxStatus(Related_Endpoint, EP_TX_NAK);
		}
		else {							/* OUT endpoint */
			if (_GetRxStallStatus(Related_Endpoint)){
				if (Related_Endpoint == ENDP0) {
					/* After clear the STALL, enable the default endpoint receiver */
					SetEPRxCount(Related_Endpoint, STD_MAXPACKETSIZE);
					_SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
				}
				else
					_SetEPRxStatus(Related_Endpoint, EP_RX_NAK);
			}
		}
		return SUCCESS;
	}

	return UNSUPPORT;
} /* Standard_ClearFeature */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_SetFeature
	INPUT:
	OUTPUT:	none
	DESCRIPTION:
		Set or enable a specific feature
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
RESULT Standard_SetFeature(void)
{
	DEVICE_INFO	*pInfo = pInformation;
	BYTE	Type_Rec = Type_Recipient;
	BYTE	wValue0 = pInfo->USBwValue0;

	if ( Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT) ) {
		if (wValue0 != DEVICE_REMOTE_WAKEUP)
			return UNSUPPORT;

		SetBit(pInfo->Current_Feature, 5);

		/****************************************/
		return SUCCESS;
	}
	else if ( Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT) ) {
		DEVICE* pDev;
		BYTE	Related_Endpoint;
		BYTE	wIndex0;
		BYTE	rEP;

		if (wValue0 != ENDPOINT_STALL)
			return UNSUPPORT;

		pDev = &Device_Table;
		wIndex0 = pInfo->USBwIndex0;
		rEP = wIndex0 & ~0x80;
		if (rEP >= pDev->Total_Endpoint)
			return UNSUPPORT;

		Related_Endpoint = ENDP0 + rEP;
		if (wIndex0 & 0x80) {		/* IN endpoint */
			_SetEPTxStatus(Related_Endpoint, EP_TX_STALL);
		}
		else {							/* OUT endpoint */
			_SetEPRxStatus(Related_Endpoint, EP_RX_STALL);
		}

		return SUCCESS;
	}

	return UNSUPPORT;
} /* Standard_SetFeature */

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	NAME:	Standard_GetDescriptorData
			Standard_GetStringDescriptor
	INPUT:	Length - Length of the data in this transfer
			pDesc - A pointer points to descriptor struct
					The structure gives the initial address
					of the descriptor and its original size
	OUTPUT:	Address of a part of the descriptor pointed by the Usb_wOffset
			The buffer pointed by this address contains at least Length bytes
	DESCRIPTION:
		These 2 routines only used for the descriptors resident in ROM or RAM
		pDesc can be in either ROM or RAM

		Standard_GetStringDescriptor is used for transfer string descriptor

		The purpose of these 2 routines is to have a versatile way to response
		descriptors request. It allows user to generate certain descriptors
		with software or read descriptors from external storage part by part.
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
BYTE *Standard_GetStringDescriptor(WORD Length, ONE_DESCRIPTOR *pDesc)
{
	int		len, offset, wOffset;

	wOffset = pInformation->Ctrl_Info.Usb_wOffset;
	if (Length == 0) {
		offset = 0;
		do {
			len = (int)*(pDesc->Descriptor + offset);
			if (wOffset >= 0 && wOffset < len) {
				len -= wOffset;
				if (len > 0)
					return (BYTE*)len;
				break;
			}

			wOffset -= len;
			offset += len;
		} while (offset < pDesc->Descriptor_Size);

		return 0;
	}

	return pDesc->Descriptor + wOffset;
}/* Standard_GetStringDescriptor */

/*============================================================================*/
/*============================================================================*/
BYTE *Standard_GetDescriptorData(WORD Length, ONE_DESCRIPTOR *pDesc)
{
	int		len, wOffset;

	wOffset = pInformation->Ctrl_Info.Usb_wOffset;
	if (Length == 0) {
		len = pDesc->Descriptor_Size - wOffset;

		if (len <= 0)
			return 0;

		return (BYTE *)len;
	}

	return pDesc->Descriptor + wOffset;
} /* Standard_GetDescriptorData */

/*-----------------------------------------------------------------------------
ROUTINE NAME : DataStageOut
INPUT/OUTPUT : None
DESCRIPTION  : Data stage of a Control Write Transfer
-----------------------------------------------------------------------------*/
void DataStageOut()
{
	ENDPOINT_INFO	*pEPinfo = &pInformation->Ctrl_Info;
	WORD	save_rLength;

	save_rLength = pEPinfo->Usb_rLength;

	if (pEPinfo->CopyData && save_rLength) {
		BYTE *Buffer;
		WORD Length;
		BYTE *Source;

		Length = pEPinfo->PacketSize;
		if (Length > save_rLength)
			Length = save_rLength;

		Buffer = (*pEPinfo->CopyData)(Length);

		pEPinfo->Usb_rLength -= Length;
		pEPinfo->Usb_rOffset += Length;

/*sb		Source = pProperty->RxEP_buffer; */
		Source = PMAAddr + (BYTE *)(_GetEPRxAddr(ENDP0)*2); /* *2 for 32 bits addr */
		while (Length) {
			*Buffer++ = *Source++;
			Length--;
			if(Length == 0) break; /* odd counter */
			*Buffer++ = *Source++;
			Length--;
			Source++;Source++; /* skip 2 bytes for 32 bit addressing */
		}
	}

	if (pEPinfo->Usb_rLength == 0) {
		/* this OUT Transaction is the last one */
		pInformation->ControlState =
			(save_rLength == pEPinfo->PacketSize) ?
					/*	If the previous read length is same as MaxPacketSize
						This is the multiple MaxPacketSize package
						Wait for another OUT token and send 0 length data
					*/
				WAIT_OUT_ZERO :
					/*	If the previous read length is NOT same as MaxPacketSize
						Wait for the IN token to finish the status stage

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄页在线观看| 成人爱爱电影网址| 中文字幕日韩精品一区| 欧美在线高清视频| 国产成人精品免费视频网站| 丝袜a∨在线一区二区三区不卡| 国产欧美日韩卡一| 91麻豆精品国产91久久久久| 欧美精品乱码久久久久久| 国产麻豆视频一区| 喷白浆一区二区| 亚洲午夜精品久久久久久久久| 欧美国产1区2区| 欧美不卡在线视频| 7777精品久久久大香线蕉| 91视频免费观看| 成人午夜免费av| 精一区二区三区| 五月激情综合婷婷| 亚洲激情综合网| 中文字幕一区二区三区精华液| 26uuu欧美| 精品国内二区三区| 日韩一级精品视频在线观看| 欧美亚洲国产一卡| 91久久久免费一区二区| 成人av在线网| 波多野结衣一区二区三区| 黄色成人免费在线| 久久99国产乱子伦精品免费| 日本在线不卡一区| 丝袜美腿亚洲综合| 日韩精品1区2区3区| 无吗不卡中文字幕| 日韩成人免费电影| 日韩av电影天堂| 日韩精品成人一区二区三区| 日韩激情中文字幕| 日本亚洲最大的色成网站www| 午夜伦欧美伦电影理论片| 亚洲网友自拍偷拍| 午夜欧美大尺度福利影院在线看| 亚洲国产乱码最新视频| 午夜电影网亚洲视频| 日韩中文字幕麻豆| 久久99久久99精品免视看婷婷| 麻豆91精品91久久久的内涵| 激情五月激情综合网| 韩国成人在线视频| 国产麻豆视频一区| 99热这里都是精品| 欧洲精品视频在线观看| 欧美久久久久免费| 精品国产91乱码一区二区三区 | 欧美精品三级日韩久久| 欧美麻豆精品久久久久久| 日韩欧美国产三级电影视频| 欧美精品一区二区高清在线观看 | 欧美美女bb生活片| 日韩女优av电影在线观看| 久久精品人人做人人综合 | 黄色小说综合网站| 欧美人xxxx| 日韩欧美在线综合网| 国产人妖乱国产精品人妖| 中文字幕中文字幕一区二区 | 日韩在线卡一卡二| 激情成人综合网| 91在线码无精品| 欧美片在线播放| 国产丝袜欧美中文另类| 亚洲私人影院在线观看| 日韩专区一卡二卡| 成人一区在线观看| 亚洲国产日韩a在线播放| 综合久久久久久久| 亚洲国产wwwccc36天堂| 久久国产视频网| 北条麻妃一区二区三区| 色综合久久中文综合久久牛| 91麻豆国产精品久久| 欧美久久久久久久久中文字幕| 久久久久久久久久久电影| 综合在线观看色| 日韩激情一区二区| jlzzjlzz亚洲日本少妇| 日韩一区二区三区视频| 亚洲另类一区二区| 国产亚洲成aⅴ人片在线观看| 一区二区三区中文在线观看| 国产精品美女久久福利网站| 国产乱人伦精品一区二区在线观看| 亚洲永久精品大片| 久久伊99综合婷婷久久伊| 欧美日本一区二区三区四区| 99re这里都是精品| 国产精品一区在线观看乱码| 日韩精品电影一区亚洲| 亚洲国产裸拍裸体视频在线观看乱了| 国产精品久久久99| www欧美成人18+| 日韩视频在线一区二区| 91成人免费网站| 91女神在线视频| av在线播放不卡| 国产白丝精品91爽爽久久| 另类调教123区| 麻豆精品视频在线| 麻豆精品在线播放| 久久爱另类一区二区小说| 奇米777欧美一区二区| 日本v片在线高清不卡在线观看| 一区二区三区免费看视频| 日韩福利电影在线| 五月天视频一区| 无码av免费一区二区三区试看| 亚洲精品免费看| 亚洲小说欧美激情另类| 一区二区三区四区中文字幕| 亚洲免费观看高清完整版在线观看| 国产精品国产三级国产三级人妇| 中文字幕中文字幕一区二区| 最近中文字幕一区二区三区| 亚洲美女在线国产| 亚洲一区二区三区国产| 爽好多水快深点欧美视频| 免费成人小视频| 国内成人自拍视频| 粉嫩在线一区二区三区视频| 91尤物视频在线观看| 色婷婷久久99综合精品jk白丝 | 免费一区二区视频| 久久91精品国产91久久小草| 国产91精品入口| 色综合中文字幕国产| 欧美综合视频在线观看| 91麻豆精品国产91久久久使用方法| 日韩欧美一二区| 国产精品久久久久久久裸模| 艳妇臀荡乳欲伦亚洲一区| 麻豆精品在线观看| 成人激情黄色小说| 欧美色网站导航| 久久亚洲免费视频| 一区二区国产盗摄色噜噜| 蜜臀av一区二区三区| 不卡的电影网站| 日韩欧美专区在线| 亚洲嫩草精品久久| 激情久久五月天| 在线观看国产91| 亚洲精品一区二区在线观看| 夜色激情一区二区| 国产99精品在线观看| 欧美日韩高清一区二区| 欧美激情综合五月色丁香| 偷拍自拍另类欧美| 成人小视频在线| 欧美日韩国产高清一区二区| 国产日韩欧美制服另类| 日韩精品福利网| 色婷婷综合久久| 国产精品私人自拍| 免费成人美女在线观看| 色综合久久久久网| 国产日产欧美一区二区视频| 婷婷丁香激情综合| 99久久国产综合色|国产精品| 国产精品沙发午睡系列990531| 亚洲va韩国va欧美va| 北岛玲一区二区三区四区| 日韩欧美国产小视频| 亚洲国产人成综合网站| 97超碰欧美中文字幕| 久久久久久久久一| 日本在线不卡视频| 欧美日韩1234| 玉米视频成人免费看| 丁香五精品蜜臀久久久久99网站 | 国产午夜精品一区二区三区视频| 亚洲成va人在线观看| 在线这里只有精品| 最近中文字幕一区二区三区| 成人一区在线看| 国产欧美日韩三级| 高清视频一区二区| 国产清纯美女被跳蛋高潮一区二区久久w| 免费成人在线观看视频| 欧美日韩电影一区| 婷婷国产在线综合| 91.com在线观看| 日本美女视频一区二区| 337p亚洲精品色噜噜噜| 五月激情综合婷婷| 欧美精品1区2区| 免费观看久久久4p| 日韩午夜电影在线观看| 久久成人综合网| 久久精品人人做人人综合| 国产精品123|