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

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

?? sx2.c

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

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

#define	COMMAND		0x04

/*聲明中斷INT2的函數(shù),用于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的狀態(tài)讀請求*/
/* 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;
		}
	}
	/*讀取寄存器的數(shù)據(jù)*/
	*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一区二区三区免费野_久草精品视频
欧美理论电影在线| 国产一区二区福利| 亚洲少妇30p| 中文字幕日韩一区| 国产欧美1区2区3区| 久久综合五月天婷婷伊人| 欧美一级高清片| 日韩三级中文字幕| 成人综合激情网| 成人免费观看男女羞羞视频| 亚洲桃色在线一区| 亚洲女人小视频在线观看| 国产精品久99| 亚洲欧美二区三区| 亚洲成人777| 狠狠色丁香久久婷婷综| 国产风韵犹存在线视精品| 国产风韵犹存在线视精品| jlzzjlzz欧美大全| 在线免费观看日韩欧美| 在线播放91灌醉迷j高跟美女| 日韩一卡二卡三卡四卡| 日韩一卡二卡三卡| 国产亚洲欧美日韩俺去了| 亚洲成在人线免费| av午夜一区麻豆| 国内精品久久久久影院色| 极品少妇xxxx精品少妇| 粉嫩久久99精品久久久久久夜 | 91污在线观看| 欧美午夜片在线观看| 欧美成人r级一区二区三区| 久久精品人人做| 亚洲免费高清视频在线| 蜜桃精品在线观看| av色综合久久天堂av综合| 欧美日韩日日夜夜| 中文字幕久久午夜不卡| 亚洲一区二区三区激情| 国产精品 日产精品 欧美精品| 在线观看免费亚洲| 中文一区一区三区高中清不卡| 日韩精品一区二区三区在线播放 | 日韩一区在线播放| 亚洲亚洲精品在线观看| 国模冰冰炮一区二区| 在线视频亚洲一区| 国产欧美日韩在线| 美国一区二区三区在线播放| av一区二区三区在线| 日韩精品专区在线影院观看| 国产精品人人做人人爽人人添| 免费在线看一区| 色悠久久久久综合欧美99| 精品国产三级a在线观看| 亚洲精品视频观看| 丁香婷婷深情五月亚洲| 欧美日韩国产免费一区二区| 欧美一级片在线看| 欧美极品另类videosde| 精品精品国产高清a毛片牛牛| 一区二区三区中文字幕电影| 国产乱码精品一区二区三区五月婷| 欧美三级电影精品| 一区二区在线观看免费 | 欧美日韩国产综合视频在线观看| 久久免费精品国产久精品久久久久| 亚洲成人在线观看视频| 色综合久久九月婷婷色综合| 国产精品无码永久免费888| 国产激情视频一区二区在线观看| 精品国内片67194| 国产一区在线精品| 日韩一区二区免费高清| 日韩精品乱码免费| 日韩一区二区不卡| 风间由美一区二区av101| 亚洲欧洲av在线| 欧美另类videos死尸| 色婷婷久久久综合中文字幕| 国产精品久久久久9999吃药| 国产91精品精华液一区二区三区| 久久精品一区二区三区不卡牛牛| 久久99日本精品| 亚洲精品在线网站| 国产不卡一区视频| 亚洲色欲色欲www| 色偷偷88欧美精品久久久| 亚洲男同性恋视频| 欧美视频中文字幕| 无吗不卡中文字幕| 精品国产免费人成在线观看| 久久精工是国产品牌吗| 国产欧美日产一区| 在线免费不卡视频| 性欧美疯狂xxxxbbbb| 欧美主播一区二区三区| 一区二区三区中文字幕电影| 久久久久国产精品厨房| 91久久免费观看| 亚洲国产成人porn| 高清shemale亚洲人妖| 国产精品久久久久久亚洲伦| www.综合网.com| 日韩va欧美va亚洲va久久| 久久久久88色偷偷免费| 91香蕉视频mp4| 日本va欧美va欧美va精品| 26uuu国产在线精品一区二区| 北条麻妃一区二区三区| 亚瑟在线精品视频| 欧美激情在线观看视频免费| 色婷婷久久久亚洲一区二区三区| 久久精品国产色蜜蜜麻豆| 国产精品久久三| 欧美大肚乱孕交hd孕妇| 成人伦理片在线| 极品少妇一区二区| 五月天亚洲精品| 国产乱理伦片在线观看夜一区| 国产亚洲成aⅴ人片在线观看| 夫妻av一区二区| 日韩成人伦理电影在线观看| 国产欧美一区二区精品仙草咪| 欧美在线看片a免费观看| 精品一区二区免费| 亚洲一区二区三区四区五区中文| 国产日韩亚洲欧美综合| 欧美精品国产精品| 91精品福利在线| 成人在线视频一区| 精久久久久久久久久久| 亚洲成年人网站在线观看| 中文字幕一区二区视频| 久久一区二区视频| 欧美α欧美αv大片| 欧美日本在线播放| 一本久久精品一区二区| 国产成人精品免费看| 蜜桃一区二区三区在线观看| 亚洲午夜精品17c| 欧美精品粉嫩高潮一区二区| 国产精品免费视频一区| 91久久精品一区二区三| 91亚洲精品久久久蜜桃网站 | 欧美一级免费大片| 欧美日韩一区成人| 欧美午夜电影在线播放| 在线观看日韩国产| 欧美日韩一区二区三区不卡| 91视频www| 色诱视频网站一区| 欧美探花视频资源| 欧美三级日韩在线| 在线91免费看| 日韩视频免费观看高清完整版| 欧美一区二区日韩一区二区| 欧美日韩国产美| 69久久99精品久久久久婷婷 | 美国毛片一区二区| 日本在线不卡一区| 麻豆精品视频在线观看视频| 日韩精品亚洲一区二区三区免费| 日韩精品国产精品| 九九精品一区二区| 成人深夜在线观看| 日本丶国产丶欧美色综合| 欧洲人成人精品| 3atv在线一区二区三区| 欧美一区二区三区在线观看| 日韩一级高清毛片| 国产日韩欧美精品电影三级在线| 亚洲国产精品成人综合| 亚洲女同女同女同女同女同69| 亚洲成人黄色影院| 久久国产婷婷国产香蕉| 国产不卡视频在线播放| 在线亚洲免费视频| 精品久久久久久久人人人人传媒| 久久久亚洲欧洲日产国码αv| 亚洲欧美在线视频| 日韩电影在线免费看| 国产一区啦啦啦在线观看| 99免费精品视频| 日韩免费看的电影| 国产精品家庭影院| 奇米777欧美一区二区| 国产乱淫av一区二区三区| 91麻豆精品秘密| 久久一区二区三区国产精品| 亚洲女与黑人做爰| 国产一区二区看久久| 日本道免费精品一区二区三区| 日韩欧美中文字幕公布| 综合欧美亚洲日本| 韩国毛片一区二区三区| 欧美图区在线视频| 国产精品国产自产拍高清av| 亚洲一区二区三区影院| 日韩一级黄色大片|