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

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

?? usb_isr.c

?? C8051F320 USB示波器測試程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
//-----------------------------------------------------------------------------
// F32x_USB_ISR.c
//-----------------------------------------------------------------------------
// Copyright 2005 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// Source file for USB firmware. Includes top level ISR with Setup,
// and Endpoint data handlers.  Also includes routine for USB suspend,
// reset, and procedural stall.
//
//
// How To Test:    See Readme.txt
//
//
// FID:            32X000023
// Target:         C8051F32x
// Tool chain:     Keil C51 7.50 / Keil EVAL C51
//                 Silicon Laboratories IDE version 2.6
// Command Line:   See Readme.txt
// Project Name:   F32x_USB_Interrupt
//
//
// Release 1.3
//    -All changes by GP
//    -22 NOV 2005
//    -Changed revision number to match project revision
//    -Modified file to fit new formatting guidelines
//    -Changed file name from USB_ISR.c
//    -Removed extraneous code that was commented out
//    -Added USB Suspend code
//   
// Release 1.0
//    -Initial Revision (DM)
//    -08 NOV 2002
//

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------

#include "c8051F320.h"#include "USB_Register.h"
#include "USB_Main.h"
#include "USB_Descriptor.h"

//-----------------------------------------------------------------------------
// Global Externs
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------

unsigned  char * usb_dptr;       /* pointer to first empty location in buffer (Rx) or to the first char to transmit (Tx) */
unsigned  char usb_ep0_dcntT;   /* data count to transmit */
unsigned  char usb_ep0_dcntR;   /* data count to receive */
unsigned  char usb_ep2_dcntT;   /* data count to transmit */
unsigned  char usb_ep2_dcntR;   /* data count to receive */


BYTE USB_State;                        // Holds the current USB State
                                       // def. in F32x_USB_Main.h

setup_buffer Setup;                    // Buffer for current device request

unsigned int DataSize;                 // Size of data to return
unsigned int DataSent;                 // Amount of data sent so far
BYTE* DataPtr;                         // Pointer to data to return

// Holds the status for each endpoint
BYTE Ep_Status[5] = {EP_IDLE, EP_IDLE, EP_IDLE, EP_IDLE, EP_IDLE};


BYTE receive_ep0;
//-----------------------------------------------------------------------------
// Interrupt Service Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Usb_ISR
//-----------------------------------------------------------------------------
//
// Called after any USB type interrupt, this handler determines which type
// of interrupt occurred, and calls the specific routine to handle it.
//
//-----------------------------------------------------------------------------
void Usb_ISR(void) interrupt 8         // Top-level USB ISR{
   BYTE bCommon, bIn, bOut;
   POLL_READ_BYTE(CMINT, bCommon);     // Read all interrupt registers   POLL_READ_BYTE(IN1INT, bIn);        // this read also clears the register
   POLL_READ_BYTE(OUT1INT, bOut);
   {
      if (bCommon & rbRSUINT)          // Handle Resume interrupt
      {
         Usb_Resume();
      }      if (bCommon & rbRSTINT)          // Handle Reset interrupt
      {
         Usb_Reset();
      }      if (bIn & rbEP0)                 // Handle Setup packet received
      {                                // or packet transmitted if Endpoint 0
		 Handle_Setup();               // is transmit mode
      }      if (bIn & rbIN2)                 // Handle In Packet sent, put new data
      {                                // on endpoint 1 fifo
         Handle_In2();
      }      if (bOut & rbOUT2)               // Handle Out packet received, take data
      {                                // off endpoint 2 fifo
         Handle_Out2();
      }
	  if( bIn & rbIN3)
	  {
	  	 Handle_In3();
	  }
	  if (bOut & rbOUT3)
	  {
	  	 Handle_Out3();
	  }

      if (bCommon & rbSUSINT)          // Handle Suspend interrupt
      {
         Usb_Suspend();
      }
   }
}

//-----------------------------------------------------------------------------
// Support Routines for ISR
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Usb_Reset
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// - Set state to default
// - Clear Usb Inhibit bit
//
//-----------------------------------------------------------------------------

void Usb_Reset(void)
{
   USB_State = DEV_DEFAULT;            // Set device state to default

   POLL_WRITE_BYTE(POWER, 0x01);       // Clear usb inhibit bit to enable USB
                                       // suspend detection

   Ep_Status[0] = EP_IDLE;             // Set default Endpoint Status
   Ep_Status[1] = EP_HALT;
   Ep_Status[2] = EP_HALT;
   Ep_Status[3] = EP_HALT;
   Ep_Status[4] = EP_HALT;
   receive_ep0	= 0;

}

