add a helper library, uart_repl, which handles basic ANSI over UART

This commit is contained in:
Alex Hirzel 2018-04-01 20:00:51 -04:00
parent a89417e26e
commit f30f57059d
6 changed files with 493 additions and 0 deletions

View file

@ -0,0 +1,31 @@
#include <stdlib.h>
#include <string.h> /* strlen */
#include <espressif/esp_common.h>
#include <espressif/user_interface.h>
#include <esp/uart.h>
#include <FreeRTOS.h>
#include <task.h>
#include <uart_repl/uart_repl.h>
void handle_command(char const d[]) {
if (!strcmp(d, "ts") || !strcmp(d, "time")) {
printf("the tick count since boot is: %u\n", xTaskGetTickCount());
} else if (!strcmp(d, "help")) {
printf("commands include ts, time\n");
} else {
printf("command not recognized, try help\n");
}
}
void user_init(void) {
uart_set_baud(0, 115200);
printf("\n\nWelcome to the uart REPL demo. try \"help\"\n");
uart_repl_init(&handle_command);
}