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

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

?? usb_test.c

?? DPS2812的USB驅動
?? C
?? 第 1 頁 / 共 2 頁
字號:
								if(hshostlink ==1)
								{
									DataToEndpoint0 = 0x55;
								}
								else
								{
									DataToEndpoint0 = 0xaa;
								}
								Write_SX2reg(SX2_EP0BUF, DataToEndpoint0);
								/*寫入要傳回的數(shù)據(jù)的長度*/
								Write_SX2reg(SX2_EP0BC, 1);
								break;
	
							/* SX2REGRD request */
							case VR_REGREAD:
								/* read the requested register */									
								Read_SX2reg(setupBuff[4], &regValue);
								break;
							
							case VR_ENDPOINT0WRITE:
								/*確定是否有數(shù)據(jù)相*/
								if (setupBuff[6] > 0 || setupBuff[7] > 0)
								{
									/*等待EP0數(shù)據(jù)包準備好的標志*/
									while(!sx2EP0Buf);
									/* 清除EP0數(shù)據(jù)包準備好的標志*/
									sx2EP0Buf = FALSE;
									/* write the data to the EP0 data buffer */
									Write_SX2reg(SX2_EP0BUF, regValue);

								   /* write the byte count so the SX2 sends one byte; */
								   /* ignore requests for more than one byte  */
									Write_SX2reg(SX2_EP0BC, 1);
								}
								else
								{
									/*無數(shù)據(jù)相*/
									Write_SX2reg(SX2_EP0BC, 0);
								}
								break;
							
							default:
								/* unsupported request */
								/* write any non-zero value to the setup register
						   		to stall the request. */
								Write_SX2reg(SX2_SETUP, 0xff);
							break;
						}
					}
					else
					{
						/*不支持的請求,寫非零數(shù)到SX2_SETUP,取消此請求*/
						Write_SX2reg(SX2_SETUP, 0xff);
					}			
				}/*解析IN類型的命令申請*/						
			}/*關于setup中斷的處理*/
		}/*自舉后進行主程序的循環(huán)*/
	}
} 

BOOL Load_descriptors(char length, char* desc)
{
	unsigned char i;
	/* write LSB of descriptor length,and the address of the Descriptor */
	if(!Write_SX2reg(SX2_DESC, (unsigned int)length))
	{
		return FALSE;
	}

	/* write high nibble of MSB of descriptor length */
	SX2_comwritebyte((unsigned char)(length >> 12));

	/* write low nibble of MSB of descriptor length */
	SX2_comwritebyte((unsigned char)((length & 0x0F00)>>8));
	
	for(i=0; i<length; i++)
	{
		/* write high nibble of MSB of descriptor length */
		SX2_comwritebyte((desc[i] >> 4));
		/* write low nibble of MSB of descriptor length */
		SX2_comwritebyte((desc[i] & 0x0F));
	}

	return TRUE;
}

/**********************************************************************************/
/*	Function: Write_SX2reg														  */
/*	Purpose:  Writes to a SX2 register											  */
/*	Input:	  addr  - address of register										  */
/*			  value - value to write to address									  */
/*	Output:	  TRUE  on success													  */
/*			  FALSE on failure													  */
/**********************************************************************************/
BOOL Write_SX2reg(unsigned char addr, unsigned int value)
{
	unsigned int transovertime = 0 ;
	/*clear the high two bit of the addr*/
	addr = addr & 0x3f;
	/* write register address to the SX2 */
	if(!SX2_comwritebyte(0x80 | addr))
	{
		return FALSE;
	}
	/* write high nibble of register data */
	SX2_comwritebyte((value >> 4) & 0xF);
	/* write low nibble of register data */
	SX2_comwritebyte(value & 0x0F);
	/*wait the ready is ok*/
	transovertime = 0;
	while((*USB_STS & 0x08) == 0 )
	{
		if( transovertime++ > usbtimeout )
		{
			return FALSE;
		}
	}
	/*the write is ok*/
	return TRUE;
}

/**********************************************************************************/
/*	Function: SX2_comwritebyte													  */
/*	Purpose:  Writes to a SX2 command interface									  */
/*	Input:	  value - value to write to address									  */
/*	Output:	  TRUE  on success													  */
/*			  FALSE on failure													  */
/**********************************************************************************/
BOOL SX2_comwritebyte(unsigned int value)
{
	unsigned int time_count = 0;
	/*wait the ready is ok*/
	while((*USB_STS & 0x08) ==0 )
	{
		if( time_count++ > usbtimeout )
		{
			return FALSE;
		}
	}
	*USB_COMMAND = value;
	/*the write is ok*/
	return TRUE;
}

