You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.1 KiB
61 lines
1.1 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <console.h>
|
|
#include <gpio.h>
|
|
#include <rcc.h>
|
|
#include <shell.h>
|
|
|
|
#include <libopencm3/stm32/usart.h>
|
|
|
|
struct usart_console *user_con, *admin_con;
|
|
struct shell user_shell, admin_shell;
|
|
|
|
static void do_echo(FILE *out, const char **argv, size_t argc)
|
|
{
|
|
if (argc < 1)
|
|
return;
|
|
|
|
fprintf(out, "%s\n", argv[0]);
|
|
}
|
|
|
|
struct cmd user_cmds[] = {
|
|
{ "echo", "", do_echo },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
struct cmd admin_cmds[] = {
|
|
{ "echo", "", do_echo },
|
|
{ "flash", "", do_flash_cmd },
|
|
{ "ftl", "", do_ftl_cmd },
|
|
{ "mufs", "", do_mufs_cmd },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
int main(void)
|
|
{
|
|
FILE *fp;
|
|
|
|
rcc_init();
|
|
gpio_init();
|
|
|
|
user_con = console_init(0);
|
|
admin_con = console_init(1);
|
|
|
|
fp = console_to_fp(user_con);
|
|
fprintf(fp, "TBM-dev (built on " __DATE__ ")\n");
|
|
|
|
fp = console_to_fp(admin_con);
|
|
fprintf(fp, "TBM-dev (built on " __DATE__ ")\n");
|
|
|
|
shell_init(&user_shell, user_cmds, user_con, "tbm $");
|
|
shell_init(&admin_shell, admin_cmds, admin_con, "tbm #");
|
|
|
|
while (1) {
|
|
shell_parse(&user_shell);
|
|
shell_parse(&admin_shell);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|