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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? combi.c

?? 這是使用CYPRESS的7C637xx芯片完成USB鼠標的例子。
?? C
?? 第 1 頁 / 共 5 頁
字號:
{

	if (ENDPOINT_A0_FIFO[USB_bmRequestType] !=  (DEVICE_TO_HOST | CLASS    | INTERFACE)) 
	{
		SET_EP0_MODE(USB_MODE_STALL_IN_OUT);
		return;
	}
    XmtBuff.bLength = 1;								//set length of protocol
    XmtBuff.p=&DeviceStatus.bProtocol;					//aim XmtBuff at it
    USB_control_read();									//initiate transfer
}


/*
**
** FUNCTION:		GetConfiguration
**
** PURPOSE:			Implements the Get Configuration command
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine is entered whenever a Get Configuration Request is received.
**					
*/

void GetConfiguration(void)
{
 	if (ENDPOINT_A0_FIFO[USB_bmRequestType] != DEVICE_TO_HOST | STANDARD | DEVICE)
	{
		SET_EP0_MODE(USB_MODE_STALL_IN_OUT);
		return;
	}
	XmtBuff.bLength = 1;								//configuration is 1-byte long
    XmtBuff.p=&DeviceStatus.bConfiguration;				//point at it
    USB_control_read();									//initiate transfer
}


/*
**
** FUNCTION:		USB_Stall_In_Out
**
** PURPOSE:			sets the SIE mode to stall IN/OUT packets on endpoint 0
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					
**					
*/

void USB_Stall_In_Out(void)
{
    SET_EP0_MODE(USB_MODE_STALL_IN_OUT);
}



#pragma memory ORG @ 0x880

const void (* StandardFunctionTable[])(void)= 
{
   GetStatus,ClearFeature,USB_Stall_In_Out,SetFeature,
   USB_Stall_In_Out,SetAddress,GetDescriptor,USB_Stall_In_Out,
   GetConfiguration,SetConfiguration,GetStatus
};
/*
** define a lookup table of function pointers to class requests
*/
const void (* ClassFunctionTable[])(void)= 
{
  USB_Stall_In_Out, GetReport, GetIdle,GetProtocol,
  USB_Stall_In_Out, USB_Stall_In_Out, USB_Stall_In_Out,USB_Stall_In_Out,
  USB_Stall_In_Out, USB_Stall_In_Out, SetIdle,SetProtocol
};


/*
**
** FUNCTION:		HandleSetup
**
** PURPOSE:			Services Setup packets 
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine is entered whenever an SETUP packet has come in on endpoint 0.
**					it performss some preliminary validation on the packet, then
**					parses the packet and calls the appropriate routine to handle the packet.
**					
*/

void HandleSetup(void)

{
	EP_A0_MODE = USB_MODE_NAK_IN_OUT;						//unlock mode register
	/*
	** Setups are always 10 bytes, with DATAVALID = 1 and DATATOGGLE = 0
	*/
	if ( (EP_A0_COUNTER & (DATAVALID | DATATOGGLE | COUNT_MASK)) ==
		  (DATAVALID | 10))
	{
		if (ENDPOINT_A0_FIFO[USB_bmRequestType] & CLASS)
		{	
								
			if (ENDPOINT_A0_FIFO[USB_bRequest] <= USB_SET_PROTOCOL)				//class request, use class table
			{
				(*ClassFunctionTable[ENDPOINT_A0_FIFO[USB_bRequest]])();
				return;
			}
		}
		else
		{
			if (ENDPOINT_A0_FIFO[USB_bRequest] <= USB_GET_INTERFACE)			//standard request, use standard table
			{
				(*StandardFunctionTable[ENDPOINT_A0_FIFO[USB_bRequest]])();
				return;
			}
		}
	}
	SET_EP0_MODE(USB_MODE_STALL_IN_OUT);										//invalid request, stall
}


//**************************************************************************************8
//PS2 routines

