<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STM32--USB詳細(xì)使用說(shuō)明

          STM32--USB詳細(xì)使用說(shuō)明

          作者: 時(shí)間:2016-11-27 來(lái)源:網(wǎng)絡(luò) 收藏

          uint8_t Out0_Process(void)
          {
          uint32_t ControlState = pInformation->ControlState;

          if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA))
          {

          //主機(jī)在完成傳輸前終止傳輸
          ControlState = STALLED;
          }
          else if ((ControlState == OUT_DATA) || (ControlState == LAST_OUT_DATA))
          {
          DataStageOut();
          ControlState = pInformation->ControlState;
          }

          else if (ControlState == WAIT_STATUS_OUT)//進(jìn)入到這個(gè)里面
          {
          (*pProperty->Process_Status_OUT)();//這個(gè)函數(shù)其實(shí)什么也沒(méi)做
          #ifndef STM32F10X_CL
          ControlState = STALLED;//狀態(tài)變成了終止發(fā)送和接受

          #endif
          }


          else
          {
          ControlState = STALLED;
          }

          pInformation->ControlState = ControlState;

          return Post0_Process();
          }

          ***************(5)**************

          獲取設(shè)備描述符以后,主機(jī)再一次的復(fù)位設(shè)備,設(shè)備又進(jìn)入初始狀態(tài)。開(kāi)始枚舉的第二步設(shè)置地址。

          void NoData_Setup0(void)
          {
          RESULT Result = USB_UNSUPPORT;
          uint32_t RequestNo = pInformation->USBbRequest;
          uint32_t ControlState;

          if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) //設(shè)備請(qǐng)求
          {


          else if (RequestNo == SET_ADDRESS) /設(shè)置地址
          {
          if ((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0)
          || (pInformation->USBwIndex != 0)
          || (pInformation->Current_Configuration != 0))

          {
          ControlState = STALLED;
          goto exit_NoData_Setup0;
          }
          else
          {
          Result = USB_SUCCESS;

          #ifdef STM32F10X_CL
          SetDeviceAddress(pInformation->USBwValue0);
          #endif
          }
          }

          ControlState = WAIT_STATUS_IN;

          USB_StatusIn();//準(zhǔn)備好發(fā)送0字節(jié)的狀態(tài)數(shù)據(jù)包SetEPTxCount(ENDP0, 0);

          //vSetEPTxStatus(EP_TX_VALID);建立階段后直接的進(jìn)入狀態(tài)階段

          exit_NoData_Setup0:
          pInformation->ControlState = ControlState;
          return;
          }

          uint8_t In0_Process(void)
          {
          uint32_t ControlState = pInformation->ControlState;

          if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA)) //控制狀態(tài)
          {
          DataStageIn();//第一次取設(shè)備描述符只取一次 當(dāng)前的狀態(tài)變?yōu)閃AIT_STATUS_IN 表明設(shè)備等待狀態(tài)過(guò)程 主機(jī)輸出0字節(jié)

          ControlState = pInformation->ControlState;
          }

          else if (ControlState == WAIT_STATUS_IN) //設(shè)置地址狀態(tài)階段進(jìn)入這個(gè)程序
          {
          if ((pInformation->USBbRequest == SET_ADDRESS) &&
          (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)))
          {
          SetDeviceAddress(pInformation->USBwValue0);//設(shè)置使用新的地址
          pUser_Standard_Requests->User_SetDeviceAddress();
          }
          (*pProperty->Process_Status_IN)();
          ControlState = STALLED; //終止發(fā)送和接受

          }

          else
          {
          ControlState = STALLED;
          }

          pInformation->ControlState = ControlState;

          return Post0_Process();
          }

          uint8_t Post0_Process(void)
          {
          #ifdef STM32F10X_CL
          USB_OTG_EP *ep;
          #endif
          SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);//設(shè)置端點(diǎn)0 要接受的字節(jié)數(shù)

          if (pInformation->ControlState == STALLED)//這種狀態(tài)下只接受SETUP命令包
          {
          vSetEPRxStatus(EP_RX_STALL);//終止端點(diǎn)0接受
          vSetEPTxStatus(EP_TX_STALL);//終止端點(diǎn)0發(fā)送

          }

          return (pInformation->ControlState == PAUSE);
          }

          ***************(6)*************

          從新地址獲取設(shè)備描述符



          上一頁(yè) 1 2 3 下一頁(yè)

          關(guān)鍵詞: STM32USB使用說(shuō)

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();