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

📄 stm32f10x_gpio.lst

📁 STM32利用正交编码器实现电机的控制
💻 LST
📖 第 1 页 / 共 3 页
字号:
    396            assert(IS_GPIO_PIN(GPIO_Pin));
    397            
    398            tmp |= GPIO_Pin;
    399            /* Set LCKK bit */
    400            GPIOx->LCKR = tmp;
    401            /* Reset LCKK bit */
    402            GPIOx->LCKR =  GPIO_Pin;
    403            /* Set LCKK bit */
    404            GPIOx->LCKR = tmp;
    405            /* Read LCKK bit*/
    406            tmp = GPIOx->LCKR;
    407            /* Read LCKK bit*/
    408            tmp = GPIOx->LCKR;
    409          }
    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          *******************************************************************************/
    423          void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)
    424          {
    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;
    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;
    438          }
    439          
    440          /*******************************************************************************
    441          * Function Name  : GPIO_EventOutputCmd
    442          * Description    : Enables or disables the Event Output.
    443          * Input          : - NewState: new state of the Event output.
    444          *                    This parameter can be: ENABLE or DISABLE.
    445          * Output         : None
    446          * Return         : None
    447          *******************************************************************************/
    448          void GPIO_EventOutputCmd(FunctionalState NewState)
    449          {
    450            /* Check the parameters */
    451            assert(IS_FUNCTIONAL_STATE(NewState));
    452            
    453            *(vu32 *) EVCR_EVOE_BB = (u32)NewState;
    454          }
    455          
    456          /*******************************************************************************
    457          * Function Name  : GPIO_PinRemapConfig
    458          * Description    : Changes the mapping of the specified pin.
    459          * Input          : - GPIO_Remap: selects the pin to remap.
    460          *                    This parameter can be one of the following values:
    461          *                       - GPIO_Remap_SPI1
    462          *                       - GPIO_Remap_I2C1
    463          *                       - GPIO_Remap_USART1
    464          *                       - GPIO_Remap_USART2
    465          *                       - GPIO_PartialRemap_USART3
    466          *                       - GPIO_FullRemap_USART3
    467          *                       - GPIO_PartialRemap_TIM1
    468          *                       - GPIO_FullRemap_TIM1
    469          *                       - GPIO_PartialRemap1_TIM2
    470          *                       - GPIO_PartialRemap2_TIM2
    471          *                       - GPIO_FullRemap_TIM2
    472          *                       - GPIO_PartialRemap_TIM3
    473          *                       - GPIO_FullRemap_TIM3
    474          *                       - GPIO_Remap_TIM4
    475          *                       - GPIO_Remap1_CAN
    476          *                       - GPIO_Remap2_CAN
    477          *                       - GPIO_Remap_PD01
    478          *                       - GPIO_Remap_SWJ_NoJTRST
    479          *                       - GPIO_Remap_SWJ_JTAGDisable
    480          *                       - GPIO_Remap_SWJ_Disable
    481          *                  - NewState: new state of the port pin remapping.
    482          *                    This parameter can be: ENABLE or DISABLE.
    483          * Output         : None
    484          * Return         : None
    485          *******************************************************************************/
    486          void GPIO_PinRemapConfig(u32 GPIO_Remap, FunctionalState NewState)
    487          {
    488            u32 tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00;
    489          
    490            /* Check the parameters */
    491            assert(IS_GPIO_REMAP(GPIO_Remap));
    492            assert(IS_FUNCTIONAL_STATE(NewState));  
    493            
    494            tmpreg = AFIO->MAPR;
    495          
    496            tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10;
    497            tmp = GPIO_Remap & LSB_MASK;
    498          
    499            if ((GPIO_Remap & DBGAFR_LOCATION_MASK) == DBGAFR_LOCATION_MASK)
    500            {
    501              tmpreg &= DBGAFR_SWJCFG_MASK;
    502            }
    503            else if ((GPIO_Remap & DBGAFR_NUMBITS_MASK) == DBGAFR_NUMBITS_MASK)
    504            {
    505              tmp1 = ((u32)0x03) << tmpmask;
    506              tmpreg &= ~tmp1;
    507            }
    508            else
    509            {
    510              tmpreg &= ~tmp;
    511            }
    512          
    513            if (NewState != DISABLE)
    514            {
    515              if ((GPIO_Remap & DBGAFR_LOCATION_MASK) == DBGAFR_LOCATION_MASK)
    516              {
    517                tmpreg |= (tmp << 0x10);
    518              }
    519              else
    520              {
    521                tmpreg |= tmp;
    522              }
    523            }
    524            AFIO->MAPR = tmpreg;
    525          }
    526          
    527          /*******************************************************************************
    528          * Function Name  : GPIO_EXTILineConfig
    529          * Description    : Selects the GPIO pin used as EXTI Line.
    530          * Input          : - GPIO_PortSource: selects the GPIO port to be used as
    531          *                    source for EXTI lines.
    532          *                  - GPIO_PinSource: specifies the EXTI line to be configured.
    533          *                   This parameter can be GPIO_PinSourcex where x can be (0..15).
    534          * Output         : None
    535          * Return         : None
    536          *******************************************************************************/
    537          void GPIO_EXTILineConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)
    538          {
    539            u32 tmp = 0x00;
    540          
    541            /* Check the parameters */
    542            assert(IS_GPIO_PORT_SOURCE(GPIO_PortSource));
    543            assert(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
    544            
    545            tmp = ((u32)0x0F) << (0x04 * (GPIO_PinSource & (u8)0x03));
    546          
    547            AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp;
    548            AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((u32)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (u8)0x03)));
    549          }
    550          
    551          /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

   Maximum stack usage in bytes:

     Function               CSTACK
     --------               ------
     GPIO_AFIODeInit            4
     GPIO_DeInit                4
     GPIO_EXTILineConfig       16
     GPIO_EventOutputCmd        8
     GPIO_EventOutputConfig    12
     GPIO_Init                 24
     GPIO_PinLockConfig        16
     GPIO_PinRemapConfig       12
     GPIO_ReadInputData         0
     GPIO_ReadInputDataBit     12
     GPIO_ReadOutputData        0
     GPIO_ReadOutputDataBit    12
     GPIO_ResetBits            12
     GPIO_SetBits              12
     GPIO_StructInit            0
     GPIO_Write                 0
     GPIO_WriteBit             16


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     GPIO_DeInit                     144
     GPIO_AFIODeInit                  20
     GPIO_Init                       306
     GPIO_StructInit                  20
     GPIO_ReadInputDataBit           126
     GPIO_ReadInputData                8
     GPIO_ReadOutputDataBit          132
     GPIO_ReadOutputData               8
     GPIO_SetBits                     28
     GPIO_ResetBits                   24
     GPIO_WriteBit                   148
     GPIO_Write                        4
     GPIO_PinLockConfig               44
     GPIO_EventOutputConfig          148
     GPIO_EventOutputCmd              36
     GPIO_PinRemapConfig             276
     GPIO_EXTILineConfig             224
     ??DataTable9                      4
     ??DataTable20                     4
     ??DataTable24                     4
     ?<Constant "C:\\David JIANG\\ST MCU...">
                                      92
      Others                          16

 
 1 724 bytes in segment CODE
    92 bytes in segment DATA_C
 
 1 708 bytes of CODE  memory (+ 16 bytes shared)
    92 bytes of CONST memory

Errors: none
Warnings: none

⌨️ 快捷键说明

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