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

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

?? usb_isr.c

?? c8051f340 usb開發程序指南
?? C
字號:
/*
   Copyright 2003 Cygnal Integrated Products, Inc.   File:    usb_isr.c
   Author:  JS
   Created: JAN 03

   Target Device: C8051F320

   Source file for USB firmware. Includes the following routines:

   - USB_ISR(): Top-level USB interrupt handler. All USB handler
      routines are called from here.
   - Endpoint0(): Endpoint0 interrupt handler.
   - BulkOrInterruptOut(): Bulk or Interrupt OUT interrupt
      handler.
   - BulkOrInterruptIn(): Bulk or Interrupt IN interrupt
      handler.
   - USBReset (): USB Reset event handler.

******************************************/
#include "c8051F320.h"
#include "usb_regs.h"
#include "usb_structs.h"
#include "usb_main.h"
#include "usb_desc.h"#include "usb_config.h"
#include "usb_request.h"

extern DEVICE_STATUS gDeviceStatus;
extern EP0_COMMAND gEp0Command;
extern EP_STATUS gEp0Status;
extern EP_STATUS gEp1InStatus;
extern EP_STATUS gEp2OutStatus;
extern BYTE OUT_PACKET[];
extern BYTE IN_PACKET[];

//---------------------------//  USB ISR//---------------------------//
// This is the top level USB ISR. All endpoint interrupt/request
// handlers are called from this function.
//
// Handler routines for any configured interrupts should be
// added in the appropriate endpoint handler call slots.
//void USB_ISR () interrupt 8{
   BYTE bCommonInt, bInInt, bOutInt;
   // Read interrupt registers
   UREAD_BYTE(CMINT, bCommonInt);   UREAD_BYTE(IN1INT, bInInt);   UREAD_BYTE(OUT1INT, bOutInt);   // Check for reset interrupt   if (bCommonInt & rbRSTINT)
   {
      // Call reset handler
      USBReset();   }
   // Check for Endpoint0 interrupt   if (bInInt & rbEP0)
   {
      // Call Endpoint0 handler
      Endpoint0 ();
   }   // Endpoint1 IN   if (bInInt & rbIN1)
   {
      // Call Endpoint1 IN handler
      BulkOrInterruptIn(&gEp1InStatus);
   }

   // Endpoint2 OUT   if (bOutInt & rbOUT2)
   {
      // Call Endpoint2 OUT handler
      BulkOrInterruptOut(&gEp2OutStatus);
   }}//---------------------------//  Endpoint0 Handler//---------------------------void Endpoint0 (){
   BYTE bTemp = 0;
   BYTE bCsr1, uTxBytes;

   UWRITE_BYTE(INDEX, 0);                 // Target ep0
   UREAD_BYTE(E0CSR, bCsr1);

   // Handle Setup End
   if (bCsr1 & rbSUEND)                   // Check for setup end
   {                                      // Indicate setup end serviced
      UWRITE_BYTE(E0CSR, rbSSUEND);
      gEp0Status.bEpState = EP_IDLE;      // ep0 state to idle
   }

   // Handle sent stall
   if (bCsr1 & rbSTSTL)                   // If last state requested a stall
   {                                      // Clear Sent Stall bit (STSTL)
      UWRITE_BYTE(E0CSR, 0);
      gEp0Status.bEpState = EP_IDLE;      // ep0 state to idle
   }

   // Handle incoming packet
   if (bCsr1 & rbOPRDY)
   {
      // Read the 8-byte command from Endpoint0 FIFO
      FIFORead(0, 8, (BYTE*)&gEp0Command);

      // Byte-swap the wIndex field
      bTemp = gEp0Command.wIndex.c[1];
      gEp0Command.wIndex.c[1] = gEp0Command.wIndex.c[0];
      gEp0Command.wIndex.c[0] = bTemp;

      // Byte-swap the wValue field
      bTemp = gEp0Command.wValue.c[1];
      gEp0Command.wValue.c[1] = gEp0Command.wValue.c[0];
      gEp0Command.wValue.c[0] = bTemp;

      // Byte-swap the wLength field
      bTemp = gEp0Command.wLength.c[1];
      gEp0Command.wLength.c[1] = gEp0Command.wLength.c[0];
      gEp0Command.wLength.c[0] = bTemp;

      // Decode received command
      switch (gEp0Command.bmRequestType & CMD_MASK_COMMON)
      {
         case  CMD_STD_DEV_OUT:           // Standard device requests
            // Decode standard OUT request
            switch (gEp0Command.bRequest)
            {
               case SET_ADDRESS:
                  SetAddressRequest();
                  break;
               case SET_FEATURE:
                  SetFeatureRequest();
                  break;
               case CLEAR_FEATURE:
                  ClearFeatureRequest();
                  break;
               case SET_CONFIGURATION:
                  SetConfigurationRequest();
                  break;
               case SET_INTERFACE:
                  SetInterfaceRequest();
                  break;
               // All other OUT requests not supported
               case SET_DESCRIPTOR:
               default:
                  gEp0Status.bEpState = EP_ERROR;
                  break;
            }
            break;

         // Decode standard IN request
         case CMD_STD_DEV_IN:
            switch (gEp0Command.bRequest)
            {
               case GET_STATUS:
                  GetStatusRequest();
                  break;
               case GET_DESCRIPTOR:
                  GetDescriptorRequest();
                  break;
               case GET_CONFIGURATION:
                  GetConfigurationRequest();
                  break;
               case GET_INTERFACE:
                  GetInterfaceRequest();
                  break;
               // All other IN requests not supported
               case SYNCH_FRAME:
               default:
                  gEp0Status.bEpState = EP_ERROR;
                  break;
            }
            break;
         // All other requests not supported
         default:
            gEp0Status.bEpState = EP_ERROR;
      }

      // Write E0CSR according to the result of the serviced out packet
      bTemp = rbSOPRDY;
      if (gEp0Status.bEpState == EP_ERROR)
      {
         bTemp |= rbSDSTL;                // Error condition handled
                                          // with STALL
         gEp0Status.bEpState = EP_IDLE;   // Reset state to idle
      }

      UWRITE_BYTE(E0CSR, bTemp);
   }

   bTemp = 0;                             // Reset temporary variable

   // If state is transmit, call transmit routine
   if (gEp0Status.bEpState == EP_TX)
   {
      // Check the number of bytes ready for transmit
      // If less than the maximum packet size, packet will
      // not be of the maximum size
      if (gEp0Status.uNumBytes <= EP0_MAXP)
      {
         uTxBytes = gEp0Status.uNumBytes;
         gEp0Status.uNumBytes = 0;        // update byte counter
         bTemp |= rbDATAEND;              // This will be the last
                                          // packet for this transfer
         gEp0Status.bEpState = EP_IDLE;   // Reset endpoint state
      }

      // Otherwise, transmit maximum-length packet
      else
      {
         uTxBytes = EP0_MAXP;
         gEp0Status.uNumBytes -= EP0_MAXP;// update byte counter
      }

      // Load FIFO
      FIFOWrite(0, uTxBytes, (BYTE*)gEp0Status.pData);

      // Update data pointer
      gEp0Status.pData = (BYTE*)gEp0Status.pData + uTxBytes;

      // Update Endpoint0 Control/Status register
      bTemp |= rbINPRDY;                  // Always transmit a packet
                                          // when this routine is called
                                          // (may be zero-length)

      UWRITE_BYTE(E0CSR, bTemp);          // Write to Endpoint0 Control/Status
   }

}
//---------------------------// Bulk or Interrupt OUT Handler//---------------------------void BulkOrInterruptOut(PEP_STATUS pEpOutStatus){
   UINT uBytes;
   BYTE bTemp = 0;
   BYTE bCsrL, bCsrH;

   UWRITE_BYTE(INDEX, pEpOutStatus->bEp); // Index to current endpoint
   UREAD_BYTE(EOUTCSRL, bCsrL);
   UREAD_BYTE(EOUTCSRH, bCsrH);

   // Make sure this endpoint is not halted
   if (pEpOutStatus->bEpState != EP_HALTED)
   {
      // Handle STALL condition sent
      if (bCsrL & rbOutSTSTL)
      {
         // Clear Send Stall, Sent Stall, and data toggle
         UWRITE_BYTE(EOUTCSRL, rbOutCLRDT);
      }

      // Read received packet(s)
      // If double-buffering is enabled, multiple packets may be ready
      while(bCsrL & rbOutOPRDY)
      {
         // Get packet length
         UREAD_BYTE(EOUTCNTL, bTemp);     // Low byte
         uBytes = (UINT)bTemp & 0x00FF;

         UREAD_BYTE(EOUTCNTH, bTemp);     // High byte
         uBytes |= (UINT)bTemp << 8;

         if (uBytes == 8)
         {
            // Read FIFO
            FIFORead(pEpOutStatus->bEp, uBytes, (BYTE*)&OUT_PACKET);
            pEpOutStatus->uNumBytes = uBytes;
         }

         // If a data packet of anything but 8 bytes is received, ignore
         // and flush the FIFO
         else
         {
            UWRITE_BYTE(EOUTCSRL, rbOutFLUSH);
         }

         // Clear out-packet-ready
         UWRITE_BYTE(INDEX, pEpOutStatus->bEp);
         UWRITE_BYTE(EOUTCSRL, 0);

         // Read updated status register
         UREAD_BYTE(EOUTCSRL, bCsrL);
      }
   }
}
//---------------------------//  Endpoint Bulk or Interrupt IN Handler//---------------------------void BulkOrInterruptIn (PEP_STATUS pEpInStatus){
   BYTE bCsrL, bCsrH;

   UWRITE_BYTE(INDEX, pEpInStatus->bEp);  // Index to current endpoint
   UREAD_BYTE(EINCSRL, bCsrL);
   UREAD_BYTE(EINCSRH, bCsrH);

   // Make sure this endpoint is not halted
   if (pEpInStatus->bEpState != EP_HALTED)
   {
      // Handle STALL condition sent
      if (bCsrL & rbInSTSTL)
      {
         UWRITE_BYTE(EINCSRL, rbInCLRDT); // Clear Send Stall and Sent Stall,
                                          // and clear data toggle
      }

      // If a FIFO slot is open, write a new packet to the IN FIFO
      while (!(bCsrL & rbInINPRDY))
      {
         pEpInStatus->uNumBytes = 8;
         pEpInStatus->pData = (BYTE*)&IN_PACKET;

         // Write <uNumBytes> bytes to the <bEp> FIFO
         FIFOWrite(pEpInStatus->bEp, pEpInStatus->uNumBytes,
            (BYTE*)pEpInStatus->pData);

         // Set Packet Ready bit (INPRDY)
         UWRITE_BYTE(EINCSRL, rbInINPRDY);

         // Check updated endopint status
         UREAD_BYTE(EINCSRL, bCsrL);
      }
   }
}

