/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2014-2020. All rights reserved. * Description: console * Author: SmartMedia_BSP * Create: 2014-06-04 */ #include #include #define KEY_CTRL_C 0x03 static struct console *g_current = NULL; int getchar(void) { #ifdef CONFIG_DISABLE_CONSOLE_INPUT return 0; #endif return g_current ? g_current->getchar() : 0; } void putchar(unsigned int ch) { if (g_current != NULL) { g_current->putchar(ch); } } int tstchar(void) { #ifdef CONFIG_DISABLE_CONSOLE_INPUT return 0; #endif if (g_current != NULL) { return g_current->tstchar(); } else { return 0; } } int isbreak(void) { if (!tstchar()) { return 0; } return (getchar() == KEY_CTRL_C); } void console_init(struct console *console) { g_current = console; }