tbm-mcu/source/main.c

75 lines
1.5 KiB
C
Raw Normal View History

2017-07-27 11:05:40 +02:00
#include <errno.h>
2017-02-27 14:48:38 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2017-02-27 14:48:38 +00:00
2017-03-11 13:07:12 +00:00
#include <console.h>
#include <gpio.h>
2017-07-27 11:05:40 +02:00
#include <flash.h>
#include <ftl.h>
2017-08-01 17:12:48 +02:00
#include <mufs.h>
#include <rcc.h>
2017-07-27 11:05:40 +02:00
#include <rtc.h>
2017-03-11 13:07:12 +00:00
#include <shell.h>
2017-02-27 14:48:38 +00:00
2017-07-27 13:17:55 +02:00
#include <shell/boot.h>
2017-07-27 11:05:40 +02:00
#include <shell/echo.h>
#include <shell/mufs.h>
#include <shell/rtc.h>
#include <shell/version.h>
2017-07-24 17:57:13 +02:00
struct console *user_con, *admin_con;
struct shell user_shell, admin_shell;
2017-07-27 11:05:40 +02:00
extern struct flash_dev *flash;
extern struct mufs *mufs;
struct cmd user_cmds[] = {
2017-07-27 11:05:40 +02:00
{ "hi", "", shell_version },
{ "cat", "", shell_cat },
{ "ls", "", shell_ls },
{ "date", "", shell_date },
{ "time", "", shell_time },
2017-07-27 13:17:55 +02:00
{ "booting", "", shell_prepare },
{ NULL, NULL, NULL },
};
struct cmd admin_cmds[] = {
2017-07-27 11:05:40 +02:00
{ "echo", "", shell_echo },
{ "flash", "", do_flash_cmd },
{ "ftl", "", do_ftl_cmd },
{ "mufs", "", do_mufs_cmd },
2017-07-27 11:05:40 +02:00
{ "date", "", shell_date },
{ "time", "", shell_time },
{ "set-date", "", shell_set_date },
{ NULL, NULL, NULL },
};
2017-02-27 14:48:38 +00:00
int main(void)
{
rcc_init();
gpio_init();
2017-07-27 10:45:50 +02:00
rtc_init(NULL);
user_con = console_init(1);
admin_con = console_init(0);
2017-07-27 13:20:42 +02:00
flash = flash_probe();
flash = ftl_mount(flash);
mufs = mufs_mount(flash);
2017-07-24 17:57:13 +02:00
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_SHOW_EXIT_CODE);
shell_init(&admin_shell, admin_cmds, admin_con, "tbm #", 0);
while (1) {
shell_parse(&user_shell);
shell_parse(&admin_shell);
}
2017-02-27 14:48:38 +00:00
return 0;
}