Source code for the Trusted Boot Module.
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.
tbm-mcu/source/main.c

45 lines
1022 B

#include <stdio.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;
FILE *user_io, *admin_io;
char user_line[128];
char admin_line[128];
int main(void)
{
rcc_init();
gpio_init();
user_con = console_init(0);
admin_con = console_init(1);
user_io = console_to_fp(user_con);
admin_io = console_to_fp(admin_con);
fprintf(user_io, "TBM-dev (built on " __DATE__ ")\n");
fprintf(admin_io, "TBM-dev (built on " __DATE__ ")\n");
fprintf(admin_io, "Welcome to the administrative interface.\n");
fprintf(user_io, "tbm # ");
while (1) {
if (console_getline(user_con, user_line, 128) == 0) {
fprintf(user_io, "user: %s\n", user_line);
fprintf(admin_io, "user: %s\n", user_line);
*user_line = '\0';
}
if (console_getline(admin_con, admin_line, 128) == 0) {
fprintf(admin_io, "admin: %s\n", admin_line);
fprintf(user_io, "admin: %s\n", admin_line);
*admin_line = '\0';
}
}
return 0;
}