void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);

时间: 2023-12-28 20:32:01 浏览: 52
这些函数是用于控制GPIO引脚的状态的函数。它们是在STM32的HAL库中定义的。 - `GPIO_SetBits()`函数用于将指定的GPIO引脚设置为高电平。 - `GPIO_ResetBits()`函数用于将指定的GPIO引脚设置为低电平。 - `GPIO_WriteBit()`函数用于将指定的GPIO引脚设置为给定的状态(高电平或低电平)。 - `GPIO_Write()`函数用于同时设置多个GPIO引脚的状态,参数PortVal是一个16位的值,每一位对应一个GPIO引脚的状态。 这些函数可以帮助你在STM32微控制器上控制GPIO引脚的电平状态。你可以根据需要选择使用其中的一个函数。
相关问题

stm32f10x_gpio.h的代码

以下是一个简单的示例代码,用于在STM32F10x系列微控制器上控制GPIO引脚: ``` #ifndef __STM32F10x_GPIO_H #define __STM32F10x_GPIO_H #include "stm32f10x.h" #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ typedef struct { uint16_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. This parameter can be any value of @ref GPIO_pins_define */ GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. This parameter can be a value of @ref GPIOMode_TypeDef */ GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. This parameter can be a value of @ref GPIOSpeed_TypeDef */ GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins. This parameter can be a value of @ref GPIOOType_TypeDef */ GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. This parameter can be a value of @ref GPIOPuPd_TypeDef */ }GPIO_InitTypeDef; void GPIO_DeInit(GPIO_TypeDef* GPIOx); void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); #endif /* __STM32F10x_GPIO_H */ ``` 这个头文件定义了各种GPIO操作函数,例如GPIO初始化、读取输入、写入输出等。如果需要使用这些函数,则需要在代码中包含此头文件,并且在你的代码中对相应的GPIO引脚进行初始化和配置。

stm32f10x_gpio.h代码

