库函数的闪亮LED

include “stm32f10x.h”

include “stm32f10x_gpio.h”

void Delay(unsigned int uCount)
{
for(;uCount>0;uCount–);
}

int main(void)
{

GPIO_InitTypeDef GPIO_InitStructure;//这个是定义一个结构体变量,这个结构体里
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);//使GPIOD的时钟打开
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_7;//引脚是2,3,4,7引脚
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//在50MHz的情况下跑LED
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//普通推免输出模式
GPIO_Init(GPIOD,&GPIO_InitStructure);//给上边那几条指令进行初始化
while(1)
{
GPIOD->BRR=GPIO_Pin_2;//这是GPIOD寄存器BRR的使用,大家可以参考手册,(我的上一篇帖子中出现过这个的介绍,可以看看)
GPIOD->BRR=GPIO_Pin_3;
GPIOD->BRR=GPIO_Pin_4;
GPIOD->BRR=GPIO_Pin_7;
Delay(0XFFFFF);
GPIOD->BSRR=GPIO_Pin_2;//同上GPIOD寄存器BSRR,
GPIOD->BSRR=GPIO_Pin_3;
GPIOD->BSRR=GPIO_Pin_4;
GPIOD->BSRR=GPIO_Pin_7;
Delay(0xFFFFF);
}
}
大家可以看看我的链接,里面有更详细的解释http://www.stmcu.org/module/forum/thread-608436-1-1.html

猜你喜欢

转载自blog.csdn.net/qq_34988341/article/details/52982567