summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/src/console.c')
-rw-r--r--zephyr/shim/src/console.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index 8b3d49cc04..d9c2554535 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -6,6 +6,9 @@
#include <device.h>
#include <drivers/uart.h>
#include <shell/shell.h>
+#ifdef CONFIG_SHELL_BACKEND_DUMMY
+#include <shell/shell_dummy.h>
+#endif
#include <shell/shell_uart.h>
#include <stdbool.h>
#include <string.h>
@@ -101,7 +104,7 @@ int uart_shell_stop(void)
k_poll_signal_init(&shell_uninit_signal);
/* Stop the shell */
- shell_uninit(shell_backend_uart_get_ptr(), shell_uninit_callback);
+ shell_uninit(shell_zephyr, shell_uninit_callback);
/* Wait for the shell to be turned off, the signal will wake us */
k_poll(&event, 1, K_FOREVER);
@@ -115,18 +118,18 @@ static const struct shell_backend_config_flags shell_cfg_flags =
static void shell_init_from_work(struct k_work *work)
{
- bool log_backend = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > 0;
- uint32_t level;
+ bool log_backend = 1;
+ uint32_t level = CONFIG_LOG_MAX_LEVEL;
ARG_UNUSED(work);
- if (CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > LOG_LEVEL_DBG) {
- level = CONFIG_LOG_MAX_LEVEL;
- } else {
+#ifdef CONFIG_SHELL_BACKEND_SERIAL
+ log_backend = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > 0;
+ if (CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL <= LOG_LEVEL_DBG)
level = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL;
- }
+#endif
/* Initialize the shell and re-enable both RX and TX */
- shell_init(shell_backend_uart_get_ptr(), uart_shell_dev,
+ shell_init(shell_zephyr, uart_shell_dev,
shell_cfg_flags, log_backend, level);
/*
@@ -213,10 +216,23 @@ static int init_ec_console(const struct device *unused)
static int init_ec_shell(const struct device *unused)
{
- shell_zephyr = shell_backend_uart_get_ptr();
+#if defined(CONFIG_SHELL_BACKEND_SERIAL)
+ shell_zephyr = shell_backend_uart_get_ptr();
+#elif defined(CONFIG_SHELL_BACKEND_DUMMY)
+ shell_zephyr = shell_backend_dummy_get_ptr();
+#else
+#error A shell backend must be enabled
+#endif
return 0;
} SYS_INIT(init_ec_shell, PRE_KERNEL_1, 50);
+#ifdef TEST_BUILD
+const struct shell *get_ec_shell(void)
+{
+ return shell_zephyr;
+}
+#endif
+
void uart_tx_start(void)
{
}