add a helper library, uart_repl, which handles basic ANSI over UART
This commit is contained in:
parent
a89417e26e
commit
f30f57059d
6 changed files with 493 additions and 0 deletions
31
examples/uart_repl_test/uart_repl_test.c
Normal file
31
examples/uart_repl_test/uart_repl_test.c
Normal 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);
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue