void USART1_IRQHandler(void) //´®¿Ú1ÖжϷþÎñ³ÌÐò { u8 Res; #ifdef OS_TICKS_PER_SEC //Èç¹ûʱÖÓ½ÚÅÄÊý¶¨ÒåÁË,˵Ã÷ҪʹÓÃucosIIÁË. OSIntEnter(); #endif if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //½ÓÊÕÖжÏ(½ÓÊÕµ½µÄÊý¾Ý±ØÐëÊÇ0x0d 0x0a½áβ) { Res =USART_ReceiveData(USART1);//(USART1->DR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý if(Res==0x31) { //LED0ÉÁÒ»´Î LED0 = 0; delay_ms(300); LED0 = 1; delay_ms(50); LED0 = 0; delay_ms(300); LED0 = 1; } //LED1 ÁÁ if(Res==0x32) { LED1 = 0; } if((USART_RX_STA&0x8000)==0)//½ÓÊÕδÍê³É { if(USART_RX_STA&0x4000) //½ÓÊÕµ½ÁË0x0d { if(Res!=0x0a)USART_RX_STA=0;//½ÓÊÕ´íÎó,ÖØпªÊ¼ else USART_RX_STA|=0x8000; //½ÓÊÕÍê³ÉÁË } else //»¹Ã»ÊÕµ½0X0D { if(Res==0x0d)USART_RX_STA|=0x4000; else { USART_RX_BUF[USART_RX_STA&0X3FFF]=Res ; USART_RX_STA++; if(USART_RX_STA>(USART_REC_LEN-1))USART_RX_STA=0;//½ÓÊÕÊý¾Ý´íÎó,ÖØпªÊ¼½ÓÊÕ } } } }
while(1) { if(USART_RX_STA&0x8000) { len=USART_RX_STA&0x3fff;//µÃµ½´Ë´Î½ÓÊÕµ½µÄÊý¾Ý³¤¶È printf("\r\nÄú·¢Ë͵ÄÏûϢΪ:\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; } else { times++; if(times%200==0)printf("\r\nѧºÅ:14160310317ÐÕÃû:ÕÔ´æµµ µÈ´ýKEY0 KEY1 ±»°´ÏÂ\r\n"); delay_ms(10); t=KEY_Scan(0); if(t) { switch(t) { case KEY_UP: printf("\r\nKEY0±»°´ÏÂ\r\n\r\n"); break; case KEY_LEFT: BEEP=1; delay_ms(300); BEEP=0; break; } } } }