busvoodoo: add UART mode to list of supported modes

This commit is contained in:
King Kévin 2018-01-24 16:37:00 +01:00
parent da1786228a
commit 513bee9298
1 changed files with 8 additions and 8 deletions

View File

@ -37,10 +37,12 @@
#include "menu.h" // menu utilities
#include "busvoodoo_global.h" // BusVoodoo definitions
#include "busvoodoo_hiz.h" // BusVoodoo HiZ mode
#include "busvoodoo_uart.h" // BusVoodoo UART mode
/** all supported BusVoodoo modes */
static struct busvoodoo_mode_t* busvoodoo_modes[] = {
&busvoodoo_hiz_mode,
&busvoodoo_uart_mode,
};
/** current BusVoodoo mode */
@ -231,10 +233,7 @@ static void command_mode(void* argument)
static void command_quit(void* argument)
{
(void)argument; // we won't use the argument
(*busvoodoo_mode->exit)(); // exit current mode
busvoodoo_mode = &busvoodoo_hiz_mode; // set HiZ mode as current mode
(*busvoodoo_mode->setup)(&terminal_prefix, NULL); // setup BusVoodoo mode
terminal_send(0); // update the terminal prompt
switch_mode(NULL); // switch do default mode
}
static void command_led(void* argument)
@ -287,10 +286,6 @@ static void command_version(void* argument)
*/
static void process_command(char* str)
{
// don't handle empty lines
if (!str || 0==strlen(str)) {
return;
}
// ensure actions are available
if (NULL==menu_commands || 0==LENGTH(menu_commands)) {
return;
@ -303,6 +298,10 @@ static void process_command(char* str)
busvoodoo_mode_complete = (*busvoodoo_mode->setup)(&terminal_prefix, str); // continue setup
terminal_send(0); // update the terminal prompt
} else {
// don't handle empty lines
if (!str || 0==strlen(str)) {
return;
}
if (!menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb)) {
if (!menu_handle_command(str, busvoodoo_global_commands, LENGTH(busvoodoo_global_commands))) {
if (!menu_handle_command(str, menu_commands, LENGTH(menu_commands))) {
@ -370,6 +369,7 @@ void main(void)
char_flag = false; // reset flag
action = true; // action has been performed
if (0x04==c) { // CTRL+D is used to quit the mode
printf("quit\n"); // acknowledge quitting
command_quit(NULL); // quit current mode
} else {
terminal_send(c); // send received character to terminal