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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usb_stdreq.c

?? c8051f340 usb開發(fā)程序指南
?? C
字號(hào):
/*
   Copyright 2003 Cygnal Integrated Products, Inc.
   File:    usb_stdreq.c
   Author:  JS
   Created: JAN 03

   Target Device: C8051F320

   Source file for USB firmware. Includes service routine
   for usb standard device requests.

******************************************/

#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 code DESCRIPTORS gDescriptorMap;
extern DEVICE_STATUS gDeviceStatus;
extern EP_STATUS gEp0Status;
extern EP_STATUS gEp2OutStatus;
extern EP_STATUS gEp1InStatus;
extern EP0_COMMAND gEp0Command;

BYTE bEpState;
UINT uNumBytes;
PIF_STATUS pIfStatus;

//------------------------------------------------------------------------
//  Standard Request Routines//------------------------------------------------------------------------//
// These functions should be called when an endpoint0 command has
// been received with a corresponding "bRequest" field.
//
// - Each routine performs all command field checking, and
//   modifies fields of the Ep0Status structure accordingly
//
// After a call to a standard request routine, the calling routine
// should check Ep0Status.bEpState to determine the required action
// (i.e., send a STALL for EP_ERROR, load the FIFO for EP_TX).
// For transmit status, the data pointer (Ep0Status.pData),
// and data length (Ep0Status.uNumBytes) are prepared before the
// standard request routine returns. The calling routine must write
// the data to the FIFO and handle all data transfer

