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

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

?? sx2.c

?? 我購買的開發板帶的元程序
?? 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一区二区三区免费野_久草精品视频
国产精品欧美精品| 亚洲国产成人自拍| 不卡视频一二三| 日本中文一区二区三区| 国产精品日韩成人| 欧美一区二区三区电影| 91蜜桃在线免费视频| 国产一区 二区| 亚洲高清免费在线| 亚洲欧洲www| 久久久欧美精品sm网站| 91精选在线观看| 一本一道久久a久久精品综合蜜臀| 裸体在线国模精品偷拍| 一级日本不卡的影视| 欧美高清在线视频| 久久综合色播五月| 日韩一区二区不卡| 欧美视频中文字幕| 国产东北露脸精品视频| 天堂成人国产精品一区| 亚洲免费观看高清| 欧美经典三级视频一区二区三区| 5858s免费视频成人| 91麻豆蜜桃一区二区三区| 久久电影网电视剧免费观看| 亚洲第一福利视频在线| 日韩美女久久久| 国产精品视频一二三| 久久婷婷综合激情| 日韩免费视频线观看| 777精品伊人久久久久大香线蕉| 91丝袜高跟美女视频| kk眼镜猥琐国模调教系列一区二区| 九色综合国产一区二区三区| 日本在线不卡视频| 午夜精品久久久久久| 亚洲国产sm捆绑调教视频| 一区二区三区精品在线观看| 日韩理论片一区二区| 国产精品久久国产精麻豆99网站 | 欧美xfplay| 91精品国产综合久久久久久久久久 | 国产乱码精品一区二区三| 日日摸夜夜添夜夜添亚洲女人| 亚洲午夜激情网页| 午夜精品久久久久久久99樱桃| 亚洲在线中文字幕| 亚洲一区二区三区四区五区黄| 亚洲男人电影天堂| 亚洲一区二区三区四区的| 一区二区三区日韩精品| 一区二区三区蜜桃| 亚洲综合在线免费观看| 亚洲自拍偷拍麻豆| 视频一区在线播放| 精品影视av免费| 国产成人在线观看免费网站| 国产精品 欧美精品| 成人av免费在线播放| 99re成人精品视频| 欧美性xxxxxx少妇| 欧美一区二区播放| 亚洲精品一区二区三区99| 久久久久久久网| 国产精品一区二区无线| 亚洲欧美激情小说另类| 美女视频黄免费的久久| 久久国产精品露脸对白| 亚洲欧美中日韩| 亚洲v中文字幕| 亚洲一二三四区| 久久爱另类一区二区小说| 伊人性伊人情综合网| 欧美日韩一区二区三区不卡| 欧洲亚洲国产日韩| 欧美人妖巨大在线| 欧美一区二区三区在线观看视频| 日韩免费视频线观看| 国产酒店精品激情| 日韩免费看的电影| 国产激情精品久久久第一区二区| 成人黄动漫网站免费app| 色婷婷久久99综合精品jk白丝| 欧美少妇xxx| 久久午夜羞羞影院免费观看| 欧美国产精品一区| 日韩精品免费视频人成| 国产激情91久久精品导航| 色欧美片视频在线观看| 91精品国产综合久久久久久| 中文字幕第一区第二区| 午夜伦欧美伦电影理论片| 国产经典欧美精品| 91麻豆精品国产| 国产精品超碰97尤物18| 免费成人美女在线观看| 91免费在线视频观看| 日韩欧美亚洲国产精品字幕久久久| 国产精品理伦片| 久久99精品国产91久久来源| 在线日韩av片| 国产视频视频一区| 秋霞午夜av一区二区三区| 91污在线观看| 国产三区在线成人av| 日韩av在线播放中文字幕| 97久久久精品综合88久久| 日韩午夜小视频| 亚洲一区二区三区四区在线 | 9i在线看片成人免费| 欧美精品日日鲁夜夜添| 亚洲欧美日韩小说| 盗摄精品av一区二区三区| 日韩免费视频一区| 香蕉久久一区二区不卡无毒影院| www.激情成人| 久久久久国产一区二区三区四区| 日本一区中文字幕| 欧美午夜精品理论片a级按摩| 亚洲三级在线播放| 国产成人在线影院| 2023国产精品自拍| 麻豆精品国产传媒mv男同 | 国产日韩精品视频一区| 日韩国产欧美视频| 欧美日韩视频不卡| 亚洲午夜精品久久久久久久久| 91一区二区三区在线观看| 国产色婷婷亚洲99精品小说| 国内久久精品视频| 精品国产精品一区二区夜夜嗨| 五月天一区二区| 欧美高清视频www夜色资源网| 亚洲一区二区三区视频在线播放| 不卡的看片网站| 国产精品美女一区二区| 成人av在线网站| 亚洲欧洲一区二区在线播放| 成人晚上爱看视频| 国产精品理论片在线观看| 99麻豆久久久国产精品免费| 国产精品色一区二区三区| 99re这里只有精品视频首页| 国产精品卡一卡二| 97精品久久久久中文字幕 | 欧美一三区三区四区免费在线看| 亚洲福利一二三区| 91精品在线观看入口| 亚洲国产欧美在线| 欧美一区二视频| 狠狠色丁香久久婷婷综合_中 | 伊人开心综合网| 欧美视频完全免费看| 日本成人在线不卡视频| 欧美电影免费观看高清完整版在线观看| 理论片日本一区| 国产欧美日韩视频在线观看| 丁香婷婷深情五月亚洲| 中文字幕五月欧美| 欧美日韩三级一区二区| 久久超碰97中文字幕| 久久婷婷成人综合色| 成人一区二区在线观看| 亚洲欧美日韩中文字幕一区二区三区 | 欧美电影免费观看高清完整版| 国产在线精品一区二区不卡了 | 久久久精品欧美丰满| 成av人片一区二区| 亚洲一区二区三区四区中文字幕| 91精品蜜臀在线一区尤物| 国产精选一区二区三区| 国产精品国模大尺度视频| 欧美日韩国产成人在线91| 韩日av一区二区| 亚洲欧美日本在线| 日韩一区二区精品葵司在线| 岛国精品在线播放| 一区二区三区久久| 精品日韩一区二区三区| 成人黄色小视频在线观看| 亚洲最大的成人av| 久久久高清一区二区三区| 色婷婷狠狠综合| 狠狠色综合播放一区二区| 亚洲欧洲精品一区二区三区不卡| 欧美精品久久99| 色狠狠色噜噜噜综合网| 美腿丝袜亚洲色图| 亚洲色图视频网| 久久综合丝袜日本网| 欧美吻胸吃奶大尺度电影 | 亚洲乱码精品一二三四区日韩在线| 欧美日本视频在线| 99麻豆久久久国产精品免费| 久久精品国产一区二区三区免费看| 亚洲欧洲av在线| 26uuu国产在线精品一区二区| 色婷婷狠狠综合| 大白屁股一区二区视频|