源文件led.c
作用:定义LED_Init()初始化函数
程序源码:
#include "led.h"
#include "stm32f4xx.h"
void LED_Init(void) //LED初始化函数定义
{
GPIO_InitTypeDef GPIO_InitStructure;//定义结构体变量,IO初始化函数中数据传入使用
//注意:定义结构体 应在 时钟使能 之前,否则编译出现警告!
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);//时钟,使能
//F9
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;//普通输出模式
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;//第九位
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;//上拉
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//100MHz
GPIO_Init(GPIOF,&GPIO_InitStructure);//初始化
//F10
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;//普通输出模式
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;//第十位
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;//上拉
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//100MHz
GPIO_Init(GPIOF,&GPIO_InitStructure);//初始化
//设置LED初始不亮
LED0 = 1;
LED1 = 1;
}
|