#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
//ALIENTEK Mini STM32¿a·¢°å·¶ày′úÂë3
//′®¿úêμÑé
//¼¼êõÖ§3Ö£o
www.openedv.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
int main(void)
{
u8 t;
u8 len;
u16 times=0;
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// éèÖÃÖD¶ÏóÅÏ輶·Ö×é2
uart_init(9600); //′®¿ú3õê¼»ˉÎa9600
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
while(1)
{
if(USART_RX_STA&0x8000)
{
len=USART_RX_STA&0x3fff;//μÃμ½′Ë′νóêÕμ½μÄêy¾Y3¤¶è
printf("
您发送的消息为:
");
for(t=0;t<len;t++)
{
USART1->DR=USART_RX_BUF[t];
while((USART1->SR&0X40)==0);//μè′y·¢Ëí½áêø
}
printf("
");//插入换行
USART_RX_STA=0;
}else
{
times++;
if(times%5000==0)
{
printf("
ALIENTEK MiniSTM32开发板 串口实验
");
printf("正点原子@ALIENTEK
");
}
if(times%200==0)printf("请输入数据,以回车键结束
");
if(times%30==0)LED0=!LED0;//éá˸LED,ìáê¾Ïμí3ÕyÔúÔËDD.
delay_ms(10);
}
}
}
一周热门 更多>