点击查看代码
/********************************************************************************* @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会亮GPIOF->BSRRH = GPIO_Pin_9;}
}