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

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

?? combi.c

?? 這是使用CYPRESS的7C637xx芯片完成USB鼠標的例子。
?? C
?? 第 1 頁 / 共 5 頁
字號:
void ReadData(void);
void SetStreamMode(void);
void StatusRequest(void);
char SetResolution(char p);
void SetScaling(void);
void ResetScaling(void);
char GetByte ( void);
void ProcessCommand(char p);
void SendMouseData(void);
void Put(char p);
void PutMsgBuff(void);
void SendMouseData(void);
void ps2main(void);
void PutNextByte(void);
void ReInitialize(void);
void ResetInterval(void);
void Ps2MouseTask(void);


/*
**
** FUNCTION:		ClearRam
**
** PURPOSE:			Clears all RAM except data and program stacks.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		Written in assembler so that only X and A are used ( no variables
**					that might be cleared as a result of this function executing)
**
*/

void ClearRam(void)
{
    #asm 
    mov     X,REGISTER_SIZE - 1
    mov     A,0
lp:
    mov     [X + REGISTER_START],A
    dec     X
    jnc     lp
    #endasm
    return;
    }


/*
**
** FUNCTION:		IsUsbInterface
**
** PURPOSE:			Determines whether a USB or PS/2 host is connected upstream.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		This function performs the following algorithm:

					1) Wake up and delay 50mS. Initialize the PS2 BAT delay counter.

					2) For a period of 2mS, poll the SCLK and SDATA lines every 10uS.
					   If we get 4 samples in a row with non-zero data on either line, 
					   detect PS2. If the 2mS expires, go to (3).

					3) Enable USB pull up resistor and delay 500uS. 
					   Poll the SCLK and SDATA lines indefinitely 
					   until a non-zero condition exists on either line. 
					   During this polling period, we begin to count down the PS2 BAT delay.  
					   If SCLK(D+) is sampled high, detect PS2. If SDATA(D-) 
					   is sampled high, go to (4).

					4) Disable the USB connect resistor and Delay 100uS.  
						if D+ and D- are both 0, detect  USB, else detect PS2.
*/

char 	IsUsbInterface(void)
{

	char temp;
	char samples = 4;
     bBatDelay = (500 - 50);								//initialize BAT delay to 500 msec
	temp = MsecStatus.b1msCounter+50;					    //wait 50 msec
  														    
	while (temp != MsecStatus.b1msCounter)
		RESET_COP();
	temp = MsecStatus.b1msCounter+2;
	while (temp != MsecStatus.b1msCounter)					//for 2 msec, sample clock and data
	{
		if ((PORT2 & (PS2_CLOCK_BIT | PS2_DATA_BIT)) && (!--samples))
				return(0);									//4  consecutive samples of either clock or data high, it's ps2
		samples = 4;					
	}

	USB_STATUS = (VREG_ENABLE_MASK | FORCE_NEG_OPEN_POS_OPEN);//enable USB pullup 
	Delay(250);												//and delay 250 usec
	while (1)												//wait forever
	{
		RESET_COP();
		if (MsecStatus.b1msFlags & ONE_MSEC_FLAG)
		{
			if (bBatDelay)									//if a msec expires, decrease bat delay
				bBatDelay--;
			MsecStatus.b1msFlags &= ~ONE_MSEC_FLAG;
		}
		if (PORT2 & PS2_CLOCK_BIT)							
			return(0);										//clock bit high it's ps2
		if (PORT2 & PS2_DATA_BIT)							//data bit high, quit the loop
			break;
	}
	USB_STATUS = FORCE_NEG_OPEN_POS_OPEN;					//disable USB pullup 
    Delay(100);  
	return(!(PORT2 & (PS2_CLOCK_BIT | PS2_DATA_BIT)));		//if both clock and data go low, it's usb
}


/*
**
** FUNCTION:		MY_RESET_ISR
**
** PURPOSE:			Reset ISR, vectored to during power-up or watchdog reset.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		This function performs the following initialization:
**					
**					1)disables interrupts;
**					2)resets the watchdog;
**					3)initializes data stack pointer;
**					4)clears ram;
**					5)initializes port I/O;
*					6)enables 1msec interrupt;
**					7)jumps to main loop
**					
**
*/

