点击查看代码
/**
******************************************************************************
* @file main.c
* @author
* @version
* @date 2024/06/27
* @brief 实现利用MCU的PF9引脚控制开发板的LED灯的亮灭
******************************************************************************
**/
#include "stm32f4xx.h" //必须包含
int main()
{
//1.定义GPIO外设的结构体变量
GPIO_InitTypeDef GPIO_InitStructure;
//2.打开GPIOF端口的时钟
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
//3.配置PF9引脚为输出模式
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
//4.对GPIOF端口进行初始化
GPIO_Init(GPIOF, &GPIO_InitStructure);
while(1)
{
//5.控制PF9引脚输出低电平,则LED会亮
GPIO_ResetBits(GPIOF,GPIO_Pin_9);
}
}