1.首先创建led.c&led.h
led.c中初始化led灯的GPIO引脚
初始设置默认小灯全熄灭setBit设置对应的引脚口
void M4_LEDN_ONLY_ONE(int ledN)定义只可以亮一个led灯
#include "led.h"
#include "main.h"
//LEDµÆµÄ³õʼ»¯
void M4_LED_INIT(){
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOE, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9| GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13| GPIO_Pin_14;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_9| GPIO_Pin_10);
GPIO_SetBits(GPIOE, GPIO_Pin_13| GPIO_Pin_14);
}
//Ö»ÁÁÒ»¸öLEDµÆ
void M4_LEDN_ONLY_ONE(int ledN)
{
switch(ledN)
{ //Ò»ºÅµÆÁÁÆð£¬ÆäËûµÆ²»ÁÁ
case