//---------------------------
// USBReset
//---------------------------
// - Initialize the global Device Status structure (all zeros)
// - Resets all endpoints
//void USBReset (){
   BYTE i, bPower = 0;
   BYTE * pDevStatus;  // Reset device status structure to all zeros (undefined)
   pDevStatus = (BYTE *)&gDeviceStatus;
   for (i=0;i<sizeof(DEVICE_STATUS);i++)
   {
      *pDevStatus++ = 0x00;
   }

   // Set device state to default
   gDeviceStatus.bDevState = DEV_DEFAULT;

   // REMOTE_WAKEUP_SUPPORT and SELF_POWERED_SUPPORT
   // defined in file "usb_desc.h"
   gDeviceStatus.bRemoteWakeupSupport = REMOTE_WAKEUP_SUPPORT;
   gDeviceStatus.bSelfPoweredStatus = SELF_POWERED_SUPPORT;   // Reset all endpoints

   // Reset Endpoint0
   gEp0Status.bEpState = EP_IDLE;         // Reset Endpoint0 state
   gEp0Status.bEp = 0;                    // Set endpoint number
   gEp0Status.uMaxP = EP0_MAXP;           // Set maximum packet size
   // Reset Endpoint1 IN
   gEp1InStatus.bEpState = EP_HALTED;     // Reset state
   gEp1InStatus.uNumBytes = 0;            // Reset byte counter

   // Reset Endpoint2 OUT
   gEp2OutStatus.bEpState = EP_HALTED;    // Reset state
   gEp2OutStatus.uNumBytes = 0;           // Reset byte counter

   // Get Suspend enable/disable status. If enabled, prepare temporary
   // variable bPower.
   if (SUSPEND_ENABLE)
   {
      bPower = 0x01;                      // Set bit0 (Suspend Enable)
   }

   // Get ISO Update enable/disable status. If enabled, prepare temporary
   // variable bPower.
   if (ISO_UPDATE_ENABLE)
   {
      bPower |= 0x80;                     // Set bit7 (ISO Update Enable)
   }

   UWRITE_BYTE(POWER, bPower);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日精品一区二区三区| 91麻豆6部合集magnet| 欧美日本在线播放| 亚洲精品菠萝久久久久久久| 成人黄页在线观看| 国产精品午夜春色av| 亚洲午夜精品久久久久久久久| 粉嫩在线一区二区三区视频| 国产精品免费人成网站| 91日韩一区二区三区| 亚洲精品国产一区二区精华液 | 男女男精品网站| 日韩精品一区在线| 国产成人精品三级| 一区二区三区成人| 欧美一区二区三区爱爱| 国产一区二区女| 综合久久久久久久| 在线综合视频播放| 国产999精品久久| 亚洲精品你懂的| 欧美一区二区三区四区高清| 国产一区二区三区在线观看免费 | 天堂va蜜桃一区二区三区| 日韩精品一区二区三区四区| 成人午夜视频在线| 亚洲国产精品一区二区久久恐怖片 | 伊人色综合久久天天人手人婷| 欧美日韩亚洲综合在线| 国产一区二区三区精品欧美日韩一区二区三区 | 成人免费视频免费观看| 成人午夜电影网站| 亚洲制服丝袜一区| 成人三级伦理片| 日产欧产美韩系列久久99| 亚洲精品乱码久久久久久| 欧美国产精品一区二区| 国产色91在线| 日韩精品一区二区三区四区| 欧美电影免费观看高清完整版在| 欧美精品自拍偷拍| 欧美日韩国产小视频| 欧美日本一区二区| 欧美视频一区二| 5858s免费视频成人| 欧美一区二区三区四区在线观看 | 国产精品国产自产拍高清av| 久久久亚洲午夜电影| 久久综合99re88久久爱| 久久综合久久鬼色| 国产精品无人区| 中文字幕字幕中文在线中不卡视频| 国产精品青草久久| 亚洲欧美电影院| 午夜婷婷国产麻豆精品| 免费观看在线综合| 国内精品视频666| 国产高清一区日本| 99久久婷婷国产综合精品电影| av中文字幕不卡| 欧美三级韩国三级日本一级| 欧美一区二区视频观看视频 | 亚洲午夜精品网| 日韩中文字幕区一区有砖一区| 麻豆国产欧美日韩综合精品二区| 精品伊人久久久久7777人| 丰满放荡岳乱妇91ww| 色欧美片视频在线观看在线视频| 欧美三区在线观看| 国产亚洲成年网址在线观看| 亚洲欧洲性图库| 首页亚洲欧美制服丝腿| 国产一区中文字幕| 日本韩国欧美三级| 欧美一三区三区四区免费在线看 | 美女视频黄a大片欧美| 国产很黄免费观看久久| 一本大道久久a久久综合婷婷| 欧美三级午夜理伦三级中视频| 日韩一级二级三级| 国产精品久久久久影院老司 | 成人性生交大片免费看视频在线| 色婷婷综合久久| 日韩欧美中文一区二区| 国产精品天美传媒沈樵| 亚洲一级在线观看| 风间由美中文字幕在线看视频国产欧美| 色婷婷国产精品| 国产亚洲女人久久久久毛片| 亚洲与欧洲av电影| 国产成人精品免费网站| 欧美精品vⅰdeose4hd| 国产精品你懂的| 久久aⅴ国产欧美74aaa| 色激情天天射综合网| 久久免费看少妇高潮| 亚洲高清在线精品| 99国产精品一区| 久久亚洲精品小早川怜子| 亚洲自拍偷拍欧美| 成人午夜看片网址| 日韩女同互慰一区二区| 亚洲在线视频网站| 97se狠狠狠综合亚洲狠狠| 欧美精品一区二区三区蜜臀| 亚洲二区在线观看| 99v久久综合狠狠综合久久| 久久亚洲精品小早川怜子| 午夜精品视频一区| 在线观看国产精品网站| 国产精品成人网| 国产美女在线观看一区| 91精品一区二区三区在线观看| 一区二区三区在线高清| 丁香一区二区三区| 久久久久国产一区二区三区四区 | 蜜臀av一区二区在线免费观看| 97久久久精品综合88久久| 国产拍欧美日韩视频二区| 久久精品久久精品| 日韩午夜在线观看| 视频一区在线播放| 欧美性高清videossexo| 亚洲欧美激情小说另类| 99精品视频在线观看免费| 亚洲国产精品99久久久久久久久| 久久 天天综合| 日韩欧美激情在线| 美国欧美日韩国产在线播放| 91.com在线观看| 亚洲综合色婷婷| 欧美日韩三级一区| 五月婷婷激情综合| 欧美日韩mp4| 日本三级韩国三级欧美三级| 日韩一区二区精品在线观看| 奇米色一区二区三区四区| 91精品国产综合久久久久| 午夜在线电影亚洲一区| 欧美精品18+| 久久激情五月激情| 久久亚洲综合色| 国产91精品久久久久久久网曝门| 中文字幕欧美日本乱码一线二线| 成人午夜免费视频| 亚洲黄色性网站| 欧美四级电影在线观看| 日韩高清中文字幕一区| 日韩精品一区二区在线| 国产伦精一区二区三区| 国产精品色在线观看| 99久久99久久综合| 亚洲一区二区五区| 日韩三级免费观看| 国产一区二区电影| 亚洲女同一区二区| 欧美亚洲综合在线| 青娱乐精品视频| 久久奇米777| 91视频一区二区三区| 亚洲va国产va欧美va观看| 91精品综合久久久久久| 国产精品一区久久久久| 专区另类欧美日韩| 欧美日本国产一区| 国产在线精品免费| 日韩一区在线播放| 欧美疯狂做受xxxx富婆| 国产一区二区精品久久| 亚洲日本乱码在线观看| 欧美精品日韩一本| 国产精品一区二区在线播放| 亚洲女爱视频在线| 日韩一级黄色大片| 99精品1区2区| 久久99精品久久久| 亚洲欧美日韩在线| 欧美一区二区三区系列电影| 国产91精品一区二区麻豆亚洲| 亚洲国产视频在线| 国产人久久人人人人爽| 日本久久一区二区三区| 久久激情综合网| 亚洲一区二区四区蜜桃| 国产三级欧美三级| 欧美喷水一区二区| 成人国产精品免费观看视频| 日韩成人免费看| 国产精品不卡一区| 精品国产精品网麻豆系列| 成人av网站免费| 理论电影国产精品| 一区二区三区高清不卡| 国产网站一区二区三区| 欧美日韩你懂得| a在线播放不卡| 国产在线视视频有精品| 亚洲福利国产精品| 亚洲三级视频在线观看| 精品999在线播放|