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

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

?? combi.c

?? USB接口的鼠標驅動源程序
?? C
?? 第 1 頁 / 共 5 頁
字號:
		}
		else if (EP_A0_MODE & IN_RECEIVED_MASK)				//if an in was received,
		{
			HandleIn();										//handle it
			if (DeviceStatus.bAddress & 0x80)		        //if the address flag was set during the setup
															//phase preceding this IN,
				  USB_DEVICE_A = DeviceStatus.bAddress;		//enable the new address
			DeviceStatus.bAddress &= ~0x80;					//and clear the new address flag
		}
	}
	POPX();
	POPA();
	return;
}


/*
**
** FUNCTION:		USB_A_EP1_ISR
**
** PURPOSE:			Endpoint 1 ISR.  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					this routine is entered upon receiving an endpoint 1 interrupt.	
**					If the ACK bit is sent, indicating that a valid mouse packet was just
**					transmitted to the host, the SIE is set to NAK ins, and the
**					datatoggle bit is flipped for the next transaction.
*/

void USB_A_EP1_ISR(void)
{
	PUSHA();
	if (EP_A1_MODE & ( 1 << ACKNOWLEDGE))
	{
		EP_A1_MODE = USB_MODE_NAK_IN;
		EP_A1_COUNTER ^= DATATOGGLE;
	}
	POPA();
	return;
}


/*
**
** FUNCTION:		TuneWakeup
**
** PURPOSE:			to tune the wakeup ISR  
**
** PARAMETERS:		none
**
** DESCRIPTION:	    The wakeup interrupt period is variable by a factor of 5 due to operating and process
**					conditions.  The period has a prescaler which adjusts the period by a factor of two.
**					This routine is called at regular intervals to tune the wakeup ISR to occur at the
**					rate at which this routine is called, to within a factor of 2.  In other words, if
**					this routine is called every 256 msec, it will tune the wakeup ISR to occur at a rate
**					between 128-256 msec.
**					
**

*/

void TuneWakeup(void)
{
	char temp;
	temp = CLOCK_CONFIGURATION & TWAKEUP_MASK;				//get the current wakeup prescale value
	if ((bWakeupCount > 2) && (temp != TWAKEUP_MAX))			//if more than two wakeup ISRs occurred since
															//the last time this routine was called, and we
															//are not at the maximum prescale value already,
															//increment the prescaler to slow down the ISR interval
		temp += TWAKEUP_2;
	if ((!bWakeupCount) && (temp))							//if no wakeup ISRs occurred, and we are not
															//at the minimum prescale value,
															//decrement the prescaler to speed up the ISR interval
		temp -= TWAKEUP_2;
    CLOCK_CONFIGURATION = PRECISION_USB_CLOCKING | temp;
	bWakeupCount = 0;
}


/*
**
** FUNCTION:		usbmain
**
** PURPOSE:			USB main processing loop 
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					main spins in an infinite loop waiting for an event that needs servicing.
**					Main is entered from either the power-on reset or the usb bus reset. Both
**					of these reset routines insures that all USB variables have been initialized
**					prior to calling usbmain.
*/

void usbmain(void)

{
   EI();
   while (1)
    {
		//clear watchdog timer
		RESET_COP();	
		ProcessOptics();											//empty the optics queue
		if (MsecStatus.b1msFlags & ONE_MSEC_FLAG)					//if 1 msec has elapsed
		{
			if (!MsecStatus.b1msCounter)							//every 256 msec tune the wakeup ISR
				TuneWakeup();
			if (DeviceStatus.bConfiguration && 
				(!(MsecStatus.b1msCounter & 3)))					//if we're configured, and if 4 msec has elapsed....
					MouseTask();									//go handle mouse stuff
			if (BusInactive())										//if the bus has gone inactive
			    Suspend();											//suspend us
			MsecStatus.b1msFlags &= ~ONE_MSEC_FLAG;	
		}
	}
}


/*
**
** FUNCTION:		Reinitialize
**
** PURPOSE:			Reinitializes system RAM and USB engine  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine initializes all USB variables to their
**					default states, and resets USB engine controls to their initial values. RAM
**					has been cleared prior to entry.
*/

void UsbReInitialize(void)
{
	DI();														//disable ints
	RESET_COP();												//reset watchdog
    CLOCK_CONFIGURATION = PRECISION_USB_CLOCKING | TWAKEUP_64 ;	//set up precision clocking, /64 wakeup prescaler
																//this will set the initial wakeup time anywhere
																//from 64 - 5*64 msec.  
		OpticsQueue.headP = bOpticsArray;						//initialize queue pointers
	OpticsQueue.tailP = bOpticsArray;
	DeviceStatus.bProtocol = REPORT_PROTOCOL;					//start in report protocol
	USB_STATUS = VREG_ENABLE_MASK | NOT_FORCING;
	PROCESSOR_STATUS &= ~(WATCHDOG_RESET_MASK 					//clear source of reset
		| POWER_ON_RESET_MASK | USB_BUS_RESET_MASK);
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE 						//enable all pertinent interrupts
		| BUS_RESET_ENABLE  | MICROSECOND_ENABLE | WAKEUP_ENABLE;
	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;
	ENDPOINT_INTERRUPT = (EPA0_ENABLE | EPA1_ENABLE);			//turn on endpoint interrupts
	return;
}


/*
**
** FUNCTION:		MouseMoved
**
** PURPOSE:			returns a 1 if the mouse's X,Y, or Z counts indicate movement.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		This routine will return a 1 if the accumulated X,Y, or Z counts are nonzero
**					.
**					 
*/

char MouseMoved(void)
{
	if (Mouse.bXcount || Mouse.bYcount)
	         return(1);
	if((DeviceStatus.bProtocol == REPORT_PROTOCOL)		//if Z wheel enabled, nonzero Z count requires a transmission
		&& Mouse.bZcount)
		return(1);
	return(0);
}
     

/*
**
** FUNCTION:		MouseTask
**
** PURPOSE:			Handles mouse data transmission.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		This routine is called every 4 msec from the main loop. It
**					maintains the idle counter, which determines the rate at which mouse packets
**					are sent to the host in the absence of a state change in the mouse itself.
**					It also sends a mouse packet if either of X,Y, or Z counts or the buttons have
**					changed state.
**					 
*/

void MouseTask(void)
{
	Mouse.bChange |= DebounceButtons();				//keep track of button changes
	/*
	** if the idle period is nonzero, and the decremented counter rolls to zero,
	** set the change flag so we will send a packet regardless.
	*/
	if (MouseStatus.bIdlePeriod && !--MouseStatus.bIdleCounter)
	{
		MouseStatus.bIdleCounter = MouseStatus.bIdlePeriod;
		Mouse.bChange = 1;
	}
   	if ((EP_A1_MODE & USB_MODE_MASK) == USB_MODE_NAK_IN)     //we are NAKing, so it's ok to transmit a new package
	{
		Mouse.bChange |= MouseMoved();
		if (Mouse.bChange)										 //ok-transmission definitely required
		{

			ENDPOINT_A1_FIFO[0] = Mouse.bButtons;				 //load mouse data into fifo
			ENDPOINT_A1_FIFO[1] = Mouse.bXcount;
				  Mouse.bXcount = 0;  
			ENDPOINT_A1_FIFO[2] = Mouse.bYcount;
			Mouse.bYcount = 0;
			ENDPOINT_A1_FIFO[3] = Mouse.bZcount;
			Mouse.bZcount = 0;
			if (DeviceStatus.bProtocol == REPORT_PROTOCOL)		  //if report protocol, include z counts in length
				EP_A1_COUNTER = (EP_A1_COUNTER & DATATOGGLE) | 4;
			else
				EP_A1_COUNTER = (EP_A1_COUNTER & DATATOGGLE) | 3; //else omit it

			EP_A1_MODE = USB_MODE_ACK_IN;						  //flip mode to ack the in with the data
			MouseStatus.bIdleCounter = MouseStatus.bIdlePeriod;	  //and reset the idle period.
			Mouse.bChange = 0;								  //clear the flag
		}
	}
}