/*
**
** FUNCTION:		ps2main
**
** PURPOSE:			main processing loop for PS/2 
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					ps2main spins in an infinite loop waiting for an event that needs servicing.
*/

void ps2main(void)
{

	char bInputByte;			//storage for byte received from host
    ReInitialize();				//reinitialize all ps2 variables to default states
    SetDefault();				//set the host-settable parameters to the default states
	EI();						//enable interrupts
	ps2BAT();					//send the BAT code
	/*
	** only now can we enable the 128 usec interrupt, which will start filling the optics queue
	** with data.  ProcessOptics must be called at regular intervals from this point on, to prevent
	** the optics queue from overflowing.
	*/
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE | MICROSECOND_ENABLE;
	while (1)
	{
		RESET_COP();									//always tickle watchdog
		ProcessOptics();								//empty optics queue
		bInputByte = GetByte();							//see if host has sent us anything
		if (!(CC.C))									//if carry is clear, a byte indeed arrived)
		{
			ProcessCommand(bInputByte);					//so go handle it
			continue;
		}
		if (Ps2Xmt.bXmtLen)								//anything to send?
		{
			PutNextByte();								//send a byte.
			continue;
		}

		if (MsecStatus.b1msFlags & ONE_MSEC_FLAG)		//1 msec expired?
		{	
			MsecStatus.b1msFlags &= ~ONE_MSEC_FLAG;
			Ps2MouseTask();								//do mouse stuff
   		}
	}
}


/*
**
** FUNCTION:		Ps2MouseTask
**
** PURPOSE:			handles ps2 mouse data packet management 
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					
*/

void Ps2MouseTask(void)
{
	if (!(MsecStatus.b1msCounter & 3))						//4 msec expired?
		Mouse.bChange |= DebounceButtons();					//yes, debounce switches
	if (!--bIntervalCount)									//if the mouse interval counter has expired,
	{
		ResetInterval();									//reset the interval
		if (MouseParms.bStream && MouseParms.bEnabled)

			SendMouseData();								//if the mouse is enabled and in stream mode, send a packet
	}
}


/*
**
** FUNCTION:		Reinitialize
**
** PURPOSE:			Reinitializes ps2 variables to their default states  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					
*/

void ReInitialize(void)
{
	DI();											//disable ints
	USB_STATUS = (PS2_PULLUP_MASK | PS2_INTERRUPT_MODE_MASK |FORCE_NEG_OPEN_POS_OPEN);
	RESET_COP();									//reset watchdog
	ClearRam();
	OpticsQueue.headP = bOpticsArray;
	OpticsQueue.tailP = bOpticsArray;
	PROCESSOR_STATUS &= ~(WATCHDOG_RESET_MASK		            //clear source of reset
		| POWER_ON_RESET_MASK | USB_BUS_RESET_MASK);
	USB_DEVICE_A = 0;											//reset device address
	EP_A0_MODE = USB_MODE_DISABLE;								//disable endpoints from responding
	EP_A1_MODE = USB_MODE_DISABLE;
	EP_A2_MODE = USB_MODE_DISABLE;
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE;						//enable only 1msec interrupt
	return;
}


/*
**
** FUNCTION:		ResetInterval
**
** PURPOSE:			Resets the mouse report interval
**
** PARAMETERS:		none
**
** DESCRIPTION:		This routine resets the mouse's report interval to the value last
**					sent by the host.  The report interval is counted down in the main loop
**					to provide a time base for sending mouse data packets.
**					
*/

void ResetInterval(void)
{
	bIntervalCount = MouseParms.bReportInterval;
}


/*
**
** FUNCTION:	GetByte		
**
** PURPOSE:		tries to get a byte from the host	
**	
** PARAMETERS:		
**
** DESCRIPTION:	GetByte checks to see if the host is requesting-to-send data, and if so,
**				clocks in a data byte from the host.  It returns the received byte 
**				and implicitly sets the carry to 0 if the reception occurred without errors.
**				GetByte turns off the 1msec interrupt during ps2 clocking so as not to
**				impose the potential for clock jitter due to that interrupt.
**					
**					
*/

