STM32F4xx GPIO函数解释

以下内容来自stm32f4xx_gpio.c

gpio.c内有14个函数,其中读写操作9个、初始化操作3个、复用( Changes the mapping of the specified pin.---更改指定引脚映像),还有一个 Specifies the pins to be toggled.<切换指定引脚>。

一、函数

1、读写操作

uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)  //读取输入I/O口的引脚值   ---0或1

uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)//读取输入I/O口状态值

uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) //读取输出I/O口的引脚值

uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)//读取输出I/O状态值

void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)//I/O口的引脚值置高

void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)//I/O口的引脚值置低

void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)/向I/O引脚写入数据

void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)//向I/O口写入数据

void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)//锁定I/O口

2、初始化操作

void GPIO_DeInit(GPIO_TypeDef* GPIOx)

void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)//I/O口初始化

void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)//GPIO_InitStruct置默认值

3、复用操作

void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)

4、toggle bit

void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)

二、使用方法

1.读写操作

读写操作使用了GPIO_TypeDef、uint16_t定义参数,使用时需根据具体要求选择合适的参数。

2.初始化操作

使用该类函数之前需要获得GPIO_InitStryct结构体,并赋值。再调用该函数。

3、4方法同上。

 

原文地址:https://www.cnblogs.com/deciduousmap/p/12193727.html