/*
**
** FUNCTION:		BusInactive
**
** PURPOSE:			Tests for upstream activity  
**
** PARAMETERS:		none
**
** DESCRIPTION:	    This routine should be called every msec from the main loop.
**					it maintains an internal count of the successive samples of the USB status register
**					in which no bus activity was recorded.  When this count exceeds 3 (msec), the
**					routine returns 1, indicating that bus activity has deceased
**					
*/

char BusInactive(void)
{
	if  (!(USB_STATUS & BUS_ACTIVITY_MASK))				//if no bus activity indicated in the status reg,
	    return(++bSuspendCounter == 3);					//return 0 if the counter has elapsed
	USB_STATUS = VREG_ENABLE_MASK;						//reset the flag (always write bit 4 to a 0 in this reg)
	bSuspendCounter = 0;
	return(0);
}


/*
**
** FUNCTION:		Suspend
**
** PURPOSE:			puts the chip into suspend  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine handles the entrance/exit from suspend. If the mouse is configured for
**					remote wakeup, the bus reset, wakeup, and gpio interrupts are enabled.  The optical
**					inputs are sampled once.  The code then enters a loop in which the chip is suspended,
**					and will wake at least as often as the wakeup ISR, but perhaps due to a GPIO or bus
**					reset interrupt. Each time the chip wakes up, the  led drive is reenabled, and the
**					switches and optical inputs are sampled to see if a change occured, and bus activity
**					is monitored. Any of these conditions will cause the firmware to exit the loop.
**
**					if the device is not enabled for remote wakeup, all ports are put into the hi-Z state,
**					only the bus reset interrupt is enabled,and the part is suspended. 
**
**					if the resume was due to bus activity, the firmware returns to the main loop.
**					if the resume was due to mouse movement or a button press, a K state is driven upstream
**					for 14 msec prior to returning to the main loop.
*/

void Suspend(void)
{
	char Optics;
	char temp = 10;
	if (!DeviceStatus.bRemoteWakeup)	
	{
		
		GLOBAL_INTERRUPT = BUS_RESET_ENABLE;				//enable bus reset ISR only
		PORT0_MODE0 = PORT0_MODE0_SUSPEND;																	
		PORT1_MODE0 = PORT1_MODE0_SUSPEND;									
		PORT0_MODE1 = PORT0_MODE1_SUSPEND;																	
		PORT1_MODE1 = PORT1_MODE1_SUSPEND;
		PORT0 = PORT0_SUSPEND;
		PORT1 = PORT1_SUSPEND;
		PROCESSOR_STATUS |= 0x8;							//suspend 
		#asm(nop);
		RESET_COP();
		PORT0_MODE0 = PORT0_MODE0_INIT;						//re-init port modes									
		PORT1_MODE0 = PORT1_MODE0_INIT;
		PORT0_MODE1 = PORT0_MODE1_INIT;									
		PORT1_MODE1 = PORT1_MODE1_INIT;
		PORT0 = PORT0_INIT;
		PORT1 = PORT1_INIT;
	}
	else
	{
		//enable gpio, wakeup, and bus reset ISRs
		GLOBAL_INTERRUPT = BUS_RESET_ENABLE | GPIO_ENABLE | WAKEUP_ENABLE ;
		Optics = OPTICS_PORT;									//sample the optics port
		while (1)
		{														
			PORT0_MODE0 = PORT0_MODE0_RW;						//set ports to remote wakeup configuration																
			PORT1_MODE0 = PORT1_MODE0_RW;									
			PORT0_MODE1 = PORT0_MODE1_RW;																	
			PORT1_MODE1 = PORT1_MODE1_RW;
			PORT0 = PORT0_RW;
			PORT1 = PORT1_RW;
			PROCESSOR_STATUS |= 0x8;							//suspend (wakeup timer will wake us up)
			#asm(nop);
			PORT0_MODE0 = PORT0_MODE0_INIT;						//re-init port modes									
			PORT1_MODE0 = PORT1_MODE0_INIT;
			PORT0_MODE1 = PORT0_MODE1_INIT;									
			PORT1_MODE1 = PORT1_MODE1_INIT;
			PORT0 = PORT0_INIT;
			PORT1 = PORT1_INIT;
			RESET_COP();
			if (USB_STATUS & BUS_ACTIVITY_MASK)					//if wakeup due to bus activity (including bus reset), get out 
																//of this loop
				break;
			if (GetButtons() != Mouse.bButtons)					//if mouse buttons switches different, get out
				break;
			Delay(20);											//wait some more time for optic led to come on
			if ((OPTICS_PORT ^ Optics) & OPTICS_MASK)			//if optics have changed, get out
				break;
		}  
	}
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE 						//reenable all interrupts used in main loop
		| BUS_RESET_ENABLE  | MICROSECOND_ENABLE | WAKEUP_ENABLE;
	temp = MsecStatus.b1msCounter + 5;							//wait 5 msec
	while (temp != MsecStatus.b1msCounter)
	{
		RESET_COP();
 		if (USB_STATUS & BUS_ACTIVITY_MASK)				    //if bus activity is present, get out now
			return;
	}
	USB_STATUS = VREG_ENABLE_MASK | FORCE_J;			    //otherwise force resume upstream for 14 msec
	USB_STATUS = VREG_ENABLE_MASK | FORCE_K;
 	temp = MsecStatus.b1msCounter +	14;						//		
	while (temp != MsecStatus.b1msCounter)
		RESET_COP();
	USB_STATUS = VREG_ENABLE_MASK | NOT_FORCING;		    //switch to nonforcing
	bSuspendCounter = 0;
	return;
}


/*
**
** FUNCTION:		HandleIn
**
** PURPOSE:			Services In packets 
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine is entered whenever an IN packet has come in on endpoint 0.
**					it processes the packet.
**					
*/

void HandleIn(void)

{
	//an ACKed IN occurs either in the case of the status phase of a control write,
	//or the data in phase of a control read.  The only thing we are expecting is the
	//data in phase -- there are no control writes to the mouse
	if ((EP_A0_MODE & USB_MODE_MASK) != USB_MODE_NAK_IN_STATUS_OUT )
	{
		SET_EP0_MODE(USB_MODE_STALL_IN_OUT);					//we weren't expecting this!!
		return;
	}
	byte_count = EP_A0_COUNTER;									//unlock the counter register by reading it
	byte_count = 0;												//zero the byte count
	if (XmtBuff.bLength)										//if we've stuff to send,
	    	byte_count = LoadEP0Fifo();			//load it into fifo
			//account for the bytes we will send this pass
	//load up the counter
	EP_A0_COUNTER = (EP_A0_COUNTER & DATATOGGLE) ^ DATATOGGLE;
	EP_A0_COUNTER |= byte_count;
	//and set the ep mode to ack the next IN with the data.
	EP_A0_MODE = USB_MODE_ACK_IN_STATUS_OUT;

}


/*
**
** FUNCTION:		USB_control_read
**
** PURPOSE:			Prepares the SIE for the first IN after a SETUP requesting data
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine is called after a SETUP has been received that is requesting
**					a data response from the mouse. Upon entry, XmtBuff has been initialized to
**					point to the data buffer that needs to be tranmsitted.  USB_control_read
**					adjusts the length of the data to be returned if the host requested less
**					data than the actual length of the buffer.  It then loads the FIFO with the
**					first chunck of data and prepares the SIE to ACK with the data.
**					
*/

void USB_control_read(void)

