#define wei0 0b00000000000000000000000000000001
#define wei1 0b00000000000000000000000000000010
#define wei2 0b00000000000000000000000000000100
#define wei3 0b00000000000000000000000000001000
#define wei4 0b00000000000000000000000000010000
#define wei5 0b00000000000000000000000000100000
#define wei6 0b00000000000000000000000001000000
#define wei7 0b00000000000000000000000010000000
#define wei8 0b00000000000000000000000100000000
#define wei9 0b00000000000000000000001000000000
#define wei10 0b00000000000000000000010000000000
#define wei11 0b00000000000000000000100000000000
#define wei12 0b00000000000000000001000000000000
#define wei13 0b00000000000000000010000000000000
#define wei14 0b00000000000000000100000000000000
#define wei15 0b00000000000000001000000000000000
#define wei16 0b00000000000000010000000000000000
#define wei17 0b00000000000000100000000000000000
#define wei18 0b00000000000001000000000000000000
#define wei19 0b00000000000010000000000000000000
#define wei20 0b00000000000100000000000000000000
#define wei21 0b00000000001000000000000000000000
#define wei22 0b00000000010000000000000000000000
#define wei23 0b00000000100000000000000000000000
#define wei24 0b00000001000000000000000000000000
#define wei25 0b00000010000000000000000000000000
#define wei26 0b00000100000000000000000000000000
#define wei27 0b00001000000000000000000000000000
#define wei28 0b00010000000000000000000000000000
#define wei29 0b00100000000000000000000000000000
#define wei30 0b01000000000000000000000000000000
#define wei31 0b10000000000000000000000000000000
#define GPIOB_DATA (*(volatile unsigned int*)(0x40011400+0x0000))
#define GPIOB_DATA_EN (*(volatile unsigned int*)(0x40011400+0X0004))
#define GPIOB_DIR (*(volatile unsigned int*)(0x40011400+0X0008))
#define led1_l GPIOB_DATA |=wei5;
#define led1_h GPIOB_DATA &=~wei5;
#define led2_l GPIOB_DATA |=wei25;
#define led2_h GPIOB_DATA &=~wei25;
#define led3_l GPIOB_DATA |=wei26;
#define led3_h GPIOB_DATA &=~wei26;
#define led4_l GPIOB_DATA |=wei18;
#define led4_h GPIOB_DATA &=~wei18;
#define led5_l GPIOB_DATA |=wei17;
#define led5_h GPIOB_DATA &=~wei17;
#define led6_l GPIOB_DATA |=wei16;
#define led6_h GPIOB_DATA &=~wei16;
#define led7_l GPIOB_DATA |=wei11;
#define led7_h GPIOB_DATA &=~wei11;
void xianshi(); //显示
void yanshi_1s(); //延时1秒
unsigned char liushui_a1;
int main(void)
{
unsigned char liushui_b1;
GPIOB_DATA_EN |=wei5+wei25+wei26+wei18+wei17+wei16+wei11; //使能
GPIOB_DIR |=wei5+wei25+wei26+wei18+wei17+wei16+wei11; //输出
GPIOB_DATA |=wei5+wei25+wei26+wei18+wei17+wei16+wei11; //输出高
while (1)
{
liushui_a1 =0x01;
liushui_b1 =7;
while(liushui_b1--)
{
xianshi(); //显示
yanshi_1s();
liushui_a1 <<=1; //左移一位
}
}
return 0;
}
void xianshi() //显示
{
if(liushui_a1&0x01){led1_h;} else{led1_l;}
if(liushui_a1&0x02){led2_h;} else{led2_l;}
if(liushui_a1&0x04){led3_h;} else{led3_l;}
if(liushui_a1&0x08){led4_h;} else{led4_l;}
if(liushui_a1&0x10){led5_h;} else{led5_l;}
if(liushui_a1&0x20){led6_h;} else{led6_l;}
if(liushui_a1&0x40){led7_h;} else{led7_l;}
}
void yanshi_1s() //延时1秒
{
volatile unsigned int x,y;
for(x=1000;x>0;x--)
for(y=2500;y>0;y--);
}
|