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

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

?? sx2.c

?? SEED_DEC5416的USB的程序源碼
?? C
字號:
/********************************************************************************
*sx2.C	v1.00		     							                            *
*	描述:完成對USB控制器CY7C68001的各項功能的控制								*
*  版權(c) 	2003-		北京合眾達電子技術有限責任公司			                *
*  設計者:	段立鋒								                                *
*********************************************************************************/
#include "type.h"
#include "sx2.h"
#include "cy7c68001.h"
#include "sysreg.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( (sysreg_read(sysstat0) & 0x4) ==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( (sysreg_read(sysstat0) & 0x4) ==0 )
	{
		if( time_count++ > usbtimeout )
		{
			return FALSE;
		}
	}
	USB_Command_Write(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( (sysreg_read(sysstat0) & 0x4) ==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_Write(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( (sysreg_read(sysstat0) & 0x4) ==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_Write(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_Write(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一区二区三区免费野_久草精品视频
国产精品美日韩| 亚洲天堂福利av| 色先锋aa成人| 国产精品亚洲专一区二区三区| 亚洲欧美中日韩| 久久久www免费人成精品| 欧美色网一区二区| 成人激情免费网站| 久久国产夜色精品鲁鲁99| 亚洲综合色噜噜狠狠| 国产精品久久午夜| 中文欧美字幕免费| 久久久久国产一区二区三区四区 | 欧美性猛片aaaaaaa做受| 成人白浆超碰人人人人| 国产a精品视频| 国产传媒一区在线| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 欧美性videosxxxxx| 91免费看片在线观看| 色婷婷香蕉在线一区二区| 波多野结衣一区二区三区| 成人黄色国产精品网站大全在线免费观看| 精品一区二区在线观看| 国产在线视频不卡二| 成人综合婷婷国产精品久久| 成人福利视频在线看| 99国产精品视频免费观看| 香蕉乱码成人久久天堂爱免费| 成人网页在线观看| 亚洲欧美偷拍卡通变态| 亚洲欧美日韩一区| 日日骚欧美日韩| 丰满亚洲少妇av| 日韩欧美一级精品久久| 亚洲欧美偷拍卡通变态| 国精产品一区一区三区mba桃花| 成人久久视频在线观看| 亚洲精品视频观看| 亚洲日本丝袜连裤袜办公室| 免费的国产精品| 色老综合老女人久久久| 久久久av毛片精品| 亚洲成人你懂的| 99亚偷拍自图区亚洲| 欧美岛国在线观看| 亚洲一区二区三区在线看| 国产成人综合网站| 91精品国产乱| 亚洲一区国产视频| 99精品久久只有精品| 久久精品夜夜夜夜久久| 人妖欧美一区二区| 欧美日韩国产欧美日美国产精品| 国产精品乱码人人做人人爱 | 日韩视频一区二区| 亚洲一区二区五区| 色综合色综合色综合色综合色综合 | 在线视频一区二区三区| 中文字幕不卡在线播放| 国产乱子伦一区二区三区国色天香 | 国产精品高潮久久久久无| 激情综合色综合久久综合| 欧美视频一区二区三区在线观看| 国产精品久久久久久亚洲毛片| 国产伦精品一区二区三区免费| 欧美成人性福生活免费看| 日韩激情一二三区| 欧美日韩久久一区二区| 亚洲高清免费在线| 欧美伊人久久久久久午夜久久久久| 国产精品国产自产拍高清av王其| 国产河南妇女毛片精品久久久 | 精品午夜一区二区三区在线观看| 91麻豆精品国产无毒不卡在线观看 | 国产精品资源在线观看| 久久久久久免费网| 国产成人免费9x9x人网站视频| 国产日韩精品视频一区| 大陆成人av片| 亚洲人成亚洲人成在线观看图片| jlzzjlzz欧美大全| 日韩毛片高清在线播放| 色综合一区二区| 艳妇臀荡乳欲伦亚洲一区| 欧美性做爰猛烈叫床潮| 午夜精品一区二区三区电影天堂| 欧美疯狂性受xxxxx喷水图片| 亚洲曰韩产成在线| 欧美久久久久中文字幕| 麻豆精品新av中文字幕| 亚洲精品在线三区| 国产99一区视频免费| 国产精品久久毛片| 色一情一乱一乱一91av| 亚洲一区二区三区在线看| 亚洲欧洲制服丝袜| 亚洲欧洲精品一区二区精品久久久| 欧美三级电影网| 老司机精品视频在线| 久久精品一区二区三区四区| 成人综合在线观看| 亚洲永久免费av| 91精品免费在线观看| 激情五月激情综合网| 国产精品私房写真福利视频| 色婷婷亚洲精品| 蜜臀久久久久久久| 国产视频一区不卡| 91理论电影在线观看| 五月综合激情日本mⅴ| 久久综合久久综合九色| 色综合久久综合中文综合网| 日本免费在线视频不卡一不卡二 | 久久精品999| 国产精品嫩草影院av蜜臀| 在线观看免费成人| 久久精品免费观看| 中文字幕一区二区三区四区不卡| 欧美日韩国产另类不卡| 国产精品2024| 亚洲一二三四久久| 久久影院视频免费| 欧美午夜一区二区三区| 精品无人码麻豆乱码1区2区| 亚洲男女一区二区三区| 日韩免费观看高清完整版在线观看| 99久久夜色精品国产网站| 日韩福利视频网| 亚洲天堂2014| 欧美成va人片在线观看| 色婷婷av一区二区三区大白胸| 日本欧美一区二区| 亚洲精品欧美专区| 久久精品欧美日韩精品| 欧美日韩午夜在线| 成人福利电影精品一区二区在线观看| 亚洲高清免费观看高清完整版在线观看| 久久亚洲一区二区三区明星换脸| 欧美系列在线观看| 成人午夜短视频| 男女性色大片免费观看一区二区 | 欧美三级日韩三级| 成年人午夜久久久| 久久精品国产亚洲高清剧情介绍| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 日韩一级精品视频在线观看| 91久久香蕉国产日韩欧美9色| 激情都市一区二区| 日本三级亚洲精品| 亚洲一卡二卡三卡四卡 | 在线亚洲欧美专区二区| 成人国产精品免费观看| 国内精品自线一区二区三区视频| 亚洲成人1区2区| 亚洲欧美日韩国产中文在线| 国产精品无人区| 欧美xxxxx裸体时装秀| 欧美人伦禁忌dvd放荡欲情| 色偷偷久久人人79超碰人人澡| 国产酒店精品激情| 老司机免费视频一区二区三区| 三级在线观看一区二区| 亚洲国产精品视频| 一级女性全黄久久生活片免费| 国产精品伦一区| 中文字幕不卡的av| 国产亚洲一区字幕| 久久精品男人的天堂| 精品99一区二区三区| 日韩一区二区电影| 日韩一区二区三免费高清| 在线播放亚洲一区| 欧美色区777第一页| 色成人在线视频| 一本一道波多野结衣一区二区| 大白屁股一区二区视频| 高清不卡在线观看| 成人综合激情网| 成人高清视频在线观看| 成人动漫中文字幕| 99久久婷婷国产综合精品| 99麻豆久久久国产精品免费| 成人av在线电影| 成人福利视频在线| 91麻豆精品在线观看| 91亚洲永久精品| 色综合中文字幕国产| 成人一区二区在线观看| 成人av影院在线| www.综合网.com| 91蜜桃传媒精品久久久一区二区| 99re这里都是精品| 欧洲一区二区三区在线| 欧美日韩国产首页在线观看| 91精品国产全国免费观看| 日韩欧美美女一区二区三区| 337p粉嫩大胆色噜噜噜噜亚洲| 国产香蕉久久精品综合网| 国产精品免费久久|