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

📄 stm32f10x_gpio.lst

📁 ek-stm32f开发板测试程序,LCD+LED+按键
💻 LST
📖 第 1 页 / 共 3 页
字号:
    357            if (BitVal != Bit_RESET)
    358            {
    359              GPIOx->BSRR = GPIO_Pin;
    360            }
    361            else
    362            {
    363              GPIOx->BRR = GPIO_Pin;
    364            }
    365          }
    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          *******************************************************************************/
    376          void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal)
    377          {
    378            GPIOx->ODR = PortVal;
    379          }
    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          *******************************************************************************/
    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;
    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****/

Errors: 1
Warnings: none

⌨️ 快捷键说明

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