void MY_RESET_ISR(void)
{
    DI();											//disable ints
	RESET_COP();									//reset watchdog

	/*
	** use assembler to initialize data stack
	*/
#asm (mov A,RAM_START + STACK_SIZE-1)			        
#asm (swap A,dsp)
      ClearRam();
	USB_STATUS = FORCE_NEG_OPEN_POS_OPEN;						//drive D+,D- to Hi-Z
	PORT0_MODE1 = PORT0_MODE1_INIT;								//set up port modes
	PORT0_MODE0 = PORT0_MODE0_INIT;								//
	PORT1_MODE0 = PORT1_MODE0_INIT ;							//
	PORT1_MODE1 = PORT1_MODE1_INIT;								//
	PORT0 = PORT0_INIT;											//set up initial values
	PORT1 = PORT1_INIT;											//
	PORT0IE = PORT0_INIT;										//set up for GPIO interrupts on switch inputs
	PORT1IE = PORT1_INIT;										//
	PORT0IP = ~PORT0_INIT;										//set up for negative edges interrupts switch inputs
	PORT1IP = ~PORT1_INIT;
	GLOBAL_INTERRUPT = MILLISECOND_ENABLE; 						//enable all pertinent interrupts
	EI();
    #asm (jmp main)
 }


/*
**
** FUNCTION:		main
**
** PURPOSE:			determines interface (usb or ps2) and dispatches to appropriate code.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		
**					
**
*/

 void main(void)
 {
    if (IsUsbInterface())								//if it is USB
    {
          UsbReInitialize();							//initialize USB variables
          usbmain();									//and go to usbmain
	}
	ps2main();											//else straight to ps2
}


/*
**
** FUNCTION:		ProcessOptics
**
** PURPOSE:			Extracts optics data from the queue, and accumulates X,Y, and Z counts
**					based on the state data of each quadrature pair.
** PARAMETERS:		none
**
** DESCRIPTION:		This routine is called from the main loop to process the optical data that has
**					accumulated during successive 128 usec interrupts. For each byte in the optics queue,
**					it extracts the X,Y,and Z state data, and uses the state data from the previous sample
**					to increment/decrement/hold the corresponding count data.	
**					
**
*/

void ProcessOptics(void)
{   
	char temp;
    char temp1;
      if (OpticsQueue.bLen > 16)								//somehow the queue overflowed
      {
		  DI();													//this should never happen, but if so
		  OpticsQueue.headP =									//reset the queue pointers and quit
		  OpticsQueue.tailP = bOpticsArray;
		  OpticsQueue.bLen = 0;
		  EI();
		  return;
      }
	while (OpticsQueue.bLen)
	{
		temp = GET_X_OPTICS(*OpticsQueue.tailP);				//get X quadrature inputs into [1:0]
		temp1 = temp;											//save temporarily
		temp |= Optics.bXstate;									//or in with previous state 
		Optics.bXstate = temp1 << 2;							//shift X inputs into [3:2] and save for next pass
		temp1 = Mouse.bXcount;
		Mouse.bXcount += quad_table[temp];						//use quadrature lookup to inc/dec xcount
		if ((unsigned char) Mouse.bXcount == 0x80)								//if overflow in either direction
			Mouse.bXcount = temp1;								//restore old count
																
		temp = GET_Y_OPTICS(*OpticsQueue.tailP);				//repeat for Y.....
		temp1 = temp;
		temp |= Optics.bYstate;
		Optics.bYstate = temp1 << 2;
		temp1 = Mouse.bYcount;
		Mouse.bYcount -= quad_table[temp];						//note, y counts need to be negated for proper direction
		if ((unsigned char) Mouse.bYcount == 0x80)
			Mouse.bYcount = temp1;

		temp = GET_Z_OPTICS(*OpticsQueue.tailP);				//repeat for Z....
		temp1 = temp;
		temp |= Optics.bZstate;
		Optics.bZstate = temp1 << 2;
		temp1 = Mouse.bZcount;
		Mouse.bZcount += z_quad_table[temp];
		if ((unsigned char) Mouse.bZcount == 0x80)
			Mouse.bZcount = temp1;

		*OpticsQueue.tailP++;									//manage queue pointers
 		if (OpticsQueue.tailP == &bOpticsArray[16])				//wrap them if necessary
			OpticsQueue.tailP = bOpticsArray;
		OpticsQueue.bLen--;
	}
}


