#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct console *user_con, *admin_con; struct shell user_shell, admin_shell; extern struct flash_dev *flash; extern struct mufs *mufs; extern struct buzzer buzzers[]; extern size_t nbuzzers; struct cmd user_cmds[] = { { "hi", shell_version }, { "buzzer", shell_buzzer }, { "led", shell_led }, { "reset", shell_alarm }, { "cat", shell_cat }, { "ls", shell_ls }, { "date", shell_date }, { "time", shell_time }, { "booting", shell_prepare }, { NULL, NULL }, }; struct cmd admin_cmds[] = { { "echo", shell_echo }, #ifdef STM32F1 { "jtag", shell_jtag }, #endif { "buzzer", shell_buzzer }, { "led", shell_led }, { "reset", shell_alarm }, { "flash_probe", shell_flash_probe }, { "flash_release", shell_flash_release }, { "flash_info", shell_flash_info }, { "flash_read", shell_flash_read }, { "flash_write", shell_flash_write }, { "flash_erase", shell_flash_erase }, { "ftl_probe", shell_ftl_probe }, { "date", shell_date }, { "time", shell_time }, { "set_date", shell_set_date }, { "set_time", shell_set_time }, { "mount", shell_mount }, { "umount", shell_unmount }, { "format", shell_format }, { "mkdir", shell_mkdir }, { "rmdir", shell_rmdir }, { "ls", shell_ls }, { "stat", shell_stat }, { "cat", shell_cat }, { "write", shell_write }, { "append", shell_append }, { "mv", shell_mv, }, { "cp", shell_cp, }, { "rm", shell_rm, }, { NULL, NULL }, }; int main(void) { size_t i; rcc_init(); gpio_init(); rtc_init(NULL); for (i = 0; i < nbuzzers; ++i) { buzzer_init(buzzers + i); } user_con = console_init(1); admin_con = console_init(0); if ((flash = flash_probe())) { flash = ftl_mount(flash); mufs = mufs_mount(flash); } else { fprintf(admin_con->fp, "error: unable to probe flash chip.\n"); } fprintf(user_con->fp, "TBM-dev (built on " BUILD_VERSION ")\n"); fprintf(admin_con->fp, "TBM-dev (built on " BUILD_VERSION ")\n"); shell_init(&user_shell, user_cmds, user_con, "tbm $", SHELL_SHOW_EXIT_CODE); shell_init(&admin_shell, admin_cmds, admin_con, "tbm #", SHELL_SHOW_EXIT_CODE); while (1) { shell_parse(&user_shell); shell_parse(&admin_shell); } return 0; }