You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
883 B
52 lines
883 B
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2014-2020. All rights reserved.
|
|
* Description: console
|
|
* Author: SmartMedia_BSP
|
|
* Create: 2014-06-04
|
|
*/
|
|
#include <console.h>
|
|
#include <td_type.h>
|
|
|
|
#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;
|
|
} |