chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

STM32F1兩個(gè)USB中斷入口詳解

CHANBAEK ? 來(lái)源:一個(gè)早起的程序員 ? 作者:一個(gè)早起的程序員 ? 2023-07-24 11:12 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

1 STM32F1兩個(gè)USB中斷入口

STM32中斷入口有兩個(gè),分別是USB_HP_CAN1_TX_IRQHandler和USB_LP_CAN1_RX0_IRQHandler。

其中USB_Istr函數(shù)調(diào)用了CTR_LP函數(shù),代碼如下。

/*******************************************************************************
* Function Name  : USB_HP_CAN1_TX_IRQHandler
* Description    : This function handles USB High Priority or CAN TX interrupts
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USB_HP_CAN1_TX_IRQHandler(void)
{
  CTR_HP();
}

/*******************************************************************************
* Function Name  : USB_LP_CAN1_RX0_IRQHandler
* Description    : This function handles USB Low Priority or CAN RX0 interrupts
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USB_LP_CAN1_RX0_IRQHandler(void)
{
  USB_Istr();
}

2 CTR_LP

CTR_LP為低優(yōu)先級(jí)端點(diǎn)傳輸正常時(shí)的中斷服務(wù)函數(shù),控制傳輸只能在CTR_LP里面處理,代碼如下。

/*******************************************************************************
* Function Name  : CTR_LP.
* Description    : Low priority Endpoint Correct Transfer interrupt's service
*                  routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void CTR_LP(void)
{
  uint32_t wEPVal = 0;
  /* stay in loop while pending ints */
  while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
  {
    _SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */
    /* extract highest priority endpoint number */
    EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
    if (EPindex == 0)
    {
      /* Decode and service control endpoint interrupt */
      /* calling related service routine */
      /* (Setup0_Process, In0_Process, Out0_Process) */

      /* save RX & TX status */
      /* and set both to NAK */
      SaveRState = _GetEPRxStatus(ENDP0);
      SaveTState = _GetEPTxStatus(ENDP0);
      _SetEPRxStatus(ENDP0, EP_RX_NAK);
      _SetEPTxStatus(ENDP0, EP_TX_NAK);


      /* DIR bit = origin of the interrupt */

      if ((wIstr & ISTR_DIR) == 0)
      {
        /* DIR = 0 */

        /* DIR = 0      = > IN  int */
        /* DIR = 0 implies that (EP_CTR_TX = 1) always  */


        _ClearEP_CTR_TX(ENDP0);
        In0_Process();

           /* before terminate set Tx & Rx status */
          _SetEPRxStatus(ENDP0, SaveRState);
          _SetEPTxStatus(ENDP0, SaveTState);
          return;
      }
      else
      {
        /* DIR = 1 */

        /* DIR = 1 & CTR_RX       = > SETUP or OUT int */
        /* DIR = 1 & (CTR_TX | CTR_RX) = > 2 int pending */

        wEPVal = _GetENDPOINT(ENDP0);
        if ((wEPVal & EP_CTR_TX) != 0)
        {
          _ClearEP_CTR_TX(ENDP0);
          In0_Process();
          /* before terminate set Tx & Rx status */
          _SetEPRxStatus(ENDP0, SaveRState);
          _SetEPTxStatus(ENDP0, SaveTState);
          return;
        }
        else if ((wEPVal &EP_SETUP) != 0)
        {
          _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
          Setup0_Process();
          /* before terminate set Tx & Rx status */
          _SetEPRxStatus(ENDP0, SaveRState);
          _SetEPTxStatus(ENDP0, SaveTState);
          return;
        }

        else if ((wEPVal & EP_CTR_RX) != 0)
        {
          _ClearEP_CTR_RX(ENDP0);
          Out0_Process();
          /* before terminate set Tx & Rx status */
          _SetEPRxStatus(ENDP0, SaveRState);
          _SetEPTxStatus(ENDP0, SaveTState);
          return;
        }
      }
    }/* if(EPindex == 0) */
    else
    {
      /* Decode and service non control endpoints interrupt  */

      /* process related endpoint register */
      wEPVal = _GetENDPOINT(EPindex);
      if ((wEPVal & EP_CTR_RX) != 0)
      {
        /* clear int flag */
        _ClearEP_CTR_RX(EPindex);

        /* call OUT service function */
        (*pEpInt_OUT[EPindex-1])();

      } /* if((wEPVal & EP_CTR_RX) */

      if ((wEPVal & EP_CTR_TX) != 0)
      {
        /* clear int flag */
        _ClearEP_CTR_TX(EPindex);

        /* call IN service function */
        (*pEpInt_IN[EPindex-1])();
      } /* if((wEPVal & EP_CTR_TX) != 0) */

    }/* if(EPindex == 0) else */

  }/* while(...) */
}