//-----------------------------------------------------------------------------
// Handle_Setup
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// - Decode Incoming Setup requests
// - Load data packets on fifo while in transmit mode
//
//-----------------------------------------------------------------------------

void Handle_Setup(void)
{

   BYTE ControlReg,TempReg;            // Temporary storage for EP control register

   POLL_WRITE_BYTE(INDEX, 0);          // Set Index to Endpoint Zero
   POLL_READ_BYTE(E0CSR, ControlReg);  // Read control register

   if (Ep_Status[0] == EP_ADDRESS)     // Handle Status Phase of Set Address command
   {
      POLL_WRITE_BYTE(FADDR, Setup.wValue.c[LSB]);
      Ep_Status[0] = EP_IDLE;
   }

   if (ControlReg & rbSTSTL)           // If last packet was a sent stall, reset
   {                                   // STSTL bit and return EP0 to idle state
      POLL_WRITE_BYTE(E0CSR, 0);
      Ep_Status[0] = EP_IDLE;
      return;
   }

   if (ControlReg & rbSUEND)           // If last setup transaction was ended prematurely then set
   {                                   
      POLL_WRITE_BYTE(E0CSR, rbDATAEND);
      POLL_WRITE_BYTE(E0CSR, rbSSUEND); // Serviced Setup End bit and return EP0
      Ep_Status[0] = EP_IDLE;          // to idle state
   }

   if (Ep_Status[0] == EP_IDLE)        // If Endpoint 0 is in idle mode
   {
      if (ControlReg & rbOPRDY)        // Make sure that EP 0 has an Out Packet ready from host
      {                                // although if EP0 is idle, this should always be the case

		 if( receive_ep0 == 0)
		 {
	         Fifo_Read(FIFO_EP0, 8, (BYTE *)&Setup);
	                                        // Get Setup Packet off of Fifo, it is currently Big-Endian
	
	                                       // Compiler Specific - these next three statements swap the
	                                       // bytes of the setup packet words to Big Endian so they
	                                       // can be compared to other 16-bit values elsewhere properly
	
			 if(Setup.bmRequestType == 0xC0 )	//MYBDM命令
			 {
				command_buffer[0] = Setup.bmRequestType;
				command_buffer[1] = Setup.bRequest;
				command_buffer[2] = Setup.wValue.c[MSB];
				command_buffer[3] = Setup.wValue.c[LSB];
				command_buffer[4] = Setup.wIndex.c[MSB];
				command_buffer[5] = Setup.wIndex.c[LSB];
				command_buffer[6] = Setup.wLength.c[MSB];
				command_buffer[7] = Setup.wLength.c[LSB];
			
				
				DataPtr = command_buffer;					// Can have a maximum of 255 strings
				
				if (Ep_Status[0] != EP_STALL)
				{
					POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Setup packet, put endpoint in transmit
					Ep_Status[0] = EP_TX;                     // mode and reset Data sent counter
					DataSent = 0;
				}
			 }
			 else if(Setup.bmRequestType == 0x40)
			 {
				command_buffer[0] = Setup.bmRequestType;
				command_buffer[1] = Setup.bRequest;
				command_buffer[2] = Setup.wValue.c[MSB];
				command_buffer[3] = Setup.wValue.c[LSB];
				command_buffer[4] = Setup.wIndex.c[MSB];
				command_buffer[5] = Setup.wIndex.c[LSB];
				command_buffer[6] = Setup.wLength.c[MSB];
				command_buffer[7] = Setup.wLength.c[LSB];
				usb_ep0_dcntR = command_buffer[6];
				if(usb_ep0_dcntR == 0)
				{
			          USB_ep0_rx(); /* the routine will not copy any data, but will launch command execution and status frame transmit */
	                /* this is cleaner as this code is in one place only */
	         	}
				else
				{
					receive_ep0 = 1;

					usb_dptr = command_buffer+6;  /* first 5 bytes stored already starting from position 1 */
					POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Setup packet, put endpoint in transmit
	
					DataSent = 0;
			 	}
		        /* data to follow, set-up pointer */  
			 }
			 else
			 {
				 Setup.wValue.i = Setup.wValue.c[MSB] + 256*Setup.wValue.c[LSB];
		         Setup.wIndex.i = Setup.wIndex.c[MSB] + 256*Setup.wIndex.c[LSB];
		         Setup.wLength.i = Setup.wLength.c[MSB] + 256*Setup.wLength.c[LSB];
		
		
		         switch(Setup.bRequest)        // Call correct subroutine to handle each kind of
		         {                             // standard request
		            case GET_STATUS:
		               Get_Status();
		               break;
		            case CLEAR_FEATURE:
		               Clear_Feature();
		               break;
		            case SET_FEATURE:
		               Set_Feature();
		               break;
		            case SET_ADDRESS:
		               Set_Address();
		               break;
		            case GET_DESCRIPTOR:
		               Get_Descriptor();
		               break;
		            case GET_CONFIGURATION:
		               Get_Configuration();
		               break;
		            case SET_CONFIGURATION:
		               Set_Configuration();
		               break;
		            case GET_INTERFACE:
		               Get_Interface();
		               break;
		            case SET_INTERFACE:
		               Set_Interface();
		               break;
		            default:
		               Force_Stall();          // Send stall to host if invalid request
		               break;
		         }
			 }
		 }
		 else	//	receive_ep0 = 1;
		 {
		 	USB_ep0_rx();
		 }
      }
   }

   if (Ep_Status[0] == EP_TX)          // See if the endpoint has data to transmit to host
   {
      if (!(ControlReg & rbINPRDY))    // Make sure you don't overwrite last packet	Endpoint 0 transmit mode
      {
		 receive_ep0 = 0;
         POLL_READ_BYTE(E0CSR, ControlReg);	   // Read control register
                                       

         if ((!(ControlReg & rbSUEND)) || (!(ControlReg & rbOPRDY)))
                                       // Check to see if Setup End or Out Packet received, if so
                                       // do not put any new data on FIFO
         {
            TempReg = rbINPRDY;        // Add In Packet ready flag to E0CSR bitmask
                                       // Break Data into multiple packets if larger than Max Packet

            if (DataSize >= EP0_PACKET_SIZE)
            {
               Fifo_Write(FIFO_EP0, EP0_PACKET_SIZE, (BYTE *)DataPtr);// Put Data on Fifo
               DataPtr  += EP0_PACKET_SIZE;                           // Advance data pointer
               DataSize -= EP0_PACKET_SIZE;                           // Decrement data size
               DataSent += EP0_PACKET_SIZE;                           // Increment data sent counter
            }
            else                       // If data is less than Max Packet size or zero
            {
               Fifo_Write(FIFO_EP0, DataSize, (BYTE *)DataPtr);       // Put Data on Fifo
               TempReg |= rbDATAEND;                                  // Add Data End bit to bitmask
               Ep_Status[0] = EP_IDLE;                                // Return EP 0 to idle state
            }

            if (DataSent == Setup.wLength.i)
                                        // This case exists when the host requests an even multiple of
                                        // your endpoint zero max packet size, and you need to exit
                                        // transmit mode without sending a zero length packet
            {
               TempReg |= rbDATAEND;    // Add Data End bit to mask

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区h| 狠狠久久亚洲欧美| 亚洲国产人成综合网站| 国产精品久久久久久久久图文区| 在线亚洲一区观看| 欧美另类z0zxhd电影| 色呦呦网站一区| 337p亚洲精品色噜噜噜| 亚洲精品在线三区| 欧美激情中文字幕| 国产午夜精品福利| 国产精品毛片无遮挡高清| 亚洲午夜一二三区视频| 五月天激情综合网| 国产在线精品国自产拍免费| 99久久婷婷国产精品综合| 欧美中文字幕一区二区三区亚洲| 91蜜桃在线免费视频| 欧美日韩五月天| www成人在线观看| 亚洲欧洲一区二区在线播放| 亚洲成人资源网| 国产剧情av麻豆香蕉精品| 不卡的av在线| 欧美一级黄色录像| 亚洲蜜臀av乱码久久精品 | 一区二区三区在线视频免费 | 国产·精品毛片| 欧美日韩在线免费视频| 国产精品传媒视频| 激情深爱一区二区| 在线亚洲一区二区| 国产婷婷色一区二区三区| 香蕉成人啪国产精品视频综合网| 成人午夜电影网站| 欧美成人一区二区三区| 性久久久久久久| 色婷婷av一区二区三区大白胸| 国产午夜精品一区二区三区视频 | 精品一区二区三区影院在线午夜| 91久久人澡人人添人人爽欧美| 日本一二三四高清不卡| 国产原创一区二区三区| 欧美日本韩国一区二区三区视频| 国产日韩欧美高清| 国产suv一区二区三区88区| 久久这里只有精品首页| 美女视频免费一区| 欧美一区二区私人影院日本| 亚洲国产人成综合网站| 精品少妇一区二区三区在线视频| 亚洲一区二区三区爽爽爽爽爽 | 午夜亚洲国产au精品一区二区| 欧美群妇大交群中文字幕| 亚洲成国产人片在线观看| 色婷婷久久久亚洲一区二区三区| 中文字幕在线不卡视频| 成人午夜碰碰视频| 日韩毛片视频在线看| 91美女片黄在线观看| 亚洲一卡二卡三卡四卡| 欧美军同video69gay| proumb性欧美在线观看| 国产精品久久久爽爽爽麻豆色哟哟| 成人性生交大片免费| 亚洲bdsm女犯bdsm网站| 国产午夜精品理论片a级大结局 | 91福利区一区二区三区| 久久99精品国产麻豆婷婷洗澡| 久久精品男人的天堂| 制服丝袜av成人在线看| 国产成人日日夜夜| 美女网站在线免费欧美精品| www国产精品av| 7777精品久久久大香线蕉| 国产一区二区久久| 一级特黄大欧美久久久| 国产亚洲精品aa午夜观看| 欧美日韩大陆一区二区| 97国产一区二区| 免费xxxx性欧美18vr| 亚洲综合色丁香婷婷六月图片| 国产欧美日韩在线看| 精品久久久久久久久久久久久久久 | 久草在线在线精品观看| 中文字幕在线一区免费| 欧美成va人片在线观看| 欧美老女人第四色| 欧美系列日韩一区| 成人av综合在线| 成人激情免费电影网址| 国产精品一区二区91| 免费成人美女在线观看.| 午夜电影一区二区| 伦理电影国产精品| 国产伦精品一区二区三区免费 | 九九视频精品免费| 国产福利不卡视频| 91啪九色porn原创视频在线观看| 色综合天天综合网天天狠天天 | 欧美性xxxxx极品少妇| 欧美日韩的一区二区| 色婷婷久久一区二区三区麻豆| 成人一级黄色片| 国产一区在线不卡| 色婷婷综合久久久久中文一区二区 | 91精品国产综合久久香蕉的特点| 日韩欧美区一区二| 中文字幕免费观看一区| 亚洲尤物视频在线| 国内精品伊人久久久久影院对白| 国产精品主播直播| 在线成人小视频| 国产精品高潮久久久久无| 亚洲mv大片欧洲mv大片精品| 国产成人精品网址| 欧美一区二区三区免费| 欧美激情综合网| 免费观看在线色综合| 欧美亚日韩国产aⅴ精品中极品| 日韩欧美123| 日韩电影免费在线看| 日本精品一区二区三区高清| 国产精品麻豆欧美日韩ww| 麻豆国产精品视频| 欧美精品乱人伦久久久久久| 亚洲日本欧美天堂| 成人av免费在线| 成人免费在线观看入口| 99久精品国产| 亚洲丝袜精品丝袜在线| 91小视频免费看| 亚洲日本中文字幕区| 99久久精品免费看| 亚洲日本在线看| 欧美日韩成人在线一区| 日日噜噜夜夜狠狠视频欧美人| 欧美顶级少妇做爰| 老司机一区二区| 久久嫩草精品久久久久| 国产不卡免费视频| 亚洲午夜久久久久久久久电影网 | 成人免费看的视频| 久久国产精品区| 水野朝阳av一区二区三区| 亚洲人成7777| 亚洲欧洲成人精品av97| 日韩免费视频一区二区| 在线综合+亚洲+欧美中文字幕| 不卡一区在线观看| proumb性欧美在线观看| 成人综合婷婷国产精品久久蜜臀| 美腿丝袜亚洲三区| 男女性色大片免费观看一区二区 | 欧美一区二区三区在| 5月丁香婷婷综合| 日韩视频免费观看高清完整版| 欧美精品乱码久久久久久| 日韩一卡二卡三卡| 久久在线观看免费| 亚洲欧洲国产日韩| 国产目拍亚洲精品99久久精品| 国产成人小视频| 亚洲成人av在线电影| 日韩理论在线观看| 国产精品久久午夜夜伦鲁鲁| 日韩欧美一区在线观看| 欧美精品国产精品| 在线免费视频一区二区| 99r国产精品| 国产91精品一区二区麻豆亚洲| 蜜乳av一区二区三区| 日韩激情视频网站| 韩国女主播一区| 国产伦理精品不卡| 成人网在线免费视频| 国产成人精品aa毛片| 国产精品一级黄| 99综合影院在线| 欧美揉bbbbb揉bbbbb| 欧美系列日韩一区| 51精品视频一区二区三区| 欧美一区二区在线免费观看| 精品日韩在线观看| 日本一区二区三区在线不卡 | 日本在线观看不卡视频| 免费精品99久久国产综合精品| 久久99久国产精品黄毛片色诱| 久久se这里有精品| 99精品国产热久久91蜜凸| 欧美高清www午色夜在线视频| 日韩久久精品一区| 亚洲欧美日韩电影| 国产一区二区福利| 99久精品国产| 91精品国产品国语在线不卡| 成人h动漫精品一区二| 白白色亚洲国产精品| 成人午夜在线视频| 在线视频一区二区三|