以下是`stm32f10x_gpio.h`的代码: ```c /** ****************************************************************************** * @file stm32f10x_gpio.h * @author MCD Application Team * @version V3.5.0 * @date 09-March-2012 * @brief This file contains all the functions prototypes for the GPIO * firmware library. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You * may not use this file except in compliance with the License. You may obtain * a copy of the License at: * * http://www.st.com/software_license_agreement_liberty_v2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_GPIO_H #define __STM32F10x_GPIO_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /** @addtogroup STM32F10x_StdPeriph_Driver * @{ */ /** @addtogroup GPIO * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIO_Exported_Constants * @{ */ /** @defgroup GPIO_pins_define * @{ */ #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ /** * @} */ /** @defgroup GPIO_Speed_Legacy * @{ */ #define GPIO_Speed_10MHz GPIO_Speed_Level_1 /*!< I/O output speed: Low 2 MHz */ #define GPIO_Speed_2MHz GPIO_Speed_Level_2 /*!< I/O output speed: Medium 10 MHz */ #define GPIO_Speed_50MHz GPIO_Speed_Level_3 /*!< I/O output speed: Fast 50 MHz */ /** * @} */ /** @defgroup GPIO_Mode_define * @{ */ #define GPIO_Mode_AIN ((uint32_t)0x00000000) /*!< Analog mode */ #define GPIO_Mode_IN_FLOATING ((uint32_t)0x04) /*!< Input floating mode */ #define GPIO_Mode_IPD ((uint32_t)0x28) /*!< Input pull-down mode */ #define GPIO_Mode_IPU ((uint32_t)0x48) /*!< Input pull-up mode */ #define GPIO_Mode_Out_OD ((uint32_t)0x14) /*!< Output open-drain mode */ #define GPIO_Mode_Out_PP ((uint32_t)0x10) /*!< Output push-pull mode */ #define GPIO_Mode_AF_OD ((uint32_t)0x1C) /*!< Alternate function output open-drain mode */ #define GPIO_Mode_AF_PP ((uint32_t)0x18) /*!< Alternate function output push-pull mode */ /** * @} */ /** @defgroup GPIO_OType_define * @{ */ #define GPIO_OType_PP ((uint16_t)0x0000) /*!< Output push-pull */ #define GPIO_OType_OD ((uint16_t)0x0010) /*!< Output open-drain */ /** * @} */ /** @defgroup GPIO_PuPd_define * @{ */ #define GPIO_PuPd_NOPULL ((uint32_t)0x00000000) /*!< No pull-up or pull-down */ #define GPIO_PuPd_UP ((uint32_t)0x08) /*!< Pull-up */ #define GPIO_PuPd_DOWN ((uint32_t)0x18) /*!< Pull-down */ /** * @} */ /** @defgroup GPIO_Pin_sources * @{ */ #define GPIO_PinSource0 ((uint8_t)0x00) #define GPIO_PinSource1 ((uint8_t)0x01) #define GPIO_PinSource2 ((uint8_t)0x02) #define GPIO_PinSource3 ((uint8_t)0x03) #define GPIO_PinSource4 ((uint8_t)0x04) #define GPIO_PinSource5 ((uint8_t)0x05) #define GPIO_PinSource6 ((uint8_t)0x06) #define GPIO_PinSource7 ((uint8_t)0x07) #define GPIO_PinSource8 ((uint8_t)0x08) #define GPIO_PinSource9 ((uint8_t)0x09) #define GPIO_PinSource10 ((uint8_t)0x0A) #define GPIO_PinSource11 ((uint8_t)0x0B) #define GPIO_PinSource12 ((uint8_t)0x0C) #define GPIO_PinSource13 ((uint8_t)0x0D) #define GPIO_PinSource14 ((uint8_t)0x0E) #define GPIO_PinSource15 ((uint8_t)0x0F) /** * @} */ /** @defgroup GPIO_Alternate_function_selection_define * @{ */ #define GPIO_AF_0 ((uint8_t)0x00) /*!< Alternate function 0 */ #define GPIO_AF_1 ((uint8_t)0x01) /*!< Alternate function 1 */ #define GPIO_AF_2 ((uint8_t)0x02) /*!< Alternate function 2 */ #define GPIO_AF_3 ((uint8_t)0x03) /*!< Alternate function 3 */ #define GPIO_AF_4 ((uint8_t)0x04) /*!< Alternate function 4 */ #define GPIO_AF_5 ((uint8_t)0x05) /*!< Alternate function 5 */ #define GPIO_AF_6 ((uint8_t)0x06) /*!< Alternate function 6 */ #define GPIO_AF_7 ((uint8_t)0x07) /*!< Alternate function 7 */ #define GPIO_AF_8 ((uint8_t)0x08) /*!< Alternate function 8 */ #define GPIO_AF_9 ((uint8_t)0x09) /*!< Alternate function 9 */ #define GPIO_AF_10 ((uint8_t)0x0A) /*!< Alternate function 10 */ #define GPIO_AF_11 ((uint8_t)0x0B) /*!< Alternate function 11 */ #define GPIO_AF_12 ((uint8_t)0x0C) /*!< Alternate function 12 */ #define GPIO_AF_13 ((uint8_t)0x0D) /*!< Alternate function 13 */ #define GPIO_AF_14 ((uint8_t)0x0E) /*!< Alternate function 14 */ #define GPIO_AF_15 ((uint8_t)0x0F) /*!< Alternate function 15 */ /** * @} */ /** @defgroup GPIO_interrupt_sources * @{ */ #define GPIO_IT_Edge ((uint16_t)0x0001) /*!< Interrupt mode is enabled on rising edge */ #define GPIO_IT_Rising ((uint16_t)0x0002) /*!< Interrupt mode is enabled on rising edge */ #define GPIO_IT_Falling ((uint16_t)0x0004) /*!< Interrupt mode is enabled on falling edge */ #define GPIO_IT_High ((uint16_t)0x0008) /*!< Interrupt mode is enabled on high level */ #define GPIO_IT_Low ((uint16_t)0x0010) /*!< Interrupt mode is enabled on low level */ #define GPIO_IT_Port_Source ((uint16_t)0x0020) /*!< Interrupt mode is enabled on pin event */ /** * @} */ /** @defgroup GPIO_Legacy * @{ */ #define GPIO_Mode_Out_Slow GPIO_Mode_Out_PP #define GPIO_Mode_In_Floating GPIO_Mode_IN_FLOATING #define GPIO_Mode_In_PU GPIO_Mode_IPU #define GPIO_Mode_In_PD GPIO_Mode_IPD #define GPIO_Mode_Out_OD GPIO_Mode_Out_OD #define GPIO_Mode_Af_OD GPIO_Mode_AF_OD #define GPIO_Mode_Af_PP GPIO_Mode_AF_PP /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* Function used to set the GPIO configuration to the default reset state ****/ void GPIO_DeInit(GPIO_TypeDef* GPIOx); /* Initialization and Configuration functions *********************************/ void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); /* GPIO Read and Write functions **********************************************/ uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); /* GPIO Alternate functions configuration functions ***************************/ void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); /* GPIO Interrupts configuration functions ************************************/ void GPIO_ITConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, FunctionalState NewState); void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); /* GPIO Low Level Interrupt management ***************************************/ void GPIO_SetInterrupt(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, Exti_TypeDef PortSource); void GPIO_ClearInterrupt(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); #ifdef __cplusplus } #endif #endif /* __STM32F10x_GPIO_H */ /** * @} */ /** * @} */ /******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/ ```

相关推荐

最新推荐

recommend-type

安装NumPy教程-详细版

附件是安装NumPy教程_详细版,文件绿色安全,请大家放心下载,仅供交流学习使用,无任何商业目的!
recommend-type

语音端点检测及其在Matlab中的实现.zip

语音端点检测及其在Matlab中的实现.zip
recommend-type

C#文档打印程序Demo

使用C#完成一般文档的打印,带有页眉,页脚文档打印,表格打印,打印预览等
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

可见光定位LED及其供电硬件具体型号,广角镜头和探测器,实验设计具体流程步骤,

1. 可见光定位LED型号:一般可使用5mm或3mm的普通白色LED,也可以选择专门用于定位的LED,例如OSRAM公司的SFH 4715AS或Vishay公司的VLMU3500-385-120。 2. 供电硬件型号:可以使用常见的直流电源供电,也可以选择专门的LED驱动器,例如Meanwell公司的ELG-75-C或ELG-150-C系列。 3. 广角镜头和探测器型号:一般可采用广角透镜和CMOS摄像头或光电二极管探测器,例如Omron公司的B5W-LA或Murata公司的IRS-B210ST01。 4. 实验设计流程步骤: 1)确定实验目的和研究对象,例如车辆或机器人的定位和导航。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这