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

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

?? combi.c

?? USB/PS2鼠標驅動
?? 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一区二区三区免费野_久草精品视频
开心九九激情九九欧美日韩精美视频电影| 激情亚洲综合在线| 国产成人日日夜夜| 欧美福利电影网| 一区二区三区资源| heyzo一本久久综合| 久久久久88色偷偷免费| 免播放器亚洲一区| 欧美日韩精品系列| 久久精品国产99国产精品| 4438x亚洲最大成人网| 天堂在线一区二区| 91麻豆精品91久久久久同性| 亚洲欧美日韩国产手机在线 | 欧美中文字幕一区二区三区 | 久久午夜电影网| 国产高清无密码一区二区三区| ww久久中文字幕| 国产成人自拍网| 亚洲欧洲精品天堂一级| 99久久婷婷国产综合精品电影| 综合分类小说区另类春色亚洲小说欧美 | 精品国产乱码久久久久久1区2区| 乱一区二区av| 国产精品青草久久| 欧美日韩综合在线免费观看| 午夜不卡av免费| 国产日韩精品一区二区三区在线| 国产人妖乱国产精品人妖| kk眼镜猥琐国模调教系列一区二区| 亚洲卡通欧美制服中文| 欧美成人a在线| 色呦呦网站一区| 福利一区福利二区| 国产麻豆精品在线| 理论片日本一区| 毛片不卡一区二区| 亚洲精品第一国产综合野| 国产精品久久久久久久久久免费看| 欧美精品一级二级| 欧美日韩国产系列| 欧美体内she精高潮| 色欧美片视频在线观看| 久久99精品国产.久久久久久| 一区二区在线观看视频| 国产精品乱人伦中文| 欧美激情一区不卡| 国产精品麻豆视频| 日韩美女视频一区| 亚洲欧洲av色图| 亚洲视频一区二区在线| 亚洲色图欧洲色图| 亚洲自拍都市欧美小说| 亚瑟在线精品视频| 日韩成人av影视| 奇米888四色在线精品| 久久国内精品视频| www.综合网.com| 欧美日韩在线亚洲一区蜜芽| 91精品国产色综合久久ai换脸| 欧美日韩激情一区二区三区| 欧美日韩视频在线一区二区| 欧美电视剧在线观看完整版| 国产日产欧美一区二区三区| 亚洲女人的天堂| 久久精品72免费观看| 99视频国产精品| 欧美一卡2卡3卡4卡| 欧美国产丝袜视频| 亚洲成人av在线电影| 国产一区二区三区日韩 | 日韩和欧美一区二区三区| 日本免费在线视频不卡一不卡二| 国产老妇另类xxxxx| 91高清在线观看| 精品国产91乱码一区二区三区| 一区在线观看视频| 韩国成人精品a∨在线观看| 91玉足脚交白嫩脚丫在线播放| 日韩欧美中文一区| 亚洲狠狠爱一区二区三区| 国产一区二三区好的| 欧美日韩一区视频| 最好看的中文字幕久久| 国产在线国偷精品免费看| 6080午夜不卡| 欧美激情在线观看视频免费| 国产精品夜夜爽| 欧美日韩一二区| 午夜激情一区二区| 欧美在线视频不卡| 亚洲欧美日韩久久精品| av在线不卡电影| 国产精品乱码一区二区三区软件| 精品一区二区av| 国产日韩在线不卡| 成人午夜视频在线| 中文字幕不卡的av| 成人午夜视频福利| 亚洲三级电影全部在线观看高清| 成人免费高清视频| 亚洲天堂成人在线观看| 91九色02白丝porn| 午夜精品久久久久久| 日韩一区二区三区高清免费看看| 日本成人在线网站| 国产亚洲欧美日韩日本| 91在线看国产| 天天射综合影视| 欧美精品久久一区二区三区| 欧美日韩不卡一区二区| 美女脱光内衣内裤视频久久影院| 88在线观看91蜜桃国自产| 天天综合网天天综合色| 日韩欧美一二三四区| 欧美疯狂性受xxxxx喷水图片| 日韩精品电影一区亚洲| 精品毛片乱码1区2区3区| 成人avav影音| 日本va欧美va精品发布| 中文字幕欧美激情| 欧美乱妇15p| eeuss鲁一区二区三区| 蜜臀国产一区二区三区在线播放| 国产亚洲视频系列| 欧美精品色一区二区三区| 不卡的电影网站| 污片在线观看一区二区| 国产亚洲欧美一区在线观看| 欧美精品自拍偷拍| 欧美在线综合视频| 色婷婷精品大在线视频| 顶级嫩模精品视频在线看| 久久99精品久久久久婷婷| 日精品一区二区三区| 亚洲一区二区视频| 玉米视频成人免费看| 国产精品久久久久影院色老大| 国产亚洲精品久| 久久夜色精品国产欧美乱极品| 91精品国产高清一区二区三区 | 日韩免费高清视频| 欧美一级黄色片| 日韩欧美一区二区三区在线| 欧美日韩国产免费| 日韩欧美www| 欧美激情在线看| 亚洲三级小视频| 一区二区三区日韩精品视频| 亚洲午夜视频在线| 视频一区在线播放| 国产一区二区日韩精品| 国产精品亚洲专一区二区三区 | 另类小说色综合网站| 久久99精品国产麻豆婷婷| 国产成人免费9x9x人网站视频| 成人性色生活片免费看爆迷你毛片| 久久蜜桃一区二区| 中文字幕在线不卡一区二区三区 | 69成人精品免费视频| 欧美成人三级在线| 欧美国产一区二区| 亚洲成人高清在线| 成人在线一区二区三区| 欧美在线观看视频在线| 欧美精品一区在线观看| 亚洲欧美另类久久久精品2019| 亚洲bdsm女犯bdsm网站| 成人免费看片app下载| 欧美精品 日韩| 亚洲欧洲日产国产综合网| 精品一区二区三区av| 91福利在线观看| 国产精品视频线看| 精品一区二区三区不卡| 欧美日韩卡一卡二| 一区二区三区电影在线播| av成人老司机| 国产精品日韩成人| 国产精品中文字幕日韩精品| 91精品国产色综合久久ai换脸| 亚洲免费色视频| 成人一区二区视频| 久久精品一区二区三区av| 精品亚洲国产成人av制服丝袜| 欧美日韩一区成人| 午夜精品久久久久影视| 99久久夜色精品国产网站| 欧美激情综合在线| 成人av网站在线| 国产精品久久久久久久裸模| 成人午夜电影网站| 最新国产精品久久精品| 色综合激情五月| 肉丝袜脚交视频一区二区| 这里是久久伊人| 国产综合久久久久久鬼色| 国产三区在线成人av| 99国产精品久久久久久久久久久| 亚洲欧美综合色|