摘要:使用控制台的嵌入式控制灯照明程序需要在控制台输入命令来控制板上的三个灯区域调光。
【嵌入式】使用FinSH控制台控制LED灯的点亮程序。
照明程序要求:在FinSH控制台输入led 1/2/3 on/off命令,控制stm32f407板上的三个led灯变暗。
# include # include # include # define le D1 _ PIN GET _ PIN(C,3)#define LED2_PIN GET_PIN(A,5)#define LED3_PIN GET_PIN(A,6)static void led(int argc,char**argv){ if (argc if(!rt_strcmp(argv[2]," off")) rt_pin_write(LED1_PIN,PIN _ LOW);else if(!rt_strcmp(argv[2]," on")) rt_pin_write(LED1_PIN,PIN _ HIGH);else rt_kprintf("请输入" led "/n ");} else if(!rt_strcmp(argv[1]," 2 "){ if(!rt_strcmp(argv[2]," off")) rt_pin_write(LED2_PIN,PIN _ LOW);else if(!rt_strcmp(argv[2]," on")) rt_pin_write(LED2_PIN,PIN _ HIGH);else rt_kprintf("请输入" led "/n ");} else if(!rt_strcmp(argv[1]," 3 "){ if(!rt_strcmp(argv[2]," off")) rt_pin_write(LED3_PIN,PIN _ LOW);else if(!rt_strcmp(argv[2]," on")) rt_pin_write(LED3_PIN,PIN _ HIGH);else rt_kprintf("请输入" led "/n ");} else { rt_kprintf("请输入" led "/n));}}MSH_CMD_EXPORT(led,led示例:led);
评论前必须登录!
注册