3 CTR_HP

CTR_HP為高優(yōu)先級(jí)端點(diǎn)傳輸正常時(shí)的中斷服務(wù)函數(shù),代碼如下。

/*******************************************************************************
* Function Name  : CTR_HP.
* Description    : High Priority Endpoint Correct Transfer interrupt's service 
*                  routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void CTR_HP(void)
{
  uint32_t wEPVal = 0;

  while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
  {
    _SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */
    /* extract highest priority endpoint number */
    EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
    /* process related endpoint register */
    wEPVal = _GetENDPOINT(EPindex);
    if ((wEPVal & EP_CTR_RX) != 0)
    {
      /* clear int flag */
      _ClearEP_CTR_RX(EPindex);

      /* call OUT service function */
      (*pEpInt_OUT[EPindex-1])();

    } /* if((wEPVal & EP_CTR_RX) */
    else if ((wEPVal & EP_CTR_TX) != 0)
    {
      /* clear int flag */
      _ClearEP_CTR_TX(EPindex);

      /* call IN service function */
      (*pEpInt_IN[EPindex-1])();


    } /* if((wEPVal & EP_CTR_TX) != 0) */

  }/* while(...) */
}

4 CTR_LP和CTR_HP各自處理的事務(wù)類(lèi)型

這兩個(gè)函數(shù)定義在usb_int.c中,用法如下。

CTR_LP(低優(yōu)先級(jí)中斷Low-priority interrupt),用于控制傳輸、中斷傳輸、批量傳輸( 單緩沖模式)。

CTR_HP(高優(yōu)先級(jí)中斷 High-priority interrupt),用于快速大數(shù)據(jù)量傳輸處理,比如同步傳輸、批量傳輸,但是都是處理雙緩沖模式。

5 核心注意要點(diǎn)

如果把只初始化了USB_LP_CAN1_RX0_IRQn中斷向量,則所有的正確傳輸中斷只會(huì)進(jìn)入U(xiǎn)SB_LP_CAN1_RX0_IRQHandler->CTR_LP,所以要想進(jìn)入CTR_HP必須對(duì)其中斷向量進(jìn)行初始化,否則會(huì)使用默認(rèn)的CTR_LP路徑進(jìn)行處理。

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • usb
    usb
    +關(guān)注

    關(guān)注

    60

    文章

    8319

    瀏覽量

    279047
  • STM32
    +關(guān)注

    關(guān)注

    2301

    文章

    11069

    瀏覽量

    369331
  • 中斷
    +關(guān)注

    關(guān)注

    5

    文章

    911

    瀏覽量

    43323
  • stm32f1
    +關(guān)注

    關(guān)注

    1

    文章

    60

    瀏覽量

    12733
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    STM32f1庫(kù)函數(shù)開(kāi)發(fā)

    ” 的學(xué)習(xí)STM32,實(shí)際操作過(guò)程中知識(shí)盲區(qū)比想象中要多很多!只做了兩個(gè)GPIO口項(xiàng)目。實(shí)戰(zhàn)一 · I/O口1. 文件夾結(jié)構(gòu)USERsystem_stm32f10x.c系統(tǒng)時(shí)鐘初始化函
    發(fā)表于 08-17 06:29

    STM32F1中斷線(xiàn)是什么?

    STM32F1中斷線(xiàn)是什么?
    發(fā)表于 11-18 06:00

    STM32F1USB串口該怎樣去使用呢

    STM32F1USB串口該怎樣去使用呢?與STM32F1USB串口基本配置相關(guān)的寄存器有哪些呢?
    發(fā)表于 12-06 07:09

    stm32F1輸入捕獲詳解

    stm32F1輸入捕獲詳解1、問(wèn)題:什么叫輸入捕獲回答:舉個(gè)例子,比如一個(gè)信號(hào)由低電平變成高電平時(shí),cpu保存定時(shí)器的值,信號(hào)再由高電平變成低電平時(shí),cpu又保存一次定時(shí)器的值,那么通
    發(fā)表于 12-06 06:12

    STM32F1外部中斷簡(jiǎn)介

    開(kāi)啟了學(xué)習(xí)機(jī)器學(xué)習(xí),本文就介紹了機(jī)器學(xué)習(xí)的基礎(chǔ)內(nèi)容。提示:以下是本篇文章正文內(nèi)容,下面案例可供參考一、 STM32F1 外部中斷簡(jiǎn)介我們首先講解 STM32F1 IO 口中斷的一些基礎(chǔ)
    發(fā)表于 12-09 07:26

    STM32F1通用定時(shí)器示例詳解--TIM15_Compleme

    STM32F1通用定時(shí)器示例詳解--TIM15_ComplementarySignals
    發(fā)表于 12-07 18:15 ?0次下載

    STM32F1通用定時(shí)器示例講解_Timebase

    STM32F1通用定時(shí)器示例詳解—Timebase
    發(fā)表于 12-07 18:14 ?0次下載

    STM32F1系列芯片中文參考手冊(cè)

    STM32F1系列芯片中文參考手冊(cè)(嵌入式開(kāi)發(fā)培訓(xùn)教程)-STM32F1系列芯片的中文用戶(hù)手冊(cè)
    發(fā)表于 07-30 09:32 ?220次下載
    <b class='flag-5'>STM32F1</b>系列芯片中文參考手冊(cè)

    STM32F1官方手冊(cè)資料(中英文)

    STM32F1官方手冊(cè)資料(中英文)
    發(fā)表于 11-05 16:28 ?69次下載

    STM32F1F4的區(qū)別

    STM32F1F4的區(qū)別
    發(fā)表于 12-04 13:51 ?24次下載
    <b class='flag-5'>STM32F1</b>和<b class='flag-5'>F</b>4的區(qū)別

    STM32F1雙DMA提高串口速度

    STM32F1雙DMA,提高串口速度
    發(fā)表于 09-26 16:11 ?5次下載

    AN3427_從STM32F1移植到STM32F2的應(yīng)用手冊(cè)

    AN3427_從STM32F1移植到STM32F2的應(yīng)用手冊(cè)
    發(fā)表于 11-21 17:06 ?10次下載
    AN3427_從<b class='flag-5'>STM32F1</b>移植到<b class='flag-5'>STM32F</b>2的應(yīng)用手冊(cè)

    AN4904_從STM32F1STM32F4的軟件移植

    AN4904_從STM32F1STM32F4的軟件移植
    發(fā)表于 11-21 17:06 ?6次下載
    AN4904_從<b class='flag-5'>STM32F1</b>到<b class='flag-5'>STM32F</b>4的軟件移植

    STM32F1 USB外設(shè)在USB系統(tǒng)的位置

    STM32F1 USB外設(shè)實(shí)現(xiàn)了USB2.0全速總線(xiàn)和APB1總線(xiàn)間的接口。
    的頭像 發(fā)表于 07-17 15:43 ?2417次閱讀
    <b class='flag-5'>STM32F1</b> <b class='flag-5'>USB</b>外設(shè)在<b class='flag-5'>USB</b>系統(tǒng)的位置

    stm32f1如何將外部中斷關(guān)掉hal庫(kù)

    引入相關(guān)的頭文件。在HAL庫(kù)中,與外部中斷相關(guān)的頭文件是stm32f1xx_hal_exti.h和stm32f1xx_hal_gpio.h。這兩個(gè)頭文件提供了對(duì)外部
    的頭像 發(fā)表于 12-22 13:52 ?5159次閱讀