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

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

?? sx2.c

?? DPS2812的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一区二区三区免费野_久草精品视频
中文字幕高清不卡| 欧美一区二区久久久| 成人午夜免费视频| 成人美女视频在线观看| caoporen国产精品视频| 国产在线日韩欧美| 日本不卡中文字幕| 国产成人自拍高清视频在线免费播放| 久久99精品久久久久久国产越南| 久久激情五月婷婷| 91在线porny国产在线看| 欧美主播一区二区三区| 91麻豆精品国产| 久久香蕉国产线看观看99| 国产精品理论在线观看| 天天色天天操综合| 成人综合在线网站| 欧美一区二区三区在线观看| 国产精品乱人伦| 日韩av电影免费观看高清完整版 | 激情综合网天天干| 99精品欧美一区二区三区小说| 欧美天堂一区二区三区| 国产亚洲欧美色| 热久久免费视频| a4yy欧美一区二区三区| 精品国产成人在线影院| 亚洲香肠在线观看| 91极品视觉盛宴| 亚洲色图欧美激情| 懂色一区二区三区免费观看| 欧美一激情一区二区三区| 亚洲乱码中文字幕| 成人黄色一级视频| 久久久蜜臀国产一区二区| 亚洲成人在线免费| 欧美性大战久久久| 亚洲同性同志一二三专区| 精一区二区三区| 久久久精品欧美丰满| 激情欧美日韩一区二区| wwwwxxxxx欧美| 国产xxx精品视频大全| 久久综合国产精品| 国产麻豆精品视频| 欧美激情在线看| 96av麻豆蜜桃一区二区| 亚洲柠檬福利资源导航| 色婷婷综合久久久中文字幕| 综合欧美一区二区三区| 欧美色精品天天在线观看视频| 亚洲一级二级三级| 8x8x8国产精品| 国产在线播放一区三区四| 国产精品久久久久一区| 在线精品视频免费播放| 日韩高清在线观看| 国产欧美精品一区二区三区四区| 成人黄色777网| 蜜臀av性久久久久蜜臀av麻豆| 欧美电视剧在线观看完整版| 亚洲香肠在线观看| 精品少妇一区二区三区在线视频| 丁香亚洲综合激情啪啪综合| 亚洲高清在线精品| 国产日韩欧美精品在线| 91麻豆精品国产自产在线观看一区| 激情五月激情综合网| 一区二区视频在线看| 日韩一级黄色片| 欧美专区日韩专区| 成年人网站91| 色综合久久99| 欧洲一区在线电影| 国产欧美日韩卡一| 在线播放中文一区| 日本精品视频一区二区| 成人一区二区三区视频 | 懂色av一区二区三区蜜臀| 日韩中文字幕1| 天堂一区二区在线| 日韩二区三区四区| 日韩激情一区二区| 免费人成精品欧美精品| 偷拍亚洲欧洲综合| 蜜桃精品视频在线观看| 蜜臀久久99精品久久久久宅男| 同产精品九九九| 毛片不卡一区二区| 国产精品99久| 99热99精品| 99久久久精品| 国产精品全国免费观看高清| 久久久精品蜜桃| 91网站黄www| 91麻豆精品视频| 不卡一区在线观看| 精品亚洲欧美一区| 日本亚洲最大的色成网站www| 中文字幕日韩av资源站| 国产精品素人视频| 久久久久久久久一| 久久九九影视网| 成人免费在线视频| 亚洲大片在线观看| 国产一区二区在线观看免费| 成人免费视频视频| 欧美日精品一区视频| 久久久久久亚洲综合| 亚洲高清三级视频| 成人午夜激情在线| 欧美日韩一本到| 欧美国产综合一区二区| 亚洲一区二区在线播放相泽| 国内外成人在线视频| 欧美亚洲国产怡红院影院| 久久嫩草精品久久久久| 石原莉奈在线亚洲二区| av高清久久久| 国产精品久久久久9999吃药| 久久精品国产色蜜蜜麻豆| 欧美卡1卡2卡| 婷婷六月综合亚洲| 欧美性xxxxxxxx| 亚洲午夜精品一区二区三区他趣| 高清beeg欧美| 亚洲美腿欧美偷拍| 欧美性受xxxx黑人xyx性爽| 亚洲午夜激情网页| 欧美精品99久久久**| 亚洲成va人在线观看| 制服丝袜中文字幕亚洲| 亚洲国产精品久久久久婷婷884 | 欧美日韩高清影院| 亚洲丰满少妇videoshd| 成人av小说网| 国产三级一区二区| av电影在线观看不卡| 亚洲国产日韩一区二区| 欧美日韩一区二区三区视频| 香蕉成人伊视频在线观看| 欧美丰满少妇xxxbbb| 国产一区二区福利| 亚洲精品欧美激情| 欧美精品1区2区| 国产精品一区二区在线观看网站| 精品国产自在久精品国产| 91在线观看视频| 日韩福利视频网| 国产丝袜欧美中文另类| 欧美日韩二区三区| 成人免费视频一区二区| 日本一道高清亚洲日美韩| 欧美国产国产综合| 欧美午夜精品一区二区三区| 久久 天天综合| 亚洲欧美福利一区二区| 精品国产欧美一区二区| 在线日韩av片| 不卡一区二区中文字幕| 精品综合久久久久久8888| 亚洲一二三四在线观看| 国产精品少妇自拍| 精品国产乱码久久久久久久久| 99re热视频精品| 老司机免费视频一区二区三区| 亚洲欧美日韩国产综合| 国产精品无人区| 2020国产精品自拍| 日韩你懂的在线观看| 4438x亚洲最大成人网| 欧美日韩激情在线| 欧美日韩久久不卡| 欧美日韩一级片网站| 正在播放亚洲一区| 欧美哺乳videos| 久久亚洲二区三区| 国产精品丝袜一区| 亚洲线精品一区二区三区| 一区二区三区日韩在线观看| 日本一区二区高清| 一区二区中文字幕在线| 亚洲自拍欧美精品| 蜜桃一区二区三区在线观看| 国产在线观看一区二区| 美女网站视频久久| 成熟亚洲日本毛茸茸凸凹| av不卡免费电影| 欧美私模裸体表演在线观看| 欧美色综合网站| 欧美—级在线免费片| 亚洲一二三级电影| 麻豆国产欧美一区二区三区| 成人激情免费视频| 666欧美在线视频| 欧美激情综合五月色丁香| 五月天网站亚洲| 色八戒一区二区三区| 国产亚洲制服色| 亚洲午夜在线观看视频在线|