|
本帖最后由 freeelectron 于 2017-2-12 23:10 编辑 前面的话:一直对通过在超级终端里面输入命令,查看系统参数等等比较好奇,前一阵才了解到linux里面叫做shell,同样的,也可以用单片机来实现一个,方便调试,当然,也可以输入参数等等。 先上个图:
PS:其他的命令类似,正确输入命令后,按回车键 代码1:
typedef void (*process_cmd)(void);是一个函数指针,指向的函数是void类型,无参数。 typedef struct _CMD { char *str; char *help; process_cmd spectical_cmd_process; }PC_CMD;这个是命令结构体,里面包含两个字符类型的指针,一个函数指针。 PC_CMD PC_CMD_TAB[]= { {"help", "List all of the valid commands.",help_process}, {"led1", "Led1 state.",led1_process}, {"led2on", "Enable led2.",led2on_process}, {"led2off", "Disable led2.",led2off_process}, {"reset", "Software reset mcu.",reset_process}, };这个是结构体数组,我们可以看到具体的命令就是在这里面定义的。 代码2:
附上代码:基于stm32l1的工程代码。
L1(shell).rar
(5.24 MB, 下载次数: 386)
|
微信公众号
手机版
共同学习,帮我顶一下这个帖子https://www.stmcu.org.cn/module/forum/thread-610437-1-1.html谢谢
共同学习,帮我顶一下这个帖子,谢谢https://www.stmcu.org.cn/module/forum/thread-610437-1-1.html:)
欢迎指导,帮我顶一下这个帖子,谢谢https://www.stmcu.org.cn/module/forum/thread-610437-1-1.html