int main(void)
{
u8 add0;
u8 add1;
u8 add2;
u8 add3;
u8 t;
u8 len; //¶¨ÒåÒ»¸öÊý¾Ý½ÓÊÕ³¤¶È±äÁ¿
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//ÉèÖÃϵͳÖжÏÓÅÏȼ¶·Ö×é2
delay_init(168); //ÑÓʱ³õʼ»¯
uart_init(115200); //´®¿Ú³õʼ»¯²¨ÌØÂÊΪ115200
LED_Init(); //³õʼ»¯ÓëLEDÁ¬½ÓµÄÓ²¼þ½Ó¿Ú
while(1)
{
add0 = PBin(12);
add1 = PBin(13);
add2 = PBin(14); //µØÖ·ÓëÏàÓ¦µÄIO¿ÚÒ»Ò»¶ÔÓ¦
add3 = PBin(15);
if(USART_RX_STA&0x8000)
{
len=USART_RX_STA&0x3fff;//µÃµ½´Ë´Î½ÓÊÕµ½µÄÊý¾Ý³¤¶È
if((add0 != (USART_RX_BUF[0]-'0'))||(add1 != (USART_RX_BUF[1]-'0'))||(add2 != (USART_RX_BUF[2]-'0'))||(add3 != (USART_RX_BUF[3]-'0'))) //´Ô»úµØÖ·ÅжÏ
{
USART_RX_STA=0;
return 0; //½áÊø
}
{
LED1 = (USART_RX_BUF[4]-'0');
LED2 = (USART_RX_BUF[5]-'0'); //´®¿Ú·¢À´µÄÊý¾ÝλÓëIO¿ÚµÄÒ»Ò»¶ÔÓ¦
LED3 = (USART_RX_BUF[6]-'0');
LED4 = (USART_RX_BUF[7]-'0');
LED5 = (USART_RX_BUF[8]-'0');
LED6 = (USART_RX_BUF[9]-'0');
LED7 = (USART_RX_BUF[10]-'0');
LED8 = (USART_RX_BUF[11]-'0');
LED9 = (USART_RX_BUF[12]-'0');
LED10 = (USART_RX_BUF[13]-'0');
LED11 = (USART_RX_BUF[14]-'0');
LED12 = (USART_RX_BUF[15]-'0');
LED13 = (USART_RX_BUF[16]-'0');
LED14 = (USART_RX_BUF[17]-'0');
LED15 = (USART_RX_BUF[18]-'0');
LED16 = (USART_RX_BUF[19]-'0');
LED17 = (USART_RX_BUF[20]-'0');
LED18 = (USART_RX_BUF[21]-'0');
LED19 = (USART_RX_BUF[22]-'0');
LED20 = (USART_RX_BUF[23]-'0');
LED21 = (USART_RX_BUF[24]-'0');
LED22 = (USART_RX_BUF[25]-'0');
LED23 = (USART_RX_BUF[26]-'0');
LED24 = (USART_RX_BUF[27]-'0');
printf("\r\nÄú·¢Ë͵ÄÏûϢΪ:\r\n");
for(t=0;t<len;t++)
{
USART_SendData(USART1, USART_RX_BUF[t]); //Ïò´®¿Ú1·¢ËÍÊý¾Ý
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);//µÈ´ý·¢ËͽáÊø
}
printf("\r\n\r\n");//²åÈë»»ÐÐ
USART_RX_STA=0;
}
}
}
}
|