当串口输入led1_on,LED1开灯,串口输入LED1_OFF,led1关灯
main.c
#include"led.h"
#include"uart4.h"
//手动封装一个延时函数
void delay_ms(int ms)
{
int i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<2000;j++)
{
}
}
}
int strcmp(char *s1,char *s2)
{
while(*s1&&(*s1==*s2))
{
*s1++;
*s2++;
}
return *s1-*s2;
}
int main()
{
//使能GPIO的外设时钟
*((unsigned int *)0X50000A28) |= (0X3<<4);
led1_init();
// led2_init();
// led3_init();
uart4_config();
// char a;
char buf[32];
while(1)
{
gets(buf);
if(strcmp(buf,"LED ON")==0)
{
led1_ctl(1);
}
else if(strcmp(buf,"LED OFF")==0)
{
led1_ctl(0);
}
puts(buf);
}
return 0;
}