C文件
#include "LED.h" //引用LED灯头文件
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;//结构体名的重定义与引用
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE);//时钟定义,还不会
GPIO_InitStructure.GPIO_Pin=LED1 | LED2;//接口端口号的选择
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;//接口端口工作模式的选择
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;//接口端口速度的选择,一般为50MHz
GPIO_Init(LEDPORT, &GPIO_InitStructure);//
}
H文件
#ifndef __LED_H
#define __LED_H
#include "sys.h"
//#define LED1 PBout(0)// PB0
//#define LED2 PBout(1)// PB1
#define LEDPORT GPIOB //定义IO接口定义这个接口组为B
#define LED1 GPIO_Pin_0 //定义IO接口
#define LED2 GPIO_Pin_1 //定义IO接口
void LED_Init(void);//初始化
#endif