char GetByte (void)
{
    char dummy;
	if (HOST_RTS)	                        				//host not requesting to send
	{
		GLOBAL_INTERRUPT = MICROSECOND_ENABLE;				//shut off msec interrupt
		dummy = ps2_receive();								//get data. ps2_receive sets the carry
															//to 1 if there was a problem in reception.
															
		GLOBAL_INTERRUPT = MILLISECOND_ENABLE | MICROSECOND_ENABLE;
		return(dummy);										//return data (and carry bit too)
	}
	CC.C = 1;												//couldn't get data, so set carry to one and exit
	return(0);
}


/*
**
** FUNCTION: ps2BAT		
**
** PURPOSE:	 delays for 500 msec, then sends the AA 00 initialization string	
**	
** PARAMETERS: none		
**
** DESCRIPTION:	 
**					
**					
*/

void ps2BAT(void)
{
	while (bBatDelay--)									//count down number of msec in bBatDelay
	{
		while (!(MsecStatus.b1msFlags & ONE_MSEC_FLAG))	//eat up a msec
			RESET_COP();
		MsecStatus.b1msFlags &= ~ONE_MSEC_FLAG;
	}
	Ps2Xmt.bMsgBuff[0] = 0xAA;							//send AA 00 to host
	Ps2Xmt.bMsgBuff[1] = 00;
	Ps2Xmt.bMsgLen = 2;
	Ps2Xmt.bXmtLen = 2;
}


/*
**
** FUNCTION:	PutNextByte		
**
** PURPOSE:		attempts to send  the next byte in the transmit queue to the host
**	
** PARAMETERS:  none		
**
** DESCRIPTION:	This routine sends the next byte  of the message buffer to the host.
**					
**					
*/

void PutNextByte(void)
{
	if (HOST_RTS || HOST_INHIBIT)								//host is requesting to send data, quit
		return;
	GLOBAL_INTERRUPT = MICROSECOND_ENABLE;
	ps2_send(Ps2Xmt.bMsgBuff[Ps2Xmt.bMsgLen-Ps2Xmt.bXmtLen]);							//send the byte
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE | MICROSECOND_ENABLE;
	if (!CC.C)
		Ps2Xmt.bXmtLen--;
}


/*
**
** FUNCTION:	Put	
**
** PURPOSE:		sends a byte to the host
**	
** PARAMETERS:	data -- byte to send	
**
** DESCRIPTION:	Put attempts to send a byte to the host. It is called to send an ACK, ERROR, or RESEND
**				to the host. In accordance with the IBM spec, these responses are not held for retransmission
**				in the event that the  host requests to send a byte before we can send the response itself.
**				Thus, this routine waits for host inhibit to go away, then sends the byte.  If the host
**				requests-to-send before this happens, it simply returns without sending the byte.
**					
**					
*/

void Put(char data)
{
	if(HOST_RTS)
		return;

	while (!HOST_RTS)
	{
		//we could sit in this loop for a long time, if the host is inhibiting us.  This is ok.
		//the 128 us interrupt is running and the optics queue might overflow, but that will
		//be fixed up upon return to the main loop (see code in ProcessOptics).  This is harmless --
		//the mouse is supposed to be disabled by the host prior to executing commands, so
		//we aren't required to be accumulating samples at this point, anyway.
		if (!HOST_INHIBIT)
		{
			GLOBAL_INTERRUPT = MICROSECOND_ENABLE;
			ps2_send(data);							//send the byte
			GLOBAL_INTERRUPT = MILLISECOND_ENABLE | MICROSECOND_ENABLE;
			return;									//ps2_send will set carry for us
		}
		RESET_COP();
	}
}


/*
**
** FUNCTION:	Reset		
**
** PURPOSE:		executes a reset 	
**	
** PARAMETERS:		
**
** DESCRIPTION:	 Reset simply gets into a loop waiting for the watchdog to perform a reset.
**					
**					
*/

void Reset(void)
{
     GLOBAL_INTERRUPT = 0;
	while (1);									//death by watchdog
}


/*
**
** FUNCTION:	Resend		
**
** PURPOSE:		Resends the last  transmission from the mouse	
**	
** PARAMETERS:	None	
**
** DESCRIPTION:	A copy of the  last  transmission is always left intact in the message buffer.
**				To resend it , we simply need to reset the message length.
**					
**					
*/

void Resend(void)
{
	Ps2Xmt.bXmtLen = Ps2Xmt.bMsgLen;

}


/*
**
** FUNCTION:	SetDefault	
**
** PURPOSE:		Sets the mouse parameters to the default settings
**	
** PARAMETERS:		
**
** DESCRIPTION:	 
**					
**					
*/

void SetDefault(void)
{
	MouseParms.bReportRate = 100;						//100 reports per second
	MouseParms.bReportInterval = 10;					//is equal to a report every 10 msec
	MouseParms.bScale = SC_1_1;							//1-to-1 scaling
	MouseParms.bStream = 1;								//stream mode on
	MouseParms.bResolution = RES_4MM;					//4 MM resolution
	MouseParms.bEnabled = 0;							//not enabled
	MouseParms.bZmouse = 0;								//z-wheel off.
}


/*
**
** FUNCTION:	Disable		
**
** PURPOSE

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区精品久久911| 亚洲va韩国va欧美va| 亚洲永久免费av| 美女在线视频一区| 欧美在线观看视频一区二区 | 日韩高清在线不卡| 成人精品免费视频| 日韩一区二区三区在线观看| 国产精品高潮呻吟| 国产精品一二三四| 日韩视频免费直播| 亚洲国产综合视频在线观看| 99国产精品久| 中文字幕精品—区二区四季| 久久精品国产色蜜蜜麻豆| 91小宝寻花一区二区三区| 国产日韩欧美电影| 国产一区二区三区精品视频| 538在线一区二区精品国产| 亚洲最大的成人av| 91视频免费播放| 一区二区中文视频| av不卡一区二区三区| 国产日韩欧美精品电影三级在线| 久久精品国产亚洲高清剧情介绍 | 日韩av电影免费观看高清完整版 | 日本不卡123| 欧美日韩一本到| 亚洲一区在线视频观看| 色猫猫国产区一区二在线视频| 欧美高清在线精品一区| 国内精品国产成人国产三级粉色 | 国产剧情一区在线| 26uuu亚洲| 国产剧情av麻豆香蕉精品| 久久精品在线免费观看| 国产成人一区二区精品非洲| 国产午夜一区二区三区| 国产不卡在线一区| 国产精品毛片大码女人| 91色九色蝌蚪| 亚洲一区二区三区不卡国产欧美| 欧美中文字幕一区二区三区 | 亚洲欧美色一区| 日本韩国欧美三级| 亚洲国产日韩精品| 欧美一区二区视频网站| 国产一区二区精品久久91| 中文字幕欧美区| 色婷婷激情久久| 日韩精品色哟哟| 久久综合成人精品亚洲另类欧美| 国产99久久久国产精品| 自拍偷拍国产亚洲| 欧美久久久影院| 狠狠v欧美v日韩v亚洲ⅴ| 中文字幕精品综合| 欧美日韩视频一区二区| 国产一区二区伦理| 亚洲激情图片一区| 欧美大片国产精品| 一本久久综合亚洲鲁鲁五月天| 五月综合激情网| 国产精品久久久久久久久免费桃花 | 欧美一区二区三区四区五区 | 欧美精品久久一区二区三区| 国内外精品视频| 亚洲精品欧美二区三区中文字幕| 欧美日韩亚州综合| 懂色av一区二区夜夜嗨| 视频一区视频二区中文| 欧美激情一区三区| 8x福利精品第一导航| 成人手机在线视频| 蜜臀av性久久久久蜜臀av麻豆| 一区二区中文字幕在线| 日韩西西人体444www| 色系网站成人免费| 国产精一品亚洲二区在线视频| 亚洲综合久久久| 国产女人18毛片水真多成人如厕| 在线不卡的av| 成人免费毛片嘿嘿连载视频| 日本sm残虐另类| 亚洲精品国产精品乱码不99| 国产清纯美女被跳蛋高潮一区二区久久w | 欧洲一区二区三区免费视频| 国产成人亚洲综合色影视| 麻豆精品久久久| 天天亚洲美女在线视频| 亚洲素人一区二区| 中国av一区二区三区| 精品剧情v国产在线观看在线| 5月丁香婷婷综合| 日本电影欧美片| 91在线精品秘密一区二区| 大胆欧美人体老妇| 国产精品18久久久久久久久 | 奇米一区二区三区| 亚洲精品高清在线| 国产精品国产三级国产三级人妇| 久久久久国产精品人| 精品日韩成人av| 日韩精品专区在线| 555夜色666亚洲国产免| 欧美美女直播网站| 欧美性色aⅴ视频一区日韩精品| av午夜精品一区二区三区| 成人国产亚洲欧美成人综合网| 国产福利精品一区二区| 国产精品一区在线观看你懂的| 精品中文字幕一区二区| 精品一区二区在线看| 麻豆91小视频| 国产一二精品视频| 成人动漫在线一区| 99精品黄色片免费大全| 91亚洲永久精品| 色94色欧美sute亚洲线路一ni | www.亚洲人| 一本一本大道香蕉久在线精品 | eeuss国产一区二区三区| 成人av综合在线| 色激情天天射综合网| 欧美日韩一区二区三区四区 | 555www色欧美视频| 日韩美女一区二区三区四区| 欧美大片在线观看| 国产精品毛片无遮挡高清| 亚洲人成伊人成综合网小说| 亚洲午夜精品久久久久久久久| 秋霞影院一区二区| 国产一区视频导航| 成人国产精品免费观看| 欧美午夜寂寞影院| 日韩精品影音先锋| 国产精品伦理在线| 亚洲国产成人av网| 久久精品国产99国产精品| 成人午夜在线免费| 欧美午夜一区二区三区免费大片| 欧美一区二区三区男人的天堂| 欧美一卡在线观看| 国产精品女主播av| 亚洲高清一区二区三区| 激情综合网最新| 91在线播放网址| 日韩三级在线观看| 综合激情成人伊人| 久久99日本精品| 91蜜桃视频在线| 精品国产不卡一区二区三区| 最新久久zyz资源站| 亚洲6080在线| 不卡的av在线播放| 日韩欧美视频一区| 亚洲精品视频一区| 国内久久婷婷综合| 精品视频999| 国产精品久久久久婷婷| 日韩va亚洲va欧美va久久| 97久久精品人人做人人爽| 5月丁香婷婷综合| 洋洋成人永久网站入口| 国产成人aaa| 2024国产精品| 天堂一区二区在线免费观看| 9人人澡人人爽人人精品| 日韩欧美卡一卡二| 亚洲va国产天堂va久久en| av电影在线观看不卡| 久久综合视频网| 免费精品视频在线| 欧美日韩国产一级| 亚洲综合一区二区| 99久久夜色精品国产网站| 久久久美女毛片| 久久丁香综合五月国产三级网站| 欧美优质美女网站| 亚洲人xxxx| 99久久er热在这里只有精品66| 国产无人区一区二区三区| 久久99精品久久只有精品| 欧美久久久影院| 午夜精品久久久| 欧美色图第一页| 亚洲成人精品在线观看| 91原创在线视频| 日韩毛片视频在线看| 波多野结衣中文一区| 欧美经典一区二区| 国产成人高清在线| 亚洲国产成人午夜在线一区| 国产综合久久久久久鬼色| 欧美一级二级在线观看| 日本va欧美va精品| 精品少妇一区二区三区在线视频| 视频在线观看91| 日韩精品一区二区三区视频在线观看 | 亚洲黄色尤物视频|