初级会员

- 积分
- 79
- 金钱
- 79
- 注册时间
- 2018-7-21
- 在线时间
- 15 小时
|
发表于 2018-7-31 17:39:31
|
显示全部楼层
唉,说说吧,你打开跑马灯的,改一下主函数
#include "sys.h"
#include "delay.h"
#include "led.h"
#include "usart.h"
#include "string.h"
char cmd[200];
int main(void)
{
u8 t;
u8 len;
delay_init();
LED_Init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
uart_init(115200);
while(1)
{
if(USART_RX_STA&0x8000)
{
len=USART_RX_STA&0x3FFF;
for(t=0;t<len;t++)
{
cmd[t]=USART_RX_BUF[t];
while((USART1->SR&0X40)==0);
}
printf("\r\n receive successful \r\n");
USART_RX_STA=0;
USART_ClearFlag(USART1, USART_FLAG_RXNE);
if(!(strcmp(cmd,"led1_on")))
{
LED0=0;
memset(cmd,0,strlen(cmd)); //??cmd[]
}
else if(!(strcmp(cmd,"led1_off")))
{
LED0=1;
memset(cmd,0,strlen(cmd)); //??cmd[]
}
else
printf("\r\n input error");
memset(cmd,0,strlen(cmd)); //??cmd[]
}
}
} |
|