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

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

?? usb_core.c

?? STM32不完全手冊 例程源碼 29個
?? C
?? 第 1 頁 / 共 3 頁
字號:
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name          : usb_core.c
* Author             : MCD Application Team
* Version            : V2.2.0
* Date               : 06/13/2008
* Description        : Standard protocol processing (USB v2.0)
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define ValBit(VAR,Place)    (VAR & (1 << Place))
#define SetBit(VAR,Place)    (VAR |= (1 << Place))
#define ClrBit(VAR,Place)    (VAR &= ((1 << Place) ^ 255))

#define Send0LengthData() { _SetEPTxCount(ENDP0, 0); \
    vSetEPTxStatus(EP_TX_VALID); \
  }

#define vSetEPRxStatus(st) (SaveRState = st)
#define vSetEPTxStatus(st) (SaveTState = st)

#define USB_StatusIn() Send0LengthData()
#define USB_StatusOut() vSetEPRxStatus(EP_RX_VALID)

#define StatusInfo0 StatusInfo.bw.bb1 /* Reverse bb0 & bb1 */
#define StatusInfo1 StatusInfo.bw.bb0

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
u16_u8 StatusInfo;
bool Data_Mul_MaxPacketSize = FALSE;
/* Private function prototypes -----------------------------------------------*/
static void DataStageOut(void);
static void DataStageIn(void);
static void NoData_Setup0(void);
static void Data_Setup0(void);
/* Private functions ---------------------------------------------------------*/

/*******************************************************************************
* Function Name  : Standard_GetConfiguration.
* Description    : Return the current configuration variable address.
* Input          : Length - How many bytes are needed.
* Output         : None.
* Return         : Return 1 , if the request is invalid when "Length" is 0.
*                  Return "Buffer" if the "Length" is not 0.
*******************************************************************************/
u8 *Standard_GetConfiguration(u16 Length)
{
  if (Length == 0)
  {
    pInformation->Ctrl_Info.Usb_wLength =
      sizeof(pInformation->Current_Configuration);
    return 0;
  }
  pUser_Standard_Requests->User_GetConfiguration();
  return (u8 *)&pInformation->Current_Configuration;
}

/*******************************************************************************
* Function Name  : Standard_SetConfiguration.
* Description    : This routine is called to set the configuration value
*                  Then each class should configure device themself.
* Input          : None.
* Output         : None.
* Return         : Return USB_SUCCESS, if the request is performed.
*                  Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_SetConfiguration(void)
{

  if ((pInformation->USBwValue0 <=
      Device_Table.Total_Configuration) && (pInformation->USBwValue1 == 0)
      && (pInformation->USBwIndex == 0)) /*call Back usb spec 2.0*/
  {
    pInformation->Current_Configuration = pInformation->USBwValue0;
    pUser_Standard_Requests->User_SetConfiguration();
    return USB_SUCCESS;
  }
  else
  {
    return USB_UNSUPPORT;
  }
}

/*******************************************************************************
* Function Name  : Standard_GetInterface.
* Description    : Return the Alternate Setting of the current interface.
* Input          : Length - How many bytes are needed.
* Output         : None.
* Return         : Return 0, if the request is invalid when "Length" is 0.
*                  Return "Buffer" if the "Length" is not 0.
*******************************************************************************/
u8 *Standard_GetInterface(u16 Length)
{
  if (Length == 0)
  {
    pInformation->Ctrl_Info.Usb_wLength =
      sizeof(pInformation->Current_AlternateSetting);
    return 0;
  }
  pUser_Standard_Requests->User_GetInterface();
  return (u8 *)&pInformation->Current_AlternateSetting;
}

