程序实现的功能:程序从LED灯的DS0-DS3逐一点亮(注意是DS0亮然后熄灭经过延时再到DS1亮,按这样的规律到DS3),点亮到DS3时其他三灯也同样亮,然后再从DS3-DS0逐一熄灭
void delay(uint32_t times)
{
while(times--)
{
uint32_t i;
for(i=0;i<0xffff;i++);
}
}
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE); //GPIOF时钟打开
LedInit(); //调用LED灯初始化函数对端口进行初始化
while(1)
{
GPIOF->ODR=0x0380; //点亮LED灯
delay(50); //延时
GPIOF->ODR=0x0340;
delay(50);
GPIOF->ODR=0x02C0;
delay(50);
GPIOF->ODR=0x01C0;
delay(50);
GPIOF->ODR=0x0000; //点亮LED灯
delay(50);
GPIOF->ODR=0x0200;
delay(50);
GPIOF->ODR=0x0300;
delay(50);
GPIOF->ODR=0x0380;
delay(50);
GPIOF->ODR=0x03C0;
delay(50);
}
} |