|
|
|
#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 console *user_con, *admin_con;
|
|
|
|
struct shell user_shell, admin_shell;
|
|
|
|
|
|
|
|
static void do_echo(struct console *con, const char **argv, size_t argc)
|
|
|
|
{
|
|
|
|
if (argc < 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fprintf(con->fp, "%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)
|
|
|
|
{
|
|
|
|
rcc_init();
|
|
|
|
gpio_init();
|
|
|
|
|
|
|
|
user_con = console_init(0);
|
|
|
|
admin_con = console_init(1);
|
|
|
|
|
|
|
|
fprintf(user_con->fp, "TBM-dev (built on " __DATE__ ")\n");
|
|
|
|
fprintf(admin_con->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;
|
|
|
|
}
|