/*******************************************************************************
* Function Name  : Standard_SetInterface.
* Description    : This routine is called to set the interface.
*                  Then each class should configure the interface them self.
* Input          : None.
* Output         : None.
* Return         : - Return USB_SUCCESS, if the request is performed.
*                  - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_SetInterface(void)
{
  RESULT Re;
  /*Test if the specified Interface and Alternate Setting are supported by
    the application Firmware*/
  Re = (*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, pInformation->USBwValue0);

  if (pInformation->Current_Configuration != 0)
  {
    if ((Re != USB_SUCCESS) || (pInformation->USBwIndex1 != 0)
        || (pInformation->USBwValue1 != 0))
    {
      return  USB_UNSUPPORT;
    }
    else if (Re == USB_SUCCESS)
    {
      pUser_Standard_Requests->User_SetInterface();
      pInformation->Current_Interface = pInformation->USBwIndex0;
      pInformation->Current_AlternateSetting = pInformation->USBwValue0;
      return USB_SUCCESS;
    }

  }

  return USB_UNSUPPORT;
}

/*******************************************************************************
* Function Name  : Standard_GetStatus.
* Description    : Copy the device request data to "StatusInfo buffer".
* Input          : - Length - How many bytes are needed.
* Output         : None.
* Return         : Return 0, if the request is at end of data block,
*                  or is invalid when "Length" is 0.
*******************************************************************************/
u8 *Standard_GetStatus(u16 Length)
{
  if (Length == 0)
  {
    pInformation->Ctrl_Info.Usb_wLength = 2;
    return 0;
  }

  StatusInfo.w = 0;
  /* Reset Status Information */

  if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
  {
    /*Get Device Status */
    u8 Feature = pInformation->Current_Feature;

    /* Remote Wakeup enabled */
    if (ValBit(Feature, 5))
    {
      SetBit(StatusInfo0, 1);
    }

    /* Bus-powered */
    if (ValBit(Feature, 6))
    {
      ClrBit(StatusInfo0, 0);
    }
    else /* Self-powered */
    {
      SetBit(StatusInfo0, 0);
    }
  }
  /*Interface Status*/
  else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
  {
    return (u8 *)&StatusInfo;
  }
  /*Get EndPoint Status*/
  else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
  {
    u8 Related_Endpoint;
    u8 wIndex0 = pInformation->USBwIndex0;

    Related_Endpoint = (wIndex0 & 0x0f);
    if (ValBit(wIndex0, 7))
    {
      /* IN endpoint */
      if (_GetTxStallStatus(Related_Endpoint))
      {
        SetBit(StatusInfo0, 0); /* IN Endpoint stalled */
      }
    }
    else
    {
      /* OUT endpoint */
      if (_GetRxStallStatus(Related_Endpoint))
      {
        SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */
      }
    }

  }
  else
  {
    return NULL;
  }
  pUser_Standard_Requests->User_GetStatus();
  return (u8 *)&StatusInfo;
}

/*******************************************************************************
* Function Name  : Standard_ClearFeature.
* Description    : Clear or disable a specific feature.
* Input          : None.
* Output         : None.
* Return         : - Return USB_SUCCESS, if the request is performed.
*                  - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_ClearFeature(void)
{
  u32     Type_Rec = Type_Recipient;
  u32     Status;


  if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT))
  {/*Device Clear Feature*/
    ClrBit(pInformation->Current_Feature, 5);
    return USB_SUCCESS;
  }
  else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
  {/*EndPoint Clear Feature*/
    DEVICE* pDev;
    u32 Related_Endpoint;
    u32 wIndex0;
    u32 rEP;

    if ((pInformation->USBwValue != ENDPOINT_STALL)
        || (pInformation->USBwIndex1 != 0))
    {
      return USB_UNSUPPORT;
    }

    pDev = &Device_Table;
    wIndex0 = pInformation->USBwIndex0;
    rEP = wIndex0 & ~0x80;
    Related_Endpoint = ENDP0 + rEP;

    if (ValBit(pInformation->USBwIndex0, 7))
    {
      /*Get Status of endpoint & stall the request if the related_ENdpoint
      is Disabled*/
      Status = _GetEPTxStatus(Related_Endpoint);
    }
    else
    {
      Status = _GetEPRxStatus(Related_Endpoint);
    }

    if ((rEP >= pDev->Total_Endpoint) || (Status == 0)
        || (pInformation->Current_Configuration == 0))
    {
      return USB_UNSUPPORT;
    }


    if (wIndex0 & 0x80)
    {
      /* IN endpoint */
      if (_GetTxStallStatus(Related_Endpoint ))
      {
        ClearDTOG_TX(Related_Endpoint);
        SetEPTxStatus(Related_Endpoint, EP_TX_VALID);
      }
    }
    else
    {
      /* OUT endpoint */
      if (_GetRxStallStatus(Related_Endpoint))
      {
        if (Related_Endpoint == ENDP0)
        {
          /* After clear the STALL, enable the default endpoint receiver */
          SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
          _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
        }
        else
        {
          ClearDTOG_RX(Related_Endpoint);
          _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
        }
      }
    }
    pUser_Standard_Requests->User_ClearFeature();
    return USB_SUCCESS;
  }

  return USB_UNSUPPORT;
}

