⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_gpio.txt

📁 STM32手持式示波器源代码
💻 TXT
📖 第 1 页 / 共 3 页
字号:
00000c  ea421200          ORR      r2,r2,r0,LSL #4
;;;472      tmpreg |= GPIO_PinSource;
000010  430a              ORRS     r2,r2,r1
;;;473      AFIO->EVCR = tmpreg;
000012  4b01              LDR      r3,|L6.24|
000014  601a              STR      r2,[r3,#0]
;;;474    }
000016  4770              BX       lr
;;;475    
                          ENDP

                  |L6.24|
                          DCD      0x40010000

                          AREA ||i.GPIO_Init||, CODE, READONLY, ALIGN=1

                  GPIO_Init PROC
;;;171      */
;;;172    void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
000000  b5f0              PUSH     {r4-r7,lr}
;;;173    {
;;;174      uint32_t currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;
000002  2200              MOVS     r2,#0
000004  2300              MOVS     r3,#0
000006  2400              MOVS     r4,#0
000008  2500              MOVS     r5,#0
;;;175      uint32_t tmpreg = 0x00, pinmask = 0x00;
00000a  2600              MOVS     r6,#0
00000c  2700              MOVS     r7,#0
;;;176      /* Check the parameters */
;;;177      assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
;;;178      assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
;;;179      assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));  
;;;180      
;;;181    /*---------------------------- GPIO Mode Configuration -----------------------*/
;;;182      currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F);
00000e  f891c003          LDRB     r12,[r1,#3]
000012  f00c020f          AND      r2,r12,#0xf
;;;183      if ((((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x10)) != 0x00)
000016  f891c003          LDRB     r12,[r1,#3]
00001a  f01c0f10          TST      r12,#0x10
00001e  d003              BEQ      |L7.40|
;;;184      { 
;;;185        /* Check the parameters */
;;;186        assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
;;;187        /* Output mode */
;;;188        currentmode |= (uint32_t)GPIO_InitStruct->GPIO_Speed;
000020  f891c002          LDRB     r12,[r1,#2]
000024  ea4c0202          ORR      r2,r12,r2
                  |L7.40|
;;;189      }
;;;190    /*---------------------------- GPIO CRL Configuration ------------------------*/
;;;191      /* Configure the eight low port pins */
;;;192      if (((uint32_t)GPIO_InitStruct->GPIO_Pin & ((uint32_t)0x00FF)) != 0x00)
000028  f8b1c000          LDRH     r12,[r1,#0]
00002c  f01c0fff          TST      r12,#0xff
000030  d031              BEQ      |L7.150|
;;;193      {
;;;194        tmpreg = GPIOx->CRL;
000032  6806              LDR      r6,[r0,#0]
;;;195        for (pinpos = 0x00; pinpos < 0x08; pinpos++)
000034  2400              MOVS     r4,#0
000036  e02b              B        |L7.144|
                  |L7.56|
;;;196        {
;;;197          pos = ((uint32_t)0x01) << pinpos;
000038  f04f0c01          MOV      r12,#1
00003c  fa0cf504          LSL      r5,r12,r4
;;;198          /* Get the port pins position */
;;;199          currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
000040  f8b1c000          LDRH     r12,[r1,#0]
000044  ea0c0305          AND      r3,r12,r5
;;;200          if (currentpin == pos)
000048  42ab              CMP      r3,r5
00004a  d120              BNE      |L7.142|
;;;201          {
;;;202            pos = pinpos << 2;
00004c  00a5              LSLS     r5,r4,#2
;;;203            /* Clear the corresponding low control register bits */
;;;204            pinmask = ((uint32_t)0x0F) << pos;
00004e  f04f0c0f          MOV      r12,#0xf
000052  fa0cf705          LSL      r7,r12,r5
;;;205            tmpreg &= ~pinmask;
000056  43be              BICS     r6,r6,r7
;;;206            /* Write the mode configuration in the corresponding bits */
;;;207            tmpreg |= (currentmode << pos);
000058  fa02fc05          LSL      r12,r2,r5
00005c  ea4c0606          ORR      r6,r12,r6
;;;208            /* Reset the corresponding ODR bit */
;;;209            if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
000060  f891c003          LDRB     r12,[r1,#3]
000064  f1bc0f28          CMP      r12,#0x28
000068  d106              BNE      |L7.120|
;;;210            {
;;;211              GPIOx->BRR = (((uint32_t)0x01) << pinpos);
00006a  f04f0c01          MOV      r12,#1
00006e  fa0cfc04          LSL      r12,r12,r4
000072  f8c0c014          STR      r12,[r0,#0x14]
000076  e00a              B        |L7.142|
                  |L7.120|
;;;212            }
;;;213            else
;;;214            {
;;;215              /* Set the corresponding ODR bit */
;;;216              if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
000078  f891c003          LDRB     r12,[r1,#3]
00007c  f1bc0f48          CMP      r12,#0x48
000080  d105              BNE      |L7.142|
;;;217              {
;;;218                GPIOx->BSRR = (((uint32_t)0x01) << pinpos);
000082  f04f0c01          MOV      r12,#1
000086  fa0cfc04          LSL      r12,r12,r4
00008a  f8c0c010          STR      r12,[r0,#0x10]
                  |L7.142|
00008e  1c64              ADDS     r4,r4,#1              ;195
                  |L7.144|
000090  2c08              CMP      r4,#8                 ;195
000092  d3d1              BCC      |L7.56|
;;;219              }
;;;220            }
;;;221          }
;;;222        }
;;;223        GPIOx->CRL = tmpreg;
000094  6006              STR      r6,[r0,#0]
                  |L7.150|
;;;224      }
;;;225    /*---------------------------- GPIO CRH Configuration ------------------------*/
;;;226      /* Configure the eight high port pins */
;;;227      if (GPIO_InitStruct->GPIO_Pin > 0x00FF)
000096  f8b1c000          LDRH     r12,[r1,#0]
00009a  f1bc0fff          CMP      r12,#0xff
00009e  dd34              BLE      |L7.266|
;;;228      {
;;;229        tmpreg = GPIOx->CRH;
0000a0  6846              LDR      r6,[r0,#4]
;;;230        for (pinpos = 0x00; pinpos < 0x08; pinpos++)
0000a2  2400              MOVS     r4,#0
0000a4  e02e              B        |L7.260|
                  |L7.166|
;;;231        {
;;;232          pos = (((uint32_t)0x01) << (pinpos + 0x08));
0000a6  f1040c08          ADD      r12,r4,#8
0000aa  f04f0e01          MOV      lr,#1
0000ae  fa0ef50c          LSL      r5,lr,r12
;;;233          /* Get the port pins position */
;;;234          currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);
0000b2  f8b1c000          LDRH     r12,[r1,#0]
0000b6  ea0c0305          AND      r3,r12,r5
;;;235          if (currentpin == pos)
0000ba  42ab              CMP      r3,r5
0000bc  d121              BNE      |L7.258|
;;;236          {
;;;237            pos = pinpos << 2;
0000be  00a5              LSLS     r5,r4,#2
;;;238            /* Clear the corresponding high control register bits */
;;;239            pinmask = ((uint32_t)0x0F) << pos;
0000c0  f04f0c0f          MOV      r12,#0xf
0000c4  fa0cf705          LSL      r7,r12,r5
;;;240            tmpreg &= ~pinmask;
0000c8  43be              BICS     r6,r6,r7
;;;241            /* Write the mode configuration in the corresponding bits */
;;;242            tmpreg |= (currentmode << pos);
0000ca  fa02fc05          LSL      r12,r2,r5
0000ce  ea4c0606          ORR      r6,r12,r6
;;;243            /* Reset the corresponding ODR bit */
;;;244            if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
0000d2  f891c003          LDRB     r12,[r1,#3]
0000d6  f1bc0f28          CMP      r12,#0x28
0000da  d105              BNE      |L7.232|
;;;245            {
;;;246              GPIOx->BRR = (((uint32_t)0x01) << (pinpos + 0x08));
0000dc  f1040c08          ADD      r12,r4,#8
0000e0  fa0efe0c          LSL      lr,lr,r12
0000e4  f8c0e014          STR      lr,[r0,#0x14]
                  |L7.232|
;;;247            }
;;;248            /* Set the corresponding ODR bit */
;;;249            if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
0000e8  f891c003          LDRB     r12,[r1,#3]
0000ec  f1bc0f48          CMP      r12,#0x48
0000f0  d107              BNE      |L7.258|
;;;250            {
;;;251              GPIOx->BSRR = (((uint32_t)0x01) << (pinpos + 0x08));
0000f2  f1040c08          ADD      r12,r4,#8
0000f6  f04f0e01          MOV      lr,#1
0000fa  fa0efe0c          LSL      lr,lr,r12
0000fe  f8c0e010          STR      lr,[r0,#0x10]
                  |L7.258|
000102  1c64              ADDS     r4,r4,#1              ;230
                  |L7.260|
000104  2c08              CMP      r4,#8                 ;230
000106  d3ce              BCC      |L7.166|
;;;252            }
;;;253          }
;;;254        }
;;;255        GPIOx->CRH = tmpreg;
000108  6046              STR      r6,[r0,#4]
                  |L7.266|
;;;256      }
;;;257    }
00010a  bdf0              POP      {r4-r7,pc}
;;;258    
                          ENDP


                          AREA ||i.GPIO_PinLockConfig||, CODE, READONLY, ALIGN=1

                  GPIO_PinLockConfig PROC
;;;430      */
;;;431    void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
000000  f44f3280          MOV      r2,#0x10000
;;;432    {
;;;433      uint32_t tmp = 0x00010000;
;;;434      
;;;435      /* Check the parameters */
;;;436      assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
;;;437      assert_param(IS_GPIO_PIN(GPIO_Pin));
;;;438      
;;;439      tmp |= GPIO_Pin;
000004  430a              ORRS     r2,r2,r1
;;;440      /* Set LCKK bit */
;;;441      GPIOx->LCKR = tmp;
000006  6182              STR      r2,[r0,#0x18]
;;;442      /* Reset LCKK bit */
;;;443      GPIOx->LCKR =  GPIO_Pin;
000008  6181              STR      r1,[r0,#0x18]
;;;444      /* Set LCKK bit */
;;;445      GPIOx->LCKR = tmp;
00000a  6182              STR      r2,[r0,#0x18]
;;;446      /* Read LCKK bit*/
;;;447      tmp = GPIOx->LCKR;
00000c  6982              LDR      r2,[r0,#0x18]
;;;448      /* Read LCKK bit*/
;;;449      tmp = GPIOx->LCKR;
00000e  6982              LDR      r2,[r0,#0x18]
;;;450    }
000010  4770              BX       lr
;;;451    
                          ENDP


                          AREA ||i.GPIO_PinRemapConfig||, CODE, READONLY, ALIGN=2

                  GPIO_PinRemapConfig PROC
;;;529      */
;;;530    void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState)
000000  b5f0              PUSH     {r4-r7,lr}
;;;531    {
;;;532      uint32_t tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00;
000002  2200              MOVS     r2,#0
000004  2300              MOVS     r3,#0
000006  2500              MOVS     r5,#0
000008  2400              MOVS     r4,#0
;;;533    
;;;534      /* Check the parameters */
;;;535      assert_param(IS_GPIO_REMAP(GPIO_Remap));
;;;536      assert_param(IS_FUNCTIONAL_STATE(NewState));  
;;;537      
;;;538      tmpreg = AFIO->MAPR;
00000a  4e17              LDR      r6,|L9.104|
00000c  6875              LDR      r5,[r6,#4]
;;;539    
;;;540      tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10;
00000e  f3c04403          UBFX     r4,r0,#16,#4
;;;541      tmp = GPIO_Remap & LSB_MASK;
000012  b282              UXTH     r2,r0
;;;542    
;;;543      if ((GPIO_Remap & (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)) == (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK))
000014  f4001640          AND      r6,r0,#0x300000
000018  f5b61f40          CMP      r6,#0x300000
00001c  d108              BNE      |L9.48|
;;;544      {
;;;545        tmpreg &= DBGAFR_SWJCFG_MASK;
00001e  f0256570          BIC      r5,r5,#0xf000000
;;;546        AFIO->MAPR &= DBGAFR_SWJCFG_MASK;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -