#include "stm32f10x.h"
#include "./led/bsp_led.h"
#include "./usart/bsp_usart.h"
int main(void)
{
char *ch;
uint16_t i=0;
/* 初始化RGB彩灯 */
LED_GPIO_Config();
/* 初始化USART 配置模式为 115200 8-N-1 */
USART_Config();
while(1)
{
/* 获取字符指令 */
do
{
*(ch+i)=getchar();
i++;
}while(*(ch+i) != '\0');
printf("接收到字符:%c\n",ch);
/* 根据字符指令控制RGB彩灯颜色 */
switch(*ch)
{
case "red":
LED_RED; break;
case "green":
LED_GREEN; break;
case "bule":
LED_BLUE; break;
default:
LED_RGBOFF; break;
}
}
} |