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

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

?? sx2.c

?? 該文件為DSP28XX系列的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一区二区三区免费野_久草精品视频
精品一区二区三区的国产在线播放| 激情综合色综合久久| 欧美伊人精品成人久久综合97| 亚洲大片精品永久免费| 欧美一区二区三区色| 国产不卡视频在线播放| 欧美体内she精视频| 岛国精品在线观看| 日韩成人免费电影| 天天色综合成人网| 综合中文字幕亚洲| 26uuu欧美| 国产日韩欧美不卡在线| 91精品国产一区二区三区蜜臀| 国产精品资源在线观看| 国产精品一区二区在线观看网站 | 91精品国产丝袜白色高跟鞋| 色一情一伦一子一伦一区| 国产精品自拍在线| 亚洲成人在线免费| 免费观看30秒视频久久| 亚洲国产精品一区二区久久恐怖片| 久久久久久久性| 国产精品麻豆99久久久久久| 精品国产三级电影在线观看| 国产.欧美.日韩| 欧美在线观看一二区| 国产成人一级电影| 精品国产一区二区精华| 久久久久国产免费免费| 欧美亚洲综合色| 亚洲精品一区二区三区四区高清| www.日本不卡| 国产成人鲁色资源国产91色综| 成人久久视频在线观看| 成人99免费视频| 国产精品中文字幕一区二区三区| 91色|porny| 色综合一个色综合亚洲| 大胆亚洲人体视频| 欧美视频中文字幕| 欧美日韩一区二区三区四区| 久久国内精品自在自线400部| 成人手机电影网| 国产一区二区三区不卡在线观看| 色欧美日韩亚洲| 欧美精品一区二区三区久久久| 久久久精品tv| 麻豆免费看一区二区三区| 国产经典欧美精品| 日韩精品一二三四| 蜜臀av一区二区在线免费观看| 日韩一区二区三区在线视频| 国产精品视频麻豆| 成人激情综合网站| 欧美极品美女视频| 成人爽a毛片一区二区免费| 久久美女艺术照精彩视频福利播放 | 美女视频黄免费的久久| 日韩欧美另类在线| 久久99精品视频| 久久综合av免费| 成人国产在线观看| 亚洲一区二区视频| 欧美老肥妇做.爰bbww| 视频在线观看91| 亚洲三级在线观看| 欧美一级二级三级蜜桃| 九九精品视频在线看| 亚洲国产精品影院| 欧美成人a在线| www.66久久| 男女男精品视频| 亚洲欧美日韩久久| 欧美日韩一区二区三区四区五区| 日韩精品成人一区二区在线| 国产精品网曝门| 538prom精品视频线放| 不卡av电影在线播放| 国产裸体歌舞团一区二区| 亚洲福利视频一区二区| 亚洲国产精品高清| 国产午夜精品久久久久久久 | 亚洲综合丝袜美腿| 日韩欧美国产一区二区三区| 欧美午夜免费电影| 欧美日韩视频在线一区二区| 丁香天五香天堂综合| 久久99久久精品欧美| 久久国产视频网| 丁香另类激情小说| 国产美女主播视频一区| 狠狠色综合日日| 成人精品一区二区三区中文字幕| 亚洲日本中文字幕区| 一区二区三区在线免费观看| 亚洲欧美日韩系列| 麻豆精品国产传媒mv男同| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲午夜久久久久久久久久久 | 一级日本不卡的影视| 国产69精品一区二区亚洲孕妇| 日韩一级片在线观看| 亚洲高清免费观看| 色欧美乱欧美15图片| 亚洲免费电影在线| 国产精品亚洲一区二区三区在线 | 成人免费毛片高清视频| 欧美一区二区三区男人的天堂| 婷婷综合在线观看| 日韩精品综合一本久道在线视频| 蜜乳av一区二区三区| 久久久久免费观看| 91免费国产在线观看| 天天操天天干天天综合网| 日韩免费电影网站| 粉嫩欧美一区二区三区高清影视| 久久日韩精品一区二区五区| 国产一区免费电影| 一区二区三区.www| 91精品国产一区二区三区香蕉| 国产一区二区三区四区五区入口| 国产精品成人网| 日韩欧美亚洲国产精品字幕久久久 | 国产一区二区三区在线观看免费视频| 国产精品理论片| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲国产日韩一区二区| 久久综合久久久久88| 欧美午夜精品一区二区蜜桃| 国产尤物一区二区| 免费观看在线综合| 亚洲午夜影视影院在线观看| 中文字幕第一区| 国产亚洲一本大道中文在线| 8v天堂国产在线一区二区| 在线视频你懂得一区| 成人网在线播放| 99re66热这里只有精品3直播| 韩国精品久久久| 精品一二线国产| 国内精品免费**视频| 麻豆高清免费国产一区| 日本欧美大码aⅴ在线播放| 亚洲一区二区三区四区中文字幕| 中文av一区二区| 国产精品国产自产拍在线| 亚洲国产成人一区二区三区| 中文字幕国产一区二区| 久久日韩精品一区二区五区| 欧美r级电影在线观看| 久久久国产精华| 国产精品色在线| 国产亚洲综合在线| 亚洲视频在线观看一区| 亚洲一区二区三区四区中文字幕| 一区二区在线观看免费视频播放| 亚洲一区二区欧美激情| 日本亚洲最大的色成网站www| 国产一区高清在线| 色综合久久中文综合久久97| 制服丝袜国产精品| 国产精品三级av| 免费视频最近日韩| 91国内精品野花午夜精品| 欧美一区二区成人| 亚洲视频一区二区免费在线观看| 亚洲国产精品久久人人爱| 国产美女精品在线| 欧美日韩精品一区二区三区四区| 精品999久久久| 日本亚洲天堂网| 欧美日韩国产片| 一区二区国产视频| 99久久久精品| 国产精品美女www爽爽爽| 国产一区二区精品在线观看| 7777精品伊人久久久大香线蕉超级流畅| 国产欧美一区二区在线观看| 九一九一国产精品| 欧美电影一区二区| 日日摸夜夜添夜夜添亚洲女人| 色一区在线观看| 一区二区激情小说| 欧美丝袜自拍制服另类| 一区二区三区波多野结衣在线观看| 成人综合婷婷国产精品久久| 国产亚洲一二三区| 成人免费观看视频| 亚洲免费在线看| 欧美日韩高清影院| 九一久久久久久| 国产精品久久久久四虎| 91电影在线观看| 久久99精品国产麻豆婷婷| 国产精品成人在线观看| 欧美日韩大陆一区二区| 精品在线免费视频| 亚洲一区中文日韩| 2023国产一二三区日本精品2022|