/**********************************************************
*
*	Function: Read_SX2reg
*	Purpose:  Reads a SX2 register
*	Input:	  addr  - address of register
*			  value - value read from register
*	Output:	  TRUE  on success
*			  FALSE on failure
*
**********************************************************/

BOOL Read_SX2reg(unsigned char addr, unsigned int *value)
{
	unsigned int transovertime = 0;
	/*READY是否準備好,延時時間到,返回*/
	while((*USB_STS & 0x08) == 0 )
	{
		if( transovertime++ > usbtimeout )
		{
			return FALSE;
		}
	}
	/*clear the high two bit of the addr*/
	addr = addr & 0x3f;
	/* write 'read register' command to SX2 */
	*USB_COMMAND = 0xC0 | addr;

	/* set read flag to indicate to the interrupt routine that we
	   are expecting an interrupt to read back the contents of the
	   addressed register. The interrupt latency of the SX2 is in
	   tens of microseconds, so it's safe to write this flag after
	   the initial 'read' byte is written.  */
	/*設置讀標志,通知中斷程序不做處理讀中斷,只要返回標志為假就可以了*/
	readFlag = 1;

	/* wait for read flag to be cleared by an interrupt */
	/*等待讀標志為假*/
	while(1)
	{
		if(readFlag == 0)
		{
			break;
		}
		else
		{
			transovertime = 0;
		}
	}
	
	/*wait the ready is ok*/
	while((*USB_STS & 0x08) == 0 )
	{
		if( transovertime++ > usbtimeout )
		{
			return FALSE;
		}
	}
	/*讀取寄存器的數(shù)據(jù)*/
	*value = *USB_COMMAND;
	return TRUE;
}

/*********************************************************/
/*                                                       */
/*	Function: SX2_FifoWrite                              */
/*	Purpose:  write buffer to sx2fifo                    */
/*	Input:	  channel,the endpoint you select			 */
/*			  pdata - the pointer to databuffer			 */
/*			  longth - the longth of the databuffer      */
/*	Output:	  TRUE  on success                           */
/*			  FALSE on failure							 */
/*														 */
/*********************************************************/

BOOL SX2_FifoWrite(int channel,unsigned int *pdata,unsigned length)
{
	unsigned int i = 0;
		if(channel == ENDPOINT2)
		{
			for(i = 0;i<length;i++)
			{
				*USB_FIFO2 = pdata[i];
			}
		}
		else if(channel == ENDPOINT4)
		{
			for(i = 0;i<length;i++)
			{
				*USB_FIFO4 = pdata[i];
			}
		}
		else if(channel == ENDPOINT6)
		{
			for(i = 0;i<length;i++)
			{
				*USB_FIFO6 = pdata[i];  
			} 
		}
		else if(channel == ENDPOINT8)
		{
			for(i = 0;i<length;i++)
			{
				*USB_FIFO8 = pdata[i]; 
			}
		}
/*		if(!SX2_FifoWriteSingle(channel,pdata[i]))
		{
			return FALSE;
		}*/
	return TRUE;	
}

BOOL SX2_FifoWriteSingle(int channel1,unsigned int pdata1)
{
	if(channel1 == ENDPOINT2)
	{
		*USB_FIFO2 = pdata1;
		return(TRUE);
	}
	else if(channel1 == ENDPOINT4)
	{
		*USB_FIFO4 = pdata1;
		return(TRUE);
	}
	else if(channel1 == ENDPOINT6)
	{
		*USB_FIFO6 = pdata1;   
		return(TRUE);
	}
	else if(channel1 == ENDPOINT8)
	{
		*USB_FIFO8 = pdata1;
		return(TRUE);
	}
	return(FALSE);
}

unsigned int SX2_FifoReadSingle(int channel1)
{
	unsigned int pdata1;
	if(channel1 == ENDPOINT2)
	{
		pdata1 = *USB_FIFO2;
	}
	else if(channel1 == ENDPOINT4)
	{
		pdata1 = *USB_FIFO4;
	}
	else if(channel1 == ENDPOINT6)
	{
		pdata1 = *USB_FIFO6;   
	}
	else if(channel1 == ENDPOINT8)
	{
		pdata1 = *USB_FIFO8;
	}
	return(pdata1);
}

interrupt void XINT2_ISR_A(void)
{
		/* during a read, an interrupt occurs after the host 
	   CPU requests a register value to read. The host CPU 
	   then reads the data from the SX2 */
		if(readFlag == 1)
		{
			readFlag = 0;
		}
	/* setup's are a special case. Whenever we get a setup 
	   the next eight interrupts represent the data of the
	   setup packet */
		else if(setupDat)
		{
			/* read the setup data */
			setupBuff[setupCnt++] = *USB_COMMAND;

			/* stop when we have collected eight bytes */
			if(setupCnt > 7)
			{
				setupDat = FALSE;
				sx2Setup = TRUE;
			}
			else
			{
				*USB_COMMAND = 0xC0 | SX2_SETUP;
			}
	     	}
		    /* if this is a new request, then we have to read the
		 value and parse the interrupt value. The value 
		 can't be parsed in the main loop, otherwise we could
		 get two interrupts back to back and trash the first 
		 one in the series. */
		 else
		 {
			/* read the interrupt register value */
			irqValue = *USB_COMMAND;

			switch(irqValue)
			{
				case SX2_INT_SETUP:
					/* endpoint 0 setup */
					/* next eight interrupts are setup data */
					/* parse the interrupt register value */		
					setupDat = TRUE;			
					setupCnt = 0;
					/* send read register command to SX2 */
					*USB_COMMAND = 0xC0 | SX2_SETUP;
					break;
		
				case SX2_INT_EP0BUF:
					/* endpoint 0 ready */
					sx2EP0Buf = TRUE;
					break;
		
				case SX2_INT_FLAGS:
					/* FIFO flags -FF,PF,EF */
					FLAGS_READ = TRUE;
					break;
		
				case SX2_INT_ENUMOK:
					/* enumeration successful */
					sx2EnumOK = TRUE;
					break;
		
				case SX2_INT_BUSACTIVITY:
					/* detected either an absence or resumption of activity on the USB bus.	 */
					/* Indicates that the host is either suspending or resuming or that a 	 */
					/* self-powered device has been plugged into or unplugged from the USB.	 */
					/* If the SX2 is bus-powered, the host processor should put the SX2 into */ 
					/* a low-power mode after detecting a USB suspend condition.			 */
					sx2BusActivity = TRUE;
					break;
				case SX2_INT_READY:
					/* awakened from low power mode via wakeup pin */
					/* or completed power on self test */
					sx2Ready = TRUE;
					break;
		
				default:
					break;
			}
	  	}
	PieCtrl.PIEACK.bit.ACK1 = 1;
	EINT;
}     

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费资源在线播放| 色婷婷精品大在线视频| 色哦色哦哦色天天综合| 日韩制服丝袜av| 欧美日韩精品欧美日韩精品| 99精品一区二区三区| 成人国产在线观看| 日本欧洲一区二区| 国产精品综合二区| 不卡在线观看av| 欧美日韩成人激情| 日本一区二区免费在线| 亚洲三级电影全部在线观看高清| 亚洲国产综合人成综合网站| 人禽交欧美网站| www.在线欧美| 日韩女优av电影| 亚洲精品第一国产综合野| 美女一区二区视频| 欧美一级视频精品观看| 激情图片小说一区| 色中色一区二区| 26uuu欧美| 日韩不卡免费视频| 91免费视频网址| 国产婷婷色一区二区三区四区 | 国产午夜精品福利| 日韩电影在线免费| 欧美视频三区在线播放| 国产精品剧情在线亚洲| 国产尤物一区二区| 久久国产精品99精品国产 | 欧美大片一区二区| 亚洲高清视频中文字幕| 91啪在线观看| 亚洲色图在线看| 欧美亚洲国产怡红院影院| 国产精品天天摸av网| 成人黄色小视频| 中文字幕一区二区三区在线观看| 国产一区二区三区视频在线播放| 高清在线成人网| 日韩经典一区二区| 色94色欧美sute亚洲线路二 | 奇米精品一区二区三区在线观看| 在线亚洲高清视频| 日本午夜一本久久久综合| 日韩一级二级三级| 国产精品一区二区久激情瑜伽| 日韩精品一区国产麻豆| 蜜臀av一区二区| 91蝌蚪国产九色| 亚洲不卡av一区二区三区| 在线观看中文字幕不卡| 亚洲成人tv网| 欧美电影免费观看高清完整版 | 色av综合在线| 强制捆绑调教一区二区| 国产精品免费丝袜| 欧美色图在线观看| 国产精品自拍在线| 三级久久三级久久久| 2023国产精品| 色婷婷精品久久二区二区蜜臂av | 午夜av区久久| 久久亚洲免费视频| 欧美乱妇15p| 99久久精品国产观看| 激情图片小说一区| 婷婷综合另类小说色区| 亚洲欧洲无码一区二区三区| 欧美一三区三区四区免费在线看 | 无吗不卡中文字幕| 最新高清无码专区| 欧美国产日韩在线观看| 成人爽a毛片一区二区免费| 黄色成人免费在线| 日韩一区欧美二区| 亚洲6080在线| 亚洲一级不卡视频| 亚洲成人1区2区| 亚洲永久精品大片| 午夜精品影院在线观看| 亚洲国产欧美在线人成| 亚洲一区二区三区小说| 亚洲视频一二区| 亚洲精品欧美专区| 亚洲成人av一区二区| 亚洲va国产va欧美va观看| 国产精品伦一区| 国产视频911| 精品国免费一区二区三区| 精品久久一区二区三区| 国产喂奶挤奶一区二区三区| 久久久久九九视频| 亚洲美女区一区| 免费日韩伦理电影| 成人福利视频网站| 欧美日韩在线直播| 久久久99精品免费观看不卡| 国产精品国产精品国产专区不蜜| 亚洲主播在线播放| 国产剧情一区在线| 91蝌蚪porny| 久久久亚洲国产美女国产盗摄 | 国产情人综合久久777777| 国产欧美日韩视频在线观看| 亚洲婷婷在线视频| 国内精品不卡在线| 欧美性一二三区| 欧美经典一区二区| 午夜精品一区二区三区三上悠亚| 国产91富婆露脸刺激对白| 欧美在线观看一区二区| 国产欧美日韩视频一区二区 | 91豆麻精品91久久久久久| 精品国精品自拍自在线| 午夜免费久久看| 欧美影院精品一区| 成人h精品动漫一区二区三区| 欧洲中文字幕精品| 亚洲欧美日韩国产综合在线| 国产aⅴ综合色| 日韩欧美资源站| 久久av资源网| 欧美成人精精品一区二区频| 日韩电影一区二区三区| 91麻豆精品国产91久久久资源速度 | 国产欧美日韩综合| 国产乱子伦视频一区二区三区| 2014亚洲片线观看视频免费| 蜜桃视频在线观看一区| 久久日一线二线三线suv| 国产91色综合久久免费分享| 亚洲国产精品传媒在线观看| 成人久久视频在线观看| 国产精品短视频| 欧美亚洲综合色| 久久99精品国产91久久来源| 亚洲精品一区二区三区香蕉 | 337p粉嫩大胆噜噜噜噜噜91av| 中文字幕免费不卡| 国产一区二区不卡| 亚洲日本乱码在线观看| 欧美色窝79yyyycom| 久久精品国产亚洲一区二区三区| 日韩一区二区免费高清| 国产精品一区在线| 亚洲综合色区另类av| 久久在线观看免费| 欧美日韩三级在线| 成人中文字幕在线| 日韩av一区二区在线影视| 国产精品乱码人人做人人爱| 欧美日韩精品欧美日韩精品| 成人亚洲一区二区一| 日韩经典一区二区| 一区二区三区日韩欧美精品| 国产亚洲自拍一区| 国产aⅴ综合色| 欧美成人精品3d动漫h| 99国产精品视频免费观看| 首页国产欧美久久| 国产精品欧美综合在线| 日韩欧美在线123| 欧美另类一区二区三区| 97久久超碰国产精品| 国产精品系列在线播放| 美女在线观看视频一区二区| 五月天婷婷综合| 亚洲国产精品久久一线不卡| 亚洲人123区| 亚洲天堂a在线| 亚洲精品日产精品乱码不卡| 最新欧美精品一区二区三区| 中文字幕在线不卡| 综合久久综合久久| 亚洲一区二区三区四区中文字幕| 日本亚洲电影天堂| 一区二区国产视频| 亚洲二区在线观看| 视频一区在线播放| 激情深爱一区二区| 成人激情动漫在线观看| 日本精品一级二级| 这里是久久伊人| 欧美精品一区二区三区蜜桃| 国产精品久久久一本精品| 亚洲欧美日韩一区二区| 日本少妇一区二区| 成人黄色av网站在线| 欧美人妇做爰xxxⅹ性高电影| 日韩视频一区二区三区| 国产精品女主播在线观看| 亚洲精品欧美专区| 国产在线播放一区| 色综合天天综合色综合av| 日韩精品一区二区三区在线观看| 亚洲视频1区2区| 国产在线精品一区二区夜色|