/*******************************************************************************
* Function Name  : Standard_SetEndPointFeature
* Description    : Set or enable a specific feature of EndPoint
* Input          : None.
* Output         : None.
* Return         : - Return USB_SUCCESS, if the request is performed.
*                  - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_SetEndPointFeature(void)
{
  u32    wIndex0;
  u32    Related_Endpoint;
  u32    rEP;
  u32   Status;

  wIndex0 = pInformation->USBwIndex0;
  rEP = wIndex0 & ~0x80;
  Related_Endpoint = ENDP0 + rEP;

  if (ValBit(pInformation->USBwIndex0, 7))
  {
    /* get Status of endpoint & stall the request if the related_ENdpoint

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久精品免费看| 国产精品福利影院| 国产综合一区二区| 视频一区二区欧美| 偷拍一区二区三区四区| 婷婷中文字幕综合| www精品美女久久久tv| 国产毛片精品一区| 国产精品一区久久久久| 国产夫妻精品视频| 久久国产精品色婷婷| 2021国产精品久久精品| 成人免费va视频| 一二三区精品视频| 欧美精品久久一区| 国产九色精品成人porny| 中文字幕免费一区| 精品视频全国免费看| 久久er99热精品一区二区| 亚洲国产成人午夜在线一区| 色悠久久久久综合欧美99| 日韩精品免费视频人成| 久久久精品国产99久久精品芒果| av一二三不卡影片| 日韩av在线播放中文字幕| 久久久不卡网国产精品二区| 综合亚洲深深色噜噜狠狠网站| 亚洲18影院在线观看| 成人黄色av电影| 3atv一区二区三区| 欧美裸体一区二区三区| 麻豆国产欧美日韩综合精品二区 | 久久毛片高清国产| 91麻豆高清视频| 日本在线不卡视频一二三区| 国产欧美日韩在线看| 91成人免费网站| 国产一区二区在线视频| 亚洲亚洲人成综合网络| 国产日产精品一区| 欧美精品vⅰdeose4hd| 成人av第一页| 久久av中文字幕片| 亚洲午夜电影在线观看| 国产精品女同一区二区三区| 色综合网色综合| 精品国产乱子伦一区| 成人国产视频在线观看| 久久精品噜噜噜成人88aⅴ| 亚洲丝袜另类动漫二区| 亚洲精品高清在线观看| 欧美精品一区二区三区久久久| 91蜜桃视频在线| 国产99一区视频免费| 奇米精品一区二区三区在线观看 | 久久免费精品国产久精品久久久久| 97精品久久久久中文字幕| 国产综合色在线视频区| 日韩激情av在线| 国产精品久久久久精k8 | 精品国产第一区二区三区观看体验| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 麻豆精品新av中文字幕| 亚洲一线二线三线视频| 1024成人网| 中文字幕av在线一区二区三区| 欧美成人在线直播| 欧美一区二区视频在线观看| 色婷婷av一区| av在线免费不卡| 成人晚上爱看视频| 国产成人免费在线| 狠狠久久亚洲欧美| 精品写真视频在线观看| 狂野欧美性猛交blacked| 日韩av网站在线观看| 亚洲6080在线| 青草国产精品久久久久久| 首页综合国产亚洲丝袜| 视频一区视频二区在线观看| jlzzjlzz国产精品久久| 国产高清视频一区| 高清不卡在线观看| 成人网在线播放| 99re在线视频这里只有精品| 色成年激情久久综合| 欧美亚洲图片小说| 欧美日本一区二区在线观看| 欧美欧美欧美欧美| 91精品婷婷国产综合久久性色| 91精品国产品国语在线不卡| 日韩欧美国产高清| 久久亚洲一区二区三区明星换脸 | 国产精品综合在线视频| 国产在线一区二区综合免费视频| 国产一区二区三区最好精华液| 国产一区二区影院| 99re在线视频这里只有精品| 在线亚洲免费视频| 91精品国产乱| 久久久亚洲午夜电影| 国产精品久久久久久久久免费樱桃| 亚洲色图一区二区| 性久久久久久久久久久久| 麻豆一区二区三区| 成人性生交大合| 欧美亚洲综合色| 欧美videossexotv100| 中文字幕欧美国产| 亚洲国产乱码最新视频| 激情综合色播五月| 91丨九色丨蝌蚪丨老版| 欧美高清视频www夜色资源网| ww久久中文字幕| 亚洲精品久久久久久国产精华液| 日韩制服丝袜先锋影音| 国产v综合v亚洲欧| 7777女厕盗摄久久久| 国产精品丝袜91| 日本中文字幕一区二区有限公司| 国产精品夜夜爽| 欧美日韩日本视频| 国产日韩欧美精品在线| 午夜电影网一区| 成人在线视频一区| 欧美一区二区三区影视| 国产精品久久久久一区二区三区| 午夜精品久久久久久久蜜桃app | 日本丰满少妇一区二区三区| 国产亚洲欧美激情| 国产亚洲欧洲997久久综合 | 奇米777欧美一区二区| 成人一道本在线| 6080yy午夜一二三区久久| 国产精品久久久久久久蜜臀 | 精品精品欲导航| 亚洲已满18点击进入久久| 高清免费成人av| 日韩欧美在线不卡| 亚洲一区二区三区视频在线播放 | 天堂在线亚洲视频| 9i在线看片成人免费| 欧美变态tickle挠乳网站| 亚洲电影第三页| av一本久道久久综合久久鬼色| 欧美va天堂va视频va在线| 丝袜美腿一区二区三区| 欧美在线观看一二区| 国产精品国产三级国产aⅴ无密码| 精品在线播放免费| 3d成人动漫网站| 五月婷婷综合在线| 在线亚洲欧美专区二区| 中文字幕日韩av资源站| 成人在线视频首页| 欧美激情中文字幕一区二区| 男人的天堂亚洲一区| 欧美三级中文字幕| 亚洲一区中文日韩| 91久久久免费一区二区| 亚洲人成精品久久久久| hitomi一区二区三区精品| 国产精品久久午夜夜伦鲁鲁| 国产不卡在线一区| 亚洲国产精品精华液ab| 成人综合在线网站| 国产精品国产三级国产专播品爱网| 国产99一区视频免费| 国产精品青草久久| 99久久er热在这里只有精品15| 国产精品久久毛片| 91无套直看片红桃| 亚洲在线视频一区| 欧美日韩一区中文字幕| 日韩精品高清不卡| 日韩女优制服丝袜电影| 精品一区二区三区在线播放| 欧美va亚洲va国产综合| 国产黄色精品视频| 日本一区二区久久| 91麻豆精品一区二区三区| 亚洲资源在线观看| 91精品国产综合久久福利| 久久99精品国产.久久久久久| 2023国产精品自拍| 国产a级毛片一区| 亚洲免费av高清| 欧美一区二区三区喷汁尤物| 国产在线观看免费一区| 中文字幕一区二区不卡| 欧美在线高清视频| 美女视频一区二区三区| 国产午夜久久久久| 91免费看视频| 日韩极品在线观看| 国产亚洲女人久久久久毛片| 色呦呦网站一区| 免费视频一区二区| 国产精品久久综合| 欧美顶级少妇做爰|