/*
**
** FUNCTION:		MICROSECONDx128_ISR
**
** PURPOSE:			128 usec ISR.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		
**					This ISR samples the mouse optics and places the sample in a queue for
**					later processing by the main loop. This is done to minimize the execution time
**					of this ISR, which can interrupt during the time ps/2 bits are being clocked
**					to the host.  The timing of the ps/2 clocking is critical (20 us margin),
**					so the corresponding execution time of this ISR must be kept to less than 20 us.
**					
**
*/

void MICROSECONDx128_ISR(void)
{
	PUSHA();
	PUSHX();
	*OpticsQueue.headP++ = OPTICS_PORT;							//sample optical data
	OpticsQueue.bLen++;											//manage queue pointers and length
	if (OpticsQueue.headP == &bOpticsArray[16])					//wrap pointers if necessary
		OpticsQueue.headP = bOpticsArray;
	POPX();
	POPA();
}


/*
**
** FUNCTION:		MILLISECOND_ISR
**
** PURPOSE:			1 msec ISR.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		
**					This ISR maintains the 1msec counter variable,
**					and sets a flag indicating a 1msec interrupt has occurred. The main loop uses
**					these variables for timing purposes.
*/

void MILLISECOND_ISR(void)
{
    PUSHA();										//save A
    RESET_COP();
	MsecStatus.b1msFlags |= ONE_MSEC_FLAG;			//set flag for main loop
	MsecStatus.b1msCounter++;					    //increment 1msec counter
    POPA();
	return;
}


/*
**
** FUNCTION:		DebounceButtons
**
** PURPOSE:			Debounces the mouse switch inputs  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					This routine should be called at regular intervals from the main loop
**					to debounce the mouse switch inputs.  It maintains a count of the number
**					of successive identical samples of the switch inputs, and returns a 1
**					if the switch inputs have changed have been stable for the debounce interval.
*/

char GetButtons(void)
{
	char bButtons = 0;


	if (LEFT_SWITCH_ASSERTED)						//format an internal copy of the switches
		bButtons |= BIT0;							//this happens to be the USB format!
	if (RIGHT_SWITCH_ASSERTED)
		bButtons |= BIT1;
	/*
	** if Zwheel is enabled in either USB or PS2 mode, report the middle switch
	*/
	if ((MouseParms.bZmouse || DeviceStatus.bProtocol) && (MIDDLE_SWITCH_ASSERTED))
		bButtons |= BIT2;
	return(bButtons);
}

char DebounceButtons(void)
{
    char bButtons;
	bButtons = GetButtons();
 	if (bButtons == bLastButtons)				    //if same as last sample
	{
		  if (bDebounceCount && !--bDebounceCount)  //and debounce interval just expired
		  {
			  Mouse.bButtons = bLastButtons;			//record new buttons
			  return(1);							//and flag that a button change occurred
		  }
		  return(0);								//else no change yet occurred
	}
	bLastButtons = bButtons;						//buttons aren't stable, reset debounce count
	bDebounceCount = DEBOUNCE_COUNT;				//
	return(0);
}


/*
**
** FUNCTION:		USB_BUS_RESET_ISR
**
** PURPOSE:			Bus Reset ISR, vectored to during USB bus reset.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		This function performs the following initialization:
**					
**					1)disables interrupts;
**					2)resets the watchdog;
**					3)initialized data stack pointer and program stack pointer;
**					4 clears ram;
**					5)makes a call to initialize system variables;
**					6)enables device to respond at address 0;
**					7)jumps to main loop
**					
**
*/

void USB_BUS_RESET_ISR(void)
{

    DI();
	RESET_COP();						//tickle watchdog
										//initialize stacks using assembler
#asm (mov A,RAM_START + STACK_SIZE-1)			        
#asm (swap A,dsp)
#asm (mov A,0)
#asm (mov psp,a)
	ClearRam();
	UsbReInitialize();						//reinitialize all system variables

	USB_DEVICE_A = 0x80;  // enable endpoint zero response at address 0
	EP_A0_MODE = USB_MODE_STALL_IN_OUT;
										//and make the leap to the main loop
#asm(jmp usbmain)							
}


/*
**
** FUNCTION:		WAKEUP_ISR
**
** PURPOSE:			ISR for wakeup interrupt.  
**
** PARAMETERS:		none
**
** DESCRIPTION:		The wakeup ISR increments a global counter which is used to "tune" the
**					frequency of the occurrence of the ISR itself (See routine TuneWakeup).
**
*/

void WAKEUP_ISR(void)
{
	bWakeupCount++;
}


/*
**
** FUNCTION:		GPIO_ISR
**
** PURPOSE:			ISR for wakeup interrupt. does nothing except returns  
**
** PARAMETERS:		none
**
** DESCRIPTION:	
**
*/

void GPIO_ISR(void)
{
	
}


/*
**
** FUNCTION:		USB_A_EP0_ISR
**
** PURPOSE:			Endpoint 0 Interrupt Service Routine.  
**
** PARAMETERS:		none
**
** DESCRIPTION:	 
**					this routine is entered upon receiving an endpoint 0 interrupt.
**					EP0 interrupts occur during the Setup, data , and status phases of a
**					setup transaction.  This ISR dispatches the proper routine to handle
**					one of these phases. The interrupt will remain active until the
**					phase in question is completely handled.
*/

void USB_A_EP0_ISR(void)
{
	PUSHA();												//save A and X,they'll get wasted
	PUSHX();
	if (EP_A0_MODE & (1 << ACKNOWLEDGE))					//if this packet was acknowledged,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合区在线| 亚洲成人先锋电影| 欧美一区二区三区在线电影| www.色精品| 风间由美中文字幕在线看视频国产欧美| 免费三级欧美电影| 日本亚洲电影天堂| 日本视频一区二区三区| 午夜激情一区二区三区| 洋洋av久久久久久久一区| 国产精品久久久久一区| 中文字幕中文在线不卡住| 国产欧美中文在线| 国产日韩欧美不卡在线| 国产亚洲精品bt天堂精选| 久久久蜜臀国产一区二区| 26uuu久久天堂性欧美| 久久亚洲影视婷婷| 久久久久久久久久美女| 国产人妖乱国产精品人妖| 国产视频一区二区在线观看| 久久久久久麻豆| 国产欧美视频一区二区| 亚洲欧美自拍偷拍| 亚洲欧美日韩中文字幕一区二区三区 | 制服丝袜av成人在线看| 欧美性猛交xxxxxxxx| 欧美日韩高清不卡| 日韩女优视频免费观看| 国产女人aaa级久久久级| 亚洲欧洲一区二区在线播放| 一区二区三区欧美激情| 日本女优在线视频一区二区| 久草在线在线精品观看| 大尺度一区二区| 色婷婷av一区二区| 欧美一级视频精品观看| 亚洲精品一区二区三区蜜桃下载 | 洋洋av久久久久久久一区| 洋洋av久久久久久久一区| 蜜臀精品久久久久久蜜臀 | 亚洲福利一区二区三区| 国产精品视频九色porn| 国产亚洲婷婷免费| 亚洲视频一区二区免费在线观看| 亚洲精品亚洲人成人网| 亚洲网友自拍偷拍| 久久9热精品视频| 成人黄色大片在线观看| 欧美午夜在线观看| 337p粉嫩大胆噜噜噜噜噜91av| 欧美激情一区二区三区全黄| 亚洲一区在线看| 激情五月婷婷综合网| 91在线精品一区二区三区| 欧美精品自拍偷拍动漫精品| 国产欧美精品国产国产专区| 亚洲国产欧美一区二区三区丁香婷| 精品无人区卡一卡二卡三乱码免费卡| 99久久免费国产| 精品电影一区二区三区| 亚洲一卡二卡三卡四卡五卡| 国产精品一品视频| 欧美午夜电影在线播放| 中文一区二区在线观看| 男男gaygay亚洲| 久久国产夜色精品鲁鲁99| 欧美色视频在线| 国产精品色哟哟网站| 久久99最新地址| 宅男噜噜噜66一区二区66| 亚洲伦在线观看| 丁香激情综合国产| 欧美大片日本大片免费观看| 一个色妞综合视频在线观看| 国产**成人网毛片九色| 欧美草草影院在线视频| 亚洲一区二区三区不卡国产欧美| 成人av在线播放网址| 国产亚洲欧美日韩日本| 激情小说欧美图片| 日韩欧美在线一区二区三区| 亚洲午夜久久久久久久久电影网| 成人黄色免费短视频| 国产亚洲午夜高清国产拍精品| 老司机精品视频一区二区三区| 在线电影一区二区三区| 亚洲精品免费播放| 91小视频在线| 日本不卡中文字幕| 欧美日韩精品一区二区三区蜜桃 | 久久精品av麻豆的观看方式| 欧美蜜桃一区二区三区| 亚洲综合一区二区三区| 一本色道综合亚洲| 一区二区高清在线| 欧美日韩精品免费观看视频| 亚洲精品中文字幕在线观看| 97久久精品人人爽人人爽蜜臀| 国产精品盗摄一区二区三区| 成a人片国产精品| 国产精品久久久久久亚洲伦 | 免费看日韩a级影片| 欧美一级艳片视频免费观看| 麻豆中文一区二区| 久久九九影视网| 成人免费黄色在线| 国产精品久久久久桃色tv| 99久久精品费精品国产一区二区| 亚洲精品ww久久久久久p站| 欧美色涩在线第一页| 视频精品一区二区| 精品久久久久久久人人人人传媒| 韩国在线一区二区| 国产精品网站导航| 欧美做爰猛烈大尺度电影无法无天| 亚洲午夜久久久久| 欧美一级高清片在线观看| 国产在线精品不卡| 亚洲天堂中文字幕| 91精品国产综合久久久久| 毛片av中文字幕一区二区| 国产亚洲精品7777| 欧美在线看片a免费观看| 日韩精品视频网站| 国产亚洲一区二区三区| 色视频一区二区| 久久99最新地址| 麻豆91精品视频| 国产三级三级三级精品8ⅰ区| 91女厕偷拍女厕偷拍高清| 亚洲图片欧美综合| 精品久久人人做人人爽| 99久久精品久久久久久清纯| 天堂va蜜桃一区二区三区 | 4hu四虎永久在线影院成人| 精品亚洲国内自在自线福利| 日韩理论片一区二区| 日韩欧美一区二区视频| 成人av在线影院| 日本一不卡视频| 伊人一区二区三区| 国产亲近乱来精品视频 | 婷婷一区二区三区| 国产精品视频线看| 欧美一区日本一区韩国一区| 99久久久免费精品国产一区二区| 麻豆国产精品777777在线| 亚洲人一二三区| 26uuu国产在线精品一区二区| 在线观看www91| 99精品国产热久久91蜜凸| 国产精品一区二区你懂的| 性感美女久久精品| 一区二区在线观看免费| 国产日产欧美精品一区二区三区| 欧美日韩国产一区二区三区地区| 大桥未久av一区二区三区中文| 裸体一区二区三区| 三级欧美在线一区| 亚洲韩国一区二区三区| 日韩美女视频一区| 自拍偷拍国产精品| 国产精品丝袜在线| 国产日韩高清在线| 国产午夜亚洲精品理论片色戒 | 国产欧美日韩另类视频免费观看| 欧美一区二区三区爱爱| 欧美日韩精品三区| 欧美日韩亚洲综合在线| 在线免费一区三区| 在线视频中文字幕一区二区| 99久久综合国产精品| 成人激情小说网站| 99久久免费精品高清特色大片| 成人免费视频一区| 国产xxx精品视频大全| 国产一本一道久久香蕉| 国产精品综合在线视频| 久久99久久99小草精品免视看| 天天影视色香欲综合网老头| 午夜一区二区三区在线观看| 五月综合激情日本mⅴ| 午夜免费久久看| 日韩vs国产vs欧美| 精品一区在线看| 国产福利电影一区二区三区| 福利电影一区二区| 盗摄精品av一区二区三区| 成人免费黄色大片| 日本乱人伦aⅴ精品| 欧美在线综合视频| 欧美一区二区视频网站| 精品粉嫩aⅴ一区二区三区四区| 亚洲精品在线观看网站| 国产调教视频一区| 一区二区三区中文免费| 亚洲成a人片综合在线| 久久精品国产亚洲aⅴ| 高清av一区二区|