[mw_shl_code=c,true]
[mw_shl_code=c,true]#ifndef __LED_H
#define __LED_H
#include "sys.h"
#define LED0B PBout(0)
#define LED1B PBout(1)
#define LED2B PBout(2)
#define LED3B PBout(3)
#define LED4B PBout(4)
#define LED5B PBout(5)
#define LED6B PBout(6)
#define LED7B PBout(7)
#define RCC_LEDB RCC_APB2Periph_GPIOB
#define PIN_LEDL (GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7)
void LED_Init(void);//初始化
#endif
[/mw_shl_code]
[mw_shl_code=c,true]#include "led.h"
#include "delay.h"
#include "sys.h"
//ALIENTEK战舰STM32开发板实验1
//跑马灯实验
//技术支持:www.openedv.com
//广州市星翼电子科技有限公司
int main(void)
{
delay_init(); //延时函数初始化
LED_Init(); //初始化与LED连接的硬件接口[/mw_shl_code]
[mw_shl_code=c,true] GPIO_PinRemapConfig (GPIO_Remap_SWJ_Disable,ENABLE); while(1)
{
[mw_shl_code=c,true] LED2B=!LED2B;[/mw_shl_code]
LED3B=!LED3B;
LED4B=!LED4B;
LED5B=!LED5B;
dealy_ms(100);
}
}[/mw_shl_code]
#include "led.h"
//初始化PB0-7为输出口.并使能这个口的时钟
//LED IO初始化
void LED_Init(void)
{[/mw_shl_code]
[mw_shl_code=c,true] GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_LEDB, ENABLE); //使能PB端口时钟
GPIO_InitStructure.GPIO_Pin = PIN_LEDL; //LED0-->

B.5 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); //根据设定参数初始化GPIOB.5
GPIO_ResetBits(GPIOB,PIN_LEDL); //PB8~15输出低,使LED灭
}[/mw_shl_code]