//---------------------------
// SET_ADDRESS device request
//---------------------------
void SetAddressRequest ()
{
   // Index and Length fields must be zero
   // Device state must be default or addressed
   if ((gEp0Command.wIndex.i) || (gEp0Command.wLength.i) ||
   (gDeviceStatus.bDevState == DEV_CONFIG))
   {
      bEpState = EP_ERROR;
   }

   else
   {
      // Assign new function address
      UWRITE_BYTE(FADDR, gEp0Command.wValue.c[1]);
      if (gDeviceStatus.bDevState == DEV_DEFAULT &&
      gEp0Command.wValue.c[1] != 0)
      {
         gDeviceStatus.bDevState = DEV_ADDRESS;
      }
      if (gDeviceStatus.bDevState == DEV_ADDRESS &&
      gEp0Command.wValue.c[1] == 0)
      {
         gDeviceStatus.bDevState = DEV_ADDRESS;
      }
      bEpState = EP_IDLE;
   }
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// SET_FEATURE device request
//---------------------------
void SetFeatureRequest ()
{
   // Length field must be zero
   // Device state must be configured, or addressed with Command Index
   // field == 0
   if ((gEp0Command.wLength.i != 0) ||
   (gDeviceStatus.bDevState == DEV_DEFAULT) ||
   (gDeviceStatus.bDevState == DEV_ADDRESS && gEp0Command.wIndex.i != 0))
   {
      bEpState = EP_ERROR;
   }

   // Handle based on recipient
   switch(gEp0Command.bmRequestType & CMD_MASK_RECIP)
   {
      // Device Request - Return error as remote wakeup is not supported
      case CMD_RECIP_DEV:
         bEpState = EP_ERROR;
         break;

      // Endpoint Request
      case CMD_RECIP_EP:
         if (gEp0Command.wValue.i == ENDPOINT_HALT)
         {
            bEpState = HaltEndpoint(gEp0Command.wIndex.i);
            break;
         }
         else
         {
            bEpState = EP_ERROR;
            break;
         }
      default:
         bEpState = EP_ERROR;
         break;
   }
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// CLEAR_FEATURE device request
//---------------------------
void ClearFeatureRequest ()
{
   // Length field must be zero
   // Device state must be configured, or addressed with Command Index
   // field == 0
   if ((gEp0Command.wLength.i != 0) || (gDeviceStatus.bDevState == DEV_DEFAULT) ||
   (gDeviceStatus.bDevState == DEV_ADDRESS && gEp0Command.wIndex.i != 0))
   {
      bEpState = EP_ERROR;
   }

   // Handle based on recipient
   switch(gEp0Command.bmRequestType & CMD_MASK_RECIP)
   {
      // Device Request
      case CMD_RECIP_DEV:
         // Remote wakeup not supported
         bEpState = EP_ERROR;
         break;

      // Endpoint Request
      case CMD_RECIP_EP:
         if (gEp0Command.wValue.i == ENDPOINT_HALT)
         {
            // Enable the selected endpoint.
            bEpState = EnableEndpoint(gEp0Command.wIndex.i);
            break;
         }
         else
         {
           bEpState = EP_ERROR;
           break;
         }
      default:
         bEpState = EP_ERROR;
         break;
   }
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// SET_CONFIGURATION device request
//---------------------------
void SetConfigurationRequest ()
{
   // Index and Length fields must be zero
   // Device state must be addressed or configured
   if ((gEp0Command.wIndex.i) || (gEp0Command.wLength.i) ||
   (gDeviceStatus.bDevState == DEV_DEFAULT))
   {
      bEpState = EP_ERROR;
   }

   else
   {
      // Make sure assigned configuration exists
      if (gEp0Command.wValue.c[1] >
      gDescriptorMap.bStdDevDsc[std_bNumConfigurations])
      {
         bEpState = EP_ERROR;
      }

      // Handle zero configuration assignment
      else if  (gEp0Command.wValue.c[1] == 0)
         gDeviceStatus.bDevState = DEV_ADDRESS;

      // Select the assigned configuration
      else
         bEpState = SetConfiguration(gEp0Command.wValue.c[1]);
   }
   gEp0Status.bEpState = bEpState;
}


//---------------------------
// SET_INTERFACE device request
//---------------------------
void SetInterfaceRequest()
{
   // Length field must be zero
   if ((gEp0Command.wLength.i) || (gDeviceStatus.bDevState != DEV_CONFIG))
      bEpState = EP_ERROR;

   else
   {
      // Check that target interface exists for this configuration
      if(gEp0Command.wIndex.i > gDeviceStatus.bNumInterf - 1)
         bEpState = EP_ERROR;

      else
      {
         // Get pointer to interface status structure
         pIfStatus = (PIF_STATUS)&gDeviceStatus.IfStatus;

         // Check that alternate setting exists for the interface
         if (gEp0Command.wValue.i > pIfStatus->bNumAlts)
            bEpState = EP_ERROR;

         // Assign alternate setting
         else
         {
            pIfStatus->bCurrentAlt = gEp0Command.wValue.i;
            bEpState = SetInterface(pIfStatus);
         }
      }
   }
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// GET_STATUS device request
//---------------------------
void GetStatusRequest ()
{
   // Value field must be zero; Length field must be 2
   if ((gEp0Command.wValue.i != 0) || (gEp0Command.wLength.i != 0x02) ||
   (gDeviceStatus.bDevState == DEV_DEFAULT) ||
   (gDeviceStatus.bDevState == DEV_ADDRESS && gEp0Command.wIndex.i != 0))
   {
      bEpState = EP_ERROR;
   }

   else
   {
      // Check for desired status (device, interface, endpoint)
      switch (gEp0Command.bmRequestType & CMD_MASK_RECIP)
      {
         // Device
         case CMD_RECIP_DEV:
            // Index must be zero for a Device status request
            if (gEp0Command.wIndex.i != 0)
               bEpState = EP_ERROR;
            else
            {
               // Prepare data_out for transmission
               gEp0Status.wData.c[1] = 0;
               gEp0Status.wData.c[0] = gDeviceStatus.bRemoteWakeupStatus;
               gEp0Status.wData.c[0] |= gDeviceStatus.bSelfPoweredStatus;
            }
            break;

         // Interface
         case CMD_RECIP_IF:
            // Prepare data_out for transmission
            gEp0Status.wData.i = 0;
            break;

         // Endpoint
         case CMD_RECIP_EP:
            // Prepare data_out for transmission
            gEp0Status.wData.i = 0;
            if (GetEpStatus(gEp0Command.wIndex.i) == EP_HALTED)
               gEp0Status.wData.c[0] |= 0x01;
            break;

         // Other cases unsupported
         default:
            bEpState = EP_ERROR;
            break;
      }

      // Endpoint0 state assignment
      bEpState = EP_TX;

      // Point ep0 data pointer to transmit data_out
      gEp0Status.pData = (BYTE *)&gEp0Status.wData.i;
      gEp0Status.uNumBytes = 2;
   }
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// GET_DESCRIPTOR device request
//---------------------------
void GetDescriptorRequest ()
{
   WORD wTempInt;

   // This request is valid in all device states
   // Switch on requested descriptor (Value field)
   switch (gEp0Command.wValue.c[0])
   {
      // Device Descriptor Request
      case DSC_DEVICE:
         // Get size of the requested descriptor
         uNumBytes = STD_DSC_SIZE;
         // Prep to send the requested length
         if (uNumBytes > gEp0Command.wLength.i)
         {
            uNumBytes = gEp0Command.wLength.i;
         }
         // Point data pointer to the requested descriptor
         gEp0Status.pData = (void*)&gDescriptorMap.bStdDevDsc;
         bEpState = EP_TX;
         break;

      // Configuration Descriptor Request
      case DSC_CONFIG:
         // Make sure requested descriptor exists
         if (gEp0Command.wValue.c[1] >
         gDescriptorMap.bStdDevDsc[std_bNumConfigurations])
         {
            bEpState = EP_ERROR;
         }
         else
         {
            // Get total length of this configuration descriptor
            // (includes all associated interface and endpoints)
            wTempInt.c[1] = gDescriptorMap.bCfg1[cfg_wTotalLength_lsb];
            wTempInt.c[0] = gDescriptorMap.bCfg1[cfg_wTotalLength_msb];
            uNumBytes = wTempInt.i;

            // Prep to transmit the requested length
            if (uNumBytes > gEp0Command.wLength.i)
            {
               uNumBytes = gEp0Command.wLength.i;
            }
            // Point data pointer to requested descriptor
            gEp0Status.pData = &gDescriptorMap.bCfg1;
            bEpState = EP_TX;
         }
         break;
   }
   gEp0Status.uNumBytes = uNumBytes;
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// GET_CONFIGURATION device request
//---------------------------
void GetConfigurationRequest ()
{
   // Length field must be 1; Index field must be 0;
   // Value field must be 0
   if ((gEp0Command.wLength.i != 1) || (gEp0Command.wIndex.i) ||
   (gEp0Command.wValue.i) || (gDeviceStatus.bDevState == DEV_DEFAULT))
   {
      bEpState = EP_ERROR;
   }

   else if (gDeviceStatus.bDevState == DEV_ADDRESS)
   {
      // Prepare data_out for transmission
      gEp0Status.wData.i = 0;
      // Point ep0 data pointer to transmit data_out
      gEp0Status.pData = (BYTE *)&gEp0Status.wData.i;
      // ep0 state assignment
      bEpState = EP_TX;
   }

   else
   {
      // Index to desired field
      gEp0Status.pData = (void *)&gDescriptorMap.bCfg1[cfg_bConfigurationValue];

      // ep0 state assignment
      bEpState = EP_TX;
   }
   gEp0Status.uNumBytes = 1;
   gEp0Status.bEpState = bEpState;
}

//---------------------------
// GET_INTERFACE device request
//---------------------------
void GetInterfaceRequest ()
{
   // Value field must be 0; Length field must be 1
   if ((gEp0Command.wValue.i) || (gEp0Command.wLength.i != 1) ||
   (gDeviceStatus.bDevState != DEV_CONFIG))
   {
      bEpState = EP_ERROR;
   }

   else
   {
      // Make sure requested interface exists
      if (gEp0Command.wIndex.i > gDeviceStatus.bNumInterf - 1)
         bEpState = EP_ERROR;
      else
      {
         // Get current interface setting
         gEp0Status.pData = (void *)&gDeviceStatus.IfStatus->bCurrentAlt;

         // Length must be 1
         gEp0Status.uNumBytes = 1;
         bEpState = EP_TX;
      }
   }
   gEp0Status.bEpState = bEpState;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美一区二区三区网站| 717成人午夜免费福利电影| 亚洲一区二区三区四区的| 国产精品欧美精品| 国产欧美精品一区二区三区四区 | 欧美最新大片在线看| av电影一区二区| 99免费精品在线| 色偷偷成人一区二区三区91 | 午夜伊人狠狠久久| 日韩制服丝袜av| 狠狠色丁香久久婷婷综合丁香| 日韩**一区毛片| 激情综合网天天干| 国产传媒久久文化传媒| av一区二区三区黑人| 欧美日韩亚洲国产综合| 日韩色视频在线观看| 久久一留热品黄| 国产精品久久久久一区二区三区| 中文字幕在线不卡一区二区三区| 亚洲欧洲www| 日韩精品五月天| 北条麻妃一区二区三区| 欧美综合一区二区三区| 日韩欧美亚洲一区二区| 国产精品久久久99| 亚洲成人在线观看视频| 国产精品一区二区在线观看网站| 成人精品视频一区二区三区尤物| 欧美在线免费观看视频| 精品电影一区二区| 亚洲人成网站色在线观看| 亚洲综合在线电影| 国产一区二三区| 在线看日本不卡| 久久久久国产精品厨房| 亚洲精品免费电影| 狠狠久久亚洲欧美| 欧美色图在线观看| 欧美国产乱子伦| 免费看日韩精品| 91黄色免费观看| 久久九九影视网| 秋霞影院一区二区| 91久久精品国产91性色tv | 成人综合婷婷国产精品久久蜜臀| 欧美在线观看一区二区| 亚洲国产成人午夜在线一区| 青青草97国产精品免费观看| av高清不卡在线| 久久久精品人体av艺术| 日韩国产在线一| 一本久久综合亚洲鲁鲁五月天 | 欧美日韩亚洲综合一区| 中文一区一区三区高中清不卡| 日韩专区欧美专区| 欧美无砖砖区免费| 亚洲欧美激情在线| av午夜一区麻豆| 国产欧美日韩精品a在线观看| 日本伊人精品一区二区三区观看方式| 91在线观看成人| 国产精品美女久久久久久2018| 精品一区免费av| 91精品国产综合久久精品图片| 亚洲在线免费播放| 在线观看日韩国产| 亚洲国产欧美日韩另类综合| 色综合久久久久综合体| 最新国产成人在线观看| 成人黄色小视频在线观看| 欧美成人一级视频| 91久久一区二区| gogogo免费视频观看亚洲一| 久久精品在这里| 一区av在线播放| 精品一区二区三区在线视频| 欧美精三区欧美精三区| 一区二区成人在线观看| 色噜噜狠狠色综合中国| 一区二区三区av电影| 日本高清免费不卡视频| 亚洲一区二区三区四区中文字幕| 色婷婷综合激情| 亚洲一级二级三级| 欧美精品色综合| 看国产成人h片视频| 久久久亚洲高清| 丁香六月综合激情| 一区二区三区影院| 777午夜精品视频在线播放| 久草在线在线精品观看| 国产日韩精品一区二区浪潮av | 不卡的电视剧免费网站有什么| 欧美激情一二三区| 91高清视频免费看| 男女性色大片免费观看一区二区| 精品噜噜噜噜久久久久久久久试看| 黑人巨大精品欧美一区| 日本一区免费视频| 91国偷自产一区二区使用方法| 亚洲高清免费视频| 久久久99久久精品欧美| 日本道色综合久久| 青青草97国产精品免费观看| 欧美高清在线视频| 欧美日韩在线播放三区| 紧缚奴在线一区二区三区| 亚洲欧洲av一区二区三区久久| 7777精品伊人久久久大香线蕉 | 色偷偷久久人人79超碰人人澡 | 亚洲欧美日韩国产中文在线| 4438成人网| 成人黄色片在线观看| 亚洲国产综合人成综合网站| 久久久久久久久久久久久久久99 | 在线观看不卡视频| 国产一区二区三区综合| 亚洲影视在线播放| 国产日韩一级二级三级| 欧美日韩精品欧美日韩精品一| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲成av人片一区二区梦乃| 久久久精品国产99久久精品芒果| 欧美视频一区二区三区四区| 高清成人免费视频| 青青青伊人色综合久久| 一区二区三区四区视频精品免费 | 亚洲日本在线天堂| 久久青草国产手机看片福利盒子 | 日韩理论片中文av| 久久久精品免费免费| 91麻豆精品国产综合久久久久久 | 久久久久久久久蜜桃| 777午夜精品视频在线播放| 成a人片亚洲日本久久| 国产一区二区三区综合| 免费高清视频精品| 日韩一区精品视频| 一区二区三区四区不卡在线| 国产精品视频第一区| 久久女同性恋中文字幕| 2017欧美狠狠色| 精品日韩av一区二区| 日韩欧美亚洲国产精品字幕久久久| 欧美日韩一级片网站| 91免费观看在线| 91麻豆蜜桃一区二区三区| 国产成人99久久亚洲综合精品| 国产精品中文有码| 国产精品99久| 成人性视频免费网站| 欧美视频一区在线观看| 91免费版pro下载短视频| 91丨九色丨黑人外教| 色综合色狠狠天天综合色| 91丨九色丨国产丨porny| 色综合久久久久久久久| 在线精品观看国产| 在线播放中文字幕一区| 日韩一区二区三区在线视频| 欧美成人bangbros| 日本一区二区三区dvd视频在线| 国产日韩欧美亚洲| 亚洲精品一卡二卡| 天天av天天翘天天综合网| 美国欧美日韩国产在线播放 | 国产精品久久久久四虎| 亚洲色图制服诱惑| 午夜视黄欧洲亚洲| 国产在线精品一区二区| 成人性生交大片免费看中文| 在线观看91精品国产入口| 欧美老年两性高潮| 久久久国产午夜精品| 一区二区在线观看免费| 日本欧美大码aⅴ在线播放| 国产在线国偷精品免费看| 99久久精品久久久久久清纯| 欧美专区在线观看一区| 欧美va在线播放| 亚洲欧洲中文日韩久久av乱码| 亚洲资源中文字幕| 国产成人亚洲精品狼色在线| 色成年激情久久综合| 精品999久久久| 亚洲影视在线观看| 国产成人精品免费网站| 欧美日韩国产另类不卡| 国产日韩欧美a| 日韩福利电影在线| 国产一区免费电影| 欧美精品国产精品| 中文字幕一区二区三区乱码在线 | 欧美极品少妇xxxxⅹ高跟鞋 | 国产女主播一区| 婷婷一区二区三区| 91片在线免费观看| 中文字幕 久热精品 视频在线|