stm32f10x_gpio.lst

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

LST
1,009
字号
    252          
    253          /*******************************************************************************
    254          * Function Name  : GPIO_ReadInputData
    255          * Description    : Reads the specified GPIO input data port.
    256          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    257          * Output         : None
    258          * Return         : GPIO input data port value.
    259          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    260          u16 GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
    261          {
    262            return ((u16)GPIOx->IDR);
   \                     GPIO_ReadInputData:
   \   00000000   8068               LDR      R0,[R0, #+8]
   \   00000002   80B2               UXTH     R0,R0
   \   00000004   7047               BX       LR               ;; return
    263          }
    264          
    265          /*******************************************************************************
    266          * Function Name  : GPIO_ReadOutputDataBit
    267          * Description    : Reads the specified output data port bit.
    268          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    269          *                : - GPIO_Pin:  specifies the port bit to read.
    270          *                    This parameter can be GPIO_Pin_x where x can be (0..15).
    271          * Output         : None
    272          * Return         : The output port pin value.
    273          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    274          u8 GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
    275          {
   \                     GPIO_ReadOutputDataBit:
   \   00000000   00B5               PUSH     {LR}
    276            u8 bitstatus = 0x00;
    277          
    278            /* Check the parameters */
    279            assert(IS_GET_GPIO_PIN(GPIO_Pin)); 
    280            
    281            if ((GPIOx->ODR & GPIO_Pin) != (u32)Bit_RESET)
   \   00000002   C068               LDR      R0,[R0, #+12]
   \   00000004   0842               TST      R0,R1
   \   00000006   01D0               BEQ.N    ??GPIO_ReadOutputDataBit_0
    282            {
    283              bitstatus = (u8)Bit_SET;
   \   00000008   0120               MOVS     R0,#+1
   \   0000000A   00BD               POP      {PC}
    284            }
    285            else
    286            {
    287              bitstatus = (u8)Bit_RESET;
   \                     ??GPIO_ReadOutputDataBit_0:
   \   0000000C   0020               MOVS     R0,#+0
    288            }
    289            return bitstatus;
   \   0000000E   00BD               POP      {PC}             ;; return
    290          }
    291          
    292          /*******************************************************************************
    293          * Function Name  : GPIO_ReadOutputData
    294          * Description    : Reads the specified GPIO output data port.
    295          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    296          * Output         : None
    297          * Return         : GPIO output data port value.
    298          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    299          u16 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
    300          {
    301            return ((u16)GPIOx->ODR);
   \                     GPIO_ReadOutputData:
   \   00000000   C068               LDR      R0,[R0, #+12]
   \   00000002   80B2               UXTH     R0,R0
   \   00000004   7047               BX       LR               ;; return
    302          }
    303          
    304          /*******************************************************************************
    305          * Function Name  : GPIO_SetBits
    306          * Description    : Sets the selected data port bits.
    307          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    308          *                  - GPIO_Pin: specifies the port bits to be written.
    309          *                    This parameter can be any combination of GPIO_Pin_x where 
    310          *                    x can be (0..15).
    311          * Output         : None
    312          * Return         : None
    313          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    314          void GPIO_SetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
    315          {
    316            /* Check the parameters */
    317            assert(IS_GPIO_PIN(GPIO_Pin));
    318            GPIOx->BSRR = GPIO_Pin;
   \                     GPIO_SetBits:
   \   00000000   0161               STR      R1,[R0, #+16]
    319          }
   \   00000002   7047               BX       LR               ;; return
    320          
    321          /*******************************************************************************
    322          * Function Name  : GPIO_ResetBits
    323          * Description    : Clears the selected data port bits.
    324          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    325          *                  - GPIO_Pin: specifies the port bits to be written.
    326          *                    This parameter can be any combination of GPIO_Pin_x where 
    327          *                    x can be (0..15).
    328          * Output         : None
    329          * Return         : None
    330          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    331          void GPIO_ResetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
    332          {
    333            /* Check the parameters */
    334            assert(IS_GPIO_PIN(GPIO_Pin));
    335            GPIOx->BRR = GPIO_Pin;
   \                     GPIO_ResetBits:
   \   00000000   4161               STR      R1,[R0, #+20]
    336          }
   \   00000002   7047               BX       LR               ;; return
    337          
    338          /*******************************************************************************
    339          * Function Name  : GPIO_WriteBit
    340          * Description    : Sets or clears the selected data port bit.
    341          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    342          *                  - GPIO_Pin: specifies the port bit to be written.
    343          *                    This parameter can be one of GPIO_Pin_x where x can be (0..15).
    344          *                  - BitVal: specifies the value to be written to the selected bit.
    345          *                    This parameter can be one of the BitAction enum values:
    346          *                       - Bit_RESET: to clear the port pin
    347          *                       - Bit_SET: to set the port pin
    348          * Output         : None
    349          * Return         : None
    350          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    351          void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal)
    352          {
    353            /* Check the parameters */
    354            assert(IS_GET_GPIO_PIN(GPIO_Pin));
    355            assert(IS_GPIO_BIT_ACTION(BitVal)); 
    356            
    357            if (BitVal != Bit_RESET)
   \                     GPIO_WriteBit:
   \   00000000   002A               CMP      R2,#+0
   \   00000002   01D0               BEQ.N    ??GPIO_WriteBit_0
    358            {
    359              GPIOx->BSRR = GPIO_Pin;
   \   00000004   0161               STR      R1,[R0, #+16]
   \   00000006   7047               BX       LR
    360            }
    361            else
    362            {
    363              GPIOx->BRR = GPIO_Pin;
   \                     ??GPIO_WriteBit_0:
   \   00000008   4161               STR      R1,[R0, #+20]
    364            }
    365          }
   \   0000000A   7047               BX       LR               ;; return
    366          
    367          /*******************************************************************************
    368          * Function Name  : GPIO_Write
    369          * Description    : Writes data to the specified GPIO data port.
    370          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    371          *                  - PortVal: specifies the value to be written to the port output
    372          *                    data register.
    373          * Output         : None
    374          * Return         : None
    375          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    376          void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal)
    377          {
    378            GPIOx->ODR = PortVal;
   \                     GPIO_Write:
   \   00000000   C160               STR      R1,[R0, #+12]
    379          }
   \   00000002   7047               BX       LR               ;; return
    380          
    381          /*******************************************************************************
    382          * Function Name  : GPIO_PinLockConfig
    383          * Description    : Locks GPIO Pins configuration registers.
    384          * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.
    385          *                  - GPIO_Pin: specifies the port bit to be written.
    386          *                    This parameter can be any combination of GPIO_Pin_x where 
    387          *                    x can be (0..15).
    388          * Output         : None
    389          * Return         : None
    390          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    391          void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
    392          {
    393            u32 tmp = 0x00010000;
    394            
    395            /* Check the parameters */
    396            assert(IS_GPIO_PIN(GPIO_Pin));
    397            
    398            tmp |= GPIO_Pin;
   \                     GPIO_PinLockConfig:
   \   00000000   51F48032           ORRS     R2,R1,#0x10000
    399            /* Set LCKK bit */
    400            GPIOx->LCKR = tmp;
   \   00000004   8261               STR      R2,[R0, #+24]
    401            /* Reset LCKK bit */
    402            GPIOx->LCKR =  GPIO_Pin;
   \   00000006   8161               STR      R1,[R0, #+24]
    403            /* Set LCKK bit */
    404            GPIOx->LCKR = tmp;
   \   00000008   8261               STR      R2,[R0, #+24]
    405            /* Read LCKK bit*/
    406            tmp = GPIOx->LCKR;
   \   0000000A   8169               LDR      R1,[R0, #+24]
    407            /* Read LCKK bit*/
    408            tmp = GPIOx->LCKR;
   \   0000000C   8069               LDR      R0,[R0, #+24]
    409          }
   \   0000000E   7047               BX       LR               ;; return
    410          
    411          /*******************************************************************************
    412          * Function Name  : GPIO_EventOutputConfig
    413          * Description    : Selects the GPIO pin used as Event output.
    414          * Input          : - GPIO_PortSource: selects the GPIO port to be used as source
    415          *                    for Event output.
    416          *                    This parameter can be GPIO_PortSourceGPIOx where x can be
    417          *                    (A..E).
    418          *                  - GPIO_PinSource: specifies the pin for the Event output.
    419          *                    This parameter can be GPIO_PinSourcex where x can be (0..15).
    420          * Output         : None
    421          * Return         : None
    422          *******************************************************************************/

   \                                 In segment CODE, align 4, keep-with-next
    423          void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)
    424          {
   \                     GPIO_EventOutputConfig:
   \   00000000   10B5               PUSH     {R4,LR}
    425            u32 tmpreg = 0x00;
    426          
    427            /* Check the parameters */
    428            assert(IS_GPIO_PORT_SOURCE(GPIO_PortSource));
    429            assert(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
    430              
    431            tmpreg = AFIO->EVCR;
   \   00000002   044A               LDR.N    R2,??GPIO_EventOutputConfig_0  ;; 0x40010000
   \   00000004   1368               LDR      R3,[R2, #+0]
    432            /* Clear the PORT[6:4] and PIN[3:0] bits */
    433            tmpreg &= EVCR_PORTPINCONFIG_MASK;
    434            tmpreg |= (u32)GPIO_PortSource << 0x04;
    435            tmpreg |= GPIO_PinSource;
    436          
    437            AFIO->EVCR = tmpreg;
   \   00000006   044C               LDR.N    R4,??GPIO_EventOutputConfig_0+0x4  ;; 0xff80
   \   00000008   1C40               ANDS     R4,R4,R3

⌨️ 快捷键说明

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