{
	//if the host requested less data than is actually available, use that length instead

	if ((!ENDPOINT_A0_FIFO[USB_wLengthHi]) && (ENDPOINT_A0_FIFO[USB_wLength] < XmtBuff.bLength))
		XmtBuff.bLength = ENDPOINT_A0_FIFO[USB_wLength];
	byte_count = 0;
	if (XmtBuff.bLength)
		byte_count = LoadEP0Fifo();							//data to send. Load FIFO with first chunck
	EP_A0_COUNTER =  DATATOGGLE | byte_count;				//set up counter
	EP_A0_MODE = USB_MODE_ACK_IN_STATUS_OUT;				//and set up SIE to ACK with the data
}


/*
**
** FUNCTION:		LoadEP0Fifo
**
** PURPOSE:			loads EP0 fifo with available data 
**
** PARAMETERS:		bLength -- length of data available to load
**
** DESCRIPTION:	 
**					This routine loads the fifo with data pointed to by XmtBuff.  It
**					returns the length of data actually loaded into the FIFO.
**					
*/

char LoadEP0Fifo(void)
{

	byte_count1 = 0;

	while (byte_count1 < 8)									//FIF0 is only 8 bytes long
	{
		ENDPOINT_A0_FIFO[byte_count1++] = *(XmtBuff.p);		//move data into FIFO
		XmtBuff.p++;
		if (!--XmtBuff.bLength)								//if we have exhausted the data, quit

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线精品国精品国产尤物884a| 国内精品第一页| √…a在线天堂一区| 久久精品一区二区三区不卡牛牛| 日韩三级伦理片妻子的秘密按摩| 这里只有精品免费| 日韩欧美一区二区视频| 精品国内二区三区| 国产欧美精品一区aⅴ影院| 国产欧美日韩在线| 亚洲视频 欧洲视频| 午夜欧美2019年伦理| 奇米精品一区二区三区在线观看 | 成人免费观看男女羞羞视频| 国产成人在线观看| 成人午夜精品在线| 色www精品视频在线观看| 欧美日韩国产a| 欧美va在线播放| 亚洲欧洲成人av每日更新| 亚洲一区二区在线免费观看视频| 日韩精品每日更新| 国产不卡视频在线播放| 色猫猫国产区一区二在线视频| 5566中文字幕一区二区电影| 2021国产精品久久精品| 综合欧美一区二区三区| 日本特黄久久久高潮| jlzzjlzz亚洲日本少妇| 欧美无乱码久久久免费午夜一区| 日韩欧美中文字幕一区| 国产精品三级电影| 首页国产丝袜综合| 99久久精品国产网站| 欧美一区二区三区公司| 国产精品欧美极品| 日韩成人午夜电影| 91亚洲国产成人精品一区二三| 欧美一区二视频| ㊣最新国产の精品bt伙计久久| 视频在线观看91| 91浏览器入口在线观看| 日韩欧美在线1卡| 一区二区三区资源| 粉嫩绯色av一区二区在线观看| 欧美日韩黄视频| 亚洲欧美在线视频观看| 激情偷乱视频一区二区三区| 欧美午夜不卡在线观看免费| 欧美国产日本视频| 另类小说图片综合网| 91福利精品视频| 国产欧美一区二区三区网站 | 99精品视频在线观看免费| 日韩欧美电影一区| 五月激情综合婷婷| 欧美三级韩国三级日本三斤| 亚洲视频狠狠干| 成人高清免费观看| 26uuu亚洲| 久久精品国产一区二区| 欧美日韩不卡一区| 亚洲一区二区三区四区在线免费观看 | 国产91精品一区二区麻豆网站| 欧美日韩精品免费观看视频 | 欧美高清视频不卡网| 一区二区在线免费| 91老司机福利 在线| 欧美激情一区二区三区在线| 国产91丝袜在线18| 欧美国产激情一区二区三区蜜月| 国产精品一区二区x88av| 欧美电影免费观看高清完整版在 | 国产激情视频一区二区三区欧美| 91精品国产乱码久久蜜臀| 婷婷综合久久一区二区三区| 欧美性三三影院| 亚洲成人手机在线| 这里只有精品免费| 蜜臀av亚洲一区中文字幕| 精品国产3级a| 国产一区二区美女| 国产欧美一区二区三区沐欲| 国产精品亚洲一区二区三区在线| 久久久久免费观看| proumb性欧美在线观看| 亚洲伊人伊色伊影伊综合网| 精品视频123区在线观看| 日韩av一区二区三区| 精品福利av导航| 成人在线视频首页| 亚洲在线成人精品| 日韩一区二区三区精品视频| 激情综合网最新| 国产精品视频在线看| 91福利社在线观看| 久久国产人妖系列| 国产精品久久久久久久久晋中 | 日韩精品电影在线观看| 精品国产髙清在线看国产毛片| 国产乱色国产精品免费视频| 国产精品久久久久久久久免费樱桃| av在线不卡网| 婷婷一区二区三区| 国产日产欧产精品推荐色| 91啪在线观看| 久久99精品网久久| 亚洲欧美一区二区三区久本道91 | 色婷婷国产精品| 日本亚洲欧美天堂免费| 国产午夜一区二区三区| 欧美亚洲动漫制服丝袜| 韩国av一区二区三区| 亚洲午夜激情网页| 国产精品系列在线| 日韩色视频在线观看| 色欧美片视频在线观看在线视频| 久久超碰97中文字幕| 亚洲精品写真福利| 国产无遮挡一区二区三区毛片日本| 色偷偷成人一区二区三区91| 国内不卡的二区三区中文字幕 | 国产欧美一区二区在线观看| 欧美日本不卡视频| 91视视频在线观看入口直接观看www | 成人一区二区三区| 日韩av不卡一区二区| 亚洲人成在线观看一区二区| 久久久久久久久久久99999| 欧美日韩在线电影| 色综合久久综合网欧美综合网| 国产一区二区三区四| 日韩黄色在线观看| 亚洲观看高清完整版在线观看| 欧美国产精品一区| 久久久高清一区二区三区| 777奇米成人网| 在线观看www91| 99国产精品久久久久| 国产.欧美.日韩| 国产精品996| 国产精品91一区二区| 国内精品国产成人国产三级粉色 | 成人黄色av电影| 国产一区二区三区久久悠悠色av| 奇米色一区二区| 日韩精品亚洲专区| 日韩**一区毛片| 日本视频一区二区| 青青草91视频| 丝袜诱惑制服诱惑色一区在线观看 | 91精品91久久久中77777| 国产成人亚洲综合a∨婷婷图片| 久久精品国产久精国产| 日本女人一区二区三区| 免费看日韩精品| 精品亚洲免费视频| 国产乱国产乱300精品| 国产乱码精品一区二区三区av| 激情亚洲综合在线| 国产精品18久久久久久久久久久久| 国产一区二区精品久久91| 国产福利精品导航| av激情综合网| 欧美在线一二三| 欧美日本免费一区二区三区| 91精品婷婷国产综合久久性色| 在线播放/欧美激情| 欧美疯狂性受xxxxx喷水图片| 7777精品伊人久久久大香线蕉 | 成人污污视频在线观看| 99国产一区二区三精品乱码| 99久久婷婷国产| 欧美日韩免费在线视频| 日韩欧美高清一区| 国产精品午夜在线观看| 一级中文字幕一区二区| 亚洲成人自拍网| 国产乱子轮精品视频| 99精品欧美一区二区三区综合在线| 一本到不卡精品视频在线观看| 欧美日韩亚洲另类| 久久亚洲精精品中文字幕早川悠里 | 色成人在线视频| 日韩一区二区高清| 国产精品欧美综合在线| 天堂成人免费av电影一区| 国模娜娜一区二区三区| 国v精品久久久网| 在线电影一区二区三区| 国产精品欧美一级免费| 视频在线观看国产精品| 成人网页在线观看| 日韩欧美一级二级| 亚洲综合网站在线观看| 国产精品亚洲视频| 777午夜精品免费视频| 日韩毛片视频在线看| 激情图区综合网| 制服丝袜亚洲播放|