stm32f10x_gpio.lst

来自「针对STM32F103的UCOS移植」· LST 代码 · 共 1,009 行 · 第 1/4 页

LST
1,009
字号
    117          {
   \                     GPIO_Init:
   \   00000000   2DE9F041           PUSH     {R4-R8,LR}
    118            u32 currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;
    119            u32 tmpreg = 0x00, pinmask = 0x00;
    120          
    121            /* Check the parameters */
    122            assert(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
    123            assert(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));  
    124            
    125          /*---------------------------- GPIO Mode Configuration -----------------------*/
    126            currentmode = ((u32)GPIO_InitStruct->GPIO_Mode) & ((u32)0x0F);
   \   00000004   CA78               LDRB     R2,[R1, #+3]
   \   00000006   1207               LSLS     R2,R2,#+28
   \   00000008   120F               LSRS     R2,R2,#+28
    127          
    128            if ((((u32)GPIO_InitStruct->GPIO_Mode) & ((u32)0x10)) != 0x00)
   \   0000000A   CB78               LDRB     R3,[R1, #+3]
   \   0000000C   DB06               LSLS     R3,R3,#+27
   \   0000000E   02D5               BPL.N    ??GPIO_Init_0
    129            { 
    130              /* Check the parameters */
    131              assert(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
    132              /* Output mode */
    133              currentmode |= (u32)GPIO_InitStruct->GPIO_Speed;
   \   00000010   1300               MOVS     R3,R2
   \   00000012   8A78               LDRB     R2,[R1, #+2]
   \   00000014   1A43               ORRS     R2,R2,R3
    134            }
    135          
    136          /*---------------------------- GPIO CRL Configuration ------------------------*/
    137            /* Configure the eight low port pins */
    138            if (((u32)GPIO_InitStruct->GPIO_Pin & ((u32)0x00FF)) != 0x00)
   \                     ??GPIO_Init_0:
   \   00000016   0023               MOVS     R3,#+0
   \   00000018   9846               MOV      R8,R3
   \   0000001A   0B88               LDRH     R3,[R1, #+0]
   \   0000001C   DBB2               UXTB     R3,R3
   \   0000001E   002B               CMP      R3,#+0
   \   00000020   1DD0               BEQ.N    ??GPIO_Init_1
    139            {
    140              tmpreg = GPIOx->CRL;
   \   00000022   0568               LDR      R5,[R0, #+0]
    141          
    142              for (pinpos = 0x00; pinpos < 0x08; pinpos++)
   \   00000024   4346               MOV      R3,R8
   \   00000026   17E0               B.N      ??GPIO_Init_2
    143              {
    144                pos = ((u32)0x01) << pinpos;
   \                     ??GPIO_Init_3:
   \   00000028   0126               MOVS     R6,#+1
   \   0000002A   9E40               LSLS     R6,R6,R3
   \   0000002C   3400               MOVS     R4,R6
    145                /* Get the port pins position */
    146                currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
    147          
    148                if (currentpin == pos)
   \   0000002E   0F88               LDRH     R7,[R1, #+0]
   \   00000030   2740               ANDS     R7,R7,R4
   \   00000032   A742               CMP      R7,R4
   \   00000034   0FD1               BNE.N    ??GPIO_Init_4
    149                {
    150                  pos = pinpos << 2;
   \   00000036   9C00               LSLS     R4,R3,#+2
    151                  /* Clear the corresponding low control register bits */
    152                  pinmask = ((u32)0x0F) << pos;
    153                  tmpreg &= ~pinmask;
    154          
    155                  /* Write the mode configuration in the corresponding bits */
    156                  tmpreg |= (currentmode << pos);
   \   00000038   0F27               MOVS     R7,#+15
   \   0000003A   A740               LSLS     R7,R7,R4
   \   0000003C   BD43               BICS     R5,R5,R7
   \   0000003E   2F00               MOVS     R7,R5
   \   00000040   12FA04F5           LSLS     R5,R2,R4
   \   00000044   3D43               ORRS     R5,R5,R7
    157          
    158                  /* Reset the corresponding ODR bit */
    159                  if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
   \   00000046   CC78               LDRB     R4,[R1, #+3]
   \   00000048   282C               CMP      R4,#+40
   \   0000004A   00D1               BNE.N    ??GPIO_Init_5
    160                  {
    161                    GPIOx->BRR = (((u32)0x01) << pinpos);
   \   0000004C   4661               STR      R6,[R0, #+20]
    162                  }
    163                  /* Set the corresponding ODR bit */
    164                  if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
   \                     ??GPIO_Init_5:
   \   0000004E   CC78               LDRB     R4,[R1, #+3]
   \   00000050   482C               CMP      R4,#+72
   \   00000052   00D1               BNE.N    ??GPIO_Init_4
    165                  {
    166                    GPIOx->BSRR = (((u32)0x01) << pinpos);
   \   00000054   0661               STR      R6,[R0, #+16]
    167                  }
    168                }
    169              }
   \                     ??GPIO_Init_4:
   \   00000056   5B1C               ADDS     R3,R3,#+1
   \                     ??GPIO_Init_2:
   \   00000058   082B               CMP      R3,#+8
   \   0000005A   E5D3               BCC.N    ??GPIO_Init_3
    170              GPIOx->CRL = tmpreg;
   \   0000005C   0560               STR      R5,[R0, #+0]
    171              tmpreg = 0;
    172            }
    173          
    174          /*---------------------------- GPIO CRH Configuration ------------------------*/
    175            /* Configure the eight high port pins */
    176            if (GPIO_InitStruct->GPIO_Pin > 0x00FF)
   \                     ??GPIO_Init_1:
   \   0000005E   0B88               LDRH     R3,[R1, #+0]
   \   00000060   5FF48074           MOVS     R4,#+256
   \   00000064   A342               CMP      R3,R4
   \   00000066   1FD3               BCC.N    ??GPIO_Init_6
    177            {
    178              tmpreg = GPIOx->CRH;
   \   00000068   4568               LDR      R5,[R0, #+4]
    179              for (pinpos = 0x00; pinpos < 0x08; pinpos++)
   \   0000006A   4346               MOV      R3,R8
   \   0000006C   19E0               B.N      ??GPIO_Init_7
    180              {
    181                pos = (((u32)0x01) << (pinpos + 0x08));
   \                     ??GPIO_Init_8:
   \   0000006E   0126               MOVS     R6,#+1
   \   00000070   1C00               MOVS     R4,R3
   \   00000072   0834               ADDS     R4,R4,#+8
   \   00000074   A640               LSLS     R6,R6,R4
   \   00000076   3400               MOVS     R4,R6
    182                /* Get the port pins position */
    183                currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);
    184                if (currentpin == pos)
   \   00000078   0F88               LDRH     R7,[R1, #+0]
   \   0000007A   2740               ANDS     R7,R7,R4
   \   0000007C   A742               CMP      R7,R4
   \   0000007E   0FD1               BNE.N    ??GPIO_Init_9
    185                {
    186                  pos = pinpos << 2;
   \   00000080   9C00               LSLS     R4,R3,#+2
    187                  /* Clear the corresponding high control register bits */
    188                  pinmask = ((u32)0x0F) << pos;
    189                  tmpreg &= ~pinmask;
    190          
    191                  /* Write the mode configuration in the corresponding bits */
    192                  tmpreg |= (currentmode << pos);
   \   00000082   0F27               MOVS     R7,#+15
   \   00000084   A740               LSLS     R7,R7,R4
   \   00000086   BD43               BICS     R5,R5,R7
   \   00000088   2F00               MOVS     R7,R5
   \   0000008A   12FA04F5           LSLS     R5,R2,R4
   \   0000008E   3D43               ORRS     R5,R5,R7
    193          
    194                  /* Reset the corresponding ODR bit */
    195                  if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
   \   00000090   CC78               LDRB     R4,[R1, #+3]
   \   00000092   282C               CMP      R4,#+40
   \   00000094   00D1               BNE.N    ??GPIO_Init_10
    196                  {
    197                    GPIOx->BRR = (((u32)0x01) << (pinpos + 0x08));
   \   00000096   4661               STR      R6,[R0, #+20]
    198                  }
    199                  /* Set the corresponding ODR bit */
    200                  if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
   \                     ??GPIO_Init_10:
   \   00000098   CC78               LDRB     R4,[R1, #+3]
   \   0000009A   482C               CMP      R4,#+72
   \   0000009C   00D1               BNE.N    ??GPIO_Init_9
    201                  {
    202                    GPIOx->BSRR = (((u32)0x01) << (pinpos + 0x08));
   \   0000009E   0661               STR      R6,[R0, #+16]
    203                  }
    204                }
    205              }
   \                     ??GPIO_Init_9:
   \   000000A0   5B1C               ADDS     R3,R3,#+1
   \                     ??GPIO_Init_7:
   \   000000A2   082B               CMP      R3,#+8
   \   000000A4   E3D3               BCC.N    ??GPIO_Init_8
    206              GPIOx->CRH = tmpreg;
   \   000000A6   4560               STR      R5,[R0, #+4]
    207            }
    208          }
   \                     ??GPIO_Init_6:
   \   000000A8   BDE8F081           POP      {R4-R8,PC}       ;; return
    209          
    210          /*******************************************************************************
    211          * Function Name  : GPIO_StructInit
    212          * Description    : Fills each GPIO_InitStruct member with its default value.
    213          * Input          : - GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure
    214          *                    which will be initialized.
    215          * Output         : None
    216          * Return         : None
    217          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    218          void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
    219          {
    220            /* Reset GPIO init structure parameters values */
    221            GPIO_InitStruct->GPIO_Pin  = GPIO_Pin_All;
   \                     GPIO_StructInit:
   \   00000000   0349               LDR.N    R1,??GPIO_StructInit_0  ;; 0xffff
   \   00000002   0180               STRH     R1,[R0, #+0]
    222            GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;
   \   00000004   0221               MOVS     R1,#+2
   \   00000006   8170               STRB     R1,[R0, #+2]
    223            GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;
   \   00000008   0421               MOVS     R1,#+4
   \   0000000A   C170               STRB     R1,[R0, #+3]
    224          }
   \   0000000C   7047               BX       LR               ;; return
   \   0000000E   00BF               Nop      
   \                     ??GPIO_StructInit_0:
   \   00000010   FFFF0000           DC32     0xffff
    225          
    226          /*******************************************************************************
    227          * Function Name  : GPIO_ReadInputDataBit
    228          * Description    : Reads the specified input port pin.
    229          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    230          *                : - GPIO_Pin:  specifies the port bit to read.
    231          *                    This parameter can be GPIO_Pin_x where x can be (0..15).
    232          * Output         : None
    233          * Return         : The input port pin value.
    234          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    235          u8 GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
    236          {
   \                     GPIO_ReadInputDataBit:
   \   00000000   00B5               PUSH     {LR}
    237            u8 bitstatus = 0x00;
    238            
    239            /* Check the parameters */
    240            assert(IS_GET_GPIO_PIN(GPIO_Pin)); 
    241            
    242            if ((GPIOx->IDR & GPIO_Pin) != (u32)Bit_RESET)
   \   00000002   8068               LDR      R0,[R0, #+8]
   \   00000004   0842               TST      R0,R1
   \   00000006   01D0               BEQ.N    ??GPIO_ReadInputDataBit_0
    243            {
    244              bitstatus = (u8)Bit_SET;
   \   00000008   0120               MOVS     R0,#+1
   \   0000000A   00BD               POP      {PC}
    245            }
    246            else
    247            {
    248              bitstatus = (u8)Bit_RESET;
   \                     ??GPIO_ReadInputDataBit_0:
   \   0000000C   0020               MOVS     R0,#+0
    249            }
    250            return bitstatus;
   \   0000000E   00BD               POP      {PC}             ;; return
    251          }

⌨️ 快捷键说明

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