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

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

?? sx2.c

?? 2812 USB程序
?? C
字號:

#include "type.h"
#include "sx2.h"
#include "cy7c68001.h" 
#include "DEC2407_USB.h"

#define	COMMAND		0x04

/*聲明中斷INT2的函數,用于USB的中斷處理*/
#pragma INTERRUPT(int2_isr);
BOOL SX2_comwritebyte(unsigned int value);
/* global variables */
BYTE irqValue;			 /* interrupt register value */
BYTE setupBuff[8];		 /* setup transaction buffer */
BOOL sx2Ready;			 /* status byte for POST */ 
BOOL sx2BusActivity;	 /* status byte for suspend */ 
BOOL sx2EnumOK;			 /* status byte for enumeration complete */
BOOL sx2EP0Buf;			 /* status for endpoint 0 buffer */
BOOL sx2Setup;			 /* setup flag set in Int0() ISR */
BOOL FLAGS_READ = FALSE; /*FIFO的狀態讀請求*/
/* shared between interrupt and register read routines */ 
/*中斷與寄存器讀之間共享,確定是否是由讀寄存器引起的中斷*/
BOOL readFlag;

unsigned int usbtimeout = 0x400;
unsigned int regdataread = 0; 	

static char setupCnt;
static BOOL setupDat = FALSE;		
/*****************************************************************************/
/*	Function: Load_descriptors												 */
/*	Purpose:  loads the descriptor memory of SX2							 */
/*	Input:	  count - number of bytes in the descriptor						 */
/*			  desc  - pointer to descriptor table							 */
/*	Output:	  TRUE  on success												 */
/*			  FALSE on failure												 */
/*																			 */
/*****************************************************************************/
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 & 0x8) ==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 & 0x8) ==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;
	/*wait the ready is ok*/
	while( (USB_STS & 0x8) ==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 = TRUE;

	/* wait for read flag to be cleared by an interrupt */
	/*等待讀標志為假*/
	while(readFlag);
	
	/*wait the ready is ok*/
	while( (USB_STS & 0x8) ==0 )
	{
		if( transovertime++ > usbtimeout )
		{
			return FALSE;
		}
	}
	/*讀取寄存器的數據*/
	*value = USB_Command_Read();
	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,u16* pdata,unsigned int longth)
{
	unsigned int i = 0;
	for(i = 0;i<longth;i++)
	{
		if(!SX2_FifoWriteSingle(channel,pdata[i]))
		{
			return FALSE;
		}
	}
	return TRUE;	
}*/
/*********************************************************/
/*                                                       */
/*	Function: SX2_FifoRead                               */
/*	Purpose:  read sx2fifo to data buffer                */
/*	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_FifoRead(int channel,u16* pdata,unsigned int longth)
{
	unsigned int i = 0;
	for(i = 0;i<longth;i++)
	{
//		pdata[i] = SX2_FifoReadSingle(channel);
	}
	return TRUE;
}
/*********************************************************/
/*************** INTERRUPT ROUTINES **********************/
/**********************************************************
*
*	Function: Int2
*	Purpose:  Interrupts on external interrupt 2
*	Input:	  None
*	Output:	  None
*
**********************************************************/

void int2_isr()
{
	/* 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)
	{
		readFlag = FALSE;
	}
	/* 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_Read();

			/* 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_Read();

			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;
				}
	  	}
}      

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美男生操女生| 亚洲电影一区二区| 国产精品中文字幕一区二区三区| 7777精品伊人久久久大香线蕉的| 麻豆一区二区三| ...av二区三区久久精品| 欧美中文一区二区三区| 精品在线播放免费| 综合久久久久久| 久久综合久久综合亚洲| 91亚洲国产成人精品一区二三| 亚洲综合色区另类av| 日本一区二区三级电影在线观看| 色噜噜久久综合| 国产成人亚洲精品青草天美| 午夜精品一区二区三区电影天堂| 欧美激情在线观看视频免费| 91精品国产一区二区三区| 国产aⅴ精品一区二区三区色成熟| 亚洲午夜久久久久| 综合久久综合久久| 国产精品网站在线观看| 欧美精品一区二区三区视频| 欧美三级资源在线| 一本高清dvd不卡在线观看| 国产另类ts人妖一区二区| 免费观看一级欧美片| 亚洲国产精品久久久久婷婷884| 中文字幕一区二区日韩精品绯色| 欧美国产97人人爽人人喊| 久久精品视频免费| 日韩美女视频一区二区| 亚洲蜜臀av乱码久久精品| 日本女优在线视频一区二区| 国产精品免费av| 亚洲色图.com| 首页欧美精品中文字幕| 日本怡春院一区二区| 青青草成人在线观看| 国产伦精品一区二区三区免费迷| 国产精品夜夜爽| 99re免费视频精品全部| 欧美在线观看视频一区二区三区| 欧洲色大大久久| 日韩欧美一级二级三级| 中文av字幕一区| 偷拍日韩校园综合在线| 美国毛片一区二区三区| 成人午夜视频福利| 欧美一区二区三区视频在线 | 欧美日韩国产影片| 精品福利一区二区三区免费视频| 国产精品美女久久久久久2018| 亚洲国产精品久久久男人的天堂| 韩国一区二区三区| 欧美一级一区二区| 亚洲不卡一区二区三区| 成人毛片在线观看| 国产亚洲自拍一区| 狠狠色丁香婷婷综合久久片| 在线观看亚洲精品视频| 亚洲乱码国产乱码精品精的特点 | 日韩av高清在线观看| 色婷婷精品大在线视频| 国产日本欧美一区二区| 免费成人av在线播放| 欧美人与禽zozo性伦| 亚洲大型综合色站| 777亚洲妇女| 另类小说欧美激情| 国产日产欧产精品推荐色| 国产suv精品一区二区6| 欧美国产视频在线| 97精品国产97久久久久久久久久久久 | 国产一区二区0| 国产欧美日韩一区二区三区在线观看| 韩国av一区二区三区四区| 制服丝袜成人动漫| 乱中年女人伦av一区二区| 精品日韩在线一区| 成人免费毛片片v| 亚洲婷婷综合久久一本伊一区| 欧美在线不卡视频| 热久久免费视频| 欧美经典一区二区| 欧美日韩三级一区二区| 日韩精品乱码免费| 国产日韩欧美高清在线| 色久优优欧美色久优优| 久久精品国产网站| 亚洲桃色在线一区| 国产亚洲欧美日韩俺去了| 91麻豆国产精品久久| 免费亚洲电影在线| 亚洲欧美综合色| 久久亚洲精精品中文字幕早川悠里 | 国产午夜三级一区二区三| 色又黄又爽网站www久久| 韩国三级中文字幕hd久久精品| 综合欧美一区二区三区| 欧美大片一区二区| 欧美精品在线观看一区二区| 成人国产电影网| 精品无码三级在线观看视频 | 7777精品伊人久久久大香线蕉的| 成人18精品视频| 成人永久免费视频| 国产精品18久久久久久vr| 日韩av午夜在线观看| 亚洲国产成人高清精品| 中文字幕一区av| 久久久高清一区二区三区| 精品免费日韩av| 欧美成人伊人久久综合网| 日韩免费视频一区| 国产视频一区在线观看| 久久久99免费| 中文字幕日韩欧美一区二区三区| 久久精品这里都是精品| 久久久久久99久久久精品网站| 久久久噜噜噜久久人人看| 久久久久久免费网| 亚洲日本护士毛茸茸| 一二三区精品视频| 日本伊人色综合网| 国产剧情一区在线| 在线视频一区二区三区| 欧美区视频在线观看| 久久久久久久久99精品| 亚洲国产wwwccc36天堂| 麻豆高清免费国产一区| 99精品国产视频| 欧美日韩国产123区| 国产欧美日韩视频一区二区| 1区2区3区精品视频| 另类综合日韩欧美亚洲| 色婷婷激情综合| 久久视频一区二区| 天堂蜜桃91精品| 91原创在线视频| 国产精品乱码久久久久久| 午夜精品123| 91国偷自产一区二区三区成为亚洲经典 | 欧美日本不卡视频| 一区二区在线看| 国产成人在线视频网站| 久久久精品国产免费观看同学| 日韩欧美一级二级| 97精品国产露脸对白| 国产精品一区二区免费不卡| 五月天中文字幕一区二区| 国产精品你懂的在线欣赏| 欧美影视一区在线| 久久蜜桃av一区二区天堂| 麻豆国产91在线播放| 亚洲视频狠狠干| 久久这里只精品最新地址| 91网站黄www| 欧美不卡123| 色综合久久88色综合天天6| 五月天亚洲婷婷| 一二三区精品福利视频| 26uuu国产在线精品一区二区| 波多野结衣在线一区| 久久99国产精品麻豆| 国产精品视频看| 99riav一区二区三区| 首页欧美精品中文字幕| 久久久精品免费网站| aa级大片欧美| 裸体一区二区三区| 中文字幕色av一区二区三区| 欧美日韩一区二区不卡| 国产精品 欧美精品| 一区二区三区在线不卡| wwwwww.欧美系列| 欧美午夜精品久久久久久超碰| 激情综合色综合久久综合| 亚洲欧美二区三区| 久久婷婷国产综合精品青草| 欧美艳星brazzers| 91小宝寻花一区二区三区| 极品销魂美女一区二区三区| 亚洲一二三区视频在线观看| 国产欧美日韩三级| 国产区在线观看成人精品 | 97久久精品人人做人人爽| 久久精工是国产品牌吗| 午夜影院久久久| 日韩精品乱码av一区二区| 亚洲第一狼人社区| 日韩激情在线观看| 丝袜亚洲精品中文字幕一区| 亚洲小说欧美激情另类| 亚洲精品水蜜桃| 日韩—二三区免费观看av| 日本亚洲一区二区| 国产.欧美.日韩| 欧美日韩精品欧美日韩精品 | 久久网站最新地址|