main()
{
unsigned int tem_c=0;
unsigned char B_k1=0,B_k2=0;
for(tem_c=0;
tem_c<50000;tem_c++);
Clock_init();
GPIO_int();
while (1)
{
if((GPIOG->IDR&0x80)==0x80)B_k1=0; //PG7为高电平,未有按键
else if(B_k1==0)//PG6按下时,指示灯亮
{
for(tem_c=0;
tem_c<500;tem_c++);
if((GPIOG->IDR&0x80)==0x00)
{
B_k1=1;
GPIOA->ODR=0x30;
}
}
if((GPIOG->IDR&0x40)==0x40)B_k2=0; //PG6为高电平,未有按键
else if(B_k2==0)//PG7按下时,指示灯灭
{
for(tem_c=0;
tem_c<500;tem_c++);
if((GPIOG->IDR&0x40)==0x00)
{
B_k2=1;
GPIOA->ODR=0x0;
}
}
}
}
此帖出自
小平头技